@charset "utf-8";
/* Zambia 2026 election tracker — hand-written CSS. No framework, no build step,
   no utility classes. Dark by default because most of the count happens at night. */

/* ==========================================================================
   TOKENS — every custom property in the stylesheet is declared here.
   Nothing below this block introduces a new variable; components only consume.
   Themes override values, never add names.
   ========================================================================== */

:root {
  color-scheme: dark light;

  /* --- surfaces ------------------------------------------------------- */
  --bg: #0b0f16;
  --bg-raised: #121826;
  --bg-sunken: #080b11;
  --line: #1f293b;
  --line-soft: #17202f;

  /* --- text ----------------------------------------------------------- */
  --ink: #eef2f8;
  --ink-dim: #a7b2c5;
  --ink-quiet: #6c7a92;

  /* --- accents and states --------------------------------------------- */
  --quiet: #2a3446;
  --accent: #c9a227;          /* muted gold — signal colour, not a party colour */
  --accent-ink: #0b0f16;
  --up: #5c9e8a;              /* desaturated: a rise is information, not applause */
  --down: #b8736a;

  /* --- map ------------------------------------------------------------ */
  --map-empty: #212b3d;       /* province with nothing declared */
  --map-edge: #0b0f16;        /* boundary stroke */
  --heat-1: #24313f;          /* narrow margin  ─┐ sequential ramp, single hue, */
  --heat-2: #35566b;          /*                 │ so the heat map cannot be */
  --heat-3: #4b7f93;          /*                 │ read as favouring anyone */
  --heat-4: #7fb0b8;          /* wide margin    ─┘ */

  /* --- geometry ------------------------------------------------------- */
  --radius: 14px;
  --radius-sm: 8px;
  --wrap: 1160px;
  --gap: clamp(1rem, 2.5vw, 1.75rem);
  --tap: 44px;                /* minimum touch target */

  /* --- type ----------------------------------------------------------- */
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;

  /* --- depth and motion ----------------------------------------------- */
  --shadow: 0 1px 0 rgb(255 255 255 / 0.03) inset, 0 12px 32px -18px rgb(0 0 0 / 0.8);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --speed: 0.6s;

  /* --- per-element channels, set inline by the templates --------------- */
  --c: var(--ink-dim);        /* a candidate's series colour */
  --strength: 0;              /* 0–1 shading weight for a province */
  --cols: 4;                  /* tile grid columns */
}

/* Light theme. Declared once and applied twice: to the OS preference when the
   reader has expressed no choice, and to an explicit [data-theme] either way.
   Same names, different values — no component knows which theme is active. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #fbfaf7;
    --bg-raised: #ffffff;
    --bg-sunken: #f2efe9;
    --line: #e2ddd3;
    --line-soft: #ece8e0;
    --ink: #14181f;
    --ink-dim: #4a5464;
    --ink-quiet: #7c8798;
    --quiet: #ded9d0;
    --accent: #96751a;
    --accent-ink: #ffffff;
    --up: #2f7d68;
    --down: #a8483c;
    --map-empty: #e6e1d7;
    --map-edge: #fbfaf7;
    --heat-1: #dfe6ea;
    --heat-2: #a8c2cc;
    --heat-3: #6d9aa8;
    --heat-4: #3d6f80;
    --shadow: 0 1px 2px rgb(20 24 31 / 0.04), 0 10px 26px -20px rgb(20 24 31 / 0.35);
  }
}

:root[data-theme="light"] {
  --bg: #fbfaf7;
  --bg-raised: #ffffff;
  --bg-sunken: #f2efe9;
  --line: #e2ddd3;
  --line-soft: #ece8e0;
  --ink: #14181f;
  --ink-dim: #4a5464;
  --ink-quiet: #7c8798;
  --quiet: #ded9d0;
  --accent: #96751a;
  --accent-ink: #ffffff;
  --up: #2f7d68;
  --down: #a8483c;
  --map-empty: #e6e1d7;
  --map-edge: #fbfaf7;
  --heat-1: #dfe6ea;
  --heat-2: #a8c2cc;
  --heat-3: #6d9aa8;
  --heat-4: #3d6f80;
  --shadow: 0 1px 2px rgb(20 24 31 / 0.04), 0 10px 26px -20px rgb(20 24 31 / 0.35);
}

/* -------------------------------------------------------------- foundation */

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

/* [hidden] must beat any display a component sets, or toggled panels leak. */
[hidden] { display: none !important; }

/* Flex and grid children default to min-width:auto, which means a long word or
   an un-wrapping badge can push a track wider than the screen. On a phone that
   silently shoved the vote percentages off the right edge. Let text containers
   shrink, and let long names break rather than overflow. */
.head-inner, .brand, .brand-text,
.result-title, .result-who,
.cand, .cand-id, .cand-bar,
.log-item, .log-what,
.also-list a, .foot-inner > div { min-width: 0; }

.cand-id h3, .result-who b, .log-what p { overflow-wrap: anywhere; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: clamp(0.95rem, 0.9rem + 0.2vw, 1.02rem);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { line-height: 1.15; letter-spacing: -0.02em; margin: 0; text-wrap: balance; }
p { margin: 0 0 0.75em; text-wrap: pretty; }
a { color: inherit; text-underline-offset: 3px; text-decoration-color: color-mix(in oklab, currentColor 35%, transparent); }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

b, strong { font-weight: 650; }
small { font-size: 0.78em; }
code { font-family: var(--mono); font-size: 0.9em; background: var(--bg-sunken); padding: 0.15em 0.4em; border-radius: 5px; }

.wrap { width: min(100% - 2rem, var(--wrap)); margin-inline: auto; }
.muted { color: var(--ink-quiet); }
.lede { color: var(--ink-dim); font-size: 1.06em; max-width: 62ch; }

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 99;
  background: var(--accent); color: var(--accent-ink); padding: 0.6rem 1rem; border-radius: 0 0 8px 0;
}
.skip:focus { left: 0; }

/* Numbers are data. They get tabular figures everywhere. */
b, .numcell, output, time, .cand-share, .status-item b, .chips-meta b, .delta { font-variant-numeric: tabular-nums; }

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

.site-head {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.head-inner {
  display: flex; align-items: center; gap: 1rem;
  padding-block: 0.7rem;
}

.brand { display: flex; align-items: center; gap: 0.6rem; text-decoration: none; margin-right: auto; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px; flex: none;
  background:
    conic-gradient(from 200deg, #1a8f4c 0 25%, #d4451f 0 50%, #12181f 0 75%, var(--accent) 0);
  box-shadow: 0 0 0 1px var(--line);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: 0.98rem; letter-spacing: -0.02em; }
.brand-text small { color: var(--ink-quiet); font-size: 0.7rem; letter-spacing: 0.04em; text-transform: uppercase; }

.site-head nav { display: flex; gap: 0.15rem; flex-wrap: wrap; }
.site-head nav a {
  padding: 0.4rem 0.7rem; border-radius: 999px; text-decoration: none;
  font-size: 0.88rem; color: var(--ink-dim);
}
.site-head nav a:hover { background: var(--bg-raised); color: var(--ink); }
.site-head nav a[aria-current="page"] { background: var(--bg-raised); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }

/* On a phone the nav scrolls sideways rather than wrapping onto a second line
   and shoving the theme button out of place. */
/* A wordmark, four destinations and a toggle do not fit one phone row. Squeezing
   them left "Method" clipped behind the toggle — present in the DOM, invisible on
   screen, with nothing to suggest the nav scrolled. So the header becomes two
   rows: identity and controls on top, navigation full-width beneath, where all
   four fit and nothing can collide. */
@media (max-width: 620px) {
  .head-inner { gap: 0.5rem; flex-wrap: wrap; row-gap: 0.55rem; padding-block: 0.6rem; }

  .brand { margin-right: auto; order: 1; }
  .brand-text small { display: none; }
  .theme-toggle { order: 2; }

  .site-head nav {
    order: 3; flex: 1 0 100%; min-width: 0;
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    gap: 0.2rem;
  }
  .site-head nav::-webkit-scrollbar { display: none; }
  .site-head nav a {
    white-space: nowrap; padding: 0.4rem 0.6rem; font-size: 0.8rem;
  }
}

/* Below ~360px the full labels stop fitting even on their own row. */
.nav-short { display: none; }
@media (max-width: 360px) {
  .nav-long { display: none; }
  .nav-short { display: inline; }
  .site-head nav a { padding-inline: 0.5rem; }
}

.theme-toggle {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--bg-raised); color: var(--ink-dim);
  cursor: pointer; font-size: 0.95rem;
}
.theme-toggle:hover { color: var(--ink); }

/* live strip */
.status-strip { border-top: 1px solid var(--line-soft); background: var(--bg-sunken); font-size: 0.82rem; }
.status-inner {
  display: flex; align-items: center; gap: 0.5rem; padding-block: 0.5rem;
  overflow-x: auto; scrollbar-width: none; white-space: nowrap;
}
.status-inner::-webkit-scrollbar { display: none; }
.status-item { color: var(--ink-dim); }
.status-item b { color: var(--ink); }
.sep { color: var(--ink-quiet); }
.pip {
  width: 7px; height: 7px; border-radius: 50%; background: var(--up); flex: none;
  box-shadow: 0 0 0 0 color-mix(in oklab, var(--up) 70%, transparent);
  animation: pulse 2.4s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--up) 60%, transparent); }
  70% { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* ------------------------------------------------------------------- shell */

main { padding-block: clamp(1.5rem, 4vw, 3rem) 4rem; }

.banner {
  background: color-mix(in oklab, var(--accent) 16%, var(--bg));
  border-block: 1px solid color-mix(in oklab, var(--accent) 35%, transparent);
  color: var(--ink);
  padding: 0.7rem 1rem; text-align: center; font-size: 0.88rem;
  margin-bottom: 2rem;
}

.hero { margin-bottom: var(--gap); }
.hero h1 { font-size: clamp(1.8rem, 1.2rem + 3vw, 3.1rem); }
.hero-sub { display: block; color: var(--ink-quiet); font-weight: 400; font-size: 0.42em; letter-spacing: 0.12em; text-transform: uppercase; margin-top: 0.7rem; }

.crumbs { font-size: 0.82rem; color: var(--ink-quiet); margin-bottom: 1.2rem; }
.crumbs a { text-decoration: none; color: var(--ink-dim); }

.panel {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(1.1rem, 2.5vw, 1.9rem);
  margin-bottom: var(--gap);
  box-shadow: var(--shadow);
}
.panel-head { margin-bottom: 1.25rem; }
.panel-title { font-size: clamp(1.1rem, 1rem + 0.6vw, 1.45rem); }
.panel-sub { color: var(--ink-quiet); font-size: 0.88rem; margin: 0.45rem 0 0; max-width: 68ch; }

/* -------------------------------------------------- the 50%+1 line (hero) */

.threshold-panel {
  background:
    radial-gradient(120% 140% at 50% -20%, color-mix(in oklab, var(--accent) 9%, transparent), transparent 60%),
    var(--bg-raised);
}

.cone { margin: 1.75rem 0 1.25rem; }

.cone-track {
  position: relative; height: 76px;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.cone-track::before {
  /* subtle 10% ticks */
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(90deg, var(--line-soft) 0 1px, transparent 1px 10%);
  opacity: 0.7;
}
.cone-band {
  position: absolute; top: 0; bottom: 0;
  background: linear-gradient(180deg,
    color-mix(in oklab, var(--c) 34%, transparent),
    color-mix(in oklab, var(--c) 14%, transparent));
  border-inline: 1px dashed color-mix(in oklab, var(--c) 60%, transparent);
  transition: left 0.7s cubic-bezier(.4,0,.2,1), width 0.7s cubic-bezier(.4,0,.2,1);
}
.cone-now {
  position: absolute; top: 0; bottom: 0; width: 3px; background: var(--c);
  transition: left 0.7s cubic-bezier(.4,0,.2,1);
}
.cone-now-label {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  background: var(--c); color: #0b0f16; font-weight: 700; font-size: 0.78rem;
  padding: 0.1rem 0.45rem; border-radius: 5px; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.cone-line {
  position: absolute; top: 0; bottom: 0; width: 2px;
  background: repeating-linear-gradient(180deg, var(--ink) 0 5px, transparent 5px 10px);
}
.cone-line span {
  position: absolute; bottom: 6px; left: 6px;
  font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink);
  background: var(--bg-sunken); padding: 0.1rem 0.35rem; border-radius: 4px;
}
.cone-scale {
  display: flex; justify-content: space-between;
  font-size: 0.7rem; color: var(--ink-quiet); margin-top: 0.35rem; font-variant-numeric: tabular-nums;
}
.cone-caption { font-size: 0.83rem; color: var(--ink-quiet); margin-top: 0.9rem; max-width: 70ch; }

.verdict {
  font-size: clamp(1.05rem, 0.95rem + 0.7vw, 1.4rem);
  line-height: 1.4; letter-spacing: -0.01em;
  border-left: 3px solid var(--accent);
  padding-left: 1rem; margin: 1.5rem 0;
  text-wrap: pretty;
}

.whatif {
  border-top: 1px solid var(--line-soft); padding-top: 1.25rem; margin-top: 1.5rem;
  font-size: 0.9rem;
}
.whatif label { display: block; color: var(--ink-dim); margin-bottom: 0.7rem; }
.whatif output { font-family: var(--mono); color: var(--ink); font-weight: 700; }
.whatif-result { margin: 0.8rem 0 0; color: var(--ink); font-size: 0.95rem; }

input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 999px; background: var(--quiet);
}
input[type="range"]::-moz-range-track { height: 6px; border-radius: 999px; background: var(--quiet); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; margin-top: -7px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--c, var(--accent)); border: 2px solid var(--bg-raised);
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.4);
}
input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--bg-raised);
  background: var(--c, var(--accent));
}

/* -------------------------------------------------------------- standings */

/* --- count status ------------------------------------------------------ */

.status-note {
  display: flex; gap: 0.85rem; align-items: flex-start; flex-wrap: wrap;
  border: 1px solid var(--line); border-left-width: 3px;
  border-radius: var(--radius-sm); padding: 0.85rem 1rem;
  margin-bottom: var(--gap); background: var(--bg-raised);
  font-size: 0.88rem;
}
.status-note.is-suspended { border-left-color: var(--down); }
.status-note.is-resumed { border-left-color: var(--up); }
.status-note p { margin: 0; flex: 1 1 18rem; min-width: 0; color: var(--ink-dim); }
.status-note a { color: var(--accent); text-decoration: none; white-space: nowrap; }
.status-badge {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 0.18rem 0.55rem; border-radius: 999px; flex: none;
}
.is-suspended .status-badge { background: color-mix(in oklab, var(--down) 20%, transparent); color: var(--down); }
.is-resumed .status-badge { background: color-mix(in oklab, var(--up) 20%, transparent); color: var(--up); }

.status-timeline { list-style: none; padding: 0; margin: 1.25rem 0 0; }
.st-item {
  display: grid; grid-template-columns: 11rem 1fr; gap: 1rem;
  padding: 1rem 0; border-top: 1px solid var(--line-soft);
  position: relative;
}
.st-item:first-child { border-top: 0; }
.st-when time { font-size: 0.85rem; font-weight: 600; }
.st-what b { display: block; margin-bottom: 0.3rem; }
.st-what p { font-size: 0.88rem; margin: 0 0 0.35rem; }
.st-suspended .st-what b { color: var(--down); }
.st-counting .st-what b { color: var(--up); }
@media (max-width: 640px) { .st-item { grid-template-columns: 1fr; gap: 0.4rem; } }

/* --- question and answer blocks ---------------------------------------- */

.faq { margin: 1rem 0 0; }
.faq dt { font-weight: 650; margin-top: 1.1rem; }
.faq dd { margin: 0.35rem 0 0; color: var(--ink-dim); }

.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.5rem 0 1.5rem; }
.prose .table-scroll { margin-block: 1.25rem; }

/* --- the result, as the top of the page ------------------------------- */

.panel-result {
  background:
    radial-gradient(120% 130% at 0% 0%, color-mix(in oklab, var(--c, var(--accent)) 10%, transparent), transparent 58%),
    var(--bg-raised);
}
.result-head { margin-bottom: 1.4rem; }

.eyebrow {
  font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-quiet); margin-bottom: 0.7rem;
}

.result-title {
  display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap;
  margin: 0 0 0.6rem;
}
.result-share {
  font-size: clamp(3.2rem, 2.2rem + 5vw, 5rem);
  font-weight: 800; letter-spacing: -0.05em; line-height: 0.85;
  color: var(--c); font-variant-numeric: tabular-nums;
}
.result-who { display: flex; flex-direction: column; gap: 0.1rem; }
.result-who b { font-size: clamp(1.1rem, 1rem + 0.7vw, 1.5rem); letter-spacing: -0.02em; }
.result-who small { font-size: 0.82rem; color: var(--ink-quiet); font-weight: 400; }

.result-line {
  font-size: clamp(0.95rem, 0.9rem + 0.4vw, 1.15rem);
  border-left: 3px solid var(--accent); padding-left: 0.9rem;
  margin: 0 0 0.8rem; text-wrap: pretty;
}
.result-head .panel-sub a { color: var(--accent); text-decoration: none; white-space: nowrap; }

.cand-list { display: flex; flex-direction: column; gap: 0.35rem; }

.cand {
  display: grid; align-items: center; gap: 0.5rem 1rem;
  grid-template-columns: 26px minmax(9rem, 1.1fr) minmax(0, 2fr) 6.5rem 5rem 5rem 6rem;
  padding: 0.85rem 0.6rem;
  border-radius: var(--radius-sm);
  border-bottom: 1px solid var(--line-soft);
}
.cand:last-child { border-bottom: 0; }
.cand:hover { background: color-mix(in oklab, var(--c) 6%, transparent); }

.cand-rank { font-family: var(--mono); color: var(--ink-quiet); font-size: 0.85rem; }
.cand-id h3 { font-size: 1rem; }
.cand-id p { margin: 0.1rem 0 0; font-size: 0.8rem; }
.tag {
  font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.08em;
  background: var(--quiet); color: var(--ink-dim); padding: 0.12rem 0.4rem; border-radius: 4px;
  vertical-align: middle; font-weight: 600;
}

.bar-track {
  position: relative; height: 22px; border-radius: 6px;
  background: var(--bg-sunken); overflow: hidden; box-shadow: inset 0 0 0 1px var(--line-soft);
}
.bar-fill {
  position: absolute; inset-block: 0; left: 0;
  background: linear-gradient(90deg, color-mix(in oklab, var(--c) 78%, black 6%), var(--c));
  border-radius: 6px 3px 3px 6px;
  transition: width 0.8s cubic-bezier(.4,0,.2,1);
}
.bar-ceiling {
  position: absolute; inset-block: 0;
  background: repeating-linear-gradient(45deg,
    color-mix(in oklab, var(--c) 22%, transparent) 0 4px, transparent 4px 8px);
  transition: left 0.8s cubic-bezier(.4,0,.2,1), width 0.8s cubic-bezier(.4,0,.2,1);
}
.bar-threshold { position: absolute; inset-block: 0; width: 2px; background: var(--ink); opacity: 0.5; }
.bar-meta { font-size: 0.72rem; margin: 0.3rem 0 0; }

.cand-share { text-align: right; display: flex; flex-direction: column; }
.cand-share b { font-size: 1.15rem; letter-spacing: -0.02em; }
.cand-share small { color: var(--ink-quiet); }

.cand-move, .cand-swing { text-align: right; display: flex; flex-direction: column; }
.cand-move small, .cand-swing small { font-size: 0.68rem; }
.delta { font-family: var(--mono); font-size: 0.86rem; font-weight: 600; }
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }

.cand-spark { display: flex; justify-content: flex-end; }
.sparkline { width: 96px; height: 26px; opacity: 0.85; }

.margin-note { margin: 1.25rem 0 0; font-size: 0.88rem; color: var(--ink-dim); }

.reconcile {
  margin: 0.6rem 0 0; font-size: 0.8rem; color: var(--ink-quiet);
  border-top: 1px dashed var(--line); padding-top: 0.7rem;
}
.reconcile b { color: var(--ink-dim); }

/* the long tail of the ballot */
.more-cands { margin-top: 0.75rem; border-top: 1px solid var(--line-soft); }
.more-cands summary {
  cursor: pointer; padding: 0.85rem 0.6rem; font-size: 0.88rem; color: var(--ink-dim);
  list-style: none; display: flex; align-items: center; gap: 0.5rem; border-radius: var(--radius-sm);
}
.more-cands summary::-webkit-details-marker { display: none; }
.more-cands summary::before {
  content: "▸"; color: var(--ink-quiet); transition: transform 0.2s ease; display: inline-block;
}
.more-cands[open] summary::before { transform: rotate(90deg); }
.more-cands summary:hover { background: var(--bg-sunken); color: var(--ink); }

/* provenance: official vs ahead-of-official */
.provenance {
  display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap;
  font-size: 0.85rem; color: var(--ink-dim);
  border: 1px solid var(--line); border-left-width: 3px;
  border-radius: var(--radius-sm); padding: 0.7rem 0.9rem; margin-bottom: var(--gap);
  background: var(--bg-raised);
}
.provenance.is-official { border-left-color: var(--up); }
.provenance.is-unofficial { border-left-color: var(--accent); }
.prov-badge {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 0.15rem 0.5rem; border-radius: 999px; flex: none;
}
.is-official .prov-badge { background: color-mix(in oklab, var(--up) 22%, transparent); color: var(--up); }
.is-unofficial .prov-badge { background: color-mix(in oklab, var(--accent) 22%, transparent); color: var(--accent); }

/* On a phone the whole point is that the result is the first thing on screen,
   so the masthead shrinks and the rows tighten until the top three fit the fold. */
@media (max-width: 620px) {
  main { padding-block: 1.1rem 3rem; }
  .hero { margin-bottom: 1rem; }
  .hero h1 { font-size: 1.45rem; }
  .hero-sub { font-size: 0.5em; margin-top: 0.4rem; letter-spacing: 0.1em; }
  .hero .lede { font-size: 0.88rem; margin-top: 0.5rem; }
  .panel { padding: 1rem 0.9rem; }
  .result-head { margin-bottom: 1rem; }
  .result-title { gap: 0.7rem; margin-bottom: 0.5rem; }
  .cand { padding: 0.6rem 0.2rem; }
  .cand-id h3 { font-size: 0.95rem; }
  .cand-id p { font-size: 0.72rem; }
  .bar-meta { display: none; }      /* the range is in the panel below */
  .cand-spark { display: none; }    /* trend needs width to mean anything */
  .banner { margin-bottom: 1rem; }
}

@media (max-width: 900px) {
  .cand {
    grid-template-columns: 22px 1fr auto;
    grid-template-areas:
      "rank id share"
      "bar bar bar"
      "move swing spark";
    row-gap: 0.5rem;
  }
  .cand-move, .cand-swing {
    flex-direction: row; align-items: baseline; gap: 0.4rem; white-space: nowrap;
  }
  .cand-rank { grid-area: rank; }
  .cand-id { grid-area: id; }
  .cand-share { grid-area: share; }
  .cand-bar { grid-area: bar; }
  .cand-move { grid-area: move; text-align: left; }
  .cand-swing { grid-area: swing; text-align: center; }
  .cand-spark { grid-area: spark; }
}

/* ------------------------------------------------------------------- map */

.map-wrap {
  position: relative; margin-block: 0.5rem 1rem;
  max-width: 640px; margin-inline: auto;
}

.zmap { display: block; width: 100%; height: auto; overflow: visible; }

/* Fills: each province stroked in its own colour so the hairline gap present
   in the source boundaries between Muchinga and Central cannot show through. */
.mp {
  fill: color-mix(in oklab, var(--c) calc(var(--strength) * 88%), var(--map-empty));
  stroke: color-mix(in oklab, var(--c) calc(var(--strength) * 88%), var(--map-empty));
  stroke-width: 8;
  stroke-linejoin: round;
  transition: fill var(--speed) var(--ease), stroke var(--speed) var(--ease);
}
.mp-quiet { fill: var(--map-empty); stroke: var(--map-empty); }

.mp-edge { fill: none; stroke: var(--map-edge); stroke-width: 2.5; stroke-linejoin: round; }

.mp-hit use { fill: transparent; stroke: transparent; stroke-width: 6; cursor: pointer; }
.mp-hit:hover use, .mp-hit:focus-visible use { stroke: var(--ink); }
.mp-hit:focus-visible { outline: none; }

.map-readout {
  position: absolute; left: 0; bottom: 0;
  background: color-mix(in oklab, var(--bg-raised) 94%, transparent);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem; font-size: 0.82rem; pointer-events: none;
  box-shadow: var(--shadow); max-width: 15rem;
}
.map-readout b { display: block; font-size: 0.95rem; }

.map-legend { display: flex; flex-wrap: wrap; gap: 0.75rem 1.5rem; align-items: center; }
.legend-ramp { display: flex; align-items: center; gap: 0.5rem; font-size: 0.78rem; color: var(--ink-dim); }
.legend-ramp .ramp {
  width: 120px; height: 11px; border-radius: 3px; display: inline-block;
  background: linear-gradient(90deg, var(--heat-1), var(--heat-2), var(--heat-3), var(--heat-4));
}

.map-alt { margin-top: 1.5rem; border-top: 1px solid var(--line-soft); padding-top: 0.5rem; }
.map-alt summary {
  cursor: pointer; padding: 0.7rem 0; font-size: 0.9rem; font-weight: 600;
  list-style: none; display: flex; align-items: center; gap: 0.5rem;
}
.map-alt summary::-webkit-details-marker { display: none; }
.map-alt summary::before { content: "▸"; color: var(--ink-quiet); transition: transform 0.2s var(--ease); }
.map-alt[open] summary::before { transform: rotate(90deg); }
.map-alt .carto { margin-top: 1rem; }

.map-credit { font-size: 0.74rem; margin: 1.25rem 0 0; }

/* ------------------------------------------------------------- cartogram */

.seg {
  display: inline-flex; gap: 2px; padding: 3px; margin-bottom: 1.1rem;
  background: var(--bg-sunken); border: 1px solid var(--line); border-radius: 999px;
}
.seg button {
  border: 0; background: transparent; color: var(--ink-dim); cursor: pointer;
  font: inherit; font-size: 0.82rem; padding: 0.35rem 0.85rem; border-radius: 999px;
}
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

.carto {
  display: grid;
  grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr));
  gap: 6px;
  max-width: 560px;
}
.tile {
  aspect-ratio: 1;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  gap: 0.15rem; padding: 0.4rem; text-align: center; text-decoration: none;
  border-radius: 10px;
  background: color-mix(in oklab, var(--c) calc(var(--strength, 0) * 82%), var(--bg-sunken));
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink);
  transition: transform 0.18s ease, background 0.6s ease;
}
.tile:hover { transform: translateY(-2px) scale(1.02); z-index: 2; }
.tile-empty { background: transparent; box-shadow: none; }
.tile-quiet { color: var(--ink-quiet); }
.tile-name { font-size: 0.72rem; font-weight: 600; line-height: 1.15; letter-spacing: -0.01em; }
.tile-val { font-size: 1.05rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.tile-quiet .tile-val { font-size: 0.68rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; }
.tile-sub { font-size: 0.62rem; color: color-mix(in oklab, currentColor 65%, transparent); }

.legend { display: flex; flex-wrap: wrap; gap: 0.5rem 1.1rem; list-style: none; padding: 0; margin: 1.2rem 0 0; font-size: 0.8rem; color: var(--ink-dim); }
.legend li { display: flex; align-items: center; gap: 0.4rem; }
.legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.legend i.quiet { background: var(--quiet); }

/* ----------------------------------------------------------------- board */

.chips {
  list-style: none; padding: 0; margin: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(14px, 1fr)); gap: 4px;
}
.chip {
  aspect-ratio: 1; border-radius: 3px; background: var(--quiet); opacity: 0.55;
}
.chip-on {
  background: var(--c); opacity: 1;
  animation: chipIn 0.5s cubic-bezier(.2,.9,.3,1.2) backwards;
}
.chip-on span { display: none; }
@keyframes chipIn { from { transform: scale(0.2); opacity: 0; } }
.chips-meta { font-size: 0.85rem; color: var(--ink-dim); margin: 1.1rem 0 0; }

/* ---------------------------------------------------------------- charts */

.chart-wrap { width: 100%; overflow-x: auto; }
.chart { width: 100%; height: clamp(240px, 34vw, 340px); display: block; }
.chart .grid { stroke: var(--line-soft); stroke-width: 1; }
.chart .axis { fill: var(--ink-quiet); font-size: 11px; font-family: var(--mono); }
.chart .axis-title { fill: var(--ink-quiet); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; }
.chart .series { stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .threshold-line { stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 6 5; opacity: 0.55; }
.chart .threshold-label { fill: var(--ink-dim); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; }

.replay-controls {
  display: flex; align-items: center; gap: 1rem; margin-top: 1.25rem;
  flex-wrap: wrap;
}
.replay-controls input[type="range"] { flex: 1 1 200px; --c: var(--accent); }
.replay-controls button {
  border: 1px solid var(--line); background: var(--bg-sunken); color: var(--ink);
  font: inherit; font-size: 0.85rem; padding: 0.4rem 0.9rem; border-radius: 999px; cursor: pointer;
}
.replay-controls button:hover { border-color: var(--accent); color: var(--accent); }
.replay-controls output { font-family: var(--mono); font-size: 0.8rem; color: var(--ink-dim); min-width: 13ch; }

.replay-readout {
  list-style: none; padding: 0; margin: 1rem 0 0;
  display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; font-size: 0.85rem;
}
.replay-readout li { display: flex; align-items: baseline; gap: 0.45rem; }
.replay-readout li::before { content: ""; width: 9px; height: 9px; border-radius: 2px; background: var(--c); }
.replay-readout b { font-family: var(--mono); }

/* ------------------------------------------------------------------- log */

.log { list-style: none; padding: 0; margin: 0; }
.log-item {
  display: grid; grid-template-columns: 12rem 1fr; gap: 1.25rem;
  padding: 1.1rem 0; border-top: 1px solid var(--line-soft);
}
.log-item:first-child { border-top: 0; padding-top: 0; }
.log-when { display: flex; flex-direction: column; gap: 0.15rem; }
.log-when time { font-size: 0.88rem; font-weight: 600; }
.log-when small { color: var(--ink-quiet); font-size: 0.75rem; letter-spacing: 0.05em; text-transform: uppercase; }
.log-what p { margin: 0 0 0.4rem; font-size: 0.9rem; }
.log-moves { list-style: none; display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; padding: 0; margin: 0.5rem 0 0; font-size: 0.82rem; }
.log-moves li { display: flex; align-items: center; gap: 0.35rem; color: var(--ink-dim); }
.log-moves li::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--c); }
.log-note { color: var(--ink-quiet); font-style: italic; font-size: 0.85rem; }
.more { font-size: 0.88rem; }

@media (max-width: 640px) {
  .log-item { grid-template-columns: 1fr; gap: 0.5rem; }
}

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

.table-scroll { overflow-x: auto; margin-inline: -0.5rem; padding-inline: 0.5rem; }
.grid-table { border-collapse: collapse; width: 100%; font-size: 0.88rem; min-width: 560px; }
.grid-table th, .grid-table td { padding: 0.6rem 0.7rem; text-align: left; border-bottom: 1px solid var(--line-soft); }
.grid-table thead th {
  font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-quiet);
  font-weight: 600; border-bottom-color: var(--line); white-space: nowrap;
}
.grid-table tbody th a { text-decoration: none; font-weight: 600; }
.grid-table tbody th a:hover { color: var(--accent); }
.numcell { text-align: right; font-variant-numeric: tabular-nums; }
.numcell.lead { font-weight: 700; color: var(--ink); }
.row-quiet { color: var(--ink-quiet); }
.grid-table tbody tr:hover { background: var(--bg-sunken); }

/* ----------------------------------------------------------------- prose */

.prose { max-width: 68ch; }
.prose h1 { font-size: clamp(1.7rem, 1.2rem + 2vw, 2.5rem); margin-bottom: 1rem; }
.prose h2 { font-size: 1.2rem; margin: 2.2rem 0 0.7rem; }
.prose ul { padding-left: 1.2rem; }
.prose li { margin-bottom: 0.5rem; }
.prose a { color: var(--accent); }

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

.site-foot { border-top: 1px solid var(--line); background: var(--bg-sunken); padding-block: 2.5rem; }
.foot-inner { display: flex; flex-wrap: wrap; gap: 2rem; justify-content: space-between; }
.foot-inner > div:first-child { max-width: 46ch; }
.foot-title { font-weight: 650; margin-bottom: 0.3rem; }
.site-foot p { font-size: 0.85rem; }
.foot-links { display: flex; flex-direction: column; gap: 0.4rem; font-size: 0.85rem; }
.foot-links a { color: var(--ink-dim); text-decoration: none; }
.foot-links a:hover { color: var(--accent); }

/* "Also from eLucive" — footer only, deliberately quiet. A live national count
   is not an ad slot, so this sits below the fold and never beside a number. */
.also { border-top: 1px solid var(--line-soft); margin-top: 2rem; padding-top: 1.5rem; }
.also-label {
  font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-quiet); margin-bottom: 0.85rem;
}
.also-list {
  list-style: none; padding: 0; margin: 0;
  display: grid; gap: 0.5rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
}
.also-list a {
  display: flex; flex-direction: column; gap: 0.15rem;
  padding: 0.7rem 0.85rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
  text-decoration: none; background: var(--bg-raised);
  min-height: var(--tap); justify-content: center;
  transition: border-color 0.2s var(--ease);
}
.also-list a:hover { border-color: var(--accent); }
.also-list strong { font-size: 0.88rem; }
.also-list span { font-size: 0.76rem; color: var(--ink-quiet); }

/* --------------------------------------------------------------- toast */

.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 140%);
  background: var(--accent); color: var(--accent-ink);
  padding: 0.7rem 1.2rem; border-radius: 999px; font-size: 0.88rem; font-weight: 600;
  box-shadow: 0 12px 34px -12px rgb(0 0 0 / 0.6); z-index: 50;
  transition: transform 0.45s cubic-bezier(.2,.9,.3,1.2);
  display: flex; align-items: center; gap: 0.6rem;
}
.toast.show { transform: translate(-50%, 0); }
.toast button {
  border: 0; background: color-mix(in oklab, var(--accent-ink) 18%, transparent);
  color: inherit; font: inherit; font-weight: 700; cursor: pointer;
  padding: 0.15rem 0.6rem; border-radius: 999px;
}

/* Flash a number that just changed. */
@keyframes flash {
  from { background: color-mix(in oklab, var(--accent) 45%, transparent); }
  to { background: transparent; }
}
.just-changed { animation: flash 1.6s ease-out; border-radius: 4px; }

@media print {
  .site-head, .site-foot, .seg, .replay-controls, .theme-toggle, .toast { display: none !important; }
  .panel { break-inside: avoid; border-color: #ccc; box-shadow: none; }
}
