/* The journey, D−0 to D+0 — second edition layout.
   Type, weights and rhythm follow the first edition (dist/journey-2026-09.html); colours come
   from /d0-tokens.css. No inline styles in the page: everything that looks is here. */

:root {
  --hdr-h: 57px;                      /* fixed header, one row */
  --pad-x: max(22px, 6vw);
  --serif: Newsreader, Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --tone-0: var(--surface-deep);
  --tone-1: var(--surface);
  --tone-2: color-mix(in srgb, var(--surface) 62%, var(--surface-raised));
  --tone-3: color-mix(in srgb, var(--surface) 30%, var(--surface-raised));
  --tone-4: var(--surface-raised);
}
@media (max-width: 1179px) { :root { --hdr-h: 95px; } }
@media (max-width: 699px) { :root { --hdr-h: 87px; } }

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--hdr-h) + 12px); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--surface); color: var(--ink); font: 400 15px/1.7 var(--mono); }
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; }
::selection { background: var(--ink); color: var(--surface); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
img { display: block; }
p, h1, h2, h3, dd, dt { overflow-wrap: break-word; }
main { overflow-x: clip; }

.skip-link { position: fixed; left: 16px; top: -80px; z-index: 200; padding: 12px 18px; background: var(--ink); color: var(--surface); font-size: .8rem; letter-spacing: .06em; transition: top .18s ease; }
.skip-link:focus { top: 12px; }

/* ── header ─────────────────────────────────────────────────────────── */
.site-header { position: fixed; left: 0; right: 0; top: 0; z-index: 60; color: var(--ink);
  background: color-mix(in srgb, var(--surface) 88%, transparent);   /* stays legible over ink and paper alike */
  -webkit-backdrop-filter: blur(16px) saturate(1.1); backdrop-filter: blur(16px) saturate(1.1);
  border-bottom: 1px solid var(--line); }
.hdr-row { display: flex; align-items: center; gap: 26px; min-height: 56px; padding: 0 28px; }
.brand { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; min-height: 44px; }
.brand img { width: 26px; height: 26px; }
.site-header[data-theme="paper"] { background: var(--surface); }      /* opaque on paper: its small labels keep 4.5:1 */
.site-header[data-theme="paper"] .brand img { filter: invert(.92); }   /* the first edition's navMark on paper */
.site-header[data-theme="paper"] .brand .dim { opacity: .7; }
.brand span { font-size: .9rem; font-weight: 500; letter-spacing: .06em; }
.brand .dim { opacity: .58; }      /* first edition .45; lifted so the wordmark reads at 4.5:1 */
.site-header :focus-visible { outline-offset: -2px; }   /* inset: the screen's top edge cut an outset ring off on phones */
.levels { display: flex; align-items: center; justify-content: center; gap: 22px; flex: 1 1 auto;
  font-size: .66rem; letter-spacing: .18em; text-transform: uppercase; }
.levels a { display: inline-flex; align-items: center; justify-content: center; min-width: 28px; min-height: 28px; padding: 2px 1px; color: var(--ink-soft); transition: color .3s ease; }
.levels a[aria-current="true"] { color: var(--ink); }
.levels a:hover { color: var(--ink); text-decoration: none; }
.hdr-right { display: flex; align-items: center; gap: 24px; flex: 0 0 auto; margin-left: auto; }
.gauge { font-size: .66rem; letter-spacing: .14em; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink-muted); }
.site-nav { display: flex; align-items: center; gap: 22px; }
.site-nav a, .menu summary { font-size: .66rem; letter-spacing: .2em; text-transform: uppercase; white-space: nowrap; }
.site-nav a { display: inline-flex; align-items: center; min-height: 28px; color: var(--ink-muted); }
.site-nav a:hover { color: var(--ink); }
.menu { position: relative; display: none; }
.menu summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 2px; color: var(--ink); }
.menu summary::-webkit-details-marker { display: none; }
.menu summary::after { content: ""; width: 7px; height: 7px; border-right: 1px solid currentColor; border-bottom: 1px solid currentColor; transform: translateY(-2px) rotate(45deg); }
.menu[open] summary::after { transform: translateY(2px) rotate(-135deg); }
.menu-panel { position: absolute; right: -6px; top: calc(100% + 6px); min-width: 210px; display: flex; flex-direction: column; padding: 8px 0; background: var(--surface-raised); border: 1px solid var(--line); }
.menu-panel a { display: flex; align-items: center; min-height: 44px; padding: 0 18px; font-size: .74rem; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-muted); }
.menu-panel a:hover { color: var(--ink); }
.hdr-progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; pointer-events: none; }
.hdr-progress span { display: block; height: 100%; background: var(--ink); transform: scaleX(0); transform-origin: 0 50%; }

@media (max-width: 1179px) {
  .hdr-row { flex-wrap: wrap; row-gap: 0; padding: 0 22px; }
  .levels { order: 3; flex: 1 0 calc(100% + 44px); justify-content: space-between; gap: 6px; min-height: 38px; margin: 0 -22px; padding: 0 22px; border-top: 1px solid var(--line); }
  .levels a { min-width: 32px; }
}
@media (max-width: 699px) {
  .hdr-row { min-height: 48px; padding: 0 16px; gap: 12px; }
  .levels { flex-basis: calc(100% + 32px); margin: 0 -16px; padding: 0 12px; font-size: .7rem; letter-spacing: .12em; }
  .hdr-right { gap: 14px; }
  .site-nav { display: none; }
  .menu { display: block; }
  .gauge { font-size: .7rem; letter-spacing: .08em; }
}

/* ── shared essay type (first edition values) ─────────────────────── */
.eyebrow { margin: 0 0 1.4em; font-size: .7rem; letter-spacing: .34em; text-transform: uppercase; color: var(--ink-soft); }
.serif { font-family: var(--serif); }
.ch-title { margin: 0 0 1.1em; font: 400 2.6rem/1.15 var(--serif); max-width: 30ch; text-wrap: balance; color: var(--ink); }
.ch-title--wide { max-width: 34ch; }
#st2 .ch-title { font-size: clamp(2.4rem, 4vw, 3.2rem); line-height: 1.1; max-width: 22ch; }
#st6 .ch-title { font-size: clamp(2.2rem, 4.6vw, 3.4rem); line-height: 1.1; max-width: 20ch; margin-bottom: 0; }

/* ── opening (D−0): the same chapter pattern as the rest of the essay ── */
.chapter--opening .hero-lede { margin: 0; max-width: 46ch; font: 400 1.22rem/1.6 var(--serif); color: var(--ink-muted); }
.chapter--opening .hero-walk { margin: 1.4em 0 0; font: italic 400 1.22rem/1.6 var(--serif); color: var(--ink); }
.descend { display: inline-flex; align-items: center; gap: 18px; min-height: 44px; margin-top: 30px; font: .75rem/1.6 var(--mono); letter-spacing: .12em; color: var(--ink); }
.descend span { font-size: 20px; }

/* ── chapters ──────────────────────────────────────────────────────── */
.chapter { position: relative; padding: clamp(96px, 11vw, 168px) var(--pad-x) clamp(80px, 9vw, 136px); border-top: 1px solid var(--line); }
#st1 { background: var(--tone-1); }
#st2 { background: var(--tone-2); }
#st3 { background: var(--tone-3); }
#st4 { background: var(--tone-4); }
/* D+3 and D+0 turn to paper, as in the first edition (its sections st5 and st6). The --tone-*
   values are computed at :root with the night tokens, so the paper sections use the tokens directly. */
#st5 { background: var(--surface); }
#st6 { background: var(--surface-raised); }
[data-theme="paper"] .ledger-table, [data-theme="paper"] .pub { background: var(--surface-raised); }
#st6 .pub { background: var(--surface); }
#st6 .pub:hover, [data-theme="paper"] .pub:hover { background: color-mix(in srgb, var(--surface) 92%, var(--ink)); }
[data-theme="paper"] .fig-plate { border-color: color-mix(in srgb, var(--ink) 30%, transparent); }
.ch-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 44px; max-width: 1320px; margin: 0 auto; }
.ch-head > :last-child { margin-bottom: 0; }
.ch-body { min-width: 0; }
@media (min-width: 1024px) {
  .ch-grid { grid-template-columns: minmax(0, 1.04fr) minmax(0, .96fr); grid-template-areas: "head fig" "body fig"; grid-template-rows: auto 1fr; column-gap: clamp(48px, 5.4vw, 104px); row-gap: 0; }
  .ch-grid > .ch-head { grid-area: head; }
  .ch-grid > .ch-body { grid-area: body; }
  .ch-grid > .ch-fig { grid-area: fig; align-self: start; position: sticky; top: calc(var(--hdr-h) + 36px); }
  .ch-grid--wide { grid-template-areas: "head fig" "body body"; grid-template-rows: auto auto; row-gap: 64px; }
  .ch-grid--wide > .ch-fig { position: static; }
  .ch-grid--d2 { grid-template-areas: "head head" "fig fig" "body body"; grid-template-rows: auto auto auto; row-gap: 52px; }
  .ch-grid--d2 > .ch-fig { position: static; }
  .ch-head .ch-title { margin-bottom: .9em; }
}

/* ── figures (illustrations) ───────────────────────────────────────── */
.fig { margin: 0; }
.fig-plate { position: relative; aspect-ratio: 4 / 3; background: var(--surface-deep); border: 1px solid var(--line); }
.fig-plate canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.fig figcaption { margin: 14px 0 0; max-width: 62ch; font-size: .78rem; line-height: 1.65; color: var(--ink-soft); }
.fig-kind { color: var(--ink-muted); }
.fig--lanes .fig-plate { aspect-ratio: 4 / 3.15; }
.fig--ground .fig-plate { aspect-ratio: 4 / 3; }
.fig--instruments .fig-plate { aspect-ratio: 1 / 1; }
.fig--ledger .fig-plate { aspect-ratio: 4 / 4.3; }
.fig--terminus .fig-plate { aspect-ratio: 1 / .92; }
.fig--minds { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; }
.fig--minds .fig-plate { aspect-ratio: 16 / 9; }
@media (min-width: 1024px) {
  .fig--minds { grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); column-gap: 40px; align-items: end; }
  .fig--minds figcaption { margin: 0; max-width: 40ch; }
}
@media (max-width: 699px) {
  .fig--instruments .fig-plate { aspect-ratio: 1 / 1.04; }
  .fig--ground .fig-plate { aspect-ratio: 1 / 1.02; }
  .fig--lanes .fig-plate { aspect-ratio: 1 / .98; }
  .fig--minds .fig-plate { aspect-ratio: 1 / .86; }
}

/* ── D−1 / D+1: card grids (first edition) ─────────────────────────── */
.cards { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.card { padding: 38px 30px; background: var(--tone-1); }
#st3 .card { background: var(--tone-3); }
.card-num { margin-bottom: 1.6em; font-size: .7rem; letter-spacing: .26em; text-transform: uppercase; color: var(--ink-soft); }
.card h3 { margin: 0 0 .7em; font: 400 1.55rem/1.25 var(--serif); color: var(--ink); }
.card p { margin: 0; font-size: .98rem; line-height: 1.7; color: var(--ink-muted); }

/* ── d0 ────────────────────────────────────────────────────────────── */
.ground-p { margin: 0 0 1.2em; max-width: 60ch; font: 400 1.22rem/1.6 var(--serif); color: var(--ink-muted); }
.ground-p:last-child { margin-bottom: 0; }
.ground-quote { margin: 2.2em 0 2em; max-width: 34ch; font: italic 400 1.5rem/1.45 var(--serif); text-wrap: balance; color: var(--ink); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr)); gap: 6px 52px; border-top: 1px solid var(--line); }
.stat { padding: 26px 0; }
.stat-n { font-size: 1.7rem; font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: -.02em; color: var(--ink); line-height: 1.3; }
.stat-d { margin-top: .7em; font-size: .92rem; line-height: 1.6; color: var(--ink-muted); }

/* ── D+2: campaigns ────────────────────────────────────────────────── */
.campaigns { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.campaign { display: flex; flex-direction: column; min-height: 260px; padding: 34px 30px 28px; background: var(--tone-4); }
.campaign-top { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-bottom: 2.2em; }
.campaign-id { font-size: .7rem; letter-spacing: .24em; text-transform: uppercase; color: var(--ink-soft); }
.tag { padding: 4px 11px; font-size: .7rem; letter-spacing: .2em; text-transform: uppercase; border: 1px solid var(--line); color: var(--ink-muted); }
.tag--closed { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.tag--open { color: var(--ink-soft); }
.campaign h3 { margin: 0 0 .8em; font: 400 1.5rem/1.22 var(--serif); text-wrap: balance; color: var(--ink); }
.campaign p { flex: 1 1 0%; margin: 0 0 2em; font-size: .95rem; line-height: 1.7; color: var(--ink-muted); overflow-wrap: anywhere; }
.campaign-foot { display: flex; justify-content: space-between; gap: 16px; padding-top: 14px; border-top: 1px solid var(--line); font-size: .7rem; letter-spacing: .26em; text-transform: uppercase; color: var(--ink-soft); }
.records-link { display: inline-flex; align-items: center; min-height: 48px; margin-top: 18px; font-size: .82rem; letter-spacing: .08em; color: var(--ink); text-decoration: underline; text-decoration-color: var(--ink-muted); text-underline-offset: 6px; text-decoration-thickness: 1px; }

/* ── D+3: the record ───────────────────────────────────────────────── */
.record-p { margin: 0 0 1.2em; max-width: 60ch; font-size: 1rem; line-height: 1.7; color: var(--ink-muted); }
.ledger-table { display: flex; flex-direction: column; margin: 2.4em 0 0; padding: 12px 26px; border: 1px solid var(--line); background: var(--tone-4); max-width: 520px; }
.ledger-table div { display: flex; justify-content: space-between; gap: 16px; padding: 13px 0; border-bottom: 1px dotted var(--line); font-size: .78rem; font-variant-numeric: tabular-nums; }
.ledger-table div:last-child { border-bottom: 0; }
.ledger-table dt { color: var(--ink-muted); }
.ledger-table dd { margin: 0; color: var(--ink); text-align: right; white-space: nowrap; }
.now { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px 28px; margin-top: 2.6em; padding-top: 30px; border-top: 1px solid var(--line); }
.now-kind { font-size: .7rem; letter-spacing: .26em; text-transform: uppercase; color: var(--ink); }
.now p { flex: 1 1 300px; min-width: 0; margin: 0; font-size: .95rem; line-height: 1.7; color: var(--ink-muted); }

/* ── D+0 ───────────────────────────────────────────────────────────── */
.terminus-p { margin: 1.6em 0 0; max-width: 48ch; font: 400 1.18rem/1.6 var(--serif); color: var(--ink-muted); }
.terminus-walk { margin: 1.4em 0 0; font: italic 400 1.18rem/1.6 var(--serif); color: var(--ink); }
.pubs { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.pub { display: block; padding: 30px 26px; background: var(--tone-4); transition: background .2s ease; }
.pub:hover { text-decoration: none; background: color-mix(in srgb, var(--tone-4) 88%, var(--ink)); }
.pub-kind { margin-bottom: 1.4em; font-size: .7rem; letter-spacing: .26em; text-transform: uppercase; color: var(--ink-soft); }
.pub-title { margin-bottom: .6em; font: 400 1.3rem/1.2 var(--serif); color: var(--ink); }
.pub p { margin: 0; font-size: .92rem; line-height: 1.65; color: var(--ink-muted); }

/* ── library threads (generated by tools/build_journey_essay.py) ───── */
.thread { margin-top: 64px; max-width: 680px; padding: 26px 28px 24px; border: 1px solid var(--line); background: color-mix(in srgb, var(--surface-deep) 50%, transparent); }
.ch-grid--wide .thread, .ch-grid--d2 .thread { margin-top: 56px; }
.thread-kind { margin: 0 0 1.1em; font-size: .7rem; letter-spacing: .26em; text-transform: uppercase; color: var(--ink-soft); }
.thread h3 { margin: 0 0 .55em; font: 400 1.4rem/1.25 var(--serif); color: var(--ink); }
.thread-text { margin: 0 0 1em; font-size: .86rem; line-height: 1.7; color: var(--ink-muted); }
.thread ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 2px; }
.thread li { font-size: .86rem; line-height: 1.6; color: var(--ink-muted); }
.thread a { display: inline-flex; align-items: center; min-height: 44px; color: var(--ink); }
.thread a span { border-bottom: 1px solid var(--ink-muted); }
.thread a:hover { text-decoration: none; }
.thread a:hover span { border-bottom-color: var(--ink); }
.thread-note { color: var(--ink-soft); }

/* ── footer ────────────────────────────────────────────────────────── */
.site-footer { padding: 72px var(--pad-x) 48px; background: var(--surface-deep); border-top: 1px solid var(--line); }
.footer-inner { max-width: 1320px; margin: 0 auto; }
.colophon { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; padding-bottom: 34px; border-bottom: 1px solid var(--line); }
.essay-credit { margin: 0; font: italic 400 1.18rem/1.5 var(--serif); color: var(--ink); }
.first-edition { margin: 0; max-width: 62ch; font-size: .82rem; line-height: 1.7; color: var(--ink-muted); }
.first-edition a { display: inline-flex; align-items: center; min-height: 44px; color: var(--ink); text-decoration: underline; text-decoration-color: var(--ink-muted); text-underline-offset: 6px; text-decoration-thickness: 1px; }
.first-edition a:hover { text-decoration-color: var(--ink); }
.eccl { display: flex; align-items: baseline; gap: 20px; margin: 8px 0 0; }
.eccl-ref { flex: 0 0 auto; font-size: .74rem; letter-spacing: .22em; text-transform: uppercase; color: var(--ink); white-space: nowrap; }
.eccl-text { flex: 1 1 0; min-width: 0; max-width: 70ch; font: italic 400 .95rem/1.55 var(--serif); color: var(--ink-muted); text-wrap: pretty; }
.footer-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 18px 40px; padding: 26px 0; }
.footer-brand { display: flex; align-items: center; gap: 14px; }
.footer-brand img { width: 30px; height: 30px; }
.footer-brand .brand { min-height: 44px; }
.footer-tag { font-size: .7rem; letter-spacing: .28em; text-transform: uppercase; color: var(--ink-soft); }
.footer-nav { display: flex; flex-wrap: wrap; gap: 4px 26px; }
.footer-nav a { display: inline-flex; align-items: center; min-height: 44px; font-size: .82rem; letter-spacing: .06em; color: var(--ink-muted); }
.footer-nav a:hover { color: var(--ink); }
.footer-legal { margin: 0; font-size: .74rem; line-height: 1.6; color: var(--ink-soft); }
@media (min-width: 1024px) {
  .colophon { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); column-gap: 64px; align-items: start; }
  .eccl { grid-column: 1 / -1; }
}

/* ── phones (first edition breakpoints and floors) ────────────────── */
@media (max-width: 699px), (min-width: 700px) and (max-width: 979px) and (orientation: portrait) {
  .ch-title { font-size: clamp(1.72rem, 6.9vw, 2.3rem); line-height: 1.18; }
  #st2 .ch-title, #st6 .ch-title { font-size: clamp(1.9rem, 7.6vw, 2.5rem); }
  .card h3 { font-size: clamp(1.24rem, 4.9vw, 1.5rem); line-height: 1.26; }
  .campaign h3 { font-size: clamp(1.24rem, 4.9vw, 1.5rem); line-height: 1.26; }
  .card, .campaign { padding: 30px 22px; }
  .eyebrow { font-size: .74rem; letter-spacing: .2em; }
  .chapter { padding-top: 88px; padding-bottom: 80px; }
  .ground-p, .hero-lede, .hero-walk { font-size: 1.12rem; }
  .ground-quote { font-size: 1.32rem; }
  .eccl { flex-direction: column; gap: 10px; }
  .thread { padding: 22px 20px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .levels a, .pub, .skip-link { transition: none; }
}
