/* ===========================================================================
   Mr.Wang Chinese — shared site navigation
   ---------------------------------------------------------------------------
   Header shell + top-level links + the "Characters" menu + the mobile panel.
   One stylesheet for every page, so the nav can never drift between pages
   again.

   LOAD ORDER: after assets/theme.css (whose tokens every --mw-* name below now
   aliases) and after style.css (and after demo.css on demo.html). Several rules
   here deliberately override the older .site-header / .header-inner /
   .site-nav-links / .brand-logo styles that still live in style.css.

   MARKUP CONTRACT (identical on every page; behaviour in assets/site-nav.js):

     header.site-header
       .header-inner
         a.brand > img.brand-logo
         nav.site-nav-links
           a.mw-nav-link
           .mw-dd > button.mw-dd-btn + .mw-dd-menu   (Characters, Tools)
           …
         .mw-header-actions
           #nav-auth                   ← auth-ui.js owns this container
           a.mw-start-btn
           button.mw-burger
       .mw-mobile

   demo.html keeps its own <header class="demo-header"> shell (it lives inside
   a viewport-locked flex column and must not become sticky) — only the inner
   layout and the .mw-* components are shared.
   =========================================================================== */

:root {
  /* Published so anything that must sit below the header can offset by it
     instead of hardcoding a second copy of the number. starter-progress.css
     is the current consumer. */
  --mw-header-h:   80px;

  /* Everything below is an ALIAS of assets/theme.css. The names keep their old
     spelling so every rule in this file — and starter-progress.css, which
     reads --mw-header-h — keeps working; only what they resolve to moved. */
  --mw-ink:        var(--t-ink);           /* #16211c, 16.6:1 on white */
  --mw-muted:      var(--t-muted);         /* #5f7168, 5.2:1 on white */
  --mw-soft:       var(--t-faint);         /* DECORATION ONLY, 2.6:1 — never type.
                                              Declared here and read by NO rule in
                                              this file; kept, not deleted, in case
                                              something outside it wants the name. */
  --mw-line:       var(--t-line-soft);     /* hairlines that only separate */
  --mw-sand:       var(--t-sand);          /* the plain hover surface, and nothing
                                              else — "you are here" is now the
                                              --t-current pair, see below */
  --mw-green:      var(--t-action-fill);   /* the CTA fill. White on it: 7.9:1 */
  --mw-green-dark: var(--t-action-hover);  /* the darker press/hover, and only that */
  --mw-ui:         var(--t-ui);
}

/* ── Header shell ─────────────────────────────────────────────────────────── */
.site-header {
  position: sticky; top: 0; z-index: 50;
  padding: 0;
  /* Kept as a literal: there is no alpha-white token, and six digits here would
     turn the bar into an opaque slab. Worth stating outright — because the bar
     is translucent over blurred page content, the contrast of the text inside it
     is NOT fully determined by any declaration in this file. Every ratio quoted
     below is nominal-on-white, i.e. the best case. Deliberately not compensated
     for here: darkening the ground is a page-level decision, not the nav's. */
  background: rgba(255, 255, 255, .95);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--mw-line);
}
/* Both shells need a positioning context for the mega menu / mobile panel.
   .demo-header already has position:relative from demo.css. */
/* The header's geometry is stated outright, never inherited or derived.
   Six pages (about, credits, privacy, terms, account, pricing) never load
   style.css and carry their own reset, so anything left to inherit — the line
   box in particular — would differ from page to page and change the bar's
   height. Pin it here instead. */
.site-header, .demo-header { font-family: var(--mw-ui); line-height: 1.5; }
.site-header *, .site-header *::before, .site-header *::after,
.demo-header *, .demo-header *::before, .demo-header *::after { box-sizing: border-box; }

.header-inner,
.demo-header .demo-header-inner {
  display: flex; align-items: center; flex-wrap: nowrap;
  max-width: 1200px; margin: 0 auto;
  /* Fixed bar height. Not padding + content: the tallest child (48px logo)
     would otherwise decide it, and that changes the moment #nav-auth renders
     an account menu. */
  min-height: var(--mw-header-h);
  /* Stated, not omitted: spacing between the three clusters is set per child
     below, and a `gap` inherited from a page stylesheet would silently add to
     the logo-to-menu distance on that page alone. */
  gap: 0;
  padding: 0 1.5rem;
}
@media (min-width: 768px)  { .header-inner, .demo-header .demo-header-inner { padding-left: 3rem; padding-right: 3rem; } }
@media (min-width: 1024px) { .header-inner, .demo-header .demo-header-inner { padding-left: 5rem; padding-right: 5rem; } }
@media (max-width: 480px)  { :root { --mw-header-h: 64px; } }

/* demo.css pushes the brand with `margin-right: auto`; the explicit spacing
   below replaces it. Selector is deliberately specific enough to win whatever
   the stylesheet order turns out to be. */
.demo-header .demo-header-inner .brand { margin-right: 0; }

.site-header .brand,
.demo-header .brand { display: flex; align-items: center; flex-shrink: 0; text-decoration: none; }
.brand-logo {
  display: block; height: 48px; width: auto;
  flex-shrink: 0; object-fit: contain;
}
@media (max-width: 480px) { .brand-logo { height: 38px; } }

/* ── Top-level links ──────────────────────────────────────────────────────── */
/* The logo-to-menu distance is a stated constant. With justify-content:
   space-between it was leftover space instead, so it moved whenever the
   right-hand cluster changed width — an account menu appearing in #nav-auth,
   or just a scrollbar on a longer page. margin-right:auto now pushes the
   actions to the right edge and leaves this gap fixed. */
.site-nav-links {
  display: flex; align-items: center; flex: 0 1 auto; min-width: 0;
  margin-left: 3rem; margin-right: auto;
  gap: 1.75rem;
  font-size: .875rem; color: var(--mw-muted);
}
@media (max-width: 1180px) { .site-nav-links { margin-left: 2rem; gap: 1.15rem; } }
@media (max-width: 900px)  { .site-nav-links { display: none; } }

.mw-nav-link {
  padding: 0; border: 0; background: none; cursor: pointer;
  font: inherit; color: var(--mw-muted); text-decoration: none; white-space: nowrap;
  transition: color .15s ease;
}
.mw-nav-link:hover { color: var(--mw-ink); text-decoration: none; }
/* Current page: --t-current with a hairline under it. Deliberately not the old
   blue pill — the pill read as a button, not as "you are here". --t-current
   is the site's one "you are here" token and is deliberately NOT what any hover
   state in this file resolves to, so "this is the page" and "this is where my
   pointer is" can never paint the same again. 7.9:1 on white; the ::after rule
   below picks it up through currentColor. */
.mw-nav-link.is-current {
  position: relative;
  color: var(--t-current); font-weight: 600;
}
.mw-nav-link.is-current::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -.5rem;
  height: 2px; border-radius: 2px; background: currentColor;
}


/* ── Dropdown menus ───────────────────────────────────────────────────────
   Three of them: "Characters" (2026-11-02, Yi: Learn and Practice merged — strokes,
   components, writing, the core characters and Visual Hanzi; its ids still say
   "learn"), "HSK" (2026-11-02: Mock Tests, Vocabulary, Exam Guide, Reading — a split
   group, below) and "Tools" (the character tools). Same component — the group name
   lives in the top-level bar, and the panel is a plain single column. */
.mw-dd { position: relative; display: flex; align-items: center; }
.mw-dd-btn { display: inline-flex; align-items: center; gap: .25rem; }
.mw-dd-btn svg { width: .75rem; height: .75rem; transition: transform .2s ease; }
/* An OPEN group is not the same statement as "you are here". This was
   `.mw-dd-btn[aria-expanded="true"]` on its own: (0,2,0), the same weight as
   `.mw-nav-link.is-current` above but declared after it, so opening the
   dropdown that holds the page you are on repainted its label from
   --t-current (#215c3b, 7.90:1 on the bar's nominal white) to --mw-ink
   (#16211c, 16.56:1) - and took the .is-current::after underline with it,
   since that rule paints currentColor. Both are legible; what was lost is
   the hue that means "this is the page". :not(.is-current) makes this
   (0,3,0) and, more to the point, stops it matching a current button at all.
   The svg rule below is deliberately NOT narrowed the same way: the chevron
   must still flip when the current group is open. */
.mw-dd-btn[aria-expanded="true"]:not(.is-current) { color: var(--mw-ink); }
.mw-dd-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
/* A split group (HSK, 2026-11-02): the word is a link to the HSK page and the
   chevron beside it is the menu button, so they read as one label, "HSK ⌄",
   like the other menus. The chevron's button is padded to a usable target and
   pulled back by the same amount, so the pair keeps the spacing of "Learn ⌄".
   The open menu reaches up over the gap under the label (::before), so a mouse
   moving down into it does not leave the group and close it. */
.mw-dd-split { gap: .25rem; }
.mw-dd-split .mw-dd-caret { padding: .5rem .375rem; margin: -.5rem -.375rem; }
.mw-dd-split:hover > .mw-nav-link:not(.is-current) { color: var(--mw-ink); }
.mw-dd-split .mw-dd-menu::before {
  content: ""; position: absolute; left: 0; right: 0; bottom: 100%; height: .875rem;
}

.mw-dd-menu {
  /* Anchored to the button's left edge, not centred under it: a 19rem panel
     centred under a short label like "HSK" would hang past the nav. */
  position: absolute; top: 100%; left: -.75rem; z-index: 60;
  margin-top: .75rem;
  width: 19rem; max-width: calc(100vw - 3rem);
  padding: .75rem;
  background: var(--t-white);
  border: 1px solid var(--mw-line); border-radius: var(--t-r-md);
  /* Was a two-part cool-slate shadow; --t-sh-3 is the same two-part idea
     (1px contact + wide lift) carried in the theme's warm ink. */
  box-shadow: var(--t-sh-3);
}
.mw-dd-menu[hidden] { display: none; }

.mw-dd-menu a {
  display: block; padding: .5rem .75rem; border-radius: .75rem;
  text-decoration: none;
  transition: background .15s ease;
}
/* Hover is a plain surface change; "you are here" is the current tint. These
   were one declaration, so a pointer resting on any item looked exactly like
   the page you were already on. Same specificity, is-current declared second,
   so hovering the current item still reads as current. */
.mw-dd-menu a:hover      { background: var(--mw-sand); text-decoration: none; }
.mw-dd-menu a.is-current { background: var(--t-current-tint); text-decoration: none; }
.mw-dd-menu b     { display: block; font-size: .875rem; font-weight: 600; color: var(--mw-ink); }
.mw-dd-menu small { display: block; margin-top: .0625rem; font-size: .75rem; font-weight: 300; line-height: 1.45; color: var(--mw-muted); }
.mw-dd-menu a.is-current b { color: var(--t-current); }   /* 7.1:1 on --t-current-tint */
/* Areas whose lessons are still being written — the page exists and explains
   the path, so it stays a normal link with an honest badge. */
.mw-dd-menu em {
  margin-left: .375rem; vertical-align: 1px;
  font-style: normal; font-size: .5625rem; font-weight: 700;
  /* Was #8f95a1 — 3.0:1 on white, which fails AA at 9px, where the large-text
     exemption does not apply. The theme is explicit that labels take --t-muted
     (5.2:1) and that the faint token is never type. It now matches the <small>
     description beneath it; the badge is still told apart by size, weight, caps
     and letter-spacing, which is most of what was carrying it already. */
  letter-spacing: .07em; text-transform: uppercase; color: var(--mw-muted);
}
/* A locked entry (assets/access.js marks it .mw-locked and draws the lock as
   its ::after). The lock came after the description, so it sat on a line of
   its own under it, leaving a gap in the menu (Yi's screenshot, 2026-11-01).
   It now sits at the right of the entry's name. (0,3,2) beats access.js's
   own (0,2,2) rule, which is injected later. */
.mw-dd-menu a.mw-locked { position: relative; padding-right: 2.25rem; }
.site-header .mw-dd-menu a.mw-locked::after,
.demo-header .mw-dd-menu a.mw-locked::after {
  position: absolute !important; top: .8rem !important; right: .8rem !important; bottom: auto !important; left: auto !important;
  margin: 0 !important;
}

/* ── Right-hand actions ───────────────────────────────────────────────────── */
.mw-header-actions { display: flex; align-items: center; gap: .75rem; flex-shrink: 0; }
/* Below the desktop breakpoint the nav is display:none, so its margin-right
   auto no longer pushes anything — the actions have to claim the space. */
@media (max-width: 900px) { .mw-header-actions { margin-left: auto; } }
/* auth-ui.js fills #nav-auth with sign-in actions or the account menu. */
.site-header .nav-auth,
.demo-header .nav-auth { display: flex; align-items: center; gap: .5rem; }
.site-header .nav-auth:empty,
.demo-header .nav-auth:empty { display: none; }

/* Every account entry uses the shared account palette, across page themes. */
:is(.site-header, .demo-header) .nav-auth {
  --mw-auth-fill: var(--auth-accent);
  --mw-auth-rgb: var(--auth-rgb);
  --mw-auth-tint: var(--auth-tint);
  --mw-auth-tint-hover: var(--auth-tint-2);
}
:is(.site-header, .demo-header) .nav-auth :is(.btn-nav-ghost, .btn-nav-primary) {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: .625rem 1.25rem;
  border: 1px solid transparent; border-radius: var(--t-r-pill);
  font: 600 1rem/1 var(--mw-ui); letter-spacing: 0; white-space: nowrap;
  cursor: pointer; text-decoration: none;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
:is(.site-header, .demo-header) .nav-auth .btn-nav-ghost {
  color: var(--mw-auth-fill); background: var(--mw-auth-tint);
  border-color: rgba(var(--mw-auth-rgb), .22);
}
:is(.site-header, .demo-header) .nav-auth .btn-nav-ghost:hover {
  color: var(--mw-auth-fill); background: var(--mw-auth-tint-hover);
  border-color: rgba(var(--mw-auth-rgb), .4);
}
:is(.site-header, .demo-header) .nav-auth .btn-nav-primary {
  color: var(--t-white); background: var(--mw-auth-fill);
  border-color: var(--mw-auth-fill);
  box-shadow: 0 4px 10px -6px rgba(var(--mw-auth-rgb), .5);
}
:is(.site-header, .demo-header) .nav-auth .btn-nav-primary:hover {
  color: var(--t-white); background: var(--mw-auth-fill);
  box-shadow: inset 0 0 0 999px rgba(0, 0, 0, .07), 0 6px 14px -7px rgba(var(--mw-auth-rgb), .5);
}
@media (max-width: 480px) {
  :is(.site-header, .demo-header) .nav-auth { gap: .375rem; }
  :is(.site-header, .demo-header) .nav-auth :is(.btn-nav-ghost, .btn-nav-primary) {
    min-height: 40px; padding: .5rem .75rem; font-size: .875rem;
  }
}

.mw-start-btn {
  display: inline-flex; align-items: center; white-space: nowrap;
  padding: .5rem 1.25rem; border-radius: var(--t-r-pill);
  background: var(--mw-green); color: var(--t-white); text-decoration: none;
  font-size: .875rem; font-weight: 500;
  transition: background .15s ease;
}
.mw-start-btn:hover { background: var(--mw-green-dark); color: var(--t-white); text-decoration: none; }
@media (max-width: 420px) {
  /* Shrink, never hide. Hidden, this was the only course entry on the whole
     site for a 375px visitor, and the burger panel carried none either. */
  .mw-start-btn { padding: .375rem .875rem; font-size: .8125rem; }
}

.mw-burger { display: none; padding: .25rem; background: none; border: 0; cursor: pointer; }
@media (max-width: 900px) { .mw-burger { display: block; } }
.mw-burger-lines { display: flex; flex-direction: column; gap: .375rem; width: 1.25rem; }
.mw-burger-lines span {
  display: block; height: 1px; background: var(--mw-ink);
  transform-origin: center;
  transition: transform .2s ease, opacity .2s ease;
}
.mw-burger[aria-expanded="true"] .mw-burger-lines span:nth-child(1) { transform: rotate(45deg)  translateY(5px); }
.mw-burger[aria-expanded="true"] .mw-burger-lines span:nth-child(2) { opacity: 0; }
.mw-burger[aria-expanded="true"] .mw-burger-lines span:nth-child(3) { transform: rotate(-45deg) translateY(-5px); }

/* ── Mobile panel ─────────────────────────────────────────────────────────── */
/* Absolutely positioned so it overlays the page instead of growing the header —
   demo.html's viewport-locked layout would break otherwise. */
.mw-mobile {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 55;
  max-height: calc(100vh - 100%); overflow-y: auto;
  padding: .75rem 1.5rem 1.25rem;
  background: var(--t-white); border-bottom: 1px solid var(--mw-line);
  box-shadow: var(--t-sh-2);
  font-family: var(--mw-ui);
}
.mw-mobile[hidden] { display: none; }
@media (min-width: 901px) { .mw-mobile { display: none; } }

.mw-mobile h3 {
  margin: 1rem 0 .25rem; padding: 0 .75rem;
  font-size: .625rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  /* Still not --mw-soft, which is now --t-faint: 2.6:1, and decoration-only. At
     10px the WCAG large-text exemption does not apply, so AA wants 4.5:1, and
     --t-muted is the theme's stated colour for eyebrows and labels. What ships
     is 5.2:1 on this panel's opaque white — down from the 6.1:1 that #5b636f
     measured, still clear of the floor. The cost, stated honestly: the label no
     longer sits a step darker than the links beneath it, so size, weight, caps
     and letter-spacing carry the heading on their own now. */
  color: var(--mw-muted);
}
.mw-mobile h3:first-child { margin-top: .25rem; }
.mw-mobile a, .mw-mobile button {
  display: block; width: 100%; text-align: left;
  padding: .5rem .75rem; border-radius: .75rem;
  border: 0; background: none; cursor: pointer;
  font-family: inherit; font-size: .9375rem; color: var(--mw-muted); text-decoration: none;
}
.mw-mobile a:hover, .mw-mobile button:hover { background: var(--mw-sand); color: var(--mw-ink); text-decoration: none; }
/* Same separation as the dropdown: hover above is the plain --mw-sand surface,
   "you are here" is the current tint with --t-current type at 7.1:1 on it. */
.mw-mobile a.is-current { background: var(--t-current-tint); color: var(--t-current); font-weight: 600; }

/* Keyboard focus for every interactive thing in the header. There was no
   author focus style here, so keyboard users got less feedback than mouse
   users on the site's primary navigation. The ring is --t-focus, not the brand
   green it used to be: a green ring landed in the same family as --t-current,
   so a focused link and the current link were saying the same thing to the
   reader. The theme keeps one focus colour precisely so those two stay apart. */
.site-header a:focus-visible,
.site-header button:focus-visible,
.demo-header a:focus-visible,
.demo-header button:focus-visible,
.mw-mobile a:focus-visible,
.mw-mobile button:focus-visible {
  outline: 2px solid var(--t-focus);
  outline-offset: 3px;
  border-radius: .5rem;
}

/* The first entry in the mobile panel: the one thing a phone visitor is most
   likely to want, and previously absent from it. */
.mw-mobile .mw-mobile-start {
  display: inline-flex; align-items: center; gap: .5rem;
  margin: .25rem 0 .5rem;
  padding: .625rem 1.125rem; border-radius: var(--t-r-pill);
  background: var(--mw-green); color: var(--t-white);
  font-size: .9375rem; font-weight: 500; text-decoration: none;
  width: auto;
}
.mw-mobile .mw-mobile-start:hover { background: var(--mw-green-dark); color: var(--t-white); }


/* demo.html: the tool's dock is position:fixed at z-index 40, while demo.css
   gives .demo-header its own stacking context at z-index 10 — the dock would
   paint over an open mobile panel. Lift the header above it. (The header is
   display:none in the tool's fullscreen mode, so nothing else shifts.) */
.demo-header { z-index: 60; }

@media print {
  .mw-dd-menu, .mw-mobile { display: none !important; }
}

/* Make room for the dedicated practice link on narrow desktop screens. */
@media (min-width:901px) and (max-width:1023px) {
  .site-nav-links { gap:.8rem; margin-left:1.5rem; }
}

/* 2026-09-25 导航栏加高、字体和 Logo 放大；去掉 Start Learning（手机菜单里仍有「Start the free course」入口） */
:root{--mw-header-h:96px}
@media (max-width:480px){:root{--mw-header-h:72px}}
.brand-logo{height:64px}
@media (max-width:480px){.brand-logo{height:46px}}
.site-nav-links{font-size:1.0625rem;gap:2.1rem;margin-left:3.5rem}
@media (max-width:1180px){.site-nav-links{gap:1.4rem;margin-left:2.25rem}}
@media (min-width:901px) and (max-width:1023px){.site-nav-links{gap:.9rem;margin-left:1.5rem;font-size:.95rem}}
.mw-dd-btn svg{width:.85rem;height:.85rem}
.mw-dd-menu a b{font-size:1rem}
.site-header .mw-start-btn,.demo-header .mw-start-btn{display:none!important}

/* 2026-09-27 导航文字放大加粗（全站，按 hanzi.html 新设计）：宽屏 25px 粗体；
   屏幕窄一些时按比例缩小（最小 16px），保证一行放得下。900px 以下仍是汉堡菜单。 */
.site-nav-links{font-size:clamp(1rem,1.74vw,1.5625rem);font-weight:700}
.site-nav-links .mw-nav-link,.mw-nav-link.is-current{font-weight:700}
.mw-dd-btn svg{width:.8em;height:.8em}
.mw-nav-link.is-current::after{height:3px}
/* 导航放大后页眉需要更宽：内容区由 1040px 放宽到 1200px，与各页正文同宽。 */
.header-inner,.demo-header .demo-header-inner{max-width:1360px}

/* The bar is a flat 96px on every screen — a fifth of a short laptop viewport.
   Its height is min-height:var(--mw-header-h), so scale the variable, not the
   box. Anything >=880px tall keeps the original 96/64. */
@media (min-width:1024px) {
  :root { --mw-header-h:clamp(64px,10.91vh,96px); }
  .brand-logo { height:clamp(42px,7.28vh,64px); }
}
