/* Roboto Bold (Latin), Apache 2.0 — self-hosted; see /fonts/README.txt */
@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/roboto-700.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #fbfaf8;
  --surface: #ffffff;
  --text: #1a1a1a;
  --muted: #5f6268;
  --rule: #e2e0dc;
  --accent: #8a4b2a;
  --code-bg: #f2f0ec;
  --grp-p: #b4532a;
  --grp-h: #2d62a8;
  --good: #2e7d4f;
  --bad: #b3322f;
  --measure: 46rem;
  --wordmark: "Roboto", ui-sans-serif, system-ui, -apple-system, "Helvetica Neue",
    Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131416;
    --surface: #1a1c1f;
    --text: #e8e6e3;
    --muted: #9a9ca1;
    --rule: #2e3136;
    --accent: #d9915f;
    --code-bg: #212429;
    --grp-p: #e8895a;
    --grp-h: #72a6ea;
    --good: #5cc28a;
    --bad: #ee7470;
    color-scheme: dark;
  }
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.65 ui-serif, Georgia, "Times New Roman", serif;
  -webkit-text-size-adjust: 100%;
}

/* ---------- header / nav ---------- */

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 1rem 2rem;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 1.75rem 1.25rem 1.25rem;
  border-bottom: 1px solid var(--rule);
}

/* Scoped to beat `.site-header a` below, which is more specific than a bare
   `.wordmark` and would otherwise override the font. */
.site-header .wordmark {
  font-family: var(--wordmark);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.06em;
  text-decoration: none;
  color: var(--text);
}

.site-header nav { margin-left: auto; }

.site-header ul {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-header a {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.9rem;
  color: var(--muted);
  text-decoration: none;
  padding-bottom: 2px;
  border-bottom: 1.5px solid transparent;
}

.site-header a:hover { color: var(--text); }

.site-header a[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* ---------- content ---------- */

main { max-width: var(--measure); margin: 0 auto; padding: 2.5rem 1.25rem 4rem; }

.prose h1 {
  font-size: clamp(1.9rem, 5vw, 2.5rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 0.75rem;
}

.prose h2 {
  font-size: 1.4rem;
  margin: 2.75rem 0 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--rule);
  letter-spacing: -0.01em;
}

.prose h3 { font-size: 1.12rem; margin: 2rem 0 0.5rem; }

/* the home page opens straight on its list, with no rule above it */
.home > h2:first-child { border-top: 0; padding-top: 0; margin-top: 0; }

.prose p, .prose li { overflow-wrap: break-word; }
.prose a { color: var(--accent); text-underline-offset: 2px; }

.meta {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 2rem;
}

blockquote {
  margin: 1.5rem 0;
  padding: 0.25rem 0 0.25rem 1.25rem;
  border-left: 3px solid var(--accent);
  color: var(--muted);
  font-style: italic;
}

/* ---------- code ---------- */

code, pre {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.86em;
}

code {
  background: var(--code-bg);
  padding: 0.12em 0.36em;
  border-radius: 4px;
  overflow-wrap: anywhere;
}

pre {
  background: var(--code-bg);
  padding: 1rem 1.1rem;
  border-radius: 8px;
  overflow-x: auto;
  line-height: 1.5;
}

pre code { background: none; padding: 0; }

/* ---------- tables (published pieces are table-heavy) ---------- */

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.85rem;
  margin: 1.5rem 0;
}

.prose thead th {
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid var(--rule);
  padding: 0.5rem 0.75rem 0.5rem 0;
  white-space: nowrap;
}

.prose tbody td {
  border-bottom: 1px solid var(--rule);
  padding: 0.5rem 0.75rem 0.5rem 0;
  vertical-align: top;
}

.prose tbody tr:hover { background: var(--surface); }

/* wrap any table in <div class="scroll"> for wide tables */
.scroll { overflow-x: auto; margin: 1.5rem 0; }
.scroll table { margin: 0; }

/* ---------- article index ---------- */

.post-list { list-style: none; margin: 2rem 0 0; padding: 0; }

.post-list li {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--rule);
}

.post-list a {
  font-size: 1.2rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--text);
  letter-spacing: -0.01em;
}

.post-list a:hover { color: var(--accent); }

.post-list .meta { margin: 0.3rem 0 0; }
.post-list .excerpt { margin: 0.5rem 0 0; color: var(--muted); font-size: 0.95rem; }

/* ---------- footer ---------- */

.site-footer {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  border-top: 1px solid var(--rule);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.8rem;
  color: var(--muted);
}

/* ---------- skip link ---------- */

.skip {
  position: absolute;
  left: -9999px;
  background: var(--accent);
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: 0 0 6px 0;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.85rem;
  z-index: 10;
}
.skip:focus { left: 0; top: 0; }

/* ---------- shared typography bits ---------- */

.kicker {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.75rem;
}

.standfirst {
  font-size: 1.12rem;
  line-height: 1.55;
  color: var(--muted);
  margin: 0 0 2rem;
}

.prose > h1 + .standfirst { margin-top: -0.25rem; }

/* ---------- home hero ---------- */

.hero {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 1rem 0 2.5rem;
}

.hero h1 {
  font-size: clamp(2rem, 6vw, 2.9rem);
  line-height: 1.1;
  letter-spacing: -0.025em;
  margin: 0 0 1rem;
}

.hero .standfirst { margin-bottom: 0; }

main > .prose + .prose { margin-top: 1rem; }

/* ---------- link cards ---------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 0.85rem;
  margin: 2rem 0;
}

.card {
  display: block;
  padding: 1.1rem 1.2rem;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--surface);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.card:hover { border-color: var(--accent); transform: translateY(-2px); }

.card h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  font-family: ui-sans-serif, system-ui, sans-serif;
  letter-spacing: -0.01em;
}

.card p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--muted);
}

/* ---------- fact box ---------- */

.factbox {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 1rem 1.5rem;
  margin: 0 0 2.5rem;
  padding: 1.1rem 1.25rem;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  background: var(--surface);
  font-family: ui-sans-serif, system-ui, sans-serif;
}

.factbox div { min-width: 0; }
.factbox .factbox-wide { grid-column: 1 / -1; }

.factbox dt {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.factbox dd {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.factbox code { font-size: 0.8rem; }

/* ---------- empty states ---------- */

.empty {
  padding: 1.5rem 1.5rem 1.25rem;
  border: 1px dashed var(--rule);
  border-radius: 10px;
  background: var(--surface);
  margin: 1.5rem 0;
}

.empty p { margin: 0 0 0.75rem; font-size: 0.95rem; color: var(--muted); }
.empty p:last-child { margin-bottom: 0; }
.empty strong { color: var(--text); }

/* ---------- index list subjects ---------- */

.subjects { margin: 0.5rem 0 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.subjects code { font-size: 0.75rem; }

/* ---------- piece footer nav + updates ---------- */

.updates {
  margin-top: 3rem;
  padding: 1.1rem 1.25rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
}

.updates h2 {
  margin: 0 0 0.6rem;
  padding: 0;
  border: 0;
  font-size: 0.95rem;
  font-family: ui-sans-serif, system-ui, sans-serif;
}

.updates ul { margin: 0; padding-left: 1.1rem; font-size: 0.9rem; color: var(--muted); }

.piece-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.9rem;
}

/* ---------- footer links ---------- */

.site-footer p { margin: 0 0 0.4rem; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--accent); }


/* ---------- interactive tables ---------- */

.datatable { margin: 1.75rem 0; overflow-x: auto; }
.datatable table { margin: 0; }
.dt-tall .dt-scroll { max-height: 38rem; overflow: auto; border: 1px solid var(--rule); }
.dt-tall .dt-scroll thead th { position: sticky; top: 0; background: var(--bg); z-index: 1; }
.dt-scroll { overflow-x: auto; }

/* ---------- diagrams ---------- */

.subject-groups code { font-size: 0.78rem; white-space: nowrap; }
.subject-groups { overflow-wrap: normal; }

.diagram { margin: 2rem 0; }
.diagram-scroll { overflow: auto; max-height: 80rem; border: 1px solid var(--rule); background: var(--surface); }
.diagram svg { display: block; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.diagram figcaption { font-size: 0.85rem; color: var(--muted); margin-top: 0.5rem; }
.diagram text { fill: var(--text); font-size: 11px; }
.diagram .t-head, .diagram .f-title { font-weight: 700; font-size: 13px; font-family: var(--wordmark); }
.diagram .t-claimed { font-weight: 700; }
.diagram .t-node { fill: var(--muted); }
.diagram .t-amt, .diagram .t-up, .diagram .f-label, .diagram .l-axis { fill: var(--muted); font-size: 10px; }
.diagram .f-label { fill: var(--text); font-size: 11px; paint-order: stroke; stroke: var(--surface); stroke-width: 5px; stroke-linejoin: round; }
.diagram .f-edge, .diagram .f-pool { fill: none; }
.diagram .t-dot-P, .diagram .l-P { fill: var(--grp-p); }
.diagram .t-dot-H, .diagram .l-H { fill: var(--grp-h); }
.diagram .t-edge-P { stroke: var(--grp-p); fill: none; opacity: 0.6; }
.diagram .t-edge-H { stroke: var(--grp-h); fill: none; opacity: 0.6; }
.diagram .f-box { fill: var(--bg); stroke: var(--muted); }
.diagram .f-box-P, .diagram .f-box-Pr { fill: var(--bg); stroke: var(--grp-p); stroke-width: 2; }
.diagram .f-box-H, .diagram .f-box-Hr { fill: var(--bg); stroke: var(--grp-h); stroke-width: 2; }
.diagram .f-box-Pr, .diagram .f-box-Hr { stroke-dasharray: 5 3; }
.diagram .f-edge { stroke: var(--muted); stroke-width: 1.2; }
.diagram .f-pool { stroke: var(--accent); stroke-width: 1.2; stroke-dasharray: 4 3; }
.diagram .f-arrow { fill: var(--muted); }
.diagram .l-grid { stroke: var(--rule); }
.diagram .l-lane { stroke: var(--rule); stroke-dasharray: 2 3; }
.diagram .l-c { fill: none; stroke: var(--text); }
.diagram .l-t { stroke: var(--muted); }
.diagram .l-b { fill: var(--good); }
.diagram .l-s { fill: var(--bad); }
.diagram .l-i { fill: var(--good); opacity: 0.6; }
.diagram .l-o { fill: var(--bad); opacity: 0.6; }
.diagram .l-d, .diagram .l-w { fill: none; stroke: var(--accent); stroke-width: 1.5; }
.diagram .l-w { fill: var(--accent); }
.diagram .l-v { stroke: var(--accent); }
.diagram .l-x { stroke: var(--muted); }

.dt-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  font-family: ui-sans-serif, system-ui, sans-serif;
}

.dt-search {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.dt-search input {
  min-width: 15rem;
  max-width: 100%;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--rule);
  border-radius: 7px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
}

.dt-search input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.dt-count {
  margin: 0;
  margin-left: auto;
  align-self: flex-end;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

.dt-empty {
  margin: 0.75rem 0 0;
  padding: 0.9rem 1rem;
  border: 1px dashed var(--rule);
  border-radius: 8px;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.88rem;
  color: var(--muted);
}

/* sortable headers */

.prose .datatable thead th { padding: 0; }

.dt-sort {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  padding: 0.5rem 0.75rem 0.5rem 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.dt-sort:hover { color: var(--accent); }

.dt-sort:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.dt-arrow {
  flex: none;
  width: 0.55rem;
  height: 0.55rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  opacity: 0.25;
  transform: rotate(45deg) translate(-1px, -1px);
}

.datatable th[aria-sort="ascending"] .dt-arrow {
  opacity: 1;
  transform: rotate(-135deg) translate(-2px, -2px);
}

.datatable th[aria-sort="descending"] .dt-arrow { opacity: 1; }
.datatable th[aria-sort="ascending"] .dt-sort,
.datatable th[aria-sort="descending"] .dt-sort { color: var(--accent); }

@media (max-width: 30rem) {
  .dt-search input { min-width: 100%; }
  .dt-count { margin-left: 0; }
}

/* a published piece's diagrams and big tables use the whole screen, not the reading column */
.publication .diagram, .publication .datatable {
  position: relative;
  width: min(96vw, 1500px);
  left: 50%;
  transform: translateX(-50%);
}

/* the account chart and the time line's extra marks */
.diagram .g-head { fill: var(--muted); font-size: 10px; font-family: var(--wordmark); }
.diagram .g-num { font-size: 10.5px; }
.diagram .g-total { font-weight: 700; font-size: 11px; }
.diagram .g-rule { stroke: var(--rule); }
.diagram .g-how { fill: var(--muted); font-size: 10px; }
.diagram .g-edge { fill: none; stroke: var(--muted); opacity: 0.7; }
.diagram .g-edge.g-P { stroke: var(--grp-p); }
.diagram .g-edge.g-H { stroke: var(--grp-h); }
.diagram .g-paid { stroke-dasharray: 4 3; }
.diagram .t-dot-Pr, .diagram .t-dot-X { fill: none; stroke: var(--grp-p); stroke-width: 1.5; }
.diagram .t-dot-Hr { fill: none; stroke: var(--grp-h); stroke-width: 1.5; }
.diagram .t-dot-O, .diagram .t-dot-D { fill: none; stroke: var(--muted); stroke-width: 1.5; }
.diagram .l-Pr, .diagram .l-X { fill: var(--grp-p); opacity: 0.75; }
.diagram .l-Hr { fill: var(--grp-h); opacity: 0.75; }
.diagram .l-d1 { fill: none; stroke: var(--accent); stroke-width: 1.5; }
.diagram .l-d2 { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 2 1; }
.diagram .l-w1 { fill: var(--accent); }
.diagram .l-w2 { fill: var(--accent); opacity: 0.5; }
.diagram .l-pay-t { stroke: var(--grp-p); stroke-width: 1; opacity: 0.8; }
.diagram .l-pay-x { stroke: var(--muted); stroke-width: 1; opacity: 0.8; }

/* every table scrolls sideways inside its own box rather than pushing the page wider */
.table-wrap { overflow-x: auto; margin: 1.5rem 0; }
.table-wrap table { margin: 0; }
.publication table { font-size: 0.85rem; }
.publication td code, .publication th code { font-size: 0.78rem; }

.subject-group { display: block; padding: 0.5rem 0; }
.subject-group + .subject-group { border-top: 1px solid var(--rule); }
.subject-tree { margin-top: 0.35rem; font-size: 0.78rem; color: var(--muted); line-height: 1.7; }
.subject-tree code { font-size: 0.72rem; margin-right: 0.25rem; }

/* a heading or term with a plain-language explanation on hover */
.tip { border-bottom: 1px dotted var(--muted); cursor: help; }

/* ---------- the series: captions and charts ---------- */
.table-caption { font-family: var(--wordmark); font-size: 0.9rem; margin: 2rem 0 0.25rem; color: var(--text); }
.chart { margin: 2rem 0; }
.publication .chart { position: relative; width: min(96vw, 1100px); left: 50%; transform: translateX(-50%); }
.chart svg { display: block; background: var(--surface); border: 1px solid var(--rule); }
.chart figcaption { font-size: 0.85rem; color: var(--muted); margin-top: 0.5rem; }
.chart .ch-title { fill: var(--text); font: 700 13px var(--wordmark); }
.chart .ch-axis { fill: var(--muted); font: 11px ui-sans-serif, system-ui, sans-serif; }
.chart .ch-grid { stroke: var(--rule); }
.chart .ch-line { fill: none; stroke-width: 1.6; }
.chart .ch-1 { stroke: var(--grp-p); fill: var(--grp-p); }
.chart .ch-2 { stroke: var(--grp-h); fill: var(--grp-h); }
.chart .ch-3 { stroke: var(--good); fill: var(--good); }
.chart .ch-4 { stroke: var(--bad); fill: var(--bad); }
.chart path.ch-line { fill: none; }
.chart .ch-dot { opacity: 0; stroke: none; }
.chart .ch-dot:hover { opacity: 1; }
.chart .ch-last { font: 700 11px ui-sans-serif, system-ui, sans-serif; stroke: none; }
.chart .ch-ranges { display: flex; justify-content: flex-end; gap: 0; margin-bottom: -1px; }
.chart .ch-ranges button { font: 600 0.75rem ui-sans-serif, system-ui, sans-serif; padding: 0.3rem 0.65rem;
  background: var(--surface); color: var(--muted); border: 1px solid var(--rule); border-left-width: 0;
  cursor: pointer; }
.chart .ch-ranges button:first-child { border-left-width: 1px; }
.chart .ch-ranges button[aria-pressed="true"] { color: var(--text); background: var(--rule); }
.chart .ch-ranges button:focus-visible { outline: 2px solid var(--text); outline-offset: -2px; }
.chart .ch-view[hidden] { display: none; }
