/* ==========================================================================
   Trang chủ (front-page.php) — Figma "SỬA MỚI" (docs/07). Sections in page order.
   Sizes: Figma ÷ 2.625 at 1920, adjusted where the literal value reads too loud (docs/07 §2.5).
   Sections not designed yet (roles, why, partners, roadmap) keep their placeholder + background.
   ========================================================================== */

/* --- 1. Hero ------------------------------------------------------------ */
.p-top-hero {
	padding-top: clamp(24px, 0.9rem + 2.6vw, 76px);
	background: var(--c-bg);
}

.p-top-hero__inner {
	display: grid;
	gap: var(--space-6);
}

.p-top-hero__kicker {
	font-family: var(--font-display);
	font-size: var(--fs-hero-kicker);
	font-weight: var(--fw-bold);
	line-height: 1.3;
	color: var(--c-primary);
}

.p-top-hero__title {
	max-width: 15em;
	margin-top: clamp(12px, 0.5rem + 1vw, 32px);
	font-family: var(--font-display);
	font-size: var(--fs-hero);
	font-weight: var(--fw-bold);
	line-height: 1.24;
	letter-spacing: var(--ls-heading);
	color: var(--c-primary);
	text-wrap: balance;
}

.p-top-hero__brand {
	color: var(--c-accent-orange);
}

.p-top-hero__media {
	position: relative;
	width: 100%;
	max-width: 640px;
	margin-inline: auto;
}

/* Pentagon photo frame, traced from the Figma layer (flat bottom = sits on the next band). */
.p-top-hero__frame {
	position: relative;
	aspect-ratio: 2233 / 1792;
	background: var(--c-pastel-ice);
	-webkit-mask: url("../../img/top/hero-mask.svg") 0 0 / 100% 100% no-repeat;
	mask: url("../../img/top/hero-mask.svg") 0 0 / 100% 100% no-repeat;
}

.p-top-hero__controls {
	position: absolute;
	bottom: clamp(12px, 0.5rem + 0.8vw, 26px);
	left: 50%;
	z-index: 2;
	transform: translateX(-50%);
}

@media (min-width: 1024px) {
	.p-top-hero__inner {
		grid-template-columns: minmax(0, 46fr) minmax(0, 54fr);
		gap: var(--space-6);
		align-items: center;
	}

	.p-top-hero__text {
		padding-bottom: clamp(24px, 4vw, 96px);   /* optical centre a bit above the photo's */
	}

	.p-top-hero__media {
		max-width: none;
		align-self: end;
	}

	.p-top-hero__controls {
		left: 0;
		transform: translateX(-12px);
	}
}

/* --- 2. Số liệu --------------------------------------------------------- */
.p-top-stats {
	position: relative;
	padding-block: clamp(28px, 1rem + 2.6vw, 72px) clamp(64px, 2.6rem + 3.6vw, 136px);
	background: var(--c-bg-cream);
}

/* 3 kids in clouds (Figma image 73 / 71 / 72, ÷ 2.625: 373 / 455 / 379 px, gaps ≈ 84 px; bottoms of
   the side clouds sit 55 / 21 px above the centre one). */
.p-top-stats__clouds {
	position: relative;
	display: flex;
	align-items: flex-end;
	justify-content: center;
	gap: clamp(6px, 4.4vw, 84px);
	margin-bottom: clamp(10px, 0.7vw, 14px);
}

.p-top-stats__cloud {
	width: clamp(100px, 19.4vw, 373px);
	height: auto;
}

.p-top-stats__cloud--left {
	margin-bottom: clamp(10px, 2.9vw, 55px);
}

.p-top-stats__cloud--center {
	width: clamp(120px, 23.7vw, 455px);
}

.p-top-stats__cloud--right {
	width: clamp(100px, 19.7vw, 379px);
	margin-bottom: clamp(4px, 1.1vw, 21px);
}

.p-top-stats__sparkle {
	position: absolute;
	z-index: 1;
	width: clamp(14px, 1.75vw, 34px);
	height: auto;
}

.p-top-stats__sparkle--blue {
	top: 12%;
	left: 66%;
}

.p-top-stats__sparkle--pink {
	bottom: 24%;
	left: 34%;
}

.p-top-stats__list {
	display: grid;
	gap: 18px;
}

.p-top-stats__item {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: clamp(24px, 0.9rem + 2.6vw, 64px) var(--space-4);
	border-radius: clamp(28px, 1.3rem + 1.9vw, 58px);
	text-align: center;
}

.p-top-stats__item--blue {
	background: var(--c-pastel-sky);
	color: var(--c-stat-blue);
}

.p-top-stats__item--green {
	background: var(--c-pastel-green);
	color: var(--c-stat-green);
}

.p-top-stats__item--pink {
	background: var(--c-pastel-pink);
	color: var(--c-stat-pink);
}

/* Figma uses "Harabara Mais Demo" (demo licence, not on Google Fonts) → Mona Sans bold, tight. */
.p-top-stats__value {
	font-size: var(--fs-stat);
	font-weight: var(--fw-bold);
	line-height: 1;
	letter-spacing: -0.035em;
}

.p-top-stats__text {
	margin-top: var(--space-3);
	font-family: var(--font-eyebrow);
	font-size: var(--fs-stat-label);
	font-weight: var(--fw-medium);
	line-height: 1.35;
}

/* Binder rings joining two boxes — vertical stack: across the top edge */
.p-top-stats__rings {
	position: absolute;
	top: 0;
	left: 50%;
	display: flex;
	gap: clamp(28px, 8vw, 56px);
	transform: translate(-50%, -50%);
}

.p-top-stats__rings i {
	display: block;
	width: 14px;
	height: 30px;
	background: var(--c-surface);
	border: 2px solid var(--c-ring);
	border-radius: var(--radius-pill);
}

@media (min-width: 768px) {
	.p-top-stats__list {
		grid-template-columns: repeat(3, minmax(0, 1fr));
		gap: 6px;
	}

	.p-top-stats__rings {
		top: 50%;
		left: -3px;
		flex-direction: column;
		gap: clamp(10px, 1.6vw, 32px);
	}

	.p-top-stats__rings i {
		width: clamp(28px, 2.8vw, 53px);
		height: clamp(13px, 1.35vw, 26px);
		border-width: clamp(2px, 0.16vw, 3px);
	}
}

/* --- 3. Bạn là ai? (placeholder — wave edge only) ------------------------ */
.p-top-roles {
	--wave-color: var(--c-pastel-rose);   /* Figma Rectangle 70: #F8BAD2 at 29% */
	position: relative;
	background: var(--c-pastel-rose);
}

/* --- 4. 8 tính năng ------------------------------------------------------ */
.p-top-features .p-top-features__grid {   /* section prefix beats reset.css ul[class] { margin: 0 } */
	display: grid;
	gap: clamp(12px, 0.3rem + 1vw, 30px);
	margin-inline: auto;
}

/* Phones (Figma HOME - PHONE, 26/11/2026): 3 small stamps per row, the last 2 centred (6-column grid,
   each card spans 2) — picture, name, sub-line and "Nhấp để xem" only; the 3 bullet points stay on the
   board. Same order as desktop (user). */
@media (max-width: 767px) {
	.p-top-features .p-top-features__grid {
		grid-template-columns: repeat(6, minmax(0, 1fr));
		gap: 8px;
		max-width: 420px;
	}

	.p-top-features__item {
		grid-column: span 2;
		grid-template-columns: minmax(0, 1fr);   /* the card never grows wider than its column */
		min-width: 0;
	}

	.p-top-features__item:nth-child(3n + 1):nth-last-child(2) {   /* last row of 2 → centred */
		grid-column: 2 / span 2;
	}

	.p-top-features__item:nth-child(3n + 1):last-child {          /* last row of 1 → centred */
		grid-column: 3 / span 2;
	}

	.p-top-features .c-postcard {
		--stamp-frame: 6px;
		--stamp-r: 3px;
	}

	.p-top-features .c-postcard__inner {
		padding: 10px 3px 10px;
	}

	.p-top-features .c-postcard__media {
		height: clamp(56px, 17vw, 76px);
		margin-bottom: 8px;
	}

	.p-top-features .c-postcard__title {
		font-size: 0.8125rem;            /* 13px */
		line-height: 1.2;
	}

	.p-top-features .c-postcard__sub {
		margin-top: 4px;
		font-size: 0.6875rem;            /* 11px (Figma ≈ 11) */
		font-weight: var(--fw-medium);
		line-height: 1.3;
	}

	.p-top-features .c-postcard__sub .u-nowrap {   /* "Dashboard Real-time" is wider than a small stamp */
		white-space: normal;
	}

	.p-top-features .c-postcard__list {
		display: none;
	}

	.p-top-features .c-postcard__foot {
		padding-top: 10px;
	}

	.p-top-features .c-postcard__more {
		gap: 3px;
		min-height: 26px;
		padding: 4px 7px;
		font-size: clamp(0.5625rem, 2.7vw, 0.6875rem);   /* 9.7px at 360 → 11px from 410 */
		white-space: nowrap;
	}

	.p-top-features .c-postcard__more .c-icon {
		width: 7px;
	}
}

.p-top-features__item {
	display: grid;
}

/* Grid ⇄ board switch (main.js adds .is-entering) */
.p-top-features [data-features-grid][hidden] {
	display: none;
}

.p-top-features .is-entering {
	animation: sk-panel-in 0.45s ease both;
}

@media (prefers-reduced-motion: reduce) {
	.p-top-features .is-entering {
		animation: none;
	}
}

@media (min-width: 768px) {
	.p-top-features .p-top-features__grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		max-width: 820px;
	}
}

@media (min-width: 1280px) {
	.p-top-features .p-top-features__grid {
		grid-template-columns: repeat(4, minmax(0, 1fr));
		max-width: 1500px;   /* Figma grid 3917 ÷ 2.625 */
	}
}

/* --- 5. Vượt trội — notebook with 3 tabs (components.css .c-book) ---------- */
.p-top-why {
	background: var(--c-surface);   /* Figma: no section background */
}

/* --- 6. Câu chuyện thương hiệu ------------------------------------------ */
.p-top-story {
	--wave-color: var(--c-pastel-ice);
	position: relative;
	padding-bottom: clamp(40px, 1.6rem + 2.6vw, 88px);
	background: var(--c-pastel-ice);
}

.p-top-story__inner {
	display: grid;
	gap: var(--space-7);
	align-items: center;
}

.p-top-story__media {
	position: relative;
	padding-bottom: 28px;
}

.p-top-story__photo {                 /* Figma image 70: 1506 × 1460 → 574px at 1920 */
	display: block;
	width: 100%;
	max-width: 574px;
	height: auto;
	margin-inline: auto;
}

.p-top-story__founder {
	position: absolute;
	bottom: 0;
	left: 50%;
	width: max-content;
	max-width: calc(100% - 16px);
	padding: var(--space-3) var(--space-6);
	background: var(--c-surface);
	border-radius: var(--radius-pill);
	box-shadow: 0 6px 17px -1px rgba(102, 102, 102, 0.33);
	color: var(--c-primary);
	font-family: var(--font-display);
	font-size: var(--fs-sm);
	font-weight: var(--fw-bold);
	text-align: center;
	transform: translateX(-50%);
}

.p-top-story .c-section-head {
	margin-bottom: var(--space-5);
}

.p-top-story__text {
	display: grid;
	gap: 1em;
	max-width: 40em;
	font-family: var(--font-eyebrow);
	font-weight: var(--fw-medium);
	line-height: 1.75;
	color: var(--c-text-eyebrow);
}

.p-top-story__link {
	margin-top: var(--space-6);
}

@media (min-width: 1024px) {
	.p-top-story__inner {
		grid-template-columns: minmax(0, 0.86fr) minmax(0, 1fr);
		gap: clamp(48px, 5.7vw, 110px);
	}
}

/* --- 6b. "SanAn kids cho mỗi ngày thêm An" ------------------------------ */
.p-top-an-band {
	--panel-pad: clamp(16px, 0.4rem + 3.5vw, 80px);
	padding-bottom: var(--section-space);
	background: var(--c-pastel-ice);
}

.p-top-an-band__title {
	position: relative;
	z-index: 1;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 0.15em 0.4em;
	padding: clamp(18px, 0.6rem + 1.9vw, 54px) var(--space-5);
	background: var(--c-pastel-pink);
	border-radius: var(--radius-lg);
	color: var(--c-primary-dark);
	font-family: var(--font-display);
	font-size: var(--fs-band);
	font-weight: var(--fw-bold);
	line-height: 1.2;
	text-align: center;
}

.p-top-an-band__logo {
	width: auto;
	height: 1.15em;
}

.p-top-an-band__accent {
	color: var(--c-accent);
}

.p-top-an-band__panel {
	margin-top: calc(var(--radius-lg) * -1);
	padding: calc(var(--radius-lg) + clamp(20px, 0.8rem + 1.3vw, 46px)) var(--panel-pad) clamp(32px, 1.2rem + 1.4vw, 56px);
	background: rgba(255, 255, 255, 0.73);
	border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.p-top-an-band__photos {
	position: relative;
	display: grid;
	gap: var(--space-7);
	justify-items: center;
}

.p-top-an-band__photo {
	--tilt: 4deg;
	--line-y: clamp(20px, 0.7rem + 0.6vw + 2px, 27px);   /* middle of the navy line = where the clip bites */
	position: relative;
	width: min(100%, 380px);
}

.p-top-an-band__photo:nth-child(2) {
	--tilt: -4deg;
}

/* Clip + photo hang together: the swing (components.css "Hanging swing") turns this box around the
   clip on the line, so the bottom of the photo travels further than the top — like a real pendulum.
   The photo keeps its own resting tilt (--tilt), so the still picture is unchanged. */
.p-top-an-band__hanger {
	position: relative;
	padding-top: clamp(40px, 1.6rem + 1.2vw, 52px);
	transform-origin: 50% var(--line-y);
}

.p-top-an-band__clip {
	position: absolute;
	top: 0;
	left: 50%;
	z-index: 1;
	width: clamp(20px, 0.9rem + 0.6vw, 28px);
	height: auto;
	transform: translateX(-50%);
}

.p-top-an-band__img {
	width: 100%;
	height: auto;
	transform: rotate(var(--tilt));
}

@media (min-width: 768px) {
	.p-top-an-band__photos {
		grid-template-columns: repeat(3, minmax(0, 1fr));
		gap: clamp(16px, 3.4vw, 64px);
	}

	/* The navy line the 3 photos hang from (Figma "Rectangle 81") */
	.p-top-an-band__photos::before {
		content: "";
		position: absolute;
		top: clamp(18px, 0.7rem + 0.6vw, 24px);
		right: calc(var(--panel-pad) * -1);
		left: calc(var(--panel-pad) * -1);
		height: clamp(4px, 0.2rem + 0.15vw, 7px);
		background: var(--c-primary-dark);
	}

	.p-top-an-band__photo {
		width: 100%;
	}
}

/* Hanging swing (main.js [data-swing], docs/07 §6g): a gust runs along the line once the photos
   come into view — damped pendulum (+A, −0.62A, +0.38A, −0.22A, +0.1A, rest), sine easing per
   swing, photos left → right 150ms apart with slightly different amplitude / period.
   Hover (mouse only): a small nudge. Only transform; none of it with reduced motion. */
@keyframes sk-swing {
	0%   { transform: rotate(0deg); animation-timing-function: cubic-bezier(0.2, 0.6, 0.45, 1); }
	11%  { transform: rotate(var(--swing-a)); animation-timing-function: cubic-bezier(0.37, 0, 0.63, 1); }
	29%  { transform: rotate(calc(var(--swing-a) * -0.62)); animation-timing-function: cubic-bezier(0.37, 0, 0.63, 1); }
	46%  { transform: rotate(calc(var(--swing-a) * 0.38)); animation-timing-function: cubic-bezier(0.37, 0, 0.63, 1); }
	63%  { transform: rotate(calc(var(--swing-a) * -0.22)); animation-timing-function: cubic-bezier(0.37, 0, 0.63, 1); }
	80%  { transform: rotate(calc(var(--swing-a) * 0.1)); animation-timing-function: cubic-bezier(0.37, 0, 0.63, 1); }
	100% { transform: rotate(0deg); }
}

.p-top-an-band__hanger {
	--swing-a: 4deg;                   /* phones: photos hang alone, a softer swing */
	--swing-t: 2.6s;
	--swing-d: 0ms;
}

.p-top-an-band__hanger.is-swinging {
	animation: sk-swing var(--swing-t) var(--swing-d) both;
}

.p-top-an-band__photos .p-top-an-band__photo .p-top-an-band__hanger.is-nudged {   /* beats the per-photo values below */
	--swing-a: 2.6deg;
	animation: sk-swing 1.5s both;
}

@media (min-width: 768px) {
	/* 80ms apart + ~6°: close enough in phase that neighbours never touch (36px gap at 1920) */
	.p-top-an-band__photo:nth-child(1) .p-top-an-band__hanger { --swing-a: 6deg; --swing-t: 2.6s; --swing-d: 0ms; }
	.p-top-an-band__photo:nth-child(2) .p-top-an-band__hanger { --swing-a: 5.7deg; --swing-t: 2.55s; --swing-d: 80ms; }
	.p-top-an-band__photo:nth-child(3) .p-top-an-band__hanger { --swing-a: 6.2deg; --swing-t: 2.65s; --swing-d: 160ms; }
}

@media (prefers-reduced-motion: reduce) {
	.p-top-an-band__hanger.is-swinging,
	.p-top-an-band__hanger.is-nudged {
		animation: none;
	}
}

/* --- 7. Sẻ chia chân thành ---------------------------------------------- */
.p-top-testimonials {
	--wave-color: var(--c-pastel-purple);
	position: relative;
	background: var(--c-pastel-purple);
}

.p-top-testimonials .p-top-testimonials__grid {
	display: grid;
	gap: clamp(20px, 1rem + 0.6vw, 30px);
	max-width: 560px;
	margin-inline: auto;
}

@media (min-width: 1024px) {
	.p-top-testimonials .p-top-testimonials__grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
		max-width: 1510px;   /* Figma 3959 ÷ 2.625 */
	}
}

/* --- 8. Đối tác — 2 logo rows (components.css .c-marquee) ---------------- */
.p-top-partners {
	background: var(--c-pastel-green);
}

.p-top-partners__rows {
	display: grid;
	gap: clamp(8px, 0.3rem + 0.5vw, 16px);
}

/* Phones / tablets (no outline on the left): rows run edge to edge so pills never stop at a hard cut.
   From 1024px they stay inside the container (decision 17/11, option A). */
@media (max-width: 1023px) {
	.p-top-partners__rows {
		margin-inline: calc(var(--container-gutter) * -1);
	}
}

.p-top-partners__foot {
	display: flex;
	flex-direction: column;
	gap: var(--space-4);
	align-items: center;
	margin-top: clamp(36px, 1.6rem + 2.2vw, 72px);
	text-align: center;
}

.p-top-partners__sub {
	margin: 0;
}

/* --- 9. Lộ trình 30 ngày (components.css .c-roadmap, docs/07 §6f) ------- */
.p-top-roadmap {
	--wave-color: var(--c-pastel-ice);       /* Figma Group 151: #EEF6FC, wavy top + bottom */
	position: relative;
	padding-bottom: calc(var(--section-space) + clamp(24px, 0.9rem + 2.9vw, 72px));   /* + bottom wave */
	background: var(--c-pastel-ice);
	overflow-x: clip;                         /* the dotted line runs a little past the container */
}

/* --- Motion preference -------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
	.c-slider__slide,
	.c-postcard {
		transition: none;
	}
}
