:root {
  --site-header-height: 76px;
  --home-cover-height: 700px;
}

body .topbar {
  height: var(--site-header-height);
  padding-inline: max(24px, calc((100vw - 1320px) / 2));
  gap: 32px;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  backdrop-filter: none;
}
.topbar .topbar-brand { font-size: 18px; gap: 10px; flex-shrink: 0; min-width: 0; }
.topbar .topbar-tabs { flex: 1; justify-content: flex-start; margin: 0; gap: 24px; }
.topbar .topbar-tabs a { padding-inline: 0; font-size: 15px; font-weight: 400; }
.topbar .topbar-tabs a::after { left: 0; right: 0; height: 2px; border-radius: 0; transition: none; }
.topbar .topbar-tabs a:not(.active):hover::after { transform: scaleX(0); }
.topbar .topbar-right { gap: 8px; margin-left: auto; flex-shrink: 0; }
.topbar .search-toggle:not([hidden]) { width: 44px; min-width: 44px; height: 44px; padding: 10px; margin: 0; border: 0; background: none; justify-content: center; }
.topbar .reader-hub-toggle { width: auto; min-width: 44px; padding-inline: 10px; display: inline-flex; gap: 8px; white-space: nowrap; }
.topbar .search-toggle .search-label, .topbar .search-toggle kbd { display: none; }
.topbar .icon-btn { width: 44px; height: 44px; border-radius: 4px; }
.topbar :is(.icon-btn, .repo-pill, .lang-btn):hover { box-shadow: none; text-shadow: none; filter: none; }
.topbar .lang-btn { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: none; font-size: 14px; letter-spacing: 0; }
.topbar .repo-pill { background: none; border-color: transparent; }
.side-primary { display: none; }

.page-home .shell { max-width: 1312px; padding: 0 40px; background: var(--paper); }
.page-home main { padding-top: 0; }   /* the first band meets the cover */
.page-home .home-foot { border-top: 1px solid var(--rule); padding-top: 24px; }

:root .page-reading { background: var(--paper); }
/* the reading page itself (column, type, blocks, the directory drawer) lives in reading.css */
@media (min-width: 1081px) {
  .topbar > .menu { display: none; }
}
@media (max-width: 1250px) and (min-width: 1081px) {
  body .topbar { gap: 20px; padding-inline: 24px; }
  .topbar .topbar-tabs { gap: 18px; }
  .topbar .repo-btn { display: none; }
}
@media (max-width: 1080px) {
  :root { --site-header-height: 64px; }
  html { scroll-padding-top: 84px; }
  body .topbar { display: flex; height: var(--site-header-height); padding: 0 20px; gap: 10px; }
  body .topbar > .topbar-brand { order: 0; min-width: 0; font-size: 17px; min-height: 44px; }
  body .topbar-brand .brand-full { position: static; width: auto; height: auto; clip-path: none; overflow: visible; white-space: nowrap; }
  body .topbar-brand .brand-short { display: none; }
  body .topbar > .topbar-right { order: 1; margin-left: auto; gap: 2px; }
  body .topbar > .menu { order: 2; display: inline-flex; flex-shrink: 0; margin-right: -10px; }
  body .topbar > .topbar-tabs { display: none; }
  body .topbar .repo-btn, body .topbar .theme, body .topbar .reader-hub-label { display: none; }
  body .topbar .search-toggle { display: inline-flex; }
  body .topbar .reader-hub-toggle { width: 44px; min-width: 44px; }
  body .side { top: var(--site-header-height); height: calc(100dvh - var(--site-header-height)); }
  body .side-scrim { inset-block-start: var(--site-header-height); }
  .side-primary { display: block; margin-bottom: 18px; border-bottom: 1px solid var(--rule); padding: 0 8px 16px; }
  .side-primary .topbar-tabs { display: grid; width: 100%; height: auto; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 12px; margin: 0; padding: 0; overflow: visible; mask-image: none; }
  .side-primary .topbar-tabs a { font-size: 14px; line-height: 1.5; min-height: 44px; padding: 8px 0; white-space: normal; }
  .side-primary .topbar-tabs a::after { display: none; }
  .side-primary .side-search { display: inline-flex; align-items: center; gap: 10px; margin-top: 8px; min-height: 44px; border: 0; background: none; color: var(--muted); font: 15px var(--body); }
  .side-primary .side-search[hidden] { display: none; }
  .page-home .shell { padding-inline: 32px; }
  :root .page-reading .shell { padding-inline: 28px; }
  :root .page-reading main { padding-top: 24px; }
}
@media (max-width: 600px) {
  :root { --home-cover-height: 420px; }
  .page-home:lang(en) { --home-cover-height: 540px; }
  body .topbar { padding-inline: 20px; gap: 6px; }
  body .topbar .search-toggle:not([hidden]) { display: none; }
  .page-home .shell { padding-inline: 22px; }
  .page-home main { padding-top: 32px; }
  :root .page-reading .shell { padding-inline: 22px; }
}
@media (max-width: 360px) {
  .page-home:lang(en) { --home-cover-height: 580px; }
  body .topbar { padding-inline: 14px; gap: 2px; }
  body .topbar .topbar-brand { font-size: 16px; gap: 7px; }}
@media print {
  .side-primary { display: none; }
}

/* ---------------------------------------------------------------- the cover (round 7)
   The title in the heavy face, then the stop strip: every stop is a thin bar, its height the
   reading time, grouped by track in map order. One red line marks "here", with a readout above
   (the first stop on a first visit; reader-hub.js moves it to where a returning reader stopped).
   Then one red button to start, and one plain one. Nothing moves on its own. */
/* the cover's grid (round 8): hairline cells, like a page ruled for notes. Title on the left, the
   lead and the two ways in on the right, the strip across the full width below. */
.strip { margin-top: 0; }
/* the strip: each track drawn as what it teaches (track_art.py), in its area's hue, seen through
   vertical slats; each stop a short tick above and below (further out for a longer stop); the
   cinnabar line is "here". Tracks this browser has opened are full strength, the rest dimmed. */
.strip-track { position: relative; flex: var(--n) 1 0; display: flex; flex-direction: column; min-width: 0; color: var(--hue, var(--muted)); }
.strip-art { display: block; height: var(--art-h); opacity: .58;
  -webkit-mask-image: repeating-linear-gradient(90deg, #000 0 4.5px, transparent 4.5px 6px); mask-image: repeating-linear-gradient(90deg, #000 0 4.5px, transparent 4.5px 6px); }
.strip-track:has(.strip-bar:is(.is-opened, .is-here)) .strip-art { opacity: 1; }
.strip-art .art, .track-card-art .art { display: block; width: 100%; height: 100%; }
.art .art-hot { fill: var(--ember); }
.art .art-hot-line { stroke: var(--ember); stroke-width: 1.6; }
.strip .strip-group { position: absolute; left: 0; right: 0; top: -26px; height: calc(var(--art-h) + 52px); display: flex; gap: 0; }
.strip .strip-bar { position: relative; flex: 1 1 0; max-width: none; height: 100%; background: none; }
.strip .strip-bar::before, .strip .strip-bar::after { content: ""; position: absolute; left: 50%; width: 5px; height: 2px; margin-left: -2.5px; background: color-mix(in srgb, var(--ink) 30%, transparent); }
.strip .strip-bar::before { top: calc(20px - var(--d, 0px)); }
.strip .strip-bar::after { bottom: calc(20px - var(--d, 0px)); }
.strip .strip-bar.is-opened::before, .strip .strip-bar.is-opened::after { background: var(--ink-soft); }
.strip .strip-bar.is-here { background: linear-gradient(var(--ember), var(--ember)) 50% 0 / 2px 100% no-repeat; }
.strip .strip-bar.is-here::before, .strip .strip-bar.is-here::after { background: var(--ember); }
.strip-n { margin-top: 34px; color: var(--faint); font: 10px/1 var(--mono); }

/* ---------------------------------------------------------------- the bands (round 7)
   Below the cover the home page runs in full-width bands: 例 01 on paper, every note in its area
   on the red, the tracks on the night. The band colours are tokens; inside a band the reading
   tokens are swapped, so the parts in it (the calculation, its buttons) take the band's colours. */
/* the six-area index: the page with an 8% cinnabar tint, text as usual */
.area-band { --band-bg: var(--band-red); --paper: var(--band-red); --rule: color-mix(in srgb, var(--ink) 16%, transparent); }

/* a row of small labelled numbers (build.py writes it into the track cards) */
.plate { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); margin: 18px 0 0; }
.plate div { min-width: 0; padding: 10px 12px 0 0; border-top: 1px solid var(--rule); }
.plate dt { color: var(--faint); font: 12px/1.4 var(--body); }
.plate dd { margin: 3px 0 0; color: var(--ink-soft); font: 14px/1.4 var(--body); font-variant-numeric: tabular-nums; }

/* the area index: each area a mono line with its counts, then its names in large type */
.prose .area-index { margin: 40px 0 0; padding: 0; list-style: none; }
.prose .area-index .area-row { margin: 0; padding: 18px 0 22px; border-top: 1px solid var(--rule); }
.prose .area-index p { margin: 0; }
.prose .area-index .area-meta { color: var(--muted); font: 14px/1.5 var(--body); font-variant-numeric: tabular-nums; }
.prose .area-index .area-names { display: flex; flex-wrap: wrap; gap: 4px 30px; margin-top: 12px; font: var(--display-weight) clamp(1.35rem, 2.3vw, 1.95rem)/1.3 var(--display); letter-spacing: 0; }
.prose .area-index .area-link { color: var(--ink); text-decoration: none; }
.prose .area-index .area-link:hover { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: .12em; }

/* the track cards: a row that scrolls sideways */
.track-cards { display: flex; gap: 16px; margin-top: 36px; padding-bottom: 14px; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: thin; }
.track-card { flex: none; width: 300px; padding: 20px; border: 1px solid var(--rule); background: var(--panel); scroll-snap-align: start; }
.track-card-art { display: block; height: 92px; margin-top: 16px; color: var(--hue, var(--muted));
  -webkit-mask-image: repeating-linear-gradient(90deg, #000 0 4.5px, transparent 4.5px 6px); mask-image: repeating-linear-gradient(90deg, #000 0 4.5px, transparent 4.5px 6px); }
/* under the drawing, one thin segment per stop: bright once opened */
.track-card-strip { display: flex; align-items: stretch; gap: 3px; height: 3px; margin-top: 12px; }
.track-card-strip .strip-bar { flex: 1 1 0; max-width: none; height: 3px; background: var(--rule); }
.track-card-strip .strip-bar.is-opened { background: var(--ink-soft); }
.track-card-stops .stop-n { flex: none; color: var(--muted); font: 12px/1.75 var(--mono); }
.track-card-more { color: var(--muted); }

@media (max-width: 600px) {
  .strip { margin-top: 0; --strip-scale: .8; }
  /* on a phone the strip keeps its drawings readable and scrolls sideways */
  .strip-track { flex: none; width: calc(var(--n) * 11px); }
  .strip-n { font-size: 9px; }
  .track-card { width: 260px; }
}
