/**
 * Layout của theme AutoParts.
 *
 * Màu sắc, font, bo góc và độ rộng khung lấy từ CSS custom property do
 * Theme Registry sinh ra, nên chỉnh trong admin là đổi được toàn site (THM-02).
 */

/* ------------------------------------------------------------------ Nền */

*,
*::before,
*::after {
	box-sizing: border-box;
}

body {
	margin: 0;
	font-family: var(--apc-font-body, system-ui), sans-serif;
	font-size: var(--apc-font-size, 16px);
	line-height: 1.6;
	-webkit-font-smoothing: antialiased;
}

img {
	max-width: 100%;
	height: auto;
}

a {
	color: var(--apc-primary, #0b5cab);
}

.apc-container {
	width: min( 100% - 32px, var(--apc-container, 1200px) );
	margin-inline: auto;
}

.screen-reader-text {
	position: absolute !important;
	overflow: hidden;
	width: 1px;
	height: 1px;
	clip: rect( 1px, 1px, 1px, 1px );
	word-wrap: normal;
}

.apc-skip:focus {
	position: fixed;
	z-index: 1000;
	top: 8px;
	left: 8px;
	width: auto;
	height: auto;
	padding: 10px 16px;
	background: #fff;
	clip: auto;
}

/* ----------------------------------------------------------- Đầu trang */

.apc-topbar {
	border-bottom: 1px solid var(--apc-border, #e5e7eb);
	background: var(--apc-surface, #f9fafb);
	font-size: 0.875rem;
}

.apc-topbar__inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	min-height: 36px;
}

.apc-topbar__hotline {
	font-weight: 600;
	text-decoration: none;
}

.apc-site-header {
	position: sticky;
	z-index: 50;
	top: 0;
	border-bottom: 1px solid var(--apc-border, #e5e7eb);
}

.apc-site-header__inner {
	display: grid;
	align-items: center;
	padding: 12px 0;
	gap: 16px;
	grid-template-columns: auto 1fr auto;
}

.apc-brand {
	color: inherit;
	font-size: 1.15rem;
	font-weight: 700;
	text-decoration: none;
}

.apc-brand__logo {
	max-height: 48px;
	width: auto;
}

/* --------------------------------------------------------------- Menu */

.apc-menu {
	display: flex;
	flex-wrap: wrap;
	padding: 0;
	margin: 0;
	gap: 4px;
	list-style: none;
}

.apc-menu li {
	position: relative;
}

.apc-menu a {
	display: block;
	padding: 10px 12px;
	color: inherit;
	font-weight: 500;
	text-decoration: none;
}

.apc-menu .sub-menu {
	position: absolute;
	z-index: 40;
	top: 100%;
	left: 0;
	display: none;
	min-width: 220px;
	padding: 6px 0;
	border: 1px solid var(--apc-border, #e5e7eb);
	border-radius: var(--apc-radius, 8px);
	margin: 0;
	background: var(--apc-bg, #fff);
	box-shadow: 0 8px 24px rgba( 17, 24, 39, 0.12 );
	list-style: none;
}

.apc-menu li:hover > .sub-menu,
.apc-menu li:focus-within > .sub-menu {
	display: block;
}

.apc-nav-toggle {
	display: none;
	width: 44px;
	height: 44px;
	border: 1px solid var(--apc-border, #e5e7eb);
	border-radius: var(--apc-radius, 8px);
	background: none;
	cursor: pointer;
}

.apc-nav-toggle__bar,
.apc-nav-toggle__bar::before,
.apc-nav-toggle__bar::after {
	display: block;
	width: 20px;
	height: 2px;
	margin-inline: auto;
	background: currentColor;
}

.apc-nav-toggle__bar::before,
.apc-nav-toggle__bar::after {
	content: "";
	transform: translateY( -6px );
}

.apc-nav-toggle__bar::after {
	transform: translateY( 4px );
}

/* -------------------------------------------------------- Thân trang */

.apc-main {
	min-height: 50vh;
	padding: 24px 0 48px;
}

.apc-breadcrumb ol {
	display: flex;
	flex-wrap: wrap;
	padding: 0;
	margin: 0 0 16px;
	gap: 6px;
	color: var(--apc-text-muted, #6b7280);
	font-size: 0.875rem;
	list-style: none;
}

.apc-breadcrumb li + li::before {
	margin-right: 6px;
	content: "/";
}

.apc-breadcrumb a {
	color: inherit;
	text-decoration: none;
}

/* ------------------------------------------------------ Trang sản phẩm */

.apc-product__top {
	display: grid;
	gap: 32px;
	grid-template-columns: minmax( 0, 5fr ) minmax( 0, 7fr );
}

.apc-product__details {
	margin-top: 40px;
}

/* --------------------------------------------------- Danh sách sản phẩm */

.apc-archive__body {
	display: grid;
	gap: 24px;
	grid-template-columns: 260px minmax( 0, 1fr );
}

.apc-archive__title {
	margin: 0 0 8px;
}

.apc-facets {
	align-self: start;
	padding: 16px;
	border: 1px solid var(--apc-border, #e5e7eb);
	border-radius: var(--apc-radius, 8px);
}

/* ---------------------------------------------------------- Bài viết */

.apc-post__thumb {
	margin: 16px 0;
}

.apc-post-card {
	overflow: hidden;
	border: 1px solid var(--apc-border, #e5e7eb);
	border-radius: var(--apc-radius, 8px);
}

.apc-post-card__link {
	color: inherit;
	text-decoration: none;
}

.apc-post-card__title {
	padding: 0 12px;
	margin: 12px 0 4px;
	font-size: 1rem;
}

.apc-post-card__excerpt,
.apc-post-card__date {
	display: block;
	padding: 0 12px 12px;
	color: var(--apc-text-muted, #6b7280);
	font-size: 0.875rem;
}

/* --------------------------------------------------------------- Banner */

.apc-slider {
	display: flex;
	overflow-x: auto;
	gap: 12px;
	scroll-snap-type: x mandatory;
}

.apc-slider__item {
	flex: 0 0 100%;
	scroll-snap-align: start;
}

.apc-slider__item img {
	width: 100%;
	border-radius: var(--apc-radius, 8px);
}

/* ------------------------------------------------------------ Chân trang */

.apc-site-footer {
	margin-top: 48px;
	padding: 40px 0 0;
}

.apc-site-footer a {
	color: inherit;
}

.apc-site-footer__inner {
	display: grid;
	gap: 32px;
	grid-template-columns: repeat( auto-fit, minmax( 220px, 1fr ) );
}

.apc-site-footer__bottom {
	padding: 16px 0;
	border-top: 1px solid rgba( 255, 255, 255, 0.12 );
	margin-top: 32px;
	font-size: 0.875rem;
}

.apc-menu--footer {
	flex-direction: column;
}

/* ------------------------------------------------------- Điểm ngắt */

@media ( max-width: 1024px ) {
	.apc-archive__body {
		grid-template-columns: 1fr;
	}

	.apc-product__top {
		grid-template-columns: 1fr;
	}
}

@media ( max-width: 767px ) {
	.apc-site-header__inner {
		grid-template-columns: auto 1fr;
	}

	.apc-site-header__search {
		order: 3;
		grid-column: 1 / -1;
	}

	.apc-nav-toggle {
		display: block;
	}

	/* Menu dạng ngăn kéo trên điện thoại. */
	.apc-site-header__nav .apc-menu {
		position: fixed;
		z-index: 60;
		top: 0;
		right: 0;
		bottom: 0;
		width: min( 320px, 86vw );
		flex-direction: column;
		padding: 24px 16px;
		background: var(--apc-bg, #fff);
		box-shadow: -8px 0 24px rgba( 17, 24, 39, 0.18 );
		overflow-y: auto;
		transform: translateX( 100% );
		transition: transform 0.2s ease;
	}

	.apc-site-header__nav.is-open .apc-menu {
		transform: none;
	}

	.apc-menu .sub-menu {
		position: static;
		display: block;
		border: 0;
		box-shadow: none;
		padding-left: 12px;
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.apc-site-header__nav .apc-menu {
		transition: none;
	}
}

/* =========================================================================
   Thang chuyển động — docs/07-chuan-giao-dien.md §4
   ========================================================================= */

:root {
	--apc-motion-fast: 120ms;
	--apc-motion-base: 200ms;
	--apc-motion-slow: 280ms;
	--apc-ease: cubic-bezier( 0.2, 0.8, 0.2, 1 );
}

/* Chỉ chuyển động transform và opacity để không gây reflow. */
.apc-card,
.apc-tile,
.apc-btn,
.apc-post-card {
	transition: transform var( --apc-motion-fast ) ease-out,
		box-shadow var( --apc-motion-fast ) ease-out,
		opacity var( --apc-motion-fast ) ease-out;
}

.apc-card:hover,
.apc-tile:hover,
.apc-post-card:hover {
	box-shadow: 0 6px 20px rgba( 17, 24, 39, 0.1 );
	transform: translateY( -2px );
}

.apc-card:active,
.apc-tile:active {
	transform: translateY( 0 );
}

.apc-card__media img {
	transition: transform var( --apc-motion-base ) var( --apc-ease );
}

.apc-card:hover .apc-card__media img {
	transform: scale( 1.04 );
}

/* Ảnh luôn giữ chỗ để nội dung không nhảy (CLS). */
.apc-card__media {
	overflow: hidden;
	aspect-ratio: 1 / 1;
}

.apc-search__suggest {
	transform-origin: top center;
	animation: apc-pop var( --apc-motion-base ) var( --apc-ease );
}

@keyframes apc-pop {
	from {
		opacity: 0;
		transform: translateY( -4px ) scale( 0.99 );
	}

	to {
		opacity: 1;
		transform: none;
	}
}

.apc-form__message {
	transition: opacity var( --apc-motion-base ) ease-out;
}

/* Tiêu điểm bàn phím luôn thấy rõ — §5. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
	outline: 2px solid var( --apc-primary, #0b5cab );
	outline-offset: 2px;
}

/* Tôn trọng người dùng tắt chuyển động — §4. */
@media ( prefers-reduced-motion: reduce ) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		scroll-behavior: auto !important;
		transition-duration: 0.01ms !important;
	}
}
