/* ══════════════════════════════════════════════════════════════════
   v26 — base layer. Token-driven; works on ink and paper modes.
   ══════════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--field);
  color: var(--text);
  font-family: var(--sans);
  font-size: var(--t-body);
  line-height: 1.7;
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
}

html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-smooth [data-lenis-prevent] { overscroll-behavior: contain; }
.lenis.lenis-stopped { overflow: hidden; }
.lenis.lenis-smooth iframe { pointer-events: none; }

img, svg { display: block; max-width: 100%; }
svg { height: auto; }

a { color: inherit; text-decoration: none; }

:focus-visible {
  outline: 2px solid var(--line-hi);
  outline-offset: 3px;
}
:focus:not(:focus-visible) { outline: none; }

::selection { background: var(--line); color: var(--field); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}

.skip-link {
  position: absolute; left: var(--gutter); top: -100%;
  z-index: 100; padding: var(--s-3) var(--s-4);
  background: var(--field-raise); color: var(--text);
  border: var(--hair) solid var(--line);
  border-radius: var(--radius);
  font: 500 var(--t-label)/1 var(--mono);
  letter-spacing: var(--track-label); text-transform: uppercase;
}
.skip-link:focus { top: var(--s-3); }

/* ── type ─────────────────────────────────────────────────────────── */

h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--display);
  font-weight: 500;
  letter-spacing: var(--track-tight);
  line-height: 1.02;
  text-wrap: balance;
  font-variation-settings: "wdth" 95, "wght" 500;
}
h1 { font-size: var(--t-h1); }
h2 { font-size: var(--t-h2); }
h3 {
  font-size: var(--t-h3);
  line-height: 1.25;
  letter-spacing: -0.02em;
  font-variation-settings: "wdth" 100, "wght" 550;
}

h1 b, h2 b, h3 b, .display b, .display em {
  font-weight: 650;
  font-style: normal;
  color: var(--text);
  font-variation-settings: "wdth" 96, "wght" 650;
}

.display {
  font-family: var(--display);
  font-size: var(--t-display);
  font-weight: 500;
  letter-spacing: var(--track-tight);
  line-height: 0.98;
  margin: 0;
  /* Was a flat 16ch, which put page titles on four short lines while the
     content below them ran the full width. Proportional like the other
     heading measures. */
  max-width: var(--measure-title);
  text-wrap: balance;
  font-variation-settings: "wdth" 92, "wght" 500;
}

.brand-mark {
  display: block;
  font-family: var(--display);
  font-size: clamp(1rem, 1.5vw, 1.2rem);
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.15;
  font-variation-settings: "wdth" 100, "wght" 650;
}

p { margin: 0; max-width: var(--measure); }
p + p { margin-top: var(--s-4); }

.lede {
  font-size: clamp(1.02rem, 1.2vw, 1.125rem);
  line-height: 1.65;
  color: var(--text-dim);
  max-width: var(--measure-lede);
  text-wrap: pretty;
}

.label {
  font: 500 var(--t-label)/1 var(--mono);
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--text-dim);
}
.label--line { color: var(--line); }

.figure {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

/* ── layout ───────────────────────────────────────────────────────── */

.shell {
  width: min(100%, var(--maxw));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section {
  padding-block: var(--section-y);
  padding-inline: var(--gutter);
  background: var(--field);
  color: var(--text);
  position: relative;
}

.section > *,
.stack.shell > * {
  width: min(100%, var(--maxw));
  margin-inline: auto;
}

.rule { height: var(--hair); background: var(--line-quiet); border: 0; margin: 0; }

/* Proportional, see --measure-title in tokens.css. */
.measure-tight { max-width: var(--measure-h2); }
.measure-mid   { max-width: var(--measure-title); }
.mt-6 { margin-top: var(--s-6); }

.field-grid { position: relative; overflow: clip; }
.field-grid > * { position: relative; z-index: 1; }
.field-grid::before {
  content: "";
  position: absolute; inset: 0;
  z-index: 0; pointer-events: none;
  opacity: 0.7;
  background:
    repeating-linear-gradient(to right,  var(--line-ghost) 0 1px, transparent 1px var(--grid)),
    repeating-linear-gradient(to bottom, var(--line-ghost) 0 1px, transparent 1px var(--grid));
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 55%, transparent 100%);
          mask-image: linear-gradient(to bottom, #000 0%, #000 55%, transparent 100%);
}

.mode-ink.field-grid::before { opacity: 0.4; }

.drawing { --stroke: var(--line); }
.drawing [stroke] { vector-effect: non-scaling-stroke; }
.drawing text {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  fill: var(--text-dim);
}

/* The mobile rule that used to sit here hid `.drawing__annotation`, which
   stripped every leader, arrow and label below 760px and left empty boxes
   behind. It was covering for a real problem: an 11px label in an 860-wide
   viewBox renders at about 4.5px on a phone. That is now solved in the
   geometry instead, by emitting a second drawing with a 300-wide viewBox and
   swapping the two at the same breakpoint. See assets/css/drawings.css. */

[data-reveal] {
  opacity: 0;
  transform: translate3d(0, 22px, 0);
  will-change: transform, opacity;
}
html.no-motion [data-reveal] {
  opacity: 1;
  transform: none;
  will-change: auto;
}

/* Hero stays visible until GSAP takes over — avoids a blank first paint. */
[data-hero-enter] { opacity: 1; transform: none; }

@media (max-width: 760px) {
  :root { --grid: 40px; }
}

/* ── progress + rail ──────────────────────────────────────────────── */

.rail-progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 60;
  height: 2px;
  pointer-events: none;
}
.rail-progress__bar {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--line);
  transform: scaleX(0);
  transform-origin: left center;
  will-change: transform;
}

.rail {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-5);
  min-height: var(--rail-h);
  padding-inline: var(--gutter);
  background: var(--field);
  border-bottom: var(--hair) solid var(--line-quiet);
  transition:
    min-height var(--d-base) var(--ease),
    border-color var(--d-base) var(--ease);
}
.rail.is-condensed {
  min-height: 58px;
  border-bottom-color: color-mix(in oklab, var(--line-quiet) 55%, var(--line) 45%);
}

.rail__id {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-width: 0;
}
.rail__mark { color: var(--line); flex: none; }
.rail__mark svg { width: 22px; height: 22px; }

.rail__name { display: flex; flex-direction: column; gap: 2px; line-height: 1.15; }
.rail__nameMain {
  font-family: var(--display);
  font-size: 1.02rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variation-settings: "wdth" 100, "wght" 650;
}
.rail__nameSub {
  font-size: 0.72rem;
  color: var(--text-dim);
}

.rail__nav {
  display: flex;
  align-items: center;
  gap: var(--s-1);
}
.rail__link {
  position: relative;
  padding: var(--s-2) var(--s-3);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-dim);
  border-radius: var(--radius);
  transition: color var(--d-fast) var(--ease), background-color var(--d-fast) var(--ease);
}
.rail__link:hover {
  color: var(--text);
  background: color-mix(in oklab, var(--field-raise) 70%, transparent);
}
.rail__link.is-current { color: var(--text); }
.rail__link.is-current::after {
  content: "";
  position: absolute;
  left: var(--s-3); right: var(--s-3); bottom: 2px;
  height: 2px;
  background: var(--line);
  border-radius: 1px;
}

.rail__cta {
  margin-left: var(--s-3);
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 40px;
  padding: 0.5rem 0.95rem;
  border: var(--hair) solid var(--line);
  border-radius: var(--radius);
  background: var(--line);
  color: var(--field);
  font: 600 var(--t-label)/1 var(--mono);
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  transition:
    background-color var(--d-fast) var(--ease),
    color var(--d-fast) var(--ease),
    border-color var(--d-fast) var(--ease);
}
.rail__cta::after {
  content: "\2192";
  transition: transform var(--d-fast) var(--ease);
}
.rail__cta:hover {
  background: var(--line-hi);
  border-color: var(--line-hi);
  color: var(--field);
}
.rail__cta:hover::after { transform: translateX(3px); }

.rail__toggle {
  display: none;
  background: none; border: 0; padding: var(--s-2);
  color: var(--text); cursor: pointer;
  border-radius: var(--radius);
}
.rail__toggle:hover { background: var(--field-raise); }
.rail__toggle svg { width: 18px; }

.rail__drawer {
  position: sticky; top: var(--rail-h); z-index: 39;
  background: var(--field-deep);
  border-bottom: var(--hair) solid var(--line-quiet);
}
.rail.is-condensed ~ .rail__drawer { top: 58px; }
.rail__drawer a {
  display: block;
  min-height: 52px;
  padding: var(--s-4) var(--gutter);
  border-bottom: var(--hair) solid var(--line-quiet);
  font-size: 1.0625rem;
  font-weight: 500;
  color: var(--text);
  transition: background-color var(--d-fast) var(--ease);
}
.rail__drawer a:hover,
.rail__drawer a:focus-visible { background: var(--field-raise); }
.rail__drawer a:last-child { border-bottom: 0; }

body.is-drawer-open { overflow: hidden; }

.foot {
  background: var(--field-deep);
  border-top: var(--hair) solid var(--line-quiet);
  padding: var(--s-7) var(--gutter) var(--s-6);
}
.foot__grid {
  width: min(100%, var(--maxw));
  margin-inline: auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: var(--s-5);
}
.foot__val { margin-top: var(--s-2); font-size: var(--t-small); color: var(--text); max-width: none; }
.foot__grid .label { color: var(--text-faint); }
.foot a {
  color: var(--line);
  transition: color var(--d-fast) var(--ease);
}
.foot a:hover {
  color: var(--line-hi);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.foot__legal {
  width: min(100%, var(--maxw));
  margin-inline: auto;
  margin-top: var(--s-6);
  padding-top: var(--s-4);
  border-top: var(--hair) solid var(--line-quiet);
  font-size: var(--t-label);
  color: var(--text-faint);
  max-width: none;
}

/* Mobile dual CTA dock.
   Slides off by transform rather than display:none so it can animate.
   It hides itself while a visitor is actively scrolling down to read (the
   whole reason to fix this: a bar pinned over 72px of every screen on
   every page reads as a permanent ask, not a convenience) and reappears
   the moment they pause or scroll back up, so it's there when wanted. */
.dock {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  gap: var(--s-2);
  padding: 10px var(--gutter) calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--field);
  border-top: var(--hair) solid var(--line-quiet);
  transform: translateY(0);
  transition: transform var(--d-base) var(--ease);
}
.dock.is-hidden-scroll { transform: translateY(110%); }
body.is-drawer-open .dock { display: none !important; }
.dock.is-hidden { display: none !important; }
.dock__btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.7rem 1rem;
  border: var(--hair) solid var(--line);
  border-radius: var(--radius);
  font: 600 var(--t-label)/1 var(--mono);
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--line);
  background: var(--field);
}
.dock__btn--primary {
  background: var(--line);
  color: var(--field);
}

@media (max-width: 960px) {
  .rail__nav { display: none; }
  .rail__cta { display: none; }
  .rail__toggle { display: block; }
  .rail__nameSub { display: none; }

  .dock { display: flex; }
  body { padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }
  .foot { padding-bottom: var(--s-5); }
}

/* ══════════════════════════════════════════════════════════════════
   Adjacent-section rhythm.

   Two stacked .section elements each contribute up to 120px of padding,
   so a heading section followed by its own content produced up to 240px
   of dead gap between them. That is the single biggest contributor to
   the airiness measured across this site.

   A section that directly follows another gets a reduced top padding,
   because the gap above it is already being paid for by the section
   before. Mode changes are exempt: a colour change needs the full break
   to read as turning a page rather than as a mistake.
   ══════════════════════════════════════════════════════════════════ */

.section + .section:not(.mode-ink) { padding-top: calc(var(--section-y) * 0.4); }
.mode-ink + .section { padding-top: var(--section-y); }

/* ── header avatar ────────────────────────────────────────────────
   A real face in the header, on every page. Rendered at 34px from a
   100px source, which stays sharp on a 2x display; the hairline ring
   keeps it from floating on the paper background. */

.rail__avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center top;
  flex: none;
  box-shadow: 0 0 0 var(--hair) var(--line-quiet);
  filter: saturate(0.9);
}

@media (max-width: 600px) {
  .rail__avatar { width: 30px; height: 30px; }
}
