/* css/style.css — shared design system for the HSK 1 & 2 study site.
   Every feature page reuses these tokens & components so the look stays consistent.
   Agents: prefer these classes; add page-specific rules in your own <style> block. */

:root {
  --red: #c8102e;          /* Chinese red accent */
  --red-dark: #9e0c24;
  --gold: #f4b400;
  --ink: #1f2330;
  --ink-soft: #565b6e;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --line: #e6e8f0;
  --green: #1f9d55;
  --red-wrong: #e02d2d;
  --blue: #2d6cdf;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 4px 18px rgba(31, 35, 48, .08);
  --shadow-lg: 0 12px 40px rgba(31, 35, 48, .16);
  --maxw: 1040px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --cjk: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Noto Sans CJK SC", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); color: var(--ink);
  background: var(--bg); line-height: 1.55;
}
:lang(zh), .hanzi, .cjk { font-family: var(--cjk); }
a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
img { max-width: 100%; }

/* ---------- navigation ---------- */
.site-nav { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50; box-shadow: 0 1px 0 rgba(0,0,0,.02); }
.nav-inner { max-width: var(--maxw); margin: 0 auto; display: flex; align-items: center; gap: 14px; padding: 10px 16px; flex-wrap: wrap; }
.nav-brand { font-family: var(--cjk); font-size: 1.5rem; font-weight: 800; color: var(--red); display: flex; align-items: baseline; gap: 8px; }
.nav-brand span { font-family: var(--font); font-size: .8rem; color: var(--ink-soft); font-weight: 700; letter-spacing: .04em; }
.nav-brand:hover { text-decoration: none; }
.nav-links { display: flex; gap: 2px; flex-wrap: wrap; margin-left: auto; }
.nav-link { color: var(--ink-soft); padding: 7px 11px; border-radius: 999px; font-size: .9rem; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.nav-link:hover { background: #f0f1f7; text-decoration: none; color: var(--ink); }
.nav-link.active { background: var(--red); color: #fff; }
.nav-ico { font-size: 1rem; }
.nav-toggle { display: none; margin-left: auto; background: none; border: 1px solid var(--line); border-radius: 8px; font-size: 1.2rem; padding: 4px 10px; cursor: pointer; }
@media (max-width: 760px) {
  .nav-toggle { display: block; }
  .nav-links { flex-basis: 100%; flex-direction: column; display: none; margin-left: 0; }
  .nav-links.open { display: flex; }
  .nav-link { width: 100%; border-radius: 8px; }
}

/* ---------- layout ---------- */
.container, .page { max-width: var(--maxw); margin: 0 auto; padding: 24px 16px 64px; }
.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: clamp(1.6rem, 3.5vw, 2.3rem); }
.page-head p { color: var(--ink-soft); margin: 0; max-width: 60ch; }
.muted { color: var(--ink-soft); }
.center { text-align: center; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.spread { justify-content: space-between; }
.stack > * + * { margin-top: 14px; }
.hidden { display: none !important; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.feature-card { display: block; color: inherit; transition: transform .12s ease, box-shadow .12s ease; }
.feature-card:hover { text-decoration: none; transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.feature-card .fc-ico { font-size: 2rem; }
.feature-card h3 { margin: 8px 0 4px; color: var(--ink); }
.feature-card p { margin: 0; color: var(--ink-soft); font-size: .92rem; }

/* ---------- buttons ---------- */
.btn { font: inherit; font-weight: 700; cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 10px 16px; border-radius: 999px; display: inline-flex; align-items: center; gap: 8px; transition: background .12s, transform .05s; }
.btn:hover { background: #f0f1f7; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); }
.btn-ghost { background: transparent; }
.btn-lg { padding: 14px 26px; font-size: 1.05rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-group { display: inline-flex; gap: 8px; flex-wrap: wrap; }

.tts-btn { border: none; background: #fdeef0; color: var(--red); border-radius: 999px; width: 38px; height: 38px; font-size: 1.05rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.tts-btn:hover { background: #fadbe0; }

/* ---------- badges / chips ---------- */
.badge { font-size: .72rem; font-weight: 800; padding: 2px 9px; border-radius: 999px; letter-spacing: .03em; }
.badge-1 { background: #e7f3ff; color: #1763b8; }
.badge-2 { background: #fff2e0; color: #b9760c; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: .85rem; cursor: pointer; font-weight: 600; color: var(--ink-soft); }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- word display ---------- */
.hanzi { font-family: var(--cjk); font-weight: 600; }
.word-card { text-align: center; }
.word-card .hanzi { font-size: 3rem; line-height: 1.1; }
.pinyin { color: var(--blue); font-weight: 700; }
.english { color: var(--ink-soft); }
.pos-tag { font-size: .72rem; color: var(--ink-soft); font-style: italic; }

/* ---------- progress ---------- */
.progress-bar { background: #eceef5; border-radius: 999px; height: 10px; overflow: hidden; }
.progress-bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--red), var(--gold)); width: 0; transition: width .4s ease; }
.stat { text-align: center; }
.stat .num { font-size: 1.9rem; font-weight: 800; color: var(--red); }
.stat .lbl { font-size: .8rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .05em; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; }

/* ---------- quiz / options (shared by mock, games, listening) ---------- */
.option { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 13px 16px; border: 2px solid var(--line); background: var(--surface); border-radius: var(--radius-sm); cursor: pointer; font: inherit; margin: 0; transition: border-color .12s, background .12s; }
.option:hover { border-color: #c9cde0; }
.option.correct { border-color: var(--green); background: #eafaf0; }
.option.wrong { border-color: var(--red-wrong); background: #fdeeee; }
.option.selected { border-color: var(--blue); }
.option-list { display: grid; gap: 10px; }

/* ---------- flashcard flip ---------- */
.flip { perspective: 1200px; }
.flip-inner { position: relative; transition: transform .5s; transform-style: preserve-3d; }
.flip.flipped .flip-inner { transform: rotateY(180deg); }
.flip-face { backface-visibility: hidden; position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.flip-back { transform: rotateY(180deg); }

/* ---------- inputs ---------- */
select, input[type=text], input[type=number] { font: inherit; padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--ink); }
label { font-weight: 600; font-size: .9rem; }

/* ---------- hero (home) ---------- */
.hero { background: linear-gradient(135deg, var(--red), var(--red-dark)); color: #fff; border-radius: 20px; padding: 40px 28px; position: relative; overflow: hidden; }
.hero h1 { font-size: clamp(1.8rem, 5vw, 2.8rem); margin-bottom: 10px; }
.hero p { font-size: 1.05rem; opacity: .95; max-width: 56ch; }
.hero .han-watermark { position: absolute; right: -10px; bottom: -40px; font-family: var(--cjk); font-size: 16rem; opacity: .12; line-height: 1; font-weight: 800; pointer-events: none; }

/* ---------- toast ---------- */
#toast-box { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 600; box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(10px); transition: all .3s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast-good { background: var(--green); }
.toast-bad { background: var(--red-wrong); }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--line); color: var(--ink-soft); font-size: .85rem; text-align: center; padding: 26px 16px; }
