/* base.css — reset, document typography, generated paper texture, and the interaction
   primitives (selection, scrollbar, focus rings). Everything a page inherits before it
   places a single element. */

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

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  color-scheme: light;
  /* Lenis owns smooth scrolling; no CSS smooth-scroll to fight it. Anchor jumps still
     clear the sticky header. */
  scroll-padding-top: calc(var(--header-scrolled) + 16px);
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-serif);
  font-weight: 430;
  font-size: var(--t-body);
  line-height: 1.62;
  font-optical-sizing: auto;
  font-feature-settings: "kern" 1, "liga" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  position: relative;
  min-height: 100vh;
  overflow-x: hidden;
}

@media (max-width: 480px) {
  body { font-size: 1.0625rem; }
}

/* ---- Generated paper texture: fine grain + coarse blotch + warmth vignette.
   Fixed, pointer-transparent, sits above prose (film-over-everything) but below the
   header/nav so chrome stays crisp. Kept faint enough not to touch AA. ---- */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='g'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='240' height='240' filter='url(%23g)'/></svg>");
  background-size: 240px 240px;
  opacity: 0.035;
  mix-blend-mode: multiply;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  background-image:
    radial-gradient(120% 90% at 50% 40%, transparent 55%, color-mix(in srgb, var(--ink-2) 6%, transparent) 100%),
    url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='600' height='600'><filter id='b'><feTurbulence type='fractalNoise' baseFrequency='0.012' numOctaves='2' stitchTiles='stitch'/></filter><rect width='600' height='600' filter='url(%23b)'/></svg>");
  background-size: 100% 100%, 600px 600px;
  opacity: 0.02;
  mix-blend-mode: multiply;
}

/* ---- Headings: Fraunces, optical sizing tracks render size. SOFT/WONK zeroed except the
   one deliberate hero exception (see components). ---- */
h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  color: var(--ink);
  text-wrap: balance;
}

/* Default H1 (page titles on /work, /book); the hero H1 and 404 title override via class. */
h1 {
  font-size: var(--t-h2);
  line-height: 1.04;
  letter-spacing: -0.012em;
  font-variation-settings: "wght" 400, "SOFT" 0, "WONK" 0;
}
h2 {
  font-size: var(--t-h2);
  line-height: 1.04;
  letter-spacing: -0.012em;
  font-variation-settings: "wght" 380, "SOFT" 0, "WONK" 0;
}
h3 {
  font-size: var(--t-h3);
  line-height: 1.12;
  letter-spacing: -0.004em;
  font-variation-settings: "wght" 460, "SOFT" 0, "WONK" 0;
}

p { margin: 0; }
p + p { margin-top: 1.05em; }

strong, b { font-weight: 500; }
em, i { font-style: italic; }

/* ---- Links: credit green, generous underline offset, mechanical hover ---- */
a {
  color: var(--green);
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
  text-decoration-color: var(--rule-strong);
  transition: color var(--d-xs) var(--ease-settle),
              text-decoration-color var(--d-xs) var(--ease-settle);
}
a:hover { color: var(--green-deep); text-decoration-color: var(--green-deep); }

/* ---- Figure: every numeral in the running sums. Tabular lining mandatory: anything that
   counts must not jitter. ---- */
.figure {
  font-family: var(--font-mono);
  font-feature-settings: "tnum" 1, "lnum" 1;
  font-variant-numeric: tabular-nums lining-nums;
  font-size: var(--t-figure);
}
/* Figures are copyable to the character (a sceptic can select and check the sum). */
.figure, [data-select] { -webkit-user-select: all; user-select: all; }

/* ---- Meta label: mono, uppercase, tracked ---- */
.meta {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--t-meta);
  line-height: 1.1;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-feature-settings: "tnum" 1, "lnum" 1;
}

/* ---- Lists reset to ledger defaults ---- */
ul, ol { margin: 0; padding: 0; list-style: none; }

img, svg, iframe { max-width: 100%; }
iframe { border: 0; }

/* ---- Selection: highlighter smear ---- */
::selection { background: var(--marker-swipe); color: var(--ink); }
.on-green ::selection, .panel ::selection { background: var(--paper); color: var(--green-deep); }

/* ---- Scrollbar: thin, square, green thumb on paper track ---- */
* { scrollbar-width: thin; scrollbar-color: var(--green) var(--paper); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--paper); }
::-webkit-scrollbar-thumb { background: var(--green); border-radius: 0; border: 2px solid var(--paper); }
::-webkit-scrollbar-thumb:hover { background: var(--green-deep); }

/* ---- Focus: ink outline + marker halo on everything interactive ---- */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
  box-shadow: 0 0 0 6px var(--marker);
}
.on-green :focus-visible, .panel :focus-visible {
  outline-color: var(--paper);
  box-shadow: 0 0 0 6px var(--marker);
}

/* ---- Skip link: first focusable, becomes a ledger tab when focused ---- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 3000;
  background: var(--ink);
  color: var(--paper);
  padding: 12px 20px;
  font-family: var(--font-mono);
  font-size: var(--t-meta);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  text-decoration: none;
}
.skip-link:focus {
  left: var(--side-pad);
  top: 12px;
}

.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;
}
