/* primitives.css — the shared, template-agnostic layer.
   Named per TEMPLATES.md §2. Build once, compose freely.
   Binding: no border-radius, no box-shadow, no object-fit:cover (C10). */

/* ═══ MK — markers & rules ══════════════════════════════════════════════ */

/* MK-CAPS. Hairline sits ABOVE the label, not below (C9) — the rule closes the
   previous chapter rather than underlining the next one. */
.marker {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--u1);
  border-top: var(--hair) solid var(--rule);
  padding-top: var(--u-half);
  margin: var(--u4) 0 var(--u1);
  font-family: var(--f-sans);
  font-size: var(--t-meta);        /* one step up the scale from caption */
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--track);
  color: var(--ink);
}
.marker:first-child { margin-top: 0; }
.marker__note {
  font-size: var(--t-caption);     /* the note stays at caption */
  font-weight: 400;
  letter-spacing: .04em;
  color: var(--ink-soft);
  white-space: nowrap;
}

/* MK-RULE */
.hair {
  border: 0;
  border-top: var(--hair) solid var(--rule);
  margin: var(--u4) 0;
}

/* ═══ Type utilities ════════════════════════════════════════════════════ */

.caps {
  font-family: var(--f-sans);
  font-size: var(--t-caption);
  text-transform: uppercase;
  letter-spacing: var(--track);
}

.meta {
  font-family: var(--f-sans);
  font-size: var(--t-caption);
  color: var(--ink-soft);
}

/* Secondary language beneath a primary string. EN full ink, 中文 at ink-soft. */
.alt {
  display: block;
  color: var(--ink-soft);
}

.measure { max-width: var(--measure); }

/* ═══ HD — head ═════════════════════════════════════════════════════════ */

/* The wordmark is a wide-tracked serif: direction_2 §7 reads this face as
   giving "the total practice a literary-cultural identity". */
.wordmark {
  display: block;          /* it is an <a> on sub-pages; inline would drop the margin */
  font-family: var(--f-serif);
  font-size: var(--t-wordmark);
  font-weight: 400;
  letter-spacing: .22em;
  line-height: var(--lh-tight);
}

/* ═══ NV — navigation ═══════════════════════════════════════════════════ */

.nav { margin-bottom: var(--u4); }
.nav__item { margin-bottom: var(--u1); }

/* Styling keys to .nav__label, not to `a`, so an item reads identically whether
   or not it is a link. Routes to pages that do not exist yet render as spans —
   honest, and they become <a> unchanged when the page arrives. */
.nav__item,
.nav a {
  display: block;
  font-size: var(--t-caption);
  line-height: 1.35;
}


/* Current state carries NO colour (C5): weight plus a leading rule. A bottom
   border was tried first and rejected — it closes the gap to the Chinese line
   beneath and makes the rail look denser on one page than another. */
.nav__item { position: relative; }
.nav a[aria-current] .nav__label { font-weight: 700; }
.nav a[aria-current]::before {
  content: "";
  position: absolute;
  left: calc(var(--u-half) * -1.4);
  top: .25em;
  bottom: .25em;
  border-left: 2px solid var(--ink);
}

/* A pending route is dimmed rather than hidden — it tells you the section
   exists without pretending it is reachable. */
.nav__item > .nav__label { color: var(--ink-soft); }
.nav a .nav__label { color: var(--ink); }

.nav--series .nav__label {
  text-transform: uppercase;
  letter-spacing: .08em;
}

/* Contact — foot of the global rail. Shared by every page that has a rail, so
   it lives here and not in a page template. */
/* Contact sits at the foot of the rail, separated from the routes by a large
   quiet interval — direction_2 §1 reads that gap as what makes the left side
   behave like a letterhead rather than a menu. */
.contact { font-size: var(--t-caption); line-height: 1.5; }
.contact > * { min-width: 0; }
.contact a { color: var(--ink-soft); overflow-wrap: anywhere; }

.contact__pending, .contact__copy { color: var(--ink-soft); }

/* Social icons — Instagram, Facebook, YouTube, SoundCloud (antheaxin.com).
   Line icons in currentColor; each target a full 32px square for touch.
   The swipe underline is for text links, not icons. */
.social {
  display: flex;
  gap: var(--u-half);
  margin: var(--u-half) 0 0 calc(var(--u-half) * -1);
}
.social a {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  color: var(--ink-soft);
  transition: color var(--fade) ease;
}
.social a:hover { color: var(--ink); }
.social a::after { display: none; }
.social .ico { width: 18px; height: 18px; stroke-width: 1.4; }
.social .ico__dot { fill: currentColor; stroke: none; }
.contact__copy { margin-top: var(--u1); }

@media (max-width: 800px) {
  .contact { display: flex; flex-wrap: wrap; gap: var(--u1) var(--u2); }
  .contact__copy { margin-top: 0; }
}

/* ═══ DT — data ═════════════════════════════════════════════════════════ */

/* DT-INDEX + G2 (index-plus-thumbnails, template Y253). Thumbnail · numeral ·
   title · year · medium. Italic titles, hairline-ruled rows.

   Text cells are baseline-aligned to each other but the thumbnail is start-
   aligned: its height varies with its own aspect ratio (C10), so baseline-
   aligning it would drag the whole row around. */
.index { }

/* Two parts, not five columns: a large plate and, beside it, the record. The
   record is centred against the plate rather than hung from its top edge — at
   this plate size a top-aligned column left the entry reading as two unrelated
   things sharing a row.

   The numeral is gone. The works are not ordered chronologically, so a running
   number implied a sequence that does not exist. */
.row {
  display: grid;
  grid-template-columns: var(--thumb) minmax(0, 1fr);
  gap: var(--u2);
  align-items: center;
  padding: var(--u2) 0;
  border-top: var(--hair) solid var(--rule);
}
.row:first-child { border-top: 0; }
.row__body { min-width: 0; display: grid; gap: var(--u2); }

/* Title, medium, then the year at the far right — where it falls under the
   series span in the marker above, so the two read down the same edge. */
.row__head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--u-half) var(--u2);
  align-items: baseline;
}
/* Medium sits under the title as its subtitle rather than in a column of its
   own; the year keeps the right edge, under the series span in the marker. */
.row__title  { grid-column: 1; grid-row: 1; }
.row__medium { grid-column: 1; grid-row: 2; }
.row__year   { grid-column: 2; grid-row: 1; }

.row__title { font-style: italic; font-size: var(--t-meta); }
/* Each language holds together, so the only break opportunity is the space
   between them: a long title breaks after the English, never mid-phrase. */
.row__title .t-en,
.row__title .t-zh { white-space: nowrap; }


.row__year,
.row__medium {
  font-family: var(--f-sans);
  font-size: var(--t-caption);
  color: var(--ink-soft);
}
.row__year { font-variant-numeric: tabular-nums; white-space: nowrap; justify-self: end; }

.row__thumb { align-self: center; }
.row__thumb img { width: 100%; transition: opacity var(--fade) ease; }
.row:hover .row__thumb img { opacity: .82; }
.row__thumb:not(:has(a)) img { opacity: .78; }

.row__desc, .reg__desc {
  font-size: var(--t-caption);
  line-height: 1.65;
  color: var(--ink-soft);
  max-width: var(--measure);
}

/* ═══ TX — text ═════════════════════════════════════════════════════════ */

/* TX-THESIS. Serif, ~52ch. The argument. */
.thesis {
  font-family: var(--f-serif);
  font-size: var(--t-thesis);
  line-height: var(--lh-thesis);
  max-width: var(--measure);
}
.thesis p + p { margin-top: var(--u1); }

/* TX-LANGSWITCH. One column, with an EN / 中文 toggle.
   Progressive enhancement: the toggle is [hidden] in markup and revealed by JS.
   With JS off both panels render stacked, so the Chinese text is never gated
   behind an interaction — the quality floor forbids that. */
.langtoggle {
  display: flex;
  gap: var(--u1);
  margin-bottom: var(--u2);
}
.langtoggle button {
  font-family: var(--f-sans);
  font-size: var(--t-caption);
  text-transform: uppercase;
  letter-spacing: var(--track);
  color: var(--ink-soft);
  background: none;
  border: 0;
  border-bottom: var(--hair) solid transparent;
  padding: 0 0 var(--u-half);
  cursor: pointer;
}
.langtoggle button:hover { color: var(--ink); }

/* Pressed state is weight + rule, never colour alone (C5). */
.langtoggle button[aria-pressed="true"] {
  color: var(--ink);
  font-weight: 700;
  border-bottom-color: var(--ink);
}

/* Only once JS has taken over does the second panel gain a top margin — before
   that the two stacked panels need separating. */
.bio:not(.is-switchable) [data-langpanel="zh"] { margin-top: var(--u2); }

/* ═══ MD — media ════════════════════════════════════════════════════════
   Intrinsic aspect ratios only. object-fit:cover appears nowhere (C10):
   ratio is semantic, so cropping destroys meaning. Space is reserved by the
   width/height attributes on the element itself. */

/* MD-FILMSTRIP — vertical thumbnail column beside the field (template W322). */
.filmstrip__item + .filmstrip__item { margin-top: var(--u2); }

.filmstrip a { display: block; }
.filmstrip img { width: 100%; transition: opacity var(--fade) ease; }
.filmstrip a:hover img { opacity: .82; }

.filmstrip__label {
  display: block;
  margin-top: var(--u-half);
  font-family: var(--f-sans);
  font-size: var(--t-caption);
  line-height: 1.35;
}


/* ═══ Collapse ══════════════════════════════════════════════════════════ */

@media (max-width: 800px) {
  .wordmark { margin-bottom: var(--u2); }
  .nav { margin-bottom: var(--u2); }

  /* Once the rails stack, the section nav reads better as a horizontal band.
     The flex target is the UL — the class sits on <nav>, whose only child is
     the list. Scoped to the tablet band only; see the 520px block. */
  .nav--sect ul {
    display: flex;
    flex-wrap: wrap;
    gap: var(--u1) var(--u2);
  }
  .nav--sect .nav__item { margin-bottom: 0; min-width: 0; }

}

@media (max-width: 700px) {
  /* Plates step down once the layout narrows, but stay the dominant element in
     the row — they are what the page is for. */
  :root { --thumb: 200px; }

  /* The marker note is nowrap so a year span never breaks — but a long note
     ("Hong Kong / Italian · United Kingdom") then becomes an unbreakable
     min-content floor that pushes the whole field past the viewport. Let the
     marker stack and the note wrap once there is no room for both on one line. */
  .marker { flex-wrap: wrap; gap: 2px var(--u1); }
  .marker__note { white-space: normal; }
}

@media (max-width: 560px) {
  /* Below the tablet band the horizontal nav stops fitting: four items, each
     carrying an English and a Chinese line, do not sit comfortably in ~293px.
     Flex wrapping does not rescue it — the items cannot shrink below their
     min-content, so the line overflows instead of breaking. Stack them. */
  .nav--sect ul { display: block; }
  .nav--sect .nav__item { margin-bottom: var(--u1); }
}


/* ═══ Project-page primitives ═══════════════════════════════════════════ */

/* DT-COLOPHON. The project as an accountable production: date-span, materials
   line, bold-name credits, support, funders. Sans throughout — this is data,
   and data is sans (see CLAUDE.md). */
.colophon { font-size: var(--t-meta); line-height: var(--lh-body); }
.colophon__span { margin-bottom: var(--u1); }
.colophon__medium { color: var(--ink-soft); margin-bottom: var(--u2); }
.colophon__credits li { margin-bottom: 2px; }
.colophon__credits strong { font-weight: 700; }
.colophon__support {
  margin-top: var(--u2);
  padding-top: var(--u1);
  border-top: var(--hair) solid var(--rule);
  font-size: var(--t-caption);
  color: var(--ink-soft);
}
.funders { display: flex; flex-wrap: wrap; gap: var(--u2); margin-top: var(--u1); }
.funders img { height: 30px; width: auto; }

/* TX-SPREAD2. Specifications left, proposition right, at equal weight —
   direction_2 §3: "neither is presented as supplementary to the other."
   445 + 27 + 445 measured; expressed as equal fractions so it scales. */
.spread {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--u2);
  align-items: start;
}

/* DT-EVENTS. Dated chronology — institutional validation, delivered before the
   documentation sequence. */
.events { font-size: var(--t-meta); line-height: 1.7; }
.events li { display: flex; flex-wrap: wrap; gap: 0 var(--u-half); }
.events .events__date { color: var(--ink-soft); }

/* MD — media chapters. Intrinsic ratios, never cropped (C10). */
.media { margin-bottom: var(--u2); }
.media img, .media video { width: 100%; }
.figcap {
  margin-top: var(--u-half);
  font-size: var(--t-caption);
  color: var(--ink-soft);
  max-width: var(--measure);
}

.grid2, .grid3 {
  display: grid;
  gap: var(--u2);
  align-items: start;      /* variable heights, top-aligned — not stretched */
  margin-bottom: var(--u2);
}
.grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid2 img, .grid3 img { width: 100%; }

/* An embed that fails must not leave a blank reserved area — direction_2 §9
   flags exactly this on the source page. Poster + ratio box + a real link out. */
.embed { position: relative; background: #EDECE8; }
.embed img { width: 100%; }
.embed__out {
  display: inline-block;
  margin-top: var(--u-half);
  font-size: var(--t-caption);
  color: var(--ink-soft);
}


/* NV-SIBLINGS. Prev / Next — the site as a traversable archive. */
.siblings {
  display: flex;
  justify-content: space-between;
  gap: var(--u2);
  margin-top: var(--u4);
  padding-top: var(--u1);
  border-top: var(--hair) solid var(--rule);
  font-size: var(--t-caption);
  text-transform: uppercase;
  letter-spacing: var(--track);
}

/* A disabled end-of-sequence stop stays in the reading order and is announced,
   but is plainly not interactive. */
.siblings [aria-disabled="true"] { color: var(--ink-soft); }

/* Local rail — a SECTION INDEX. Not related works, and not a list of siblings:
   it is a map of this page, and each entry jumps to a chapter. direction_2 §9
   asks for exactly this ("a small internal section index") because the page runs
   long enough that the reader loses their place.
   Thumbnails keep their own ratios and the label is centred beneath. */
.sectionindex__item + .sectionindex__item { margin-top: var(--u2); }
.sectionindex a { display: block; }
.sectionindex img { width: 100%; transition: opacity var(--fade) ease; }
.sectionindex a:hover img { opacity: .82; }
.sectionindex__label {
  display: block;
  margin-top: var(--u-half);
  text-align: center;
  font-size: var(--t-caption);
  line-height: 1.35;
}

.sectionindex__label .alt { text-align: center; }

/* Anchor targets clear the top edge when jumped to. */
[id^="c-"] { scroll-margin-top: var(--u2); }

@media (max-width: 800px) {
  .spread { grid-template-columns: minmax(0, 1fr); gap: var(--u4); }
  .sectionindex { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--u2); }
  .sectionindex__item + .sectionindex__item { margin-top: 0; }
}
@media (max-width: 560px) {
  .grid2, .grid3 { grid-template-columns: minmax(0, 1fr); }
  .sectionindex { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* An external route that has no URL yet is shown as text, never as a dead href.
   The affordance still has to exist — direction_2 §9 requires every embed to
   offer a way out — but it must not pretend to be live. */
.embed__out--pending { border-bottom-style: dotted; }

/* ═══ Switch — shared two-state control (language, colour scheme) ════════ */
.switch, .langtoggle { display: flex; gap: var(--u1); }
.switch button {
  font-family: var(--f-sans);
  font-size: var(--t-caption);
  text-transform: uppercase;
  letter-spacing: var(--track);
  color: var(--ink-soft);
  background: none;
  border: 0;
  border-bottom: var(--hair) solid transparent;
  padding: 0 0 var(--u-half);
  cursor: pointer;
}
.switch button:hover { color: var(--ink); }
.switch button[aria-pressed="true"] {
  color: var(--ink);
  font-weight: 700;
  border-bottom-color: var(--ink);
}
/* Icon-only: no label text, so the control needs a real target size and the
   icons carry the whole meaning. Accessible names live on aria-label. */
/* The two rail controls are one block above the contact details. Both are the
   same width with the same two columns, so EN sits over the sun and 中文 over
   the moon rather than the pair drifting apart. */
.switches { margin-bottom: var(--u4); }
.switches .switch {
  display: grid;
  /* A fixed first column, identical on both rows, is what keeps EN above the sun
     and 中文 above the moon. Sizing it to content instead would let the two rows
     drift apart; sizing it in fr spread them much too far. */
  grid-template-columns: 1.6em auto;
  gap: var(--u-half);
  justify-items: start;
  align-items: center;
}
.switches .switch + .switch { margin-top: var(--u1); }
.theme { margin-top: var(--u2); }
.theme button { padding: var(--u-half) 0; font-size: var(--t-meta); }
.theme .ico { width: 1.15em; height: 1.15em; }
.theme button[aria-pressed="true"] { border-bottom-color: var(--ink); }

/* ═══ Rail scroll — internal scrolling for an over-long rail ════════════
   The page scrollbar moves the page; a sticky rail taller than the viewport
   would simply clip. A second visible scrollbar would be unwieldy, so the
   viewport scrolls without one and two small arrows appear only when there is
   somewhere to go. Arrows sit in their own rows — they never overlap content. */
.railscroll {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}
.railscroll__viewport {
  overflow-y: auto;
  min-height: 0;
  overscroll-behavior: contain;
  scrollbar-width: none;          /* Firefox */
  -ms-overflow-style: none;       /* old Edge */
}
.railscroll__viewport::-webkit-scrollbar { width: 0; height: 0; }

.railscroll__arrow {
  flex: none;
  width: 100%;
  background: none;
  border: 0;
  padding: var(--u-half) 0;
  color: var(--ink-soft);
  font-size: var(--t-caption);
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--fade) ease;
}
/* No overflow at all: the arrows take no space. */
.railscroll:not(.is-scrollable) .railscroll__arrow { display: none; }
/* Overflow exists: both slots are reserved so nothing shifts while scrolling,
   and each arrow fades in only when that direction is available. */
.railscroll__arrow.is-on { opacity: 1; pointer-events: auto; }
.railscroll__arrow:hover { color: var(--ink); }
.railscroll__arrow--up   { border-bottom: var(--hair) solid var(--rule); }
.railscroll__arrow--down { border-top:    var(--hair) solid var(--rule); }

/* The local rail is bounded by the viewport so its content can scroll inside. */
.rail--local .rail__inner {
  min-height: 0;
  max-height: calc(100vh - var(--u2) * 2);
}

/* The local rail's title ("Works", "Contents") sits level with the first
   series in the global rail: dropped by the rail head (the glyph) plus the gap
   above the nav. No rule above it, and the nav label's own size and leading. */
.rail--local .rail__inner > .marker:first-child {
  border-top: 0;
  padding-top: 0;
  margin-top: calc(var(--glyph-h) + var(--u4));
  font-size: var(--t-caption);
  line-height: 1.35;
}
/* lang.css gives 中文 1.8 leading; inside this one-line title that deepens the
   line box and drops the English 3px below the nav. Hold it to the nav's. */
.rail--local .rail__inner > .marker:first-child :lang(zh) { line-height: 1.35; }

@media (max-width: 800px) {
  /* Stacked: there is no fold to exceed, so the rail scrolls with the page. */
  .rail--local .rail__inner { max-height: none; }
  .railscroll__viewport { overflow: visible; }
  .railscroll__arrow { display: none !important; }
}

/* ═══ Icons ═════════════════════════════════════════════════════════════ */
.ico {
  width: 1em;
  height: 1em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  vertical-align: -.14em;
}
/* The moon is a solid crescent; the sun is drawn. */
.switch button[data-theme-btn="dark"] .ico { fill: currentColor; stroke: none; }
.switch button { display: inline-flex; align-items: center; gap: .5em; }

/* ═══ Mobile menu ═══════════════════════════════════════════════════════ */
.rail__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--u2); }
.rail__head .wordmark { margin-bottom: 0; }

/* The mark: the artist's brushed 昕 (xīn, "dawn"), white on transparency, taken
   from antheaxin.com. In the light theme it is inverted to ink. This filters the
   MARK, never an artwork — images of works are never inverted or filtered. */
.wordmark:has(.wordmark__glyph) {
  display: inline-flex;
  align-items: center;
  gap: var(--u1);
}
.wordmark__glyph {
  display: block;
  flex: none;
  width: auto;
  height: var(--glyph-h);
}
/* XĪN set beside the glyph in the original wordmark style — Roboto Mono,
   wide-tracked, inherited from .wordmark. Not Jost: its Ī macron touches the
   stem and reads as a T. */
.wordmark__text { line-height: 1; font-size: 18px; }   /* well under the 30px wordmark: the glyph leads */
:root:not([data-theme="dark"]) .wordmark__glyph { filter: invert(1); }
@media (max-width: 800px) { .wordmark__glyph { height: 36px; } }

.menubtn {
  display: inline-flex;
  align-items: center;
  gap: .5em;
  background: none;
  border: 0;
  padding: var(--u-half) 0;
  color: var(--ink-soft);
  font-family: var(--f-sans);
  font-size: var(--t-caption);
  text-transform: uppercase;
  letter-spacing: var(--track);
  cursor: pointer;
}
.menubtn:hover { color: var(--ink); }
.menubtn .ico--menu { width: 1.25em; height: 1.25em; stroke-width: 1.6; }
/* One icon, two states, driven by the button's own expanded state. */
.menubtn .ico__close { display: none; }
.menubtn[aria-expanded="true"] .ico__bars  { display: none; }
.menubtn[aria-expanded="true"] .ico__close { display: block; }

/* The wordmark row keeps its interval; the nav region carries the rest. */
.rail__nav { margin-top: var(--u4); }

@media (max-width: 800px) {
  .rail__nav { margin-top: var(--u2); }
  .rail__head { align-items: center; }
}
.rail__head:has(.wordmark__glyph) { align-items: center; }

/* ═══ Narrow-width containment ══════════════════════════════════════════
   Mono is materially wider than the grotesque it replaced, so long unbroken
   tokens (an email address, a tracked caps run) now exceed a phone column and
   push their container past the viewport. Nothing here is cosmetic: each rule
   removes a min-content floor that would otherwise widen the whole page. */
@media (max-width: 800px) {
  .rail,
  .rail__inner,
  .rail__top,
  .rail__nav,
  .rail__bottom,
  .rail__head,
  .field { max-width: 100%; min-width: 0; }

  /* The head row must never push the menu button out of view. */
  .rail__head { flex-wrap: nowrap; }
  .rail__head .wordmark { min-width: 0; overflow-wrap: anywhere; }
  .menubtn { flex: none; }
}

@media (max-width: 560px) {
  /* Stacked, not a flex row: three mono strings do not fit side by side and
     the email cannot shrink below its own width. */
  .contact { display: block; }
  .contact > * + * { margin-top: var(--u-half); }
  .contact__copy { margin-top: var(--u1); }

  /* Tracked caps in mono are the widest thing on the page; drop the tracking
     and let long notes wrap. */
  .marker { letter-spacing: .04em; }
  .marker__note { white-space: normal; letter-spacing: .02em; }
}

/* ═══ TRIPTYCH — profile · material · CV (template K384) ════════════════
   Three columns divided by vertical hairlines, each headed by a caps label with
   a deliberate gap before its content. Small mono throughout — the template is
   already in the register we now use. This is a whole about-page in one screen:
   who, what, and the record, side by side rather than in sequence. */
.tri {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2.6fr);
  align-items: stretch;
}
.tri__col { min-width: 0; }

/* Profile holds the left column and spans both rows, so its dividing rule runs
   the full height of the page rather than stopping at the CV. */
.tri__col--profile  { grid-column: 1; grid-row: 1 / span 2; padding-right: var(--u2); }
/* Material and CV share the right column, stacked. Both carry the same left
   rule, so it reads as one continuous division. */
.tri__col--material,
.tri__col--cv { grid-column: 2; padding-left: var(--u2); border-left: var(--hair) solid var(--rule); }
.tri__col--material { grid-row: 1; }
.tri__col--cv       { grid-row: 2; padding-top: var(--u4); }

/* The header sits at the top; content begins well below it. That interval is
   the template's, and it is what stops three dense columns reading as a table. */
.tri__head {
  font-size: var(--t-caption);
  text-transform: uppercase;
  letter-spacing: var(--track);
  color: var(--ink);
  margin-bottom: var(--u4);
}
.tri__label {
  font-size: var(--t-caption);
  text-transform: uppercase;
  letter-spacing: var(--track);
  margin-bottom: var(--u1);
}
.tri__col p { font-size: var(--t-caption); line-height: 1.6; }
.tri__col p + p { margin-top: var(--u1); }
.tri__sep { margin: var(--u2) 0; }

/* Middle column — a plate, then its record set beside a number. */
.entry { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: var(--u2); }
.entry__n { font-size: var(--t-caption); }
.entry__meta { font-size: var(--t-caption); line-height: 1.6; color: var(--ink-soft); }
.entry__meta strong { color: var(--ink); font-weight: 400; }
.workplate { margin-bottom: var(--u1); }
.workplate img { width: 100%; }

/* CV — now beneath the material column, so it has real width to spend. The
   label stays in a fixed narrow gutter and the entries fan out into as many
   columns as the width allows, rather than running as one long thin list. */
.cv { display: grid; grid-template-columns: 8.5em minmax(0, 1fr); gap: var(--u2); }
.cv dt {
  font-size: var(--t-caption);
  text-transform: uppercase;
  letter-spacing: var(--track);
  color: var(--ink-soft);
}
.cv dd {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13em, 1fr));
  gap: var(--u1) var(--u2);
  align-items: start;
}
.cv dd p { font-size: var(--t-caption); line-height: 1.55; margin: 0; }
.cv__rule {
  grid-column: 1 / -1;
  border: 0;
  border-top: var(--hair) solid var(--rule);
  margin: var(--u-half) 0;
}

@media (max-width: 800px) {
  .tri { grid-template-columns: minmax(0, 1fr); }
  .tri__col--profile,
  .tri__col--material,
  .tri__col--cv {
    grid-column: 1;
    grid-row: auto;
    padding: var(--u2) 0 0;
    border-left: 0;
    border-top: var(--hair) solid var(--rule);
    margin-top: var(--u4);
  }
  .tri__col--profile { margin-top: 0; border-top: 0; padding-top: 0; }
  .tri__head { margin-bottom: var(--u2); }
  .entry { grid-template-columns: minmax(0, 1fr); gap: var(--u1); }
}
@media (max-width: 560px) {
  .cv { grid-template-columns: minmax(0, 1fr); gap: var(--u-half); }
  .cv dt { margin-top: var(--u1); }
  .cv dd { grid-template-columns: minmax(0, 1fr); }
}

/* ═══ REGISTER — index + tags + thumbnail strip (template Y253) ══════════
   Four columns: title and date, publication metadata, filed-under tags, and a
   strip of small plates. Rows are hairline-ruled and vary in height with their
   own content; the thumbnails top-align rather than stretch. A text register
   that still shows the material. */
.reg { }

.reg__browse {
  display: flex;
  flex-wrap: wrap;
  gap: var(--u1) var(--u2);
  align-items: baseline;
  margin-bottom: var(--u4);
  font-size: var(--t-caption);
}
.reg__browse-label { color: var(--ink-soft); }
.reg__filters { display: flex; flex-wrap: wrap; gap: var(--u1) var(--u2); }
.reg__filters button {
  font: inherit;
  font-family: var(--f-sans);
  text-transform: uppercase;
  letter-spacing: var(--track);
  color: var(--ink-soft);
  background: none;
  border: 0;
  border-bottom: var(--hair) solid transparent;
  padding: 0 0 2px;
  cursor: pointer;
}
.reg__filters button:hover { color: var(--ink); }
/* Selected state is weight plus a rule — never colour (C5). */
.reg__filters button[aria-pressed="true"] {
  color: var(--ink);
  font-weight: 700;
  border-bottom-color: var(--ink);
}

.reg__row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--u1) var(--u2);
  align-items: start;
  padding: var(--u2) 0;
  border-top: var(--hair) solid var(--rule);
}
/* The three text columns carry the record; the description runs beneath them
   and the plate strip spans both rows at the right. */
.reg__title { grid-column: 1; grid-row: 1; }
.reg__meta  { grid-column: 2; grid-row: 1; }
.reg__tags  { grid-column: 3; grid-row: 1; }
.reg__strip { grid-column: 4; grid-row: 1 / span 2; }
.reg__desc  { grid-column: 1 / 4; grid-row: 2; margin-top: var(--u-half); }
.reg__row:last-child { border-bottom: var(--hair) solid var(--rule); }

.reg__title { font-size: var(--t-caption); }

.reg__date { display: block; margin-top: 2px; color: var(--ink-soft); font-size: var(--t-caption); }

.reg__meta { font-size: var(--t-caption); line-height: 1.6; }
.reg__meta .it { font-style: italic; }
.reg__meta .lab { color: var(--ink-soft); }

.reg__tags { font-size: var(--t-caption); line-height: 1.6; }
.reg__tags dt { color: var(--ink); }
.reg__tags dd { margin: 0; color: var(--ink-soft); }

.reg__strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--u-half); }
.reg__strip img { width: 100%; transition: opacity var(--fade) ease; }
.reg__row a:hover .reg__strip img { opacity: .82; }

@media (max-width: 900px) {
  .reg__row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--u1) var(--u2); }
  .reg__title { grid-column: 1; grid-row: 1; }
  .reg__meta  { grid-column: 2; grid-row: 1; }
  .reg__tags  { grid-column: 1 / -1; grid-row: 2; }
  .reg__desc  { grid-column: 1 / -1; grid-row: 3; }
  .reg__strip { grid-column: 1 / -1; grid-row: 4; margin-top: var(--u1); }
}
@media (max-width: 560px) {
  .reg__row { grid-template-columns: minmax(0, 1fr); }
  .reg__title, .reg__meta, .reg__tags, .reg__desc, .reg__strip { grid-column: 1; grid-row: auto; }
  .reg__strip { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.reg__row.is-last { border-bottom: var(--hair) solid var(--rule); }
.reg__row:last-child:not(.is-last) { border-bottom: 0; }

/* ═══ CONTACT SHEET — dense coded plates (template P953) ════════════════
   Rows of plates at deliberately unequal sizes, bottom-aligned on a common
   baseline, each over a three-line caption: code, name, source tag. The density
   is the point; equalising the plates would destroy it. */
.sheet {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));   /* five across, never more */
  align-items: end;              /* the shared baseline the template works from */
  gap: var(--u4) var(--u2);
}
.sheet__item { position: relative; min-width: 0; }
/* Captions are held to a common height so the PLATES land on one line, not just
   the item boxes. Without this a two-line title drops its neighbour's plate. */
.sheet__cap { min-height: calc(1.4em * 3); }
/* A button, not a link: its job is to reveal the record, and there is no page
   to navigate to yet. Reset to look like the plate it wraps. */
.sheet__link {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.sheet__plate img { width: 100%; transition: opacity var(--fade) ease; }
.sheet__link:hover .sheet__plate img { opacity: .82; }

.sheet__cap { display: block; margin-top: var(--u-half); font-size: var(--t-caption); line-height: 1.4; }
.sheet__code { display: block; }
.sheet__name { display: block; }
.sheet__src  { display: block; color: var(--ink-soft); }

/* Irregularity now lives INSIDE the cell: each plate takes a different share of
   its column, and its height still follows its own ratio. The grid caps the row
   at five; the varying fill keeps P953's unevenness. */
.sheet__plate { display: block; }
.w1 .sheet__plate { width: 62% }
.w2 .sheet__plate { width: 74% }
.w3 .sheet__plate { width: 84% }
.w4 .sheet__plate { width: 92% }
.w5 .sheet__plate { width: 100% }
.w6 .sheet__plate { width: 100% }

/* ── Hover panel ─────────────────────────────────────────────
   Enlarged cover beside the full record. Opens on hover AND on focus-within so
   the keyboard reaches it; the content sits in the DOM regardless, tied to the
   control by aria-describedby, so a screen reader never waits for the panel.

   Landscape rather than portrait: cover left, text right. Stacking them made
   the panel taller than the fold on the lower rows.

   It is anchored to its item rather than floating near it — vertically centred
   on the plate, overlapping it slightly, with a connector notch on the leading
   edge. The notch is a rotated square carrying two of the panel border sides,
   so the hairline reads as continuous rather than as an applied arrow.

   display:none is kept for the closed state because a laid-out panel at
   left:100% contributes to scroll width — that is what put a horizontal
   scrollbar on this page. transition-behavior:allow-discrete plus
   @starting-style animate out of display:none properly. */
.pop {
  position: absolute;
  left: 100%;
  top: 50%;
  z-index: 30;
  width: 560px;
  margin-left: -14px;            /* the overlap onto the plate */
  padding: var(--u2);
  background: var(--paper);
  border: var(--hair) solid var(--rule);   /* a hairline, never a shadow */
  display: none;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: var(--u2);
  align-items: start;
  opacity: 0;
  transform: translateY(-50%) translateX(-10px) scale(.99);
  transition:
    opacity var(--glide) var(--ease),
    transform var(--glide) var(--ease),
    display var(--glide) allow-discrete;
}
.sheet__item:hover .pop,
.sheet__item:focus-within .pop {
  display: grid;
  opacity: 1;
  transform: translateY(-50%);
}
@starting-style {
  .sheet__item:hover .pop,
  .sheet__item:focus-within .pop {
    opacity: 0;
    transform: translateY(-50%) translateX(-10px) scale(.99);
  }
}

/* The connector notch, on the middle of the leading edge. */
.pop::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 50%;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  background: var(--paper);
  border-left: var(--hair) solid var(--rule);
  border-bottom: var(--hair) solid var(--rule);
  transform: rotate(45deg);
}

/* Near the right edge the panel opens to the left; the notch and the glide
   follow it across. */
.pop--flip {
  left: auto;
  right: 100%;
  margin-left: 0;
  margin-right: -14px;
  transform: translateY(-50%) translateX(10px) scale(.99);
}
.sheet__item:hover .pop--flip,
.sheet__item:focus-within .pop--flip { transform: translateY(-50%); }
.pop--flip::before {
  left: auto;
  right: -7px;
  border-left: 0;
  border-bottom: 0;
  border-right: var(--hair) solid var(--rule);
  border-top: var(--hair) solid var(--rule);
}

.pop__cover img { width: 100%; }
.pop__body { min-width: 0; }

.pop__code  { font-size: var(--t-caption); color: var(--ink-soft); }
.pop__title { font-size: var(--t-meta); line-height: 1.3; margin: 2px 0 var(--u2); }
.pop__title .alt { color: var(--ink-soft); }

/* The record proper — a small ledger, label left, value right. */
.pop__spec { display: grid; grid-template-columns: 6.5em minmax(0, 1fr); gap: 3px var(--u1); font-size: var(--t-caption); }
.pop__spec dt { color: var(--ink-soft); }
.pop__spec dd { margin: 0; }
.pop__rule { border: 0; border-top: var(--hair) solid var(--rule); margin: var(--u1) 0; }

.pop__desc { font-size: var(--t-caption); line-height: 1.65; margin-bottom: var(--u1); }
.pop__keys { font-size: var(--t-caption); color: var(--ink-soft); margin-bottom: var(--u1); }
.pop__links { display: grid; gap: 3px; font-size: var(--t-caption); }
.pop__pending { color: var(--ink-soft); border-bottom: var(--hair) dotted var(--rule); justify-self: start; }
.pop__pending { color: var(--ink-soft); border-bottom: var(--hair) dotted var(--rule); }

@media (max-width: 1100px) { .sheet { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 900px)  { .sheet { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

@media (max-width: 800px) {
  .sheet { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--u2) var(--u1); }
  /* Touch has no hover: the panel becomes a static block under its plate, so
     nothing is reachable only by pointing. */
  .pop {
    position: static; display: block; width: auto;
    opacity: 1; transform: none; transition: none;
    margin: var(--u-half) 0 0; border: 0; border-top: var(--hair) solid var(--rule);
    padding: var(--u1) 0 0;
  }
  .pop::before { display: none; }
  .pop__cover { display: none; }   /* the plate above it already shows the cover */
  .sheet__cap { min-height: 0; }
  [class*="w"] .sheet__plate { width: 100%; }
}

/* Stacked: the plate above its record once there is no room beside it. */
@media (max-width: 1000px) {
  .row { grid-template-columns: minmax(0, 1fr); gap: var(--u1); }
  .row__head { grid-template-columns: minmax(0, 1fr); gap: var(--u-half); }
  .row__year { justify-self: start; }
  .row__thumb { margin-bottom: var(--u-half); }
}


/* ═══ Swipe underline ═══════════════════════════════════════════════════
   The rule draws in from the left rather than appearing whole. A pseudo-element
   scaled on X, so nothing reflows and the hairline stays exactly 1px at any
   zoom. Sits inside the raised motion budget (45): a hover reveal, not an
   entrance animation. The reduced-motion guard collapses the duration, leaving
   the rule to appear instantly — the affordance survives, the movement does not. */
.swipe { position: relative; }
.swipe::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: var(--hair);
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform var(--fade) var(--ease);
}
a:hover .swipe::after,
a.swipe:hover::after,
button:hover .swipe::after { transform: scaleX(1); }

/* Everything that used to grow a static border on hover now draws one. */
.nav__label,
.row__title .t-en,
.reg__title a,
.filmstrip__label,
.sectionindex__label,
.siblings a,
.pop__links a,
.embed__out,
.contact a { position: relative; }

.nav a:hover .nav__label::after,
a.row__title:hover .t-en::after,
.reg__title a:hover::after,
.filmstrip a:hover .filmstrip__label::after,
.sectionindex a:hover .sectionindex__label::after,
.siblings a:hover::after,
.pop__links a:hover::after,
.embed__out:hover::after,
.contact a:hover::after { transform: scaleX(1); }

.nav__label::after,
.row__title .t-en::after,
.reg__title a::after,
.filmstrip__label::after,
.sectionindex__label::after,
.siblings a::after,
.pop__links a::after,
.embed__out::after,
.contact a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: var(--hair);
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform var(--fade) var(--ease);
}
/* Aim the rule at the label itself, not at a block that stretches past it. */
.nav__label, .filmstrip__label, .sectionindex__label { display: inline-block; }


/* CV entries as a dated ledger: year in a fixed gutter, entry beside it, one per
   line and in order. The auto-fill columns used elsewhere scramble a chronology. */
.cvlist li {
  display: grid;
  grid-template-columns: 3.6em minmax(0, 1fr);
  gap: var(--u1);
  padding: 3px 0;
}
.cvlist__yr { color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.cvlist__t em { font-style: italic; }

/* The CV is a single flowing list here, not the multi-column block. */
.tri__col--cv .cv dd { display: block; }

/* Portrait sits at the head of the biography column. */
.portrait { max-width: 34em; }
.bioprose p { font-size: var(--t-caption); line-height: 1.7; }
.bioprose p + p { margin-top: var(--u1); }
.bioprose em { font-style: italic; }

@media (max-width: 560px) {
  .cvlist li { grid-template-columns: minmax(0, 1fr); gap: 0; }
}


/* A short curatorial lead under each series marker, before its works. */
.series__lead { max-width: 91ch; margin-bottom: var(--u4); }
.series__lead p { font-size: var(--t-caption); line-height: 1.7; color: var(--ink-soft); }


/* Local rail — where we are. The item in view (aria-current="location", set by
   rail-anchors.js) carries the underline, drawn as on hover. No weight change
   and no side bar: those mark the page you are on in the global rail. */
.rail--local .nav a[aria-current] .nav__label { font-weight: inherit; }
.rail--local .nav a[aria-current]::before { display: none; }
.rail--local a[aria-current] .nav__label::after,
.rail--local a[aria-current] .sectionindex__label::after { transform: scaleX(1); }


/* ═══ Prose — justified, inter-word ═════════════════════════════════════
   Every running paragraph in the central column is set justified, the slack
   taken up between words, never by breaking a word (client). Centred lines —
   calls to action, ornaments, verse, captions, kickers — are not prose and are
   left as they are. 中文 has no spaces to spread, so it justifies by its own
   rules. */
.field .statement p,
.field .piece__text p,
.field .off-prose:not(.off-verse) > p:not(.off-cta):not(.off-orn):not(.off-lede):not(.off-verse),
.field .off-spread__text > p:not(.off-cta):not(.off-orn),
.field .thesis p,
.field .series__lead p,
.field .reg__desc,
.field .perf__desc,
.field .tri__col p,
.field .bioprose p,
.field .hgal__text,
.field .hnote__text,
.field .off-quotes blockquote p {
  text-align: justify;
  text-justify: inter-word;
  hyphens: manual;
  word-break: normal;
}
.field :lang(zh).thesis p,
.field .thesis:lang(zh) p,
.field p:lang(zh) { text-justify: auto; }


/* ═══ Rail fits the screen ═══════════════════════════════════════════════
   Everything in the global rail — routes, switches, contact, social icons, ©
   — must be visible without scrolling (client). The rail's gaps scale with
   the screen's height: the full 54px rhythm on tall screens, tightening on
   shorter ones (≈34px at 900px, ≈23px at 720px), and the space between items
   likewise. The local rail's title stays level with the first series label
   because it is placed by the same gap. If a window is shorter still, the rail
   scrolls within itself rather than cutting anything off. Desktop only — on
   phones the rail is the collapsed menu. */
:root {
  --rail-gap:  clamp(8px, calc(8vh - 40px), var(--u4));
  --rail-step: clamp(5px, calc(1.5vh - 5px), var(--u1));
}
@media (min-width: 801px) {
  .rail--global .rail__nav    { margin-top: var(--rail-gap); }
  .rail--global .nav          { margin-bottom: var(--rail-gap); }
  .rail--global .nav__item    { margin-bottom: var(--rail-step); }
  .rail--global .rail__bottom { padding-top: var(--rail-gap); }
  .rail--global .switches     { margin-bottom: var(--rail-gap); }
  .rail--global .contact__copy { margin-top: var(--rail-step); }
  .rail--local .rail__inner > .marker:first-child { margin-top: calc(var(--glyph-h) + var(--rail-gap)); }
  .rail--global .rail__inner {
    max-height: calc(100vh - var(--u2) * 2);
    overflow-y: auto;
    scrollbar-width: none;
  }
  .rail--global .rail__inner::-webkit-scrollbar { display: none; }
}

/* Short screens (under 820px tall): the rail starts nearer the top edge, the
   language and theme switches share one row, and the © line sits beside the
   social icons — so the whole rail still fits. */
@media (min-width: 801px) and (max-height: 820px) {
  .rail__inner { top: var(--u1); }
  .rail--global .rail__inner {
    min-height: calc(100vh - var(--u2));
    max-height: calc(100vh - var(--u2));
  }
  .rail--global .switches { display: flex; align-items: center; gap: var(--u2); }
  .rail--global .switches .switch + .switch { margin-top: 0; }
  .rail--global .contact { display: flex; flex-wrap: wrap; align-items: center; column-gap: var(--u1); }
  .rail--global .contact > :first-child { flex-basis: 100%; }
  .rail--global .contact__copy { margin-top: 0; }
}

/* Phone menu (client): no © line — the email and social icons stay — and in
   English the menu carries no 中文 beneath its labels. Desktop unchanged. */
@media (max-width: 800px) {
  .rail--global .contact__copy { display: none; }
  .has-js[data-lang="en"] .rail--global .nav [lang="zh"] { display: none; }
}

/* Phone menu, every page (client): closed, the rail is only the wordmark and
   the Menu button — the switches and icons fold away with the routes, as on the
   home and gallery pages. Open, its inner column covers the whole screen on an
   80% ground and the page behind stops scrolling. The rail itself stays in the
   flow, held at its closed height by menu.js, so the page never moves when the
   menu opens or closes. Keyed to the button being shown, so with JS off (button
   hidden) the rail stays an ordinary open block in the flow. */
@media (max-width: 800px) {
  .rail--global:has(.menubtn:not([hidden])[aria-expanded="false"]) .rail__bottom { display: none; }
  .rail--global:has(.menubtn:not([hidden])[aria-expanded="true"]) .rail__inner {
    position: fixed;
    inset: 0;
    z-index: 20;
    padding: inherit;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: color-mix(in srgb, var(--paper) 80%, transparent);
  }
  html:has(.rail--global .menubtn:not([hidden])[aria-expanded="true"]) { overflow: hidden; }
}

/* The language and colour switches share one row in the rail, at every
   screen size (client) — formerly stacked, sharing a row only on short
   screens. */
.rail--global .switches { display: flex; align-items: center; flex-wrap: wrap; gap: var(--u1) var(--u2); }
.rail--global .switches .switch + .switch { margin-top: 0; }
.rail--global .theme { margin-top: 0; }

/* Both rail switches exactly the same size (client): every button — EN, 中文,
   sun, moon — is the same box, its content centred, the pressed one marked by
   the same rule beneath. */
.rail--global .switches .switch { display: inline-flex; gap: 4px; }
.rail--global .switch button {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 28px;
  padding: 0;
  font-size: var(--t-caption);
  line-height: 1;
}
.rail--global .switch .ico { width: 15px; height: 15px; }

/* ── Video facade (video.js) ──────────────────────────────────────────────
   The poster with a play button, and the player that replaces it on click.
   Performance and Research. A short (.yt--short) is vertical, 9:16. */
.yt { position: relative; display: block; }
.yt img { width: 100%; }
.yt__play {
  position: absolute;
  top: 50%; left: 50%;
  width: 84px; height: 84px;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  border: 1.5px solid #F5F5F5;            /* on the image in both themes */
  border-radius: 50%;                     /* a play control, not a card — the one round */
  background: rgba(17, 16, 19, .35);
  color: #F5F5F5;
  transition: background var(--fade) ease;
}
.yt__play svg { width: 34px; height: 34px; fill: currentColor; margin-left: 4px; }
.yt:hover .yt__play,
.yt:focus-visible .yt__play { background: rgba(17, 16, 19, .6); }
.yt__frame {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  border: 0;
}

.yt--short img { aspect-ratio: 9 / 16; object-fit: cover; }   /* the poster is the frame itself */
.yt__frame--short { aspect-ratio: 9 / 16; }
/* Never taller than 80% of the screen; the player keeps the poster's size. */
.yt--short,
.yt__frame--short { width: min(100%, calc(80vh * 9 / 16)); }

/* ── Menu groups (Shop, Press — C72/C73) ──────────────────────────────────
   The group's name reads exactly as a menu item; a small chevron turns as
   it opens. Its items open like an accordion: the height animates from 0 to
   the content's own (grid rows 0fr → 1fr), and closed items are hidden from
   the keyboard and screen readers. Without JS every item shows. menu.js flips the state. */
.nav__toggle {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-size: var(--t-caption);
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
}
.nav__toggle .nav__label { color: var(--ink); position: relative; }
.nav__toggle:hover .nav__label::after { transform: scaleX(1); }
.nav__toggle:focus-visible { outline: var(--hair) solid currentColor; outline-offset: 3px; }
.nav__caret {
  display: inline-block;
  width: .42em;
  height: .42em;
  margin-left: .55em;
  border-right: 1.2px solid currentColor;
  border-bottom: 1.2px solid currentColor;
  transform: translateY(-.2em) rotate(45deg);
  transition: transform var(--fade) var(--ease);
}
.nav__group.is-open .nav__caret { transform: translateY(0) rotate(-135deg); }

.nav__subwrap {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 350ms var(--ease), visibility 0s linear 0s;
}
.nav__sub {
  min-height: 0;
  overflow: hidden;
  margin: 0;
  padding: 0 0 0 var(--u1);
  list-style: none;
}
.nav__sub > .nav__item:first-child { margin-top: var(--u1); }
.nav__sub > .nav__item:last-child { margin-bottom: 0; }
.has-js .nav__group:not(.is-open) .nav__subwrap {
  grid-template-rows: 0fr;
  visibility: hidden;
  transition: grid-template-rows 350ms var(--ease), visibility 0s linear 350ms;
}
@media (prefers-reduced-motion: reduce) {
  .nav__subwrap,
  .has-js .nav__group:not(.is-open) .nav__subwrap,
  .nav__caret { transition: none; }
}
/* In the tablet band the sections run as a wrapping row: a group takes the
   whole row so its items open beneath it. */
@media (max-width: 800px) {
  .nav--sect .nav__group { flex-basis: 100%; }
}

/* On shorter screens a group's first item sits at the rail's item step. */
@media (min-width: 801px) and (max-height: 900px) {
  .rail--global .nav__sub > .nav__item:first-child { margin-top: var(--rail-step); }
}
/* The rail must still fit with a group open (C55). Nothing above the group
   moves: only the gaps below it — before Contact, the switches and the icons,
   which the opening group pushes down anyway — close up, in step with it. */
@media (min-width: 801px) {
  .rail--global .nav--sect,
  .rail--global .rail__bottom,
  .rail--global .nav--foot,
  .rail--global .switches { transition: margin 350ms var(--ease), padding 350ms var(--ease); }
}
@media (min-width: 801px) and (max-height: 1000px) {
  .rail--global:has(.nav__group.is-open) .nav--sect { margin-bottom: 8px; }
  .rail--global:has(.nav__group.is-open) .rail__bottom { padding-top: 8px; }
  .rail--global:has(.nav__group.is-open) .nav--foot,
  .rail--global:has(.nav__group.is-open) .switches { margin-bottom: 8px; }
}
@media (min-width: 801px) and (max-height: 760px) {
  .rail--global:has(.nav__group.is-open) .nav--sect { margin-bottom: 4px; }
  .rail--global:has(.nav__group.is-open) .rail__bottom { padding-top: 4px; }
  .rail--global:has(.nav__group.is-open) .nav--foot,
  .rail--global:has(.nav__group.is-open) .switches { margin-bottom: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  .rail--global .nav--sect,
  .rail--global .rail__bottom,
  .rail--global .nav--foot,
  .rail--global .switches { transition: none; }
}
/* Shorter still: in English the group's items drop their 中文 lines (as the
   phone menu does, C67), so an open group fits a 720px screen. */
@media (min-width: 801px) and (max-height: 820px) {
  .has-js[data-lang="en"] .rail--global .nav__sub .alt { display: none; }
}

/* Items set apart above the switches (Contact): a menu item of their own, the
   rail's gap between them and the switches. */
.rail--global .nav--foot { margin: 0 0 var(--rail-gap, var(--u2)); }
.rail--global .nav--foot .nav__item:last-child { margin-bottom: 0; }
@media (max-width: 800px) {
  .rail--global .nav--foot { margin-bottom: var(--u2); }
}
