/* muhammadtayyabshabbir.com v2 · "A Page From His Book"
   Shared stylesheet. Tokens, type, grid, figures, margins, sources, chrome, motion.
   Page-specific CSS goes in its own file, declared in the page front matter (extra_css).
   Read src_v2/DESIGN_NOTES.md before adding classes. */

/* ------------------------------------------------------------------ fonts */
@font-face { font-family: "CMU Serif Display"; src: url("/assets/fonts/cmu-serif-roman.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: optional; }
@font-face { font-family: "CMU Serif"; src: url("/assets/fonts/cmu-serif-roman.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "CMU Serif"; src: url("/assets/fonts/cmu-serif-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
/* CMU text Greek draws θ like ϑ; this one-glyph face (declared after the italic, so it wins for U+03B8) is the closed math theta, slanted to match */
@font-face { font-family: "CMU Serif"; src: url("/assets/fonts/cmu-serif-theta.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; unicode-range: U+03B8; }
@font-face { font-family: "IBM Plex Sans"; src: url("/assets/fonts/plex-sans-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("/assets/fonts/plex-sans-600.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("/assets/fonts/plex-mono-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
/* Metric-matched fallbacks (computed with fontTools against the subset files) so swaps do not shift layout */
@font-face { font-family: "CMU Fallback"; src: local("Times New Roman"), local("TimesNewRomanPSMT"), local("Liberation Serif"); size-adjust: 109.57%; ascent-override: 85.34%; descent-override: 22.82%; line-gap-override: 0%; }
@font-face { font-family: "Plex Sans Fallback"; src: local("Arial"), local("ArialMT"), local("Liberation Sans"); size-adjust: 100.19%; ascent-override: 102.31%; descent-override: 27.45%; line-gap-override: 0%; }
@font-face { font-family: "Plex Sans Fallback"; src: local("Arial Bold"), local("Arial-BoldMT"), local("Liberation Sans Bold"); font-weight: 600; size-adjust: 96.82%; ascent-override: 105.86%; descent-override: 28.40%; line-gap-override: 0%; }
@font-face { font-family: "Plex Mono Fallback"; src: local("Courier New"), local("CourierNewPSMT"), local("Liberation Mono"); size-adjust: 99.98%; ascent-override: 102.52%; descent-override: 27.50%; line-gap-override: 0%; }

/* ----------------------------------------------------------------- tokens */
:root {
  /* palette (REPORT.md section 3, contrast computed for every pair) */
  --paper: #F4EFE6;
  --paper-deep: #EAE2D4;
  --ink: #1A1814;
  --ink-mute: #5E574C;
  --green: #163A75;
  --green-text: #1F4A8F;
  --night: #0F1218;
  --night-deep: #161A22;
  --night-ink: #E9E4DA;
  --night-mute: #A39A8C;
  --night-green: #9DBDF2;

  /* semantic roles: use these in components, never the raw palette */
  --bg: var(--paper);
  --bg-alt: var(--paper-deep);
  --fg: var(--ink);
  --fg-mute: var(--ink-mute);
  --link: var(--green-text);
  --rule: var(--ink);
  --rule-soft: color-mix(in srgb, var(--ink) 22%, transparent);
  --btn-bg: var(--green);
  --btn-fg: var(--paper);
  --mark-bg: color-mix(in srgb, var(--green-text) 12%, transparent);
  color-scheme: light;

  /* type */
  --font-display: "CMU Serif Display", "CMU Serif", "CMU Fallback", "Latin Modern Roman", Georgia, serif;
  --font-serif: "CMU Serif", "CMU Fallback", "Latin Modern Roman", Georgia, serif;
  --font-sans: "IBM Plex Sans", "Plex Sans Fallback", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", "Plex Mono Fallback", ui-monospace, Menlo, Consolas, monospace;
  /* the fixed scale: 13 / 15 / 18 / 40 / 176. Nothing sits between 40 and 176. */
  --fs-label: 13px;
  --fs-caption: 15px;
  --fs-body: 18px;
  --fs-head: 40px;
  --fs-display: clamp(56px, 12.2vw, 176px);
  --lh-body: 1.6;

  /* layout */
  --gutter: 20px;
  --measure: 680px;
  --margin-col: 240px;
  --margin-gap: 48px;
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 40px;
  --space-5: 64px;
  --space-6: 104px;

  /* motion: equation 2, settle. x(t) = 1 - (1 + wt) e^(-wt), w = 7, sampled as linear() */
  --ease-settle: linear(0, 0.049 5%, 0.156 10%, 0.283 15%, 0.408 20%, 0.522 25%, 0.620 30%, 0.702 35%, 0.769 40%, 0.822 45%, 0.864 50%, 0.897 55%, 0.922 60%, 0.941 65%, 0.956 70%, 0.967 75%, 0.976 80%, 0.982 85%, 0.987 90%, 0.993 95%, 1 100%);
  --dur-settle: 420ms;
  /* equation 1, draw. s(t) = L (1 - t / T): constant pen speed, so the easing is linear */
  --dur-draw: 750ms;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: var(--night);
    --bg-alt: var(--night-deep);
    --fg: var(--night-ink);
    --fg-mute: var(--night-mute);
    --link: var(--night-green);
    --rule: var(--night-ink);
    --rule-soft: color-mix(in srgb, var(--night-ink) 22%, transparent);
    --btn-bg: var(--night-green);
    --btn-fg: var(--night);
    --mark-bg: color-mix(in srgb, var(--night-green) 14%, transparent);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: var(--night);
  --bg-alt: var(--night-deep);
  --fg: var(--night-ink);
  --fg-mute: var(--night-mute);
  --link: var(--night-green);
  --rule: var(--night-ink);
  --rule-soft: color-mix(in srgb, var(--night-ink) 22%, transparent);
  --btn-bg: var(--night-green);
  --btn-fg: var(--night);
  --mark-bg: color-mix(in srgb, var(--night-green) 14%, transparent);
  color-scheme: dark;
}

/* Forced bands (Phase 3 night chapter). .band--night is night in light mode and paper in dark mode. */
.band--night, .band--green {
  --bg: var(--night); --bg-alt: var(--night-deep); --fg: var(--night-ink); --fg-mute: var(--night-mute);
  --link: var(--night-green); --rule: var(--night-ink); --rule-soft: color-mix(in srgb, var(--night-ink) 22%, transparent);
  --btn-bg: var(--night-green); --btn-fg: var(--night);
}
.band--green { --bg: var(--green); --bg-alt: var(--green); --fg: var(--paper); --fg-mute: #D6D0C4; --link: var(--paper); --btn-bg: var(--paper); --btn-fg: var(--green); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .band--night {
    --bg: var(--paper); --bg-alt: var(--paper-deep); --fg: var(--ink); --fg-mute: var(--ink-mute);
    --link: var(--green-text); --rule: var(--ink); --rule-soft: color-mix(in srgb, var(--ink) 22%, transparent);
    --btn-bg: var(--green); --btn-fg: var(--paper);
  }
}
:root[data-theme="dark"] .band--night {
  --bg: var(--paper); --bg-alt: var(--paper-deep); --fg: var(--ink); --fg-mute: var(--ink-mute);
  --link: var(--green-text); --rule: var(--ink); --rule-soft: color-mix(in srgb, var(--ink) 22%, transparent);
  --btn-bg: var(--green); --btn-fg: var(--paper);
}

/* ------------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}
.band, .band--night, .band--green, .band--alt { background: var(--bg); color: var(--fg); }
.band--alt { background: var(--bg-alt); }
img, svg, video { max-width: 100%; height: auto; }
img { display: block; }
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
p, ul, ol, dl, blockquote, figure { margin: 0 0 var(--space-3); }
ul, ol { padding-left: 1.2em; }
hr { border: 0; border-top: 1px solid var(--rule-soft); margin: var(--space-4) 0; }
strong, b { font-weight: 600; }
abbr[title] { text-decoration: none; }
::selection { background: var(--green); color: var(--paper); }

/* ------------------------------------------------------------- type scale */
h1, h2, h3, h4 { margin: 0 0 var(--space-3); font-weight: 400; color: var(--fg); }
h1, .display {
  font-family: var(--font-display);
  font-size: var(--fs-display);
  line-height: 0.86;
  letter-spacing: -0.025em;
  text-wrap: balance;
  overflow-wrap: normal; word-break: normal; hyphens: manual;
}
.grid > h1 { grid-column: wide; }
h1.h1--head { font-family: var(--font-serif); font-size: var(--fs-head); line-height: 1.15; letter-spacing: -0.005em; }
/* Inner-page opener: a one-word chapter title at display size, then the descriptive line at 40px */
h1.page-title { margin: 0 0 var(--space-3); }
.page-sub { grid-column: main; font-family: var(--font-serif); font-size: var(--fs-head); line-height: 1.15; letter-spacing: -0.005em; text-wrap: balance; margin: 0 0 var(--space-4); color: var(--fg); }
@media (min-width: 768px) { h1.page-title { margin-bottom: var(--space-4); } }
h2, .head {
  font-family: var(--font-serif);
  font-size: var(--fs-head);
  line-height: 1.15;
  letter-spacing: -0.005em;
  font-variant-numeric: lining-nums tabular-nums;
  text-wrap: balance;
}
h3, .subhead { font-family: var(--font-sans); font-size: var(--fs-body); line-height: 1.4; font-weight: 600; text-wrap: balance; }
h4, .label {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  line-height: 1.4;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.caption, figcaption, small { font-size: var(--fs-caption); line-height: 1.5; color: var(--fg-mute); }
.mute { color: var(--fg-mute); }
.num { font-family: var(--font-serif); font-size: var(--fs-head); line-height: 1; font-variant-numeric: lining-nums tabular-nums; }
.tnum { font-variant-numeric: tabular-nums; }
.lede { font-size: var(--fs-body); max-width: 36em; }
/* Equations: upright by default (numerals, brackets, operators); variables in <var> are italic, as in the book.
   Accents: <var class="dot">θ</var> and <var class="ddot">θ</var> for θ̇ and θ̈ (combining marks sit badly in CMU). */
.eq { font-family: var(--font-serif); font-style: normal; white-space: nowrap; font-size: 1.08em; font-variant-numeric: lining-nums; }
.eq var { font-style: italic; }
.eq .dot, .eq .ddot { position: relative; display: inline-block; }
.eq .dot::after, .eq .ddot::after { position: absolute; left: 0; right: 0; top: -0.13em; text-align: center; font-style: normal; line-height: 1; padding-left: 0.12em; }
.eq .dot::after { content: "\02D9"; }
.eq .ddot::after { content: "\00A8"; }
h2 .anchor { font-family: var(--font-mono); font-size: var(--fs-label); margin-left: 0.6em; color: var(--fg-mute); text-decoration: none; vertical-align: middle; }
h2 .anchor:hover, h2 .anchor:focus-visible { color: var(--link); }

/* -------------------------------------------------------------- the grid
   Every section is a .grid. Children sit in the main column by default.
   Desktop (>= 1100px): [gutter][main 680][gap 48][margin 240][gutter], centred.
   Narrower: the margin column collapses into the main column. */
.grid {
  display: grid;
  grid-template-columns:
    [full-start] minmax(var(--gutter), 1fr)
    [main-start wide-start] minmax(0, var(--measure))
    [main-end] 0 [margin-start] 0 [margin-end wide-end]
    minmax(var(--gutter), 1fr) [full-end];
}
.grid > * { grid-column: main; min-width: 0; }
.grid > .wide { grid-column: wide; }
.grid > .full { grid-column: full; }
.grid > .margin { grid-column: main; }
@media (min-width: 1100px) {
  .grid {
    grid-template-columns:
      [full-start] minmax(var(--gutter), 1fr)
      [main-start wide-start] minmax(0, var(--measure))
      [main-end] var(--margin-gap) [margin-start] var(--margin-col) [margin-end wide-end]
      minmax(var(--gutter), 1fr) [full-end];
  }
  .grid > .margin { grid-column: margin; align-self: start; }
}
.section { padding-block: var(--space-5); }
.section + .section { border-top: 1px solid var(--rule-soft); }
@media (min-width: 768px) { .section { padding-block: var(--space-6); } }
.stack > * + * { margin-top: var(--space-3); }
.cols-2 { display: grid; gap: var(--space-4); }
@media (min-width: 768px) { .cols-2 { grid-template-columns: 1fr 1fr; } }
/* keep a number with its unit, or a last word with its source marker */
.nw { white-space: nowrap; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ----------------------------------------------------------- running heads
   A running head sits at the top of each section, as in a printed book. */
.running-head {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 0.9em;
  margin: 0 0 var(--space-4);
  padding-bottom: var(--space-1);
  border-bottom: 1px solid var(--rule);
  font-family: var(--font-mono); font-size: var(--fs-label); line-height: 1.6;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-mute);
}
.running-head > span + span::before { content: "·"; margin-right: 0.9em; }
.running-head .rh-end { margin-left: auto; }
.running-head .rh-end::before { content: none; }

/* --------------------------------------------------------------- skip link */
.skip {
  position: absolute; left: var(--gutter); top: -100px; z-index: 100;
  padding: 10px 16px; background: var(--btn-bg); color: var(--btn-fg);
  font-family: var(--font-sans); font-size: var(--fs-caption); font-weight: 600; text-decoration: none;
}
.skip:focus { top: 12px; }

/* ------------------------------------------------------------------- focus */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 3px; border-radius: 1px; }
.btn:focus-visible { outline-offset: 4px; }

/* ----------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5em;
  min-height: 44px; padding: 10px 20px;
  border: 1px solid var(--btn-bg); border-radius: 0;
  background: var(--btn-bg); color: var(--btn-fg);
  font: 600 var(--fs-caption)/1.2 var(--font-sans);
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { text-decoration: none; filter: brightness(1.12); }
.btn--quiet { background: transparent; color: var(--fg); border-color: var(--rule); }
.btn--quiet:hover { background: var(--bg-alt); filter: none; }
.btn--small { min-height: 36px; padding: 6px 14px; font-size: var(--fs-label); }
.textbtn {
  appearance: none; border: 0; background: none; padding: 0; margin: 0; cursor: pointer;
  font: inherit; color: var(--link); text-decoration: underline; text-underline-offset: 0.18em; text-decoration-thickness: 1px;
}
.more { font-weight: 600; }
.more::after { content: " →"; }

/* --------------------------------------------------------------- masthead
   DOM order: wordmark, nav, CTA, running head, sources toggle (focus order matches the visual order).
   Phones: wordmark on one line; nav row; CTA row with "Show sources" at its right end; no running head below 600px.
   From 1100px: wordmark | nav | CTA on one row, running head below with the toggle at its right end.
   (Not from 900px: below 1100px the row is only 680px wide and needs about 830px, so the nav ran over the wordmark.) */
.masthead { padding-top: var(--space-3); }
.masthead-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--space-1) var(--space-3);
}
.wordmark {
  grid-column: 1 / -1; grid-row: 1; justify-self: start;
  display: inline-block; color: var(--fg); text-decoration: none;
  font-family: var(--font-display); font-size: 20px; line-height: 1.1; letter-spacing: -0.005em;
  white-space: nowrap;
}
.wordmark:hover { text-decoration: none; }
.wordmark .wordmark-svg { background-color: var(--link); }
/* Drop-in logo: an SVG used as a mask takes currentColor, so one file works in light and dark. */
.wordmark-svg {
  display: block; height: 40px; aspect-ratio: var(--wordmark-ratio, 3.92);
  background: currentColor;
  -webkit-mask: url("/assets/wordmark.png") left center / contain no-repeat;
  mask: url("/assets/wordmark.png") left center / contain no-repeat;
}
.nav { grid-column: 1 / -1; grid-row: 2; }
.nav ul { list-style: none; margin: 0; padding: 0; display: flex; justify-content: space-between; gap: var(--space-2); }
.nav a {
  display: inline-block; padding: 10px 0; color: var(--fg); text-decoration: none;
  font-size: var(--fs-caption); line-height: 1.2; white-space: nowrap;
}
.nav a:hover { text-decoration: underline; }
.nav a[aria-current="page"] { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 0.3em; }
.masthead-cta { grid-column: 1; grid-row: 3; justify-self: start; }
.masthead .running-head { grid-column: 1 / -1; grid-row: 4; margin: var(--space-1) 0 0; }
.rh-toggle { grid-column: 2; grid-row: 3; justify-self: end; margin: 0; font-family: var(--font-mono); font-size: var(--fs-label); line-height: 1.6; letter-spacing: 0.08em; text-transform: uppercase; }
@media (max-width: 599px) {
  .masthead .running-head { display: none; }
}
@media (min-width: 600px) {
  .rh-toggle { grid-row: 4; align-self: end; margin-bottom: var(--space-1); }
  .rh-toggle .show-sources-btn { padding: 0; min-height: 0; }
}
@media (min-width: 1100px) {
  .masthead-row { grid-template-columns: auto minmax(0, 1fr) auto; row-gap: var(--space-2); }
  .wordmark { font-size: 24px; grid-column: 1; grid-row: 1; }
  .nav { grid-column: 2; grid-row: 1; justify-self: end; }
  .masthead-cta { grid-column: 3; grid-row: 1; justify-self: end; }
  .masthead .running-head { grid-row: 2; margin: 0; }
  .rh-toggle { grid-column: 3; grid-row: 2; }
  .nav ul { justify-content: flex-end; gap: var(--space-4); }
}

/* "Show sources" control at the right end of the masthead running head. Hidden without JS. */
.show-sources-btn {
  appearance: none; background: none; border: 0; padding: 4px 0; cursor: pointer; min-height: 36px;
  font: inherit; letter-spacing: inherit; text-transform: inherit; color: var(--link);
}
.show-sources-btn[aria-pressed="true"]::before { content: "● "; }
.show-sources-btn[aria-pressed="false"]::before { content: "○ "; }

/* ---------------------------------------------------------------- figures
   Every image is a numbered figure with an exact caption. */
.fig { margin: 0 0 var(--space-4); }
.fig-frame { position: relative; border: 1px solid var(--rule); padding: 10px; background: var(--bg); }
.fig-frame > img, .fig-frame > svg, .fig-frame > picture img { width: 100%; height: auto; }
.fig-frame--bare { border: 0; padding: 0; }
.fig figcaption { margin-top: var(--space-2); max-width: 36em; }
.fig-num {
  font-family: var(--font-mono); font-size: var(--fs-label); letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--fg); margin-right: 0.5em; white-space: nowrap;
}
/* Typeset figure (no photograph exists): e.g. the book's title page, the PTV poster */
.fig-type {
  display: grid; place-content: center; text-align: center; gap: var(--space-2);
  aspect-ratio: 3 / 4; padding: var(--space-4) var(--space-3);
  background: var(--paper); color: var(--ink); border: 1px solid var(--ink);
  font-family: var(--font-serif);
}
.fig-type--green { background: var(--green); color: var(--paper); border-color: var(--green); }

/* ------------------------------------------------------ margin notes (dates)
   Use inside a .grid as a .margin child, or float one inside a paragraph with .mnote. */
.mnote, .margin-note {
  display: block; font-size: var(--fs-caption); line-height: 1.5; color: var(--fg-mute);
  border-top: 1px solid var(--rule-soft); padding-top: var(--space-1); margin: var(--space-2) 0;
}
.mnote .label, .margin-note .label, .mnote-date { display: block; color: var(--fg); margin-bottom: 2px; font-family: var(--font-mono); font-size: var(--fs-label); letter-spacing: 0.08em; text-transform: uppercase; }

/* ----------------------------------------------------- sources: the layer
   Marker:  <sup class="src">  holds a plain link (fallback) and a popover button.
   Note:    <span class="sidenote" id="src-N" popover>  directly after the marker.
   Desktop: the note floats into the margin column, always visible.
   Narrow:  the button opens the note as a bottom sheet (native popover, no JS).
   No popover support: the plain link to /press#fact-N is shown instead. */
.src { font-size: 0.7em; line-height: 0; vertical-align: super; margin-left: 0.1em; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.src a, .src button {
  display: inline-block; min-width: 1.6em; padding: 0 0.25em; color: var(--link); text-decoration: none;
  font: inherit; line-height: 1.4; border: 0; background: none; cursor: pointer; border-radius: 2px;
}
.src a:hover, .src button:hover { background: var(--mark-bg); }
.src .src-link { display: none; }
.src .src-btn { display: inline-block; }
@supports not selector(:popover-open) {
  .src .src-link { display: inline-block; }
  .src .src-btn { display: none; }
}
.sidenote {
  font-family: var(--font-sans); font-size: var(--fs-caption); line-height: 1.5; font-weight: 400;
  color: var(--fg-mute); font-style: normal; text-align: left; letter-spacing: 0;
}
.sidenote .sn-num { font-family: var(--font-mono); font-size: var(--fs-label); color: var(--link); margin-right: 0.4em; }
.sidenote a { color: var(--link); overflow-wrap: anywhere; }
.sidenote .sn-close { display: none; }
/* narrow screens: native popover bottom sheet */
.sidenote:popover-open {
  position: fixed; inset: auto 0 0 0; margin: 0; width: 100%; max-width: none; max-height: 70svh; overflow: auto;
  padding: var(--space-3) var(--gutter) calc(var(--space-3) + env(safe-area-inset-bottom));
  background: var(--bg); color: var(--fg); border: 0; border-top: 1px solid var(--rule);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.18);
}
.sidenote:popover-open .sn-close { display: flex; width: fit-content; margin-top: var(--space-2); }
.sidenote::backdrop { background: rgba(15, 18, 24, 0.35); }
/* Show sources (mobile): every note expands inline under its paragraph */
html.show-sources .sidenote:not(:popover-open) {
  display: block; margin: var(--space-1) 0 var(--space-2); padding: var(--space-1) var(--space-2);
  border-left: 2px solid var(--link); background: var(--mark-bg);
  position: static; inset: auto; width: auto; height: auto; overflow: visible; color: var(--fg); border-top: 0; border-right: 0; border-bottom: 0;
}
html.show-sources .src a, html.show-sources .src button { background: var(--mark-bg); }
/* desktop: Tufte sidenotes in the margin column */
@media (min-width: 1100px) {
  .src .src-btn { display: none; }
  .src .src-link { display: inline-block; }
  .sidenote, .sidenote:popover-open, html.show-sources .sidenote:not(:popover-open) {
    display: block; position: relative; inset: auto; overflow: visible; height: auto; max-height: none; box-shadow: none;
    float: right; clear: right;
    width: var(--margin-col);
    margin: 0.3em calc(-1 * (var(--margin-col) + var(--margin-gap))) var(--space-2) 0;
    padding: var(--space-1) 0 0; border: 0; border-top: 1px solid var(--rule-soft); background: none;
    color: var(--fg-mute);
  }
  .sidenote .sn-close { display: none !important; }
  html.show-sources .sidenote, html.show-sources .sidenote:not(:popover-open) {
    color: var(--fg); border-top: 2px solid var(--link); background: var(--mark-bg); padding: var(--space-1);
  }
  /* margin notes floated from inside running text */
  .mnote--float {
    float: right; clear: right; width: var(--margin-col);
    margin: 0.3em calc(-1 * (var(--margin-col) + var(--margin-gap))) var(--space-2) 0;
  }
}

/* .src-inline: for sources inside multi-column layouts (strips, cards) with no margin column beside each claim.
   At every width the number opens the note as a sheet and "Show sources" expands it in place. */
@media (min-width: 1100px) {
  .src-inline .src .src-btn { display: inline-block; }
  .src-inline .src .src-link { display: none; }
  .src-inline .sidenote:not(:popover-open) { display: none; float: none; width: auto; margin: 0; }
  .src-inline .sidenote:popover-open {
    position: fixed; inset: auto 0 0 0; float: none; margin: 0 auto; width: 100%; max-width: 720px;
    padding: var(--space-3); background: var(--bg); color: var(--fg);
    border: 1px solid var(--rule); border-bottom: 0; box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.18);
  }
  .src-inline .sidenote:popover-open .sn-close { display: flex !important; width: fit-content; margin-top: var(--space-2); }
  html.show-sources .src-inline .sidenote:not(:popover-open) {
    display: block; float: none; width: auto; margin: var(--space-1) 0 0; padding: var(--space-1);
    border-top: 2px solid var(--link); background: var(--mark-bg); color: var(--fg);
  }
}
@supports not selector(:popover-open) {
  .src-inline .src .src-link { display: inline-block; }
  .src-inline .src .src-btn { display: none; }
}

/* -------------------------------------------------------------- popovers (general) */
[popover].sheet:popover-open {
  position: fixed; inset: auto 0 0 0; margin: 0; width: 100%; max-height: 80svh; overflow: auto;
  padding: var(--space-3) var(--gutter); background: var(--bg); color: var(--fg);
  border: 0; border-top: 1px solid var(--rule);
}

/* ----------------------------------------------------------------- footer */
.site-footer { margin-top: 0; padding-top: var(--space-5); border-top: 1px solid var(--rule); background: var(--bg); color: var(--fg); overflow: hidden; }
.site-footer .label { color: var(--fg-mute); margin-bottom: var(--space-2); }
.routes { list-style: none; margin: 0 0 var(--space-5); padding: 0; display: grid; gap: var(--space-4); }
.routes li { border-top: 1px solid var(--rule-soft); padding-top: var(--space-2); }
.routes h3 { margin-bottom: var(--space-1); }
.routes p { margin: 0 0 var(--space-1); font-size: var(--fs-caption); color: var(--fg-mute); }
@media (min-width: 768px) { .routes { grid-template-columns: repeat(3, 1fr); gap: var(--space-4); } }
.footer-links { display: grid; gap: var(--space-4); margin-bottom: var(--space-5); }
.footer-links ul { list-style: none; margin: 0; padding: 0; }
.footer-links li { margin: 0 0 6px; font-size: var(--fs-caption); }
.footer-links a { color: var(--fg); }
@media (min-width: 768px) { .footer-links { grid-template-columns: repeat(4, 1fr); } }
.colophon { font-size: var(--fs-caption); line-height: 1.6; color: var(--fg-mute); max-width: 44em; }
.colophon ol { list-style: none; padding: 0; margin: var(--space-1) 0 var(--space-2); }
.colophon li { margin: 0 0 4px; }
.colophon .eq { color: var(--fg); }
.legal { font-size: var(--fs-label); line-height: 1.6; color: var(--fg-mute); margin: var(--space-3) 0 0; }
.legal p { margin: 0 0 4px; }
/* fitted wordmark: CMU advance for the 23 characters is 12.63 em, kerned in Chrome it measures 12.25 em, so 100cqi / 12.3 fills the row */
.footer-fit { container-type: inline-size; margin-top: var(--space-4); padding-inline: var(--gutter); margin-bottom: var(--space-3); }
.footer-wordmark {
  display: block; margin: 0; padding: 0 0 0.04em; white-space: nowrap; overflow: clip;
  font-family: var(--font-display); font-weight: 400; color: var(--fg);
  font-size: calc(100vw / 14); line-height: 1; letter-spacing: -0.01em; padding-bottom: 0.22em;
  user-select: none;
}
@supports (font-size: 1cqi) { .footer-wordmark { font-size: calc(100cqi / 12.3); } }

/* ------------------------------------------------------------- slots (pending assets) */
.slot-empty { display: none; }

/* ------------------------------------------------------------------ motion
   Equation 1 (draw): stroke-dashoffset with pathLength="1", linear, 750 ms.
   Equation 2 (settle): var(--ease-settle).
   Equation 3 (swing): I θ̈ = τ − c θ̇, integrated in JS; CSS only applies --theta.
   Content is complete by default. Undrawn states exist only under html.js-motion,
   which the head script sets only when reduced motion is not requested. */
.draw path, .draw line, .draw polyline, .draw rect, .draw circle { stroke-dasharray: 1; stroke-dashoffset: 0; }
.door-leaf { transform-origin: left center; transform: rotateY(calc(var(--theta, 0) * 1deg)); will-change: transform; } /* positive: a push swings the leaf away from the viewer */

@media (prefers-reduced-motion: no-preference) {
  html.js-motion .draw:not(.is-in) path,
  html.js-motion .draw:not(.is-in) line,
  html.js-motion .draw:not(.is-in) polyline,
  html.js-motion .draw:not(.is-in) rect,
  html.js-motion .draw:not(.is-in) circle { stroke-dashoffset: 1; }
  html.js-motion .draw path, html.js-motion .draw line, html.js-motion .draw polyline,
  html.js-motion .draw rect, html.js-motion .draw circle {
    transition: stroke-dashoffset var(--dur-draw) linear;
    transition-delay: calc(var(--i, 0) * 120ms);
  }
  .btn, .src a, .src button, .show-sources-btn, .textbtn {
    transition: transform var(--dur-settle) var(--ease-settle), background-color var(--dur-settle) var(--ease-settle), filter 200ms linear;
  }
  .btn:active, .src button:active { transform: translateY(1px) scale(0.98); }
  :focus-visible { transition: outline-offset var(--dur-settle) var(--ease-settle); }
  .sidenote:popover-open { animation: settle-up var(--dur-settle) var(--ease-settle); }
  html.show-sources .sidenote { animation: settle-in var(--dur-settle) var(--ease-settle); }
  @keyframes settle-up { from { transform: translateY(24px); } to { transform: none; } }
  @keyframes settle-in { from { transform: translateX(8px); } to { transform: none; } }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ------------------------------------------------------------------ print */
@media print {
  .masthead nav, .show-sources-btn, .src-btn, .skip, .footer-fit { display: none !important; }
  .sidenote { display: inline !important; position: static !important; float: none !important; margin: 0 !important; width: auto !important; }
  .sidenote::before { content: " ["; } .sidenote::after { content: "]"; }
  body { background: #fff; color: #000; }
}

/* Section running heads on phones: the masthead already carries the name, so drop it to keep one line */
@media (max-width: 599px) {
  .main .running-head > span:first-child { display: none; }
  .main .running-head > span:nth-child(2)::before { content: none; }
}

/* light/dark switch beside the running head (mirrors the Show sources toggle) */
.rh-toggle .show-sources-btn + .theme-btn { margin-left: 1.5em; }
.theme-btn { font-family: var(--font-mono); font-size: var(--fs-label); letter-spacing: 0.08em; text-transform: uppercase; background: none; border: 0; padding: 4px 0; color: var(--link); cursor: pointer; }
.theme-btn:focus-visible { outline: 2px solid var(--link); outline-offset: 3px; }
.book-cover { display: block; width: 100%; height: auto; box-shadow: 0 1px 0 var(--rule), 0 10px 24px rgba(0,0,0,0.18); }
