/* HanziLore landing page.
   Colours and fonts are set once here; change a value and the whole page follows.
   They match the web app (web/src/app.css). */
:root {
	--paper: #ffffff;
	--mist: #f2f4f7;          /* alternate section background */
	--ink: #1d2431;           /* text, dark section */
	--muted: #5d6677;
	--rule: #d4dae3;
	--component: #3552a3;     /* component keywords, like the app */
	--meaning: #b5382a;       /* meanings, hanzi */
	--anchor: #22705e;        /* sound anchors */
	--tone-1: #b5382a;
	--tone-2: #c07a12;
	--tone-3: #22705e;
	--tone-4: #3552a3;
	--tone-5: #7a8291;
	--grid: rgba(181, 56, 42, 0.5); /* 田字格 practice-square lines */

	--font: 'Atkinson Hyperlegible', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
	--font-han: 'Noto Serif SC', 'Songti SC', 'STSong', 'SimSun', 'Source Han Serif SC', serif;
	--wrap: 1120px;
	--radius: 10px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
	margin: 0;
	background: var(--paper);
	color: var(--ink);
	font: 18px/1.6 var(--font);
	-webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; }
a { color: inherit; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--component) 55%, transparent); outline-offset: 3px; border-radius: 4px; }
code { font: 0.92em ui-monospace, 'Cascadia Mono', Consolas, monospace; background: var(--mist); padding: 0.05em 0.35em; border-radius: 4px; }
.band-ink code { background: rgba(255, 255, 255, 0.12); }
i { font-style: italic; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }
.narrow { max-width: 760px; }

/* ---------- type ---------- */
h1, h2, h3 { margin: 0; line-height: 1.12; letter-spacing: -0.015em; }
h1 { font-size: clamp(2.6rem, 5.6vw, 4.6rem); line-height: 1.02; letter-spacing: -0.035em; max-width: 11em; }
h2 { font-size: clamp(1.9rem, 3.4vw, 2.75rem); letter-spacing: -0.025em; max-width: 20em; }
h3 { font-size: 1.2rem; margin-bottom: 0.4rem; }
p { margin: 0 0 1em; max-width: 66ch; }
.lede { font-size: 1.2rem; color: var(--muted); margin-top: 1.4rem; }
.section-lede { font-size: 1.15rem; color: var(--muted); margin: 1rem 0 2.5rem; }
.note { color: var(--muted); font-size: 0.95rem; }
.band-ink .section-lede, .band-ink .note { color: rgba(255, 255, 255, 0.72); }

/* highlight tags, same meaning as in the app */
.t-r { color: var(--component); }
.t-m { color: var(--meaning); }
.t-a { color: var(--anchor); }
.tone-1 { color: var(--tone-1); }
.tone-2 { color: var(--tone-2); }
.tone-3 { color: var(--tone-3); }
.tone-4 { color: var(--tone-4); }
.tone-5 { color: var(--tone-5); }
.pinyin { font-weight: 700; letter-spacing: 0.01em; }
.pinyin.big { font-size: 2.4rem; line-height: 1; margin: 0 0 0.6rem; }

/* ---------- buttons ---------- */
.btn {
	display: inline-flex; align-items: center; justify-content: center;
	padding: 0.6rem 1.15rem; border-radius: 8px;
	background: var(--ink); color: #fff; border: 1.5px solid var(--ink);
	font-weight: 700; text-decoration: none; white-space: nowrap;
	transition: background-color 120ms, color 120ms;
}
.btn:hover { background: #333c4d; border-color: #333c4d; }
.btn-big { padding: 0.85rem 1.5rem; font-size: 1.08rem; }
.btn-quiet { background: transparent; color: var(--ink); border-color: var(--rule); }
.btn-quiet:hover { background: var(--mist); border-color: var(--rule); }
.link { font-weight: 700; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1.5px; }

/* ---------- 田字格 practice square ---------- */
.tzg {
	--s: 64px;
	position: relative; flex: none;
	width: var(--s); height: var(--s);
	display: grid; place-items: center;
	background: #fff;
	border: 2px solid var(--grid);
	border-radius: 4px;
	font-family: var(--font-han); font-weight: 600;
	font-size: calc(var(--s) * 0.66); line-height: 1; color: var(--ink);
}
.tzg::before {
	content: ''; position: absolute; inset: 0;
	background:
		linear-gradient(to right, transparent calc(50% - 0.5px), var(--grid) calc(50% - 0.5px), var(--grid) calc(50% + 0.5px), transparent calc(50% + 0.5px)),
		linear-gradient(to bottom, transparent calc(50% - 0.5px), var(--grid) calc(50% - 0.5px), var(--grid) calc(50% + 0.5px), transparent calc(50% + 0.5px)),
		linear-gradient(45deg, transparent calc(50% - 0.5px), var(--grid) calc(50% - 0.5px), var(--grid) calc(50% + 0.5px), transparent calc(50% + 0.5px)),
		linear-gradient(-45deg, transparent calc(50% - 0.5px), var(--grid) calc(50% - 0.5px), var(--grid) calc(50% + 0.5px), transparent calc(50% + 0.5px));
	mask: repeating-linear-gradient(45deg, #000 0 5px, transparent 5px 9px);
	-webkit-mask: repeating-linear-gradient(45deg, #000 0 5px, transparent 5px 9px);
	opacity: 0.55;
}
.tzg span { position: relative; }
.tzg.sm { --s: 64px; }
.tzg.md { --s: 112px; }
.tzg.lg { --s: 176px; }
.tzg.wide { width: calc(var(--s) * 1.7); font-size: calc(var(--s) * 0.5); }
.tzg.wide::before { display: none; }

/* ---------- header ---------- */
.top {
	position: sticky; top: 0; z-index: 10;
	background: color-mix(in srgb, var(--paper) 88%, transparent);
	backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
	border-bottom: 1px solid color-mix(in srgb, var(--rule) 70%, transparent);
}
.top-row { display: flex; align-items: center; gap: 28px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; text-decoration: none; }
.brand img { border-radius: 50%; }
.top-nav { display: flex; gap: 22px; margin-right: auto; font-size: 0.95rem; }
.top-nav a { text-decoration: none; color: var(--muted); }
.top-nav a:hover { color: var(--ink); }
.top-actions { display: flex; align-items: center; gap: 18px; font-size: 0.95rem; }
@media (max-width: 860px) { .top-nav { display: none; } .top-actions { margin-left: auto; } }
@media (max-width: 420px) { .top-actions .link { display: none; } }

/* ---------- hero ---------- */
.hero {
	display: grid; grid-template-columns: 1.15fr 1fr; gap: 56px; align-items: center;
	padding-top: clamp(48px, 9vw, 112px); padding-bottom: clamp(56px, 9vw, 120px);
}
.cta-row { display: flex; align-items: center; flex-wrap: wrap; gap: 22px; margin-top: 2rem; }
.hero-demo {
	margin: 0; padding: 32px;
	background: var(--mist); border-radius: 18px;
	display: flex; flex-direction: column; gap: 18px;
}
.build { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.build .op { font-size: 2rem; color: var(--muted); font-weight: 700; }
.keys { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 1.05rem; }
.keys .pinyin { font-size: 2rem; }
.story { margin: 0; font-size: 1.05rem; padding-left: 14px; border-left: 3px solid var(--rule); }
.hero-demo figcaption { font-size: 0.9rem; color: var(--muted); }
@media (max-width: 900px) {
	.hero { grid-template-columns: 1fr; gap: 40px; }
	.tzg.lg { --s: 132px; }
}

/* the one orchestrated animation: the hero builds 女 + 子 = 好, then tells its stories */
.js [data-demo] [data-step], .js .hero-demo > [data-step] {
	opacity: 0; transform: translateY(8px);
	transition: opacity 420ms ease, transform 420ms ease;
}
.js .hero-demo .on { opacity: 1 !important; transform: none !important; }
.js .tzg.lg[data-step] { transform: scale(0.92); }
@media (prefers-reduced-motion: reduce) {
	.js [data-demo] [data-step], .js .hero-demo > [data-step] { opacity: 1; transform: none; transition: none; }
}

/* ---------- sections ---------- */
.section { padding-top: clamp(72px, 10vw, 128px); padding-bottom: clamp(72px, 10vw, 128px); }
.band { background: var(--mist); padding: clamp(72px, 10vw, 128px) 0; }
.band-ink { background: var(--ink); color: #fff; }
.band-ink .checks li::before { background: var(--tone-2); }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 56px; margin-top: 56px; }
.split h3 + p, .split p + h3 { margin-top: 0; }
.split h3:not(:first-child) { margin-top: 1.8rem; }
@media (max-width: 820px) { .split { grid-template-columns: 1fr; gap: 36px; } }

/* how it works: a real sequence, so it is numbered */
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 40px; counter-reset: step; }
.steps li { counter-increment: step; position: relative; padding-top: 8px; }
.steps .tzg { margin-bottom: 18px; }
.steps h3::before { content: counter(step) '. '; color: var(--muted); }
.steps li:not(:last-child)::after {
	content: ''; position: absolute; top: 40px; left: 92px; right: -24px; height: 2px;
	background: repeating-linear-gradient(90deg, var(--rule) 0 6px, transparent 6px 12px);
}
.steps p { color: var(--muted); }
@media (max-width: 820px) { .steps { grid-template-columns: 1fr; } .steps li::after { display: none; } }

/* sound anchors */
.anchors { display: grid; grid-template-columns: repeat(3, 1fr); gap: 40px; }
.anchor-col { border-top: 3px solid var(--anchor); padding-top: 18px; }
.anchor-col p { color: var(--muted); }
.tone-spots { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.tone-spots span { display: inline-block; width: 1.6em; font-weight: 700; }
.worked { display: flex; gap: 28px; align-items: center; margin-top: 56px; padding: 28px; border: 1.5px solid var(--rule); border-radius: 18px; }
.worked p:last-child { margin-bottom: 0; }
@media (max-width: 820px) { .anchors { grid-template-columns: 1fr; gap: 28px; } .worked { flex-direction: column; align-items: flex-start; } }

/* 60 levels, grouped by HSK band */
.levels { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; }
.levels .bandgrp { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.levels .lv {
	aspect-ratio: 1; display: grid; place-items: center; border-radius: 4px;
	font-size: 0.72rem; font-weight: 700; color: #fff;
	background: color-mix(in srgb, var(--component) var(--k), #fff);
}
.levels-legend { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; margin-top: 10px; font-size: 0.9rem; color: var(--muted); }
@media (max-width: 640px) {
	.levels, .levels-legend { grid-template-columns: repeat(3, 1fr); }
	.levels-legend { display: none; }
	.levels .bandgrp { position: relative; padding-bottom: 22px; }
	.levels .bandgrp::after { content: attr(data-label); position: absolute; bottom: 0; left: 0; font-size: 0.85rem; color: var(--muted); }
}
/* Rank ladder: five steps that climb left to right */
.ranks { list-style: none; margin: 2.5rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; align-items: stretch; }
/* Every card is the same height. Subgrid keeps the portrait, name, wait time and joke on shared rows across all five. */
.rank { display: grid; grid-template-rows: subgrid; grid-row: span 4; row-gap: 8px; align-content: start; padding: 20px 20px 24px; background: #fff; border: 1px solid var(--rule); border-top: 4px solid var(--rank, var(--component)); border-radius: 6px; }
.rank b { font-size: 1.2rem; }
.rank-img { width: 104px; height: 104px; image-rendering: pixelated; margin: 0 0 4px; }
.rank .wait { color: var(--ink); font-size: 0.95rem; line-height: 1.45; }
.rank .quip { color: var(--muted); font-size: 0.95rem; line-height: 1.45; font-style: italic; }
.r1 { --rank: #b5832a; }
.r2 { --rank: #22705e; }
.r3 { --rank: #3552a3; }
.r4 { --rank: #6b46a3; }
.r5 { --rank: #1d2431; background: var(--ink); color: #fff; }
.r5 .wait { color: #fff; } .r5 .quip { color: #c9d0dc; }
@media (max-width: 860px) {
	.ranks { grid-template-columns: 1fr; }
	.rank { grid-row: auto; grid-template-rows: none; }
	}

/* review features */
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 36px 40px; margin: 2.5rem 0 0; }
.features dt { font-weight: 700; font-size: 1.1rem; margin-bottom: 0.3rem; }
.features dd { margin: 0; color: var(--muted); }
@media (max-width: 900px) { .features { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .features { grid-template-columns: 1fr; } }

/* tick lists */
.checks { list-style: none; margin: 0 0 1.2rem; padding: 0; display: grid; gap: 8px; }
.checks li { position: relative; padding-left: 22px; }
.checks li::before { content: ''; position: absolute; left: 2px; top: 0.62em; width: 8px; height: 8px; border-radius: 2px; background: var(--anchor); }

/* plans */
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.plan { border: 1.5px solid var(--rule); border-radius: 18px; padding: 32px; display: flex; flex-direction: column; }
.plan .btn { margin-top: auto; align-self: flex-start; }
.plan-premium { border-color: var(--ink); box-shadow: 6px 6px 0 var(--ink); }
.plan-price { font-size: 1.6rem; font-weight: 700; margin: 0.2rem 0 1.4rem; }
@media (max-width: 760px) { .plans { grid-template-columns: 1fr; } }

/* FAQ */
details { border-bottom: 1px solid var(--rule); }
details:first-of-type { border-top: 1px solid var(--rule); margin-top: 2rem; }
summary {
	cursor: pointer; list-style: none; padding: 20px 40px 20px 0; position: relative;
	font-weight: 700; font-size: 1.1rem;
}
summary::-webkit-details-marker { display: none; }
summary::after {
	content: ''; position: absolute; right: 8px; top: 50%; width: 12px; height: 12px; margin-top: -8px;
	border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
	transform: rotate(45deg); transition: transform 160ms ease;
}
details[open] summary::after { transform: rotate(-135deg); margin-top: -2px; }
details p { color: var(--muted); padding-bottom: 8px; }

/* image block for sections you add later */
.shot { margin: 0; }
.shot img { display: block; border-radius: var(--radius); border: 1px solid var(--rule); }
.shot figcaption { margin-top: 10px; font-size: 0.9rem; color: var(--muted); }

/* closing */
.closing { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 24px; padding-top: clamp(80px, 11vw, 140px); padding-bottom: clamp(80px, 11vw, 140px); }
.closing h2 { max-width: none; }

/* footer */
.foot { border-top: 1px solid var(--rule); padding: 28px 0; font-size: 0.92rem; color: var(--muted); }
.foot-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.foot nav { display: flex; gap: 20px; }
.foot a { text-decoration: none; }
.foot a:hover { color: var(--ink); }

.plan-note { color: var(--muted); font-size: 0.95rem; margin: -0.6rem 0 1.2rem; }

.faq-more { margin-top: 1.5rem; color: var(--muted); }
