:root {
  --paper: #f2ece1;
  --paper-raised: #eae1d0;
  --ink: #1c1a17;
  --ink-soft: #57503f;
  --ink-faint: #86795f;
  --rule: #c9bda2;
  --accent: #9c3b2e;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;

  --d1: rgba(28, 26, 23, 1.000);
  --d2: rgba(28, 26, 23, 0.718);
  --d3: rgba(28, 26, 23, 0.602);
  --d4: rgba(28, 26, 23, 0.539);
  --d5: rgba(28, 26, 23, 0.499);
  --d6: rgba(28, 26, 23, 0.471);
  --d7: rgba(28, 26, 23, 0.451);
  --d8: rgba(28, 26, 23, 0.436);
  --d9: rgba(28, 26, 23, 0.423);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { background: var(--paper); }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(1rem, 0.94rem + 0.3vw, 1.125rem);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 42rem;
  margin: 0 auto;
  padding: clamp(2rem, 6vw, 5rem) 1.25rem clamp(3rem, 8vw, 6rem);
}

h1, h2 {
  font-weight: 600;
  line-height: 1.2;
  color: var(--ink);
}

h1 {
  font-size: clamp(1.6rem, 1.3rem + 1.4vw, 2.35rem);
  margin: 0 0 1.4rem;
  letter-spacing: -0.01em;
}

h2 {
  font-size: clamp(1.15rem, 1.05rem + 0.4vw, 1.4rem);
  margin: 3rem 0 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}

p { margin: 0 0 1.1rem; }

.lede {
  font-size: 1.12em;
  color: var(--ink-soft);
}

em.hl { font-style: normal; color: var(--accent); }

a { color: var(--accent); }
a:not(:hover) { text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent); }

code, .num {
  font-family: var(--mono);
  font-size: 0.92em;
  letter-spacing: -0.01em;
}

/* ---- diagram ---- */

.diagram-wrap {
  margin: 1.5rem -0.25rem 0.75rem;
}

.diagram-frame {
  width: min(100%, 30rem);
  margin: 0 auto;
  display: block;
}

svg#dial { width: 100%; height: auto; display: block; }

.pt { fill: var(--ink); }
.pt.d1 { fill: var(--d1); }
.pt.d2 { fill: var(--d2); }
.pt.d3 { fill: var(--d3); }
.pt.d4 { fill: var(--d4); }
.pt.d5 { fill: var(--d5); }
.pt.d6 { fill: var(--d6); }
.pt.d7 { fill: var(--d7); }
.pt.d8 { fill: var(--d8); }
.pt.d9 { fill: var(--d9); }

.wedge { fill: var(--paper-raised); stroke: var(--rule); stroke-width: 1; }
.wedge.d1 { fill: color-mix(in srgb, var(--accent) 14%, var(--paper-raised)); }

.wedge-label .digit {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 15px;
  fill: var(--ink);
}
.wedge-label .pct {
  font-family: var(--mono);
  font-size: 10.5px;
  fill: var(--ink-faint);
}

figcaption {
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--ink-soft);
  text-align: center;
  max-width: 30rem;
  margin: 0.75rem auto 0;
  line-height: 1.5;
}

/* ---- controls (progressive enhancement only) ---- */

.controls {
  font-family: var(--sans);
  font-size: 0.88rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1rem;
  margin: 1.5rem auto 0;
  max-width: 30rem;
  padding: 0.9rem 1rem;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: 3px;
}

.controls[hidden] { display: none; }

.controls label { color: var(--ink-soft); white-space: nowrap; }

.controls input[type="range"] {
  flex: 1 1 10rem;
  accent-color: var(--accent);
}

.controls output {
  font-family: var(--mono);
  min-width: 3.4em;
  text-align: right;
}

.controls button {
  font-family: var(--sans);
  font-size: 0.85rem;
  background: transparent;
  border: 1px solid var(--ink-soft);
  color: var(--ink);
  padding: 0.35rem 0.7rem;
  border-radius: 2px;
  cursor: pointer;
}
.controls button:hover { border-color: var(--ink); }
.controls button:focus-visible,
.controls input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- table ---- */

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 0.85rem;
  margin: 1.75rem 0;
}

caption {
  text-align: left;
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin-bottom: 0.5rem;
}

th, td {
  text-align: right;
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--rule);
}

th:first-child, td:first-child { text-align: left; }

thead th {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--ink-soft);
}

tbody tr:last-child td { border-bottom: none; }

/* ---- sources ---- */

.sources {
  margin-top: 3.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.sources ol { margin: 0.5rem 0 0; padding-left: 1.2rem; }
.sources li { margin: 0 0 0.4rem; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
