/* Layout: a ledger page. One reading column; charts stick beside the steps on wide
   screens and pin to the top of the screen on phones. Lessons sit as gold-ruled
   margin notes. One colour per funding measure, the same in every chart. */
:root {
  --paper: #f4f6f9;
  --card: #ffffff;
  --ink: #141c33;
  --ink-2: #47506a;
  --ink-3: #737b93;
  --rule: #d8dce6;
  --rule-2: #e7eaf1;
  --commit: #256abf;          /* commitments, allocated share */
  --commit-y1: #6da7ec;       /* year steps of the commitment ramp */
  --commit-y2: #2a78d6;
  --commit-y3: #184f95;
  --pay: #c4521f;             /* estimated payments to date */
  --unknown: #858ca1;         /* hatching: exists, size unknown */
  --excluded: #b6bccb;        /* fails the NGO definition */
  --gold: #c99400;            /* lesson marker */
  --gold-wash: #fbf3dc;
  --ev-audit: #1d6b52;
  --ev-official: #2b4f9e;
  --ev-recipient: #6b4a8c;
  --ev-allegation: #a33a2c;
  --ev-ours: #5a6178;

  --display: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --body: "Public Sans", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", "SFMono-Regular", Menlo, Consolas, monospace;

  --step-0: 0.8125rem;
  --step-1: 0.9375rem;
  --step-2: 1.0625rem;
  --step-3: 1.375rem;
  --step-4: 1.875rem;
  --step-5: clamp(2.25rem, 1.4rem + 3.6vw, 3.75rem);
  --measure: 38rem;
  --wide: 72rem;
  --gutter: 1rem;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0e1322; --card: #161d31; --ink: #e8ecf5; --ink-2: #b3bad0; --ink-3: #8a92aa;
    --rule: #2b3350; --rule-2: #20283f;
    --commit: #3987e5; --commit-y1: #86b6ef; --commit-y2: #3987e5; --commit-y3: #1c5cab;
    --pay: #e8743d; --unknown: #8d94aa; --excluded: #4a5270;
    --gold: #e8b923; --gold-wash: #2a2614;
    --ev-audit: #5cc29d; --ev-official: #8aa8ef; --ev-recipient: #b99be0; --ev-allegation: #ef8a7c; --ev-ours: #a3aac0;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0e1322; --card: #161d31; --ink: #e8ecf5; --ink-2: #b3bad0; --ink-3: #8a92aa;
  --rule: #2b3350; --rule-2: #20283f;
  --commit: #3987e5; --commit-y1: #86b6ef; --commit-y2: #3987e5; --commit-y3: #1c5cab;
  --pay: #e8743d; --unknown: #8d94aa; --excluded: #4a5270;
  --gold: #e8b923; --gold-wash: #2a2614;
  --ev-audit: #5cc29d; --ev-official: #8aa8ef; --ev-recipient: #b99be0; --ev-allegation: #ef8a7c; --ev-ours: #a3aac0;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--step-2)/1.6 var(--body);
  padding-inline: var(--gutter);
  padding-block: 0 3rem;
  margin: 0;
  -webkit-font-smoothing: antialiased;
}
@media (min-width: 40rem) { :root { --gutter: 1.5rem; } }
a { color: var(--commit); text-underline-offset: 0.15em; text-decoration-thickness: 1px; }
a:focus-visible, button:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid var(--gold); outline-offset: 2px;
}
h1, h2, h3 { font-family: var(--display); text-wrap: balance; line-height: 1.12; margin: 0; }
p { margin: 0; }
strong { font-weight: 600; font-variant-numeric: tabular-nums; }
abbr[title] { text-decoration: underline dotted; text-decoration-color: var(--ink-3); text-underline-offset: 0.2em; }
code { font: 400 0.85em var(--mono); overflow-wrap: anywhere; }
img { max-width: 100%; height: auto; display: block; }

[hidden] { display: none !important; }
.skip { position: absolute; left: -999px; }
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.skip:focus { left: var(--gutter); top: 0.5rem; background: var(--card); padding: 0.5rem 0.75rem; z-index: 10; }

/* Hero */
.hero {
  max-width: var(--wide);
  margin-inline: auto;
  padding-block: 1.25rem 2rem;
  display: grid;
  gap: 1.25rem;
}
.hero__art { margin: 0; }
.hero__art img { border-radius: 2px; aspect-ratio: 1600 / 994; object-fit: cover; width: 100%; }
.hero__text { display: grid; gap: 0.9rem; max-width: 46rem; }
.kicker, .chapter__no {
  font: 600 var(--step-0)/1.3 var(--body);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.hero h1 { font-size: var(--step-5); font-weight: 600; letter-spacing: -0.015em; }
.dek { font: 400 var(--step-3)/1.45 var(--display); color: var(--ink-2); }
.dek strong { color: var(--ink); }
.byline { font-size: var(--step-0); color: var(--ink-3); }
@media (min-width: 60rem) {
  .hero { grid-template-columns: 1.15fr 1fr; align-items: end; padding-block-start: 2rem; }
  .hero__text { padding-block-end: 1.5rem; }
}

/* Contents */
.toc {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 5;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(6px);
  border-block: 1px solid var(--rule);
  margin-inline: calc(-1 * var(--gutter));
  padding-inline: var(--gutter);
}
.toc ol {
  list-style: none; margin: 0 auto; padding: 0; max-width: var(--wide);
  display: flex; gap: 1.25rem; overflow-x: auto; scrollbar-width: none;
  counter-reset: toc;
}
.toc li { counter-increment: toc; flex: none; }
.toc a {
  display: block; padding-block: 0.6rem; font-size: var(--step-0); font-weight: 500;
  color: var(--ink-2); text-decoration: none; border-bottom: 2px solid transparent;
}
.toc a::before { content: counter(toc) " "; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.toc a[aria-current="true"] { color: var(--ink); border-bottom-color: var(--commit); }

/* Chapters */
.chapter {
  max-width: var(--wide);
  margin-inline: auto;
  padding-block: 3.5rem 1rem;
  display: grid;
  gap: 1.75rem;
  border-top: 1px solid var(--rule);
}
.chapter:first-child { border-top: 0; }
.chapter__head { display: grid; gap: 0.6rem; max-width: var(--measure); }
.chapter h2 { font-size: var(--step-4); font-weight: 600; }
.chapter__dek { font: 400 var(--step-2)/1.55 var(--body); color: var(--ink-2); }
.subhead { font-size: var(--step-3); font-weight: 600; margin-top: 0.5rem; }

/* Scrollytelling */
.scrolly { display: grid; gap: 0; position: relative; }
.scrolly__graphic {
  position: sticky;
  top: calc(env(safe-area-inset-top, 0px) + 2.6rem);
  z-index: 1;
  background: var(--paper);
  padding-block: 0.5rem;
}
.scrolly__steps { display: grid; gap: 45vh; padding-block: 35vh 30vh; position: relative; z-index: 2; }
.step {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 1rem 1.1rem;
  display: grid;
  gap: 0.75rem;
  max-width: 30rem;
  box-shadow: 0 1px 2px color-mix(in srgb, var(--ink) 8%, transparent);
  transition: opacity 0.3s;
}
.step.is-active { opacity: 1; }
@media (min-width: 60rem) {
  .scrolly { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 2.5rem; }
  .scrolly__graphic {
    grid-column: 1; grid-row: 1; align-self: start;
    top: calc(env(safe-area-inset-top, 0px) + 4rem);
    max-height: none; overflow: visible;
  }
  .scrolly__steps { grid-column: 2; grid-row: 1; gap: 55vh; padding-block: 20vh 40vh; }
  .step { opacity: 0.4; }
  .tabs { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) { .step { transition: none; } }

/* Quotes and evidence */
.quote {
  font-size: var(--step-1);
  color: var(--ink-2);
  border-left: 2px solid var(--rule);
  padding-left: 0.75rem;
  display: grid;
  gap: 0.3rem;
}
.quote__text { color: var(--ink); }
.quote__meta { display: flex; flex-wrap: wrap; gap: 0.35rem 0.6rem; align-items: center; font-size: var(--step-0); }
.quote__meta a { color: var(--ink-3); }
.quote--wide, .notes, .lesson--wide { max-width: var(--measure); }
.notes { display: grid; gap: 1rem; }
.ev {
  display: inline-flex; align-items: center; gap: 0.35em;
  font: 600 0.72rem/1 var(--body); letter-spacing: 0.04em; text-transform: uppercase;
  padding: 0.25em 0.5em; border-radius: 2px; border: 1px solid currentColor; white-space: nowrap;
}
.ev::before { content: ""; width: 0.55em; height: 0.55em; background: currentColor; }
.ev--audited-finding { color: var(--ev-audit); }
.ev--official-statement, .ev--call-or-grant-document { color: var(--ev-official); }
.ev--official-statement::before, .ev--call-or-grant-document::before { border-radius: 50%; }
.ev--recipient-disclosure, .ev--funder-disclosure { color: var(--ev-recipient); }
.ev--recipient-disclosure::before, .ev--funder-disclosure::before { clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.ev--allegation, .ev--news { color: var(--ev-allegation); }
.ev--allegation::before, .ev--news::before { background: none; border: 1.5px solid currentColor; border-radius: 50%; }
.ev--our-inference, .ev--our-calculation { color: var(--ev-ours); }
.ev--our-inference::before, .ev--our-calculation::before { transform: rotate(45deg); }

.lesson {
  background: var(--gold-wash);
  border-left: 3px solid var(--gold);
  padding: 0.7rem 0.9rem;
  display: grid;
  gap: 0.25rem;
}
.lesson::before {
  content: "Lesson for public-finance readers";
  font: 700 0.7rem/1.2 var(--body); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2);
}
.lesson p { font: 500 var(--step-1)/1.5 var(--body); }

/* Charts */
.chart { margin: 0; display: grid; gap: 0.5rem; min-width: 0; }
.chart--wide { max-width: var(--wide); }
.chart--wide .chart__body { max-width: 46rem; }
.chart__title { font: 600 var(--step-1)/1.35 var(--body); }
.chart__source, .chart__note { font-size: var(--step-0); color: var(--ink-3); line-height: 1.45; }
.chart__note:empty { display: none; }
.chart__body { min-width: 0; }
.chart__body svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart__legend { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; font-size: var(--step-0); color: var(--ink-2); }
.chart__legend:empty { display: none; }
.key { display: inline-flex; align-items: center; gap: 0.4rem; }
.key__swatch { width: 0.9rem; height: 0.7rem; border-radius: 1px; flex: none; }
.key__tick { width: 3px; height: 0.9rem; background: var(--pay); flex: none; }
svg text { fill: var(--ink-2); font-family: var(--body); font-size: 12px; }
svg .t-strong { fill: var(--ink); font-weight: 600; }
svg .t-muted { fill: var(--ink-3); }
svg .t-num { font-variant-numeric: tabular-nums; }
svg .grid { stroke: var(--rule-2); stroke-width: 1; }
svg .axis { stroke: var(--rule); stroke-width: 1; }
svg .m-commit { fill: var(--commit); }
svg .m-y0 { fill: var(--commit-y1); }
svg .m-y1 { fill: var(--commit-y2); }
svg .m-y2 { fill: var(--commit-y3); }
svg .m-excluded { fill: var(--excluded); }
svg .m-unknown { fill: url(#hatch); stroke: var(--unknown); stroke-width: 1; }
svg .m-open { fill: none; stroke: var(--unknown); stroke-width: 1.5; stroke-dasharray: 5 4; }
svg .m-pay { fill: var(--pay); }
svg .m-line { fill: none; stroke: var(--commit); stroke-width: 2; }
svg .m-dot { fill: var(--commit); stroke: var(--card); stroke-width: 2; }
svg .m-share { fill: var(--ink-2); stroke: var(--card); stroke-width: 2; }
svg .hatch-line { stroke: var(--unknown); stroke-width: 1.2; }
svg .hit { fill: transparent; cursor: default; }
svg .fade { animation: fade 0.45s ease-out both; }
@keyframes fade { from { opacity: 0.25; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { svg .fade { animation: none; } }

.tabs { display: flex; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 0.35rem; }
.tabs button { flex: none; }
.tabs button, .filters button {
  font: 500 var(--step-0)/1.2 var(--body); color: var(--ink-2);
  background: var(--card); border: 1px solid var(--rule); border-radius: 2px;
  padding: 0.45rem 0.65rem; cursor: pointer;
}
.tabs button[aria-selected="true"] { color: var(--card); background: var(--ink); border-color: var(--ink); }

.table-view summary { cursor: pointer; font-size: var(--step-0); color: var(--ink-2); }
.table-scroll { overflow-x: auto; max-width: 100%; }
table { border-collapse: collapse; font-size: var(--step-0); font-variant-numeric: tabular-nums; width: 100%; }
th, td { text-align: left; padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--rule-2); vertical-align: top; }
th { font-weight: 600; color: var(--ink-2); border-bottom-color: var(--rule); }
td.num, th.num { text-align: right; white-space: nowrap; }
td.unknown { color: var(--ink-3); font-style: italic; }

/* Explorer */
.explorer { display: grid; gap: 1.25rem; }
.filters {
  display: grid; gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr));
  background: var(--card); border: 1px solid var(--rule); border-radius: 3px; padding: 0.9rem;
  align-items: end;
}
.filters label { display: grid; gap: 0.3rem; font: 600 var(--step-0)/1.2 var(--body); color: var(--ink-2); min-width: 0; }
.filters select {
  font: 400 var(--step-1)/1.3 var(--body); color: var(--ink); background: var(--paper);
  border: 1px solid var(--rule); border-radius: 2px; padding: 0.45rem; width: 100%; min-width: 0;
}
.explorer__out { display: grid; gap: 1.25rem; }
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); gap: 0.75rem; margin: 0; }
.figure { border-top: 2px solid var(--rule); padding-top: 0.5rem; display: grid; gap: 0.15rem; align-content: start; }
.figure--commit { border-top-color: var(--commit); }
.figure--pay { border-top-color: var(--pay); }
.figure--unknown { border-top-color: var(--unknown); border-top-style: dashed; }
.figure dt { font-size: var(--step-0); color: var(--ink-2); }
.figure dd { margin: 0; font: 600 var(--step-3)/1.2 var(--display); font-variant-numeric: tabular-nums; }
.figure small { font-size: var(--step-0); color: var(--ink-3); }
.statement { font: 400 var(--step-2)/1.5 var(--display); max-width: var(--measure); }
.explorer__charts { display: grid; gap: 1.5rem; }
@media (min-width: 60rem) { .explorer__charts { grid-template-columns: 1fr 1fr; } }
.empty {
  border: 1.5px dashed var(--unknown); padding: 1rem; border-radius: 3px; display: grid; gap: 0.5rem;
  max-width: var(--measure);
}
.empty h3 { font-size: var(--step-3); }

/* Profiles */
.profiles { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 21rem), 1fr)); }
.profile {
  background: var(--card); border: 1px solid var(--rule); border-radius: 3px;
  padding: 1rem; display: grid; gap: 0.7rem; align-content: start; min-width: 0;
}
.profile h3 { font-size: var(--step-3); }
.profile__rank { font: 500 var(--step-0)/1 var(--mono); color: var(--ink-3); }
.profile__legal { font-size: var(--step-0); color: var(--ink-3); }
.profile dl { display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 0.8rem; margin: 0; font-size: var(--step-1); }
.profile dt { color: var(--ink-3); }
.profile dd { margin: 0; font-variant-numeric: tabular-nums; min-width: 0; }

/* Links matrix */
.matrix th.type { text-align: center; min-width: 6.5rem; }
.matrix td.mark { text-align: center; }
.matrix .dot { display: inline-block; width: 0.8rem; height: 0.8rem; border-radius: 50%; background: var(--ink); }
.matrix .dot--control { border-radius: 1px; background: var(--ev-allegation); }
.matrix .none { color: var(--ink-3); }
.matrix .group td { font: 700 0.72rem/1.2 var(--body); text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); padding-top: 1rem; }
.matrix td small { display: block; color: var(--ink-3); }
@media (max-width: 47.99rem) {
  .matrix, .matrix tbody, .matrix tr, .matrix td { display: block; }
  .matrix thead { display: none; }
  .matrix tr { padding-block: 0.8rem; border-bottom: 1px solid var(--rule); }
  .matrix tr.group { padding-block: 0.5rem 0; border-bottom: 0; }
  .matrix td { border: 0; padding: 0.15rem 0; text-align: left; }
  .matrix td.org { font-weight: 600; font-size: var(--step-2); }
  .matrix td.mark { display: inline-flex; align-items: center; gap: 0.4rem; margin-right: 0.9rem; }
  .matrix td.mark::after { content: attr(data-label); font-size: var(--step-0); color: var(--ink-2); }
  .matrix td.mark--none { display: none; }
  .matrix td.num { text-align: left; white-space: normal; }
  .matrix td.num small { display: inline; margin-left: 0.4rem; }
  .matrix td[data-label]:not(.mark)::before { content: attr(data-label) ": "; color: var(--ink-3); }
}

/* Advocacy origins */
.origins { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr)); }
.origin { display: grid; gap: 0.8rem; align-content: start; border-top: 3px solid var(--ink); padding-top: 0.7rem; min-width: 0; }
.origin h3 { font-size: var(--step-3); }
.origin__def { font-size: var(--step-0); color: var(--ink-3); }
.origin__who { font-size: var(--step-1); }
.origin__who li { margin-bottom: 0.3rem; }
.timeline { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.9rem; max-width: var(--measure); border-left: 2px solid var(--rule); }
.timeline li { padding-left: 1rem; position: relative; }
.timeline li::before {
  content: ""; position: absolute; left: -6px; top: 0.45rem; width: 10px; height: 10px;
  background: var(--paper); border: 2px solid var(--ink-2); border-radius: 50%;
}
.timeline .quote { border-left: 0; padding-left: 0; }

/* Gaps */
.gaps { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 21rem), 1fr)); }
.gap {
  border: 1.5px dashed var(--unknown); border-radius: 3px; padding: 1rem; display: grid; gap: 0.7rem;
  align-content: start; background: var(--card); min-width: 0;
}
.gap h3 { font-size: var(--step-3); }
.gap__fix { font-size: var(--step-1); border-top: 1px solid var(--rule); padding-top: 0.6rem; }
.gap__fix b { display: block; font-size: var(--step-0); text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); }

/* Conclusions */
.verdicts { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); }
.verdict { display: grid; gap: 0.8rem; align-content: start; border-top: 3px solid var(--ink); padding-top: 0.7rem; min-width: 0; }
.verdict--no { border-top-style: dashed; border-top-color: var(--unknown); }
.verdict--fix { border-top-color: var(--gold); }
.verdict h3 { font-size: var(--step-3); }
.verdict ul { margin: 0; padding-left: 1.1rem; display: grid; gap: 0.5rem; font-size: var(--step-1); }
.verdict > div { display: grid; gap: 0.8rem; }

/* Illustrations: kept apart from charts */
.illustration { margin: 0; display: grid; gap: 0.35rem; }
.illustration--inline { max-width: 52rem; }
.illustration--narrow { max-width: 30rem; }
.illustration img { border-radius: 2px; }
.credit { font-size: 0.75rem; color: var(--ink-3); line-height: 1.4; }
.credit a { color: inherit; }

/* Methods */
.methods { display: grid; gap: 2rem; }
@media (min-width: 60rem) { .methods { grid-template-columns: 1fr 1fr; } }
.methods > div { display: grid; gap: 0.8rem; align-content: start; min-width: 0; }
.methods h3 { font-size: var(--step-3); margin-top: 0.5rem; }
.glossary { margin: 0; display: grid; gap: 0.6rem; }
.glossary dt { font-weight: 600; }
.glossary dd { margin: 0; color: var(--ink-2); font-size: var(--step-1); }
.sources, .credits, .evidence-key { margin: 0; padding-left: 1.2rem; display: grid; gap: 0.45rem; font-size: var(--step-0); color: var(--ink-2); }
.evidence-key { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.sources a { overflow-wrap: anywhere; }
.colophon { max-width: var(--wide); margin: 2rem auto 0; font-size: var(--step-0); color: var(--ink-3); border-top: 1px solid var(--rule); padding-top: 1rem; }

.tooltip {
  position: fixed; z-index: 20; pointer-events: none;
  background: var(--ink); color: var(--paper); font-size: var(--step-0); line-height: 1.4;
  padding: 0.45rem 0.6rem; border-radius: 2px; max-width: 18rem;
}
.tooltip b { font-weight: 600; }

/* Legend swatches: the same measure classes as the chart marks */
.sw-commit { background: var(--commit); }
.sw-excluded { background: var(--excluded); }
.sw-y0 { background: var(--commit-y1); }
.sw-y1 { background: var(--commit-y2); }
.sw-y2 { background: var(--commit-y3); }
.sw-unknown { background: repeating-linear-gradient(45deg, var(--unknown) 0 1.2px, transparent 1.2px 4px); border: 1px solid var(--unknown); }
.sw-open { border: 1.5px dashed var(--unknown); }
svg .hit:focus-visible, svg circle:focus-visible, svg rect[tabindex]:focus-visible { outline: none; stroke: var(--gold); stroke-width: 2; }
.matrix .group-note { display: block; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--ink-2); margin-top: 0.2rem; }
.evidence-key li { display: grid; gap: 0.3rem; }
.evidence-key li > b { font-size: var(--step-0); color: var(--ink-2); }
.evidence-key li > span.badges { display: flex; flex-wrap: wrap; gap: 0.35rem; }
