/* base.css — reset, font faces, type scale, baseline grid. */

/* ── Faces ────────────────────────────────────────────────────────────
   Self-hosted, latin-subsetted. Source Serif 4 keeps its wght axis
   (300–700); its opsz axis is pinned at the text optical size, which
   costs 64 KB less and is the correct choice anyway — a controlled
   document sets its title in the text face, not a display cut. */
@font-face {
  font-family: "Source Serif 4";
  src: url("../fonts/source-serif-4-var.woff2") format("woff2-variations");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Commit Mono";
  src: url("../fonts/commit-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Commit Mono";
  src: url("../fonts/commit-mono-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ── Reset ────────────────────────────────────────────────────────────*/
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-block-start: var(--space-8);
  background: var(--paper);
  color-scheme: dark;
}
[data-mode="paper"] { color-scheme: light; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--t-base);
  line-height: var(--lh-body);
  font-synthesis-weight: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img { max-width: 100%; display: block; }
a { color: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
ul, ol { list-style: none; }
table { border-collapse: collapse; width: 100%; }

::selection { background: var(--ink); color: var(--paper); }

/* Focus is never removed, only styled. Offset so it clears hairlines. */
:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
  border-radius: 1px;
}

/* ── Tabular figures ──────────────────────────────────────────────────
   CLAUDE.md §5: the single property that does most for the conceit.
   Applied to every element that can contain a numeral. */
.mono, .num, table, time, dd, .chip, .rail, .doc-foot, .toc, code, kbd {
  font-variant-numeric: tabular-nums;
}

/* ── Type scale ───────────────────────────────────────────────────────
   Font sizes on the 1.2 ratio; line-heights and margins on the 8px grid. */
.mono {
  font-family: var(--font-mono);
  font-variant-ligatures: none;
}

h1, h2, h3, h4 {
  font-weight: 600;
  line-height: var(--lh-tight);
  text-wrap: balance;
}

h1 {
  font-size: clamp(var(--t-2xl), 7vw, var(--t-3xl));
  letter-spacing: var(--track-tight);
  line-height: var(--lh-flat);
}

h2 {
  font-size: var(--t-xl);
  letter-spacing: var(--track-tight);
}

h3 {
  font-size: var(--t-l);
  letter-spacing: var(--track-normal);
}

p {
  max-inline-size: var(--measure);
  margin-block-end: var(--space-3);
}
p:last-child { margin-block-end: 0; }

strong { font-weight: 600; color: var(--ink); }

/* The uppercase mono label — the most repeated element in the document.
   Wide tracking is what makes it read as a stamped field name. */
.label {
  font-family: var(--font-mono);
  font-size: var(--t-2xs);
  font-weight: 400;
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.skip {
  position: absolute;
  inset-block-start: -100%;
  inset-inline-start: var(--space-2);
  z-index: var(--z-skip);
  background: var(--ink);
  color: var(--paper);
  padding: var(--space-1) var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--t-2xs);
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
  text-decoration: none;
}
.skip:focus { inset-block-start: var(--space-2); }

/* ── Motion ───────────────────────────────────────────────────────────
   The entire budget is one stamp-in on RECEIVED at load.

   This is the one place !important is used, against CLAUDE.md §6. A
   reduced-motion override has to beat every later declaration including
   ones added in future; without it the guarantee is only as good as the
   next stylesheet edit. Documented rather than silently taken. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}
