/* historyofaudit.com — styles for every page.
 * Look: a page from an old ledger. Cream paper, green ledger rules, a red
 * margin line, and the auditor's red ink for ticks and stamps.
 * Light by default; a "night ledger" dark scheme follows the OS setting.
 * Every animation is off under prefers-reduced-motion. The only JavaScript is
 * consent.js (the cookie banner and the analytics it gates, CLAUDE.md §5b).
 * Pages are generated by build.py: when this file changes, bump V["css"]
 * there and rebuild (CLAUDE.md §5a). */

/* ---- Fonts (self-hosted, latin subset; licences beside the files) -------- */
@font-face {
  font-family: "IM Fell English";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/assets/fonts/fell-normal-latin.woff2?v=1) format("woff2");
}
@font-face {
  font-family: "IM Fell English";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url(/assets/fonts/fell-italic-latin.woff2?v=1) format("woff2");
}
@font-face {
  font-family: "Source Serif 4";
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url(/assets/fonts/source-serif-4-normal-latin.woff2?v=1) format("woff2");
}
@font-face {
  font-family: "Source Serif 4";
  font-style: italic;
  font-weight: 200 900;
  font-display: swap;
  src: url(/assets/fonts/source-serif-4-italic-latin.woff2?v=1) format("woff2");
}
@font-face {
  font-family: "Special Elite";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/assets/fonts/special-elite-latin.woff2?v=1) format("woff2");
}

/* ---- Tokens ------------------------------------------------------------- */
/* WCAG text contrast, measured 2026-10-28, on --paper and on --paper-2 (the
 * boxes). Light: --ink 12.5/11.3, --ink-soft 6.8/6.1, --ink-faint 5.5/5.0,
 * --red 6.3/5.7, --green 6.3/5.7. Dark: --ink 13.6/12.5, --ink-soft 8.5/7.8,
 * --ink-faint 5.8/5.3, --red 5.2/4.8, --green 8.7/8.0. Keep text >= 4.5.
 * --rule, --rule-faint and --margin are decorative only; never use for text. */
:root {
  color-scheme: light dark;
  --paper: #f4ecd8;
  --paper-2: #ece1c6;
  --paper-3: #e4d6b4;
  --ink: #1f2a2e;
  --ink-soft: #4a5257;
  --ink-faint: #595f62;
  --red: #a3241c;
  --green: #2e5e4e;
  --rule: #9fbfb0;
  --rule-faint: #cddbd0;
  --margin: #d27a72;
  --shadow: rgba(70, 48, 12, .14);
  --blend: multiply;

  --display: "IM Fell English", "Iowan Old Style", Georgia, serif;
  --serif: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --type: "Special Elite", "Courier New", ui-monospace, monospace;

  --gutter: max(16px, 4vw);
  --measure: 40rem;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #161b1a;
    --paper-2: #1c2321;
    --paper-3: #24302c;
    --ink: #ece3cc;
    --ink-soft: #bdb5a0;
    --ink-faint: #9b9481;
    --red: #e0675c;
    --green: #8fc2ad;
    --rule: #3a5a4e;
    --rule-faint: #24342f;
    --margin: #7a3530;
    --shadow: rgba(0, 0, 0, .4);
    --blend: screen;
  }
}

/* ---- Base --------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--paper);
  /* paper grain: a static SVG noise tile, very faint */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .25 0 0 0 0 .1 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
  color: var(--ink);
  font: 400 1.0625rem/1.65 var(--serif);
  font-optical-sizing: auto;
  overflow-x: clip;
}
/* the ledger's red double margin line, desktop only */
body::before {
  content: "";
  position: fixed;
  inset: 0 auto 0 clamp(14px, 3.2vw, 56px);
  width: 7px;
  border-inline: 2px solid var(--margin);
  opacity: .55;
  pointer-events: none;
}
@media (max-width: 720px) { body::before { display: none; } }

a { color: var(--green); text-decoration-thickness: 1px; text-underline-offset: .18em; }
a:hover { color: var(--red); }
:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; border-radius: 2px; }
abbr[title] { text-decoration: underline dotted; text-underline-offset: .2em; cursor: help; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.wrap {
  width: 100%;
  max-width: 68rem;
  margin-inline: auto;
  padding-inline: var(--gutter);
}
@media (min-width: 721px) {
  .wrap { padding-left: max(var(--gutter), calc(clamp(14px, 3.2vw, 56px) + 3rem)); }
}

/* ---- Top bar ------------------------------------------------------------ */
.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.5rem;
  justify-content: space-between;
  align-items: baseline;
  padding-block: 1.25rem;
  border-bottom: 1px solid var(--rule);
  font-family: var(--type);
  font-size: .875rem;
  letter-spacing: .04em;
  color: var(--ink-soft);
}
.topbar__name { margin: 0; color: var(--ink); text-decoration: none; }
a.topbar__name:hover { color: var(--red); }
.topnav { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; }
.topnav a { color: var(--ink-soft); text-decoration: none; }
.topnav a:hover { color: var(--red); }
.topnav a[aria-current="page"] { color: var(--ink); text-decoration: underline; text-decoration-color: var(--red); }

/* ---- Hero --------------------------------------------------------------- */
.hero {
  --hero-pad: clamp(3rem, 12vh, 8rem);
  position: relative;
  padding-block: var(--hero-pad) clamp(2.5rem, 8vh, 5rem);
}
.title {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(3.1rem, 11.5vw, 8rem);
  line-height: .95;
  letter-spacing: -.01em;
  color: var(--ink);
}
.title span { display: block; font-style: italic; padding-left: .55em; }
.lede {
  margin: 1.75rem 0 0;
  max-width: var(--measure);
  font-family: var(--display);
  font-style: italic;
  font-size: clamp(1.35rem, 3vw, 1.9rem);
  line-height: 1.3;
  color: var(--ink-soft);
}
.intro { max-width: 36rem; color: var(--ink-soft); }
.intro p { margin: 1.25rem 0 0; }
.intro strong { color: var(--ink); font-weight: 600; }
.cues { display: flex; flex-wrap: wrap; gap: .9rem 2.25rem; margin: 2.25rem 0 0; }
.cues .cue { margin-top: 0; }
.cue {
  display: inline-flex;
  align-items: center;
  gap: .6em;
  margin-top: 2.25rem;
  font-family: var(--type);
  font-size: .9rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--green);
}
.cue::after { content: "\2193"; font-family: var(--serif); }
.cue--go::after { content: "\2192"; }

/* The rubber stamp. Thumps down once on load, slightly crooked, with worn ink
 * (a noise mask). Sits over the title on wide screens, below it on phones. */
.stamp {
  display: inline-block;
  margin-top: 2rem;
  padding: .3em .75em .25em;
  border: .3em double currentColor;
  border-radius: .35em;
  font-family: var(--type);
  font-size: clamp(1.1rem, 2.6vw, 1.65rem);
  letter-spacing: .1em;
  line-height: 1.2;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--red);
  mix-blend-mode: var(--blend);
  transform: rotate(-8deg);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='w'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.75' numOctaves='2' seed='11'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -2.4 2.05'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23w)'/%3E%3C/svg%3E");
          mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='w'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.75' numOctaves='2' seed='11'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -2.4 2.05'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23w)'/%3E%3C/svg%3E");
}
.stamp small { display: block; font-size: .5em; letter-spacing: .2em; text-align: center; opacity: .9; }
/* Wide screens: lift it beside the title's second line ("of Audit"), clear of
 * "History". The first title line is ≈ 7.6rem tall once the title reaches its
 * 8rem cap (from ~1113px). Below 1200px it would collide with the title, so it
 * stays in the flow after the intro. */
@media (min-width: 1200px) {
  .hero .stamp { position: absolute; right: var(--gutter); top: calc(var(--hero-pad) + 8rem); margin: 0; }
}

/* ---- Tally-stick divider ------------------------------------------------- */
.tally { display: block; width: min(100%, 34rem); height: auto; margin: 0 auto; color: var(--ink-faint); }
.tally .wood { fill: var(--paper-3); stroke: currentColor; stroke-width: 1.5; }
.tally .notch { stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; }
.tally .split { stroke: currentColor; stroke-width: 1; stroke-dasharray: 3 4; }

/* ---- Sections ----------------------------------------------------------- */
.section { padding-block: clamp(3rem, 9vh, 5.5rem); }
.eyebrow {
  margin: 0 0 .6rem;
  font-family: var(--type);
  font-size: .85rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--red);
}
h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2rem, 5vw, 3.1rem);
  line-height: 1.05;
}

/* ---- The ledger (the homepage's list of articles) ------------------------- */
.ledger {
  list-style: none;
  margin: 0;
  padding: 0;
}
.ledger__head, .entry {
  display: grid;
  grid-template-columns: 9rem 1fr 4.5rem;
  gap: 0 1.5rem;
  align-items: start;
}
.ledger__head {
  margin-top: 2.5rem;
  padding: .5rem 0;
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  font-family: var(--type);
  font-size: .78rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.ledger__head span:last-child { text-align: center; }
.entry {
  padding: 1.05rem 0;
  border-bottom: 1px solid var(--rule);
}
.entry__date {
  font-family: var(--type);
  font-size: .95rem;
  color: var(--red);
  padding-top: .2rem;
  font-variant-numeric: tabular-nums;
}
.entry__text { max-width: 46rem; }
.entry__text h3 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.55rem;
  line-height: 1.1;
  color: var(--ink);
}
.entry__text p { margin: .45rem 0 0; color: var(--ink-soft); }
.entry__more { font-family: var(--type); font-size: .85rem; letter-spacing: .04em; }
.tick { width: 2.2rem; height: 2.2rem; justify-self: center; color: var(--red); }
.tick path {
  fill: none;
  stroke: currentColor;
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 32;
  stroke-dashoffset: 0;
}

@media (max-width: 600px) {
  .ledger__head { display: none; }
  .ledger { margin-top: 2rem; border-top: 2px solid var(--ink); }
  .entry { grid-template-columns: 1fr 2.2rem; gap: .2rem 1rem; }
  .entry__date { grid-column: 1; }
  .entry__text { grid-column: 1; grid-row: 2; }
  .tick { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
}

/* ---- Closing section of the homepage ---------------------------------------- */
.closing h2 { margin-bottom: .25rem; }
.closing p { margin: 1rem 0 0; max-width: var(--measure); color: var(--ink-soft); }
.closing__line {
  font-family: var(--display);
  font-style: italic;
  font-size: clamp(1.3rem, 2.6vw, 1.6rem);
  line-height: 1.3;
}
.closing p.closing__line { margin-top: 1.75rem; color: var(--ink); }

/* ---- Footer ------------------------------------------------------------- */
footer {
  margin-top: clamp(2rem, 6vh, 4rem);
  border-top: 1px solid var(--rule);
  padding-block: 1.75rem 2.5rem;
  font-family: var(--type);
  font-size: .82rem;
  letter-spacing: .03em;
  color: var(--ink-faint);
}
footer p { margin: .25rem 0; }

/* ---- 404 ---------------------------------------------------------------- */
.lost { padding-block: clamp(3rem, 14vh, 9rem) 3rem; position: relative; }
.lost__code { margin: 0 0 1rem; font-family: var(--type); letter-spacing: .12em; text-transform: uppercase; color: var(--red); }
.lost h1 { margin: 0; max-width: 18ch; font-family: var(--display); font-weight: 400; font-size: clamp(2.4rem, 7vw, 4.75rem); line-height: 1; }
.lost__text { margin: 1.5rem 0 0; max-width: 34rem; color: var(--ink-soft); }
.lost .stamp { margin-top: 2.25rem; }
@media (min-width: 900px) { .lost .stamp { position: absolute; right: var(--gutter); top: clamp(4rem, 12vh, 7rem); margin: 0; } }

/* ---- Footer links: privacy notice + cookie settings ---------------------- */
.footer__links { display: flex; flex-wrap: wrap; gap: .25rem 1.5rem; }
.linklike {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  letter-spacing: inherit;
  color: var(--green);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .18em;
  cursor: pointer;
}
.linklike:hover { color: var(--red); }
.linklike[hidden] { display: none; }

/* ---- Consent banner (built by consent.js; absent without JS) --------------
 * A slip of ledger paper pinned to the corner. Reject and Accept are
 * deliberately identical in size and weight: refusing must be as easy as
 * accepting (ICO / EDPB guidance). Don't "promote" Accept. */
.consent {
  position: fixed;
  z-index: 10;
  right: clamp(12px, 3vw, 32px);
  bottom: clamp(12px, 3vw, 32px);
  width: min(26rem, calc(100vw - 24px));
  padding: 1.15rem 1.35rem 1.25rem;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-top: 4px double var(--red);
  box-shadow: 0 22px 50px -18px var(--shadow), 0 2px 6px var(--shadow);
}
.consent[hidden] { display: none; }
.consent__title {
  margin: 0;
  font-family: var(--type);
  font-size: .85rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--red);
}
.consent__text { margin: .6rem 0 0; font-size: .95rem; line-height: 1.55; color: var(--ink-soft); }
.consent__actions { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-top: 1rem; }
.consent__btn {
  padding: .7rem .75rem .6rem;
  border: 1.5px solid var(--ink);
  border-radius: 2px;
  background: transparent;
  font-family: var(--type);
  font-size: .85rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink);
  cursor: pointer;
}
.consent__btn:hover { background: var(--ink); color: var(--paper); }
@media (max-width: 520px) {
  .consent { left: 12px; right: 12px; bottom: 12px; width: auto; }
}

/* ---- Prose pages: articles, About, Where to start, the privacy notice ------
 * The privacy notice is set as "notes to the accounts": each section a numbered
 * note. Articles end with their sources as footnotes. */
.prose { padding-block: clamp(2.5rem, 9vh, 5rem) clamp(2rem, 6vh, 4rem); }
.prose > * { max-width: 44rem; }
.prose h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2.6rem, 8vw, 4.75rem);
  line-height: 1;
}
.prose .lede { margin-top: 1.5rem; }
.prose .meta { margin: 1rem 0 0; font-family: var(--type); font-size: .85rem; letter-spacing: .04em; color: var(--ink-faint); }
.prose h2 {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .2rem .85rem;
  margin: 2.75rem 0 0;
  padding-top: 1.1rem;
  border-top: 1px solid var(--rule);
  font-size: clamp(1.55rem, 3.4vw, 2rem);
  line-height: 1.15;
}
.prose h2 .n { font-family: var(--type); font-size: .85rem; letter-spacing: .1em; text-transform: uppercase; color: var(--red); }
.prose h3 { margin: 1.75rem 0 0; font-size: 1.1rem; font-weight: 600; }
.prose p, .prose li { color: var(--ink-soft); }
.prose p { margin: .85rem 0 0; }
.prose ul { margin: .85rem 0 0; padding-left: 1.2em; }
.prose li { margin: .4rem 0 0; }
.prose li::marker { color: var(--red); }
.prose strong { color: var(--ink); font-weight: 600; }
.prose code { font-family: var(--type); font-size: .92em; color: var(--ink); }
.table-wrap { margin: 1.25rem 0 0; overflow-x: auto; border: 1px solid var(--rule); background: var(--paper-2); }  /* scrolls itself, never the page */
.prose table { width: 100%; min-width: 36rem; border-collapse: collapse; font-size: .95rem; }
.prose th, .prose td { padding: .6rem .8rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--rule); color: var(--ink-soft); }
.prose th {
  font-family: var(--type);
  font-weight: 400;
  font-size: .78rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  border-bottom-color: var(--ink);
}
.prose tr:last-child td { border-bottom: 0; }
/* Two-column tables (the reading guide's glossary) fit a phone without the
 * sideways scroll the wider ones need: no minimum width, the term column wraps.
 * Browsers without :has() keep the scrolling wrapper. */
.prose table:not(:has(th:nth-child(3))) { min-width: 0; }
.prose table:not(:has(th:nth-child(3))) th:first-child { width: 32%; }
.prose em { font-style: italic; }
.article .lede { color: var(--ink-soft); }
.prose p.next {
  margin-top: 2.5rem;
  padding: .9rem 1.1rem;
  border-left: 4px double var(--red);
  background: var(--paper-2);
  color: var(--ink);
}
.fnref { font-size: .72em; line-height: 0; }
.fnref a { padding: 0 .12em; font-family: var(--type); text-decoration: none; }
.notes { margin: 1rem 0 0; padding-left: 1.8em; font-size: .93rem; overflow-wrap: break-word; }
.notes li { margin: .7rem 0 0; color: var(--ink-soft); }
.notes li::marker { color: var(--red); font-family: var(--type); }
.notes li:target { background: var(--paper-2); outline: 6px solid var(--paper-2); }
.fnback { margin-left: .15em; text-decoration: none; }

/* ---- Motion (all of it, and only with permission) ------------------------ */
@media (prefers-reduced-motion: no-preference) {
  .rise { animation: rise .9s cubic-bezier(.2, .7, .2, 1) both; }
  .rise--2 { animation-delay: .12s; }
  .rise--3 { animation-delay: .24s; }
  .rise--4 { animation-delay: .36s; }
  .rise--5 { animation-delay: .48s; }
  @keyframes rise { from { opacity: 0; transform: translateY(14px); } }

  .stamp { animation: thump .55s cubic-bezier(.3, 1.6, .5, 1) 1.1s both; }
  /* the consent slip slides in after the stamp has landed; at once when it is
     reopened from "Cookie settings" */
  .consent { animation: rise .7s cubic-bezier(.2, .7, .2, 1) 1.9s both; }
  .consent--now { animation-delay: 0s; }
  @keyframes thump {
    0%   { opacity: 0; transform: rotate(-16deg) scale(2.4); }
    60%  { opacity: 1; transform: rotate(-7deg) scale(.94); }
    100% { opacity: 1; transform: rotate(-8deg) scale(1); }
  }
  /* The desk shakes a little when the stamp lands. The title rises in first;
     jolt deliberately has no fill mode, or its `none` keyframe would hold
     during the delay and cancel the rise. */
  .hero .title, .lost h1 { animation: rise .9s cubic-bezier(.2, .7, .2, 1) .12s both, jolt .35s ease-out 1.42s; }
  @keyframes jolt {
    0%, 100% { transform: none; }
    30% { transform: translate(1px, 2px); }
    60% { transform: translate(-1px, -1px); }
  }

  /* Ticks are drawn in as each ledger line scrolls into view, where the browser
     supports scroll-driven animations. Elsewhere they are simply there. */
  @supports (animation-timeline: view()) {
    .tick path {
      stroke-dashoffset: 32;
      animation: draw linear both;
      animation-timeline: view();
      animation-range: entry 35% cover 45%;
    }
    @keyframes draw { to { stroke-dashoffset: 0; } }
  }
}
.cue--back::after { content: none; }
.cue--back::before { content: "\2190"; font-family: var(--serif); }
