/* NigeriaAnalytics — public election site.
 *
 * Institutional register: near-black ink, disciplined green brand accent,
 * a full-bleed ink hero band that carries the headline figures, sans-led
 * display type with real weight contrast, FT-style data tables.
 *
 * Still no webfont, no framework, no build step. This page arrives on phones
 * over Nigerian mobile networks; a 40KB display face would be paid for by
 * every one of those readers. Segoe UI Variable / SF / Roboto at weight 800
 * with tight tracking carries the display work instead, and the identity is
 * carried by layout, the green, and the ink band — not by a font file.
 */

:root {
  --paper:      #ffffff;
  --paper-2:    #f5f6f7;
  --ink:        #0b0d10;
  --ink-2:      #3f4750;
  --ink-3:      #707a85;
  --rule:       #d8dde2;
  --rule-2:     #e9edf0;

  /* Brand green — deep, institutional, and not a party colour on our maps. */
  --accent:     #0a7d4d;
  --accent-ink: #06552f;

  --flag:       #b45309;
  --flag-bg:    #fdf6ec;
  --note-bg:    #f0f4fb;

  /* The ink band. */
  --hero-bg:     #0b0d10;
  --hero-ink:    #f7f8f9;
  --hero-muted:  #9aa4ae;
  --hero-rule:   #262b31;
  --hero-accent: #35b37e;
  --hero-flag:   #f0b169;

  --sans: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system,
          "Helvetica Neue", Roboto, sans-serif;
  --serif: ui-serif, Georgia, "Iowan Old Style", serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, monospace;

  --measure: 36rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:      #0c0e11;
    --paper-2:    #15181c;
    --ink:        #f2f4f6;
    --ink-2:      #b6bec7;
    --ink-3:      #7e8791;
    --rule:       #2b3138;
    --rule-2:     #1e2328;

    --accent:     #35b37e;
    --accent-ink: #6fd2a6;

    --flag:       #f0b169;
    --flag-bg:    #211a0e;
    --note-bg:    #121a26;

    --hero-bg:     #10141a;
    --hero-ink:    #f7f8f9;
    --hero-muted:  #96a0ab;
    --hero-rule:   #272e36;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
html, body { overflow-x: clip; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--accent); color: #fff; }

.wrap { max-width: 46rem; margin: 0 auto; padding: 0 1.25rem 6rem; }

/* ── masthead: sticky, quiet, always present ── */
.masthead {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: .4rem 1rem;
  margin: 0 calc(50% - 50vw); padding: .85rem max(1.25rem, calc(50vw - 21.75rem));
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}
.wordmark {
  display: inline-flex; align-items: center; gap: .55rem;
  font-weight: 800; font-size: .95rem; letter-spacing: -0.01em;
  color: var(--ink); text-decoration: none; white-space: nowrap;
}
.wordmark::before {
  content: ""; width: 11px; height: 11px; background: var(--accent);
  display: inline-block; border-radius: 2px;
}
.masthead nav { font-size: .82rem; font-weight: 600; letter-spacing: .01em; }
.masthead nav a {
  color: var(--ink-3); text-decoration: none; margin-left: 1.15rem;
  padding-bottom: .2rem; border-bottom: 2px solid transparent;
}
.masthead nav a:hover { color: var(--ink); }
.masthead nav a[aria-current] { color: var(--ink); border-bottom-color: var(--accent); }

/* ── the ink band: every page opens under it ── */
.hero {
  margin: 0 calc(50% - 50vw) 2.6rem;
  background: var(--hero-bg);
  color: var(--hero-ink);
}
.hero-in {
  max-width: 46rem; margin: 0 auto;
  padding: 3.4rem 1.25rem 3rem;
}
header.lede { margin: 0; }

.kicker {
  font-size: .72rem; font-weight: 800; letter-spacing: .18em;
  text-transform: uppercase; color: var(--hero-accent); margin: 0 0 1rem;
}

h1 {
  font-size: clamp(2.4rem, 7.5vw, 4rem);
  line-height: 1.02;
  letter-spacing: -0.035em;
  font-weight: 800;
  margin: 0 0 .9rem;
  text-wrap: balance;
}
.hero h1 { color: var(--hero-ink); }

.standfirst {
  font-family: var(--serif);
  font-size: 1.18rem; line-height: 1.55; color: var(--hero-muted);
  margin: 0; max-width: var(--measure); text-wrap: pretty;
}

/* headline figures inside the band */
.hero .figures {
  display: flex; flex-wrap: wrap; gap: 0;
  margin: 2.4rem 0 0; padding-top: 1.6rem;
  border-top: 1px solid var(--hero-rule);
}
.hero .figure {
  flex: 1 1 9rem; min-width: 8.5rem; padding: 0 1.4rem;
  border-left: 1px solid var(--hero-rule);
}
.hero .figure:first-child { padding-left: 0; border-left: 0; }
.hero .figure .n { color: var(--hero-ink); }
.hero .figure .n.flagged { color: var(--hero-flag); }
.hero .figure .l { color: var(--hero-muted); }
.hero .hint { color: var(--hero-muted); margin-top: 1.5rem; }

/* figures outside the band (detail views) */
.figures { display: flex; flex-wrap: wrap; gap: 2.2rem; margin: 1.5rem 0 .4rem; }
.figure { min-width: 7rem; }
.figure .n {
  display: block; font-size: clamp(2rem, 6vw, 2.9rem); line-height: 1;
  font-weight: 800; letter-spacing: -0.04em; font-variant-numeric: tabular-nums;
}
.figure .n.flagged { color: var(--flag); }
.figure .l {
  display: block; font-size: .72rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3);
  margin-top: .55rem; max-width: 11rem; line-height: 1.4;
}

/* ── content structure ── */
h2 {
  font-size: 1.45rem; line-height: 1.15; letter-spacing: -0.02em;
  font-weight: 800; margin: 0 0 .35rem; text-wrap: balance;
}
h3 { font-size: 1.05rem; font-weight: 700; margin: 0 0 .3rem; letter-spacing: -0.01em; }

p { max-width: var(--measure); text-wrap: pretty; }

section {
  border-top: 1px solid var(--rule);
  padding-top: 2rem;
  margin-top: 2.6rem;
}
section.plain { border-top: 0; padding-top: 0; margin-top: 2rem; }

.section-label {
  font-size: .7rem; font-weight: 800; letter-spacing: .18em;
  text-transform: uppercase; color: var(--accent);
  margin: 0 0 1.1rem;
}

/* ── controls ── */
.controls { display: flex; flex-wrap: wrap; gap: 1.1rem; margin: 1.4rem 0 0; }
.control { flex: 1 1 12rem; min-width: 0; }
label {
  display: block; font-size: .68rem; font-weight: 800;
  letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3);
  margin-bottom: .5rem;
}
select, input {
  width: 100%; padding: .78rem .9rem; font-family: var(--sans); font-size: 1rem;
  color: var(--ink); background: var(--paper);
  border: 1.5px solid var(--rule); border-radius: 6px;
  transition: border-color .12s, box-shadow .12s;
}
input[type="search"] { font-size: 1.05rem; }
select:hover, input:hover { border-color: var(--ink-3); }
select:focus, input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.hint { font-size: .84rem; color: var(--ink-3); margin: .6rem 0 0; max-width: var(--measure); }

/* ── search results ── */
ul.results { list-style: none; margin: 1.1rem 0 0; padding: 0; }
ul.results li + li { border-top: 1px solid var(--rule-2); }
ul.results button {
  width: 100%; text-align: left; background: none; border: 0; color: inherit;
  padding: .85rem .6rem .85rem .8rem; font: inherit; cursor: pointer; display: block;
  border-left: 3px solid transparent;
  transition: background .1s, border-color .1s;
}
ul.results button:hover, ul.results button:focus-visible {
  background: var(--paper-2); border-left-color: var(--accent);
}
.pu-name { font-weight: 700; letter-spacing: -0.01em; }
.pu-meta { font-size: .8rem; color: var(--ink-3); margin: .15rem 0 0; font-variant-numeric: tabular-nums; }

/* ── data tables: heavy top rule, hairline rows ── */
table { width: 100%; border-collapse: collapse; margin-top: 1.1rem; font-size: .95rem; }
th {
  font-size: .66rem; font-weight: 800; letter-spacing: .13em;
  text-transform: uppercase; color: var(--ink-3);
  text-align: left; padding: 0 .5rem .55rem 0;
  border-bottom: 2px solid var(--ink);
}
td { padding: .62rem .5rem .62rem 0; border-bottom: 1px solid var(--rule-2); vertical-align: top; }
td.num, th.num { text-align: right; padding-right: 0; font-variant-numeric: tabular-nums; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--paper-2); }
td.neg { color: #c2410c; font-weight: 600; }
td.pos { color: var(--accent); font-weight: 600; }
@media (prefers-color-scheme: dark) {
  td.neg { color: #fda874; }
}

.bar { height: 8px; border-radius: 2px; min-width: 3px; margin-top: .4rem; }
.swatch {
  display: inline-block; width: 10px; height: 10px; border-radius: 3px;
  margin-right: .55rem; vertical-align: baseline;
}

/* ── caveats: labelled marginal notes ── */
.note, .warn {
  font-size: .88rem; line-height: 1.55;
  padding: 1rem 1.1rem; margin: 1.2rem 0 0;
  border-left: 3px solid var(--rule); border-radius: 0 6px 6px 0;
  background: var(--note-bg); color: var(--ink-2);
  max-width: var(--measure);
}
.warn { border-left-color: var(--flag); background: var(--flag-bg); }
.note strong, .warn strong { color: var(--ink); }

/* ── stat rows ── */
.stat {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: .55rem 0; border-bottom: 1px solid var(--rule-2);
  font-size: .95rem;
}
.stat span:last-child { font-variant-numeric: tabular-nums; font-weight: 700; }

/* ── links & buttons ── */
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-ink); }
.back {
  background: none; border: 0; padding: 0; cursor: pointer;
  font-family: var(--sans); font-size: .8rem; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; color: var(--accent);
}
.back:hover { color: var(--accent-ink); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── waterfall ── */
.wf-track { position: relative; height: 12px; background: var(--paper-2); border-radius: 2px; }
.wf-track::after { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--rule); }
.wf-bar { position: absolute; top: 1px; bottom: 1px; border-radius: 1px; }
.wf-bar.gain { background: var(--accent); }
.wf-bar.loss { background: #c2410c; }
@media (prefers-color-scheme: dark) {
  .wf-bar.loss { background: #fb923c; }
}

/* ── map ── */
svg.map { width: 100%; height: auto; display: block; margin-top: 1.3rem; }
svg.map path { transition: opacity .12s; }
svg.map path:hover { opacity: .72; }
.legend {
  display: flex; flex-wrap: wrap; gap: 1.1rem; margin-top: 1.1rem;
  align-items: center; font-size: .82rem; color: var(--ink-2);
}
.legend .key { display: inline-flex; align-items: center; font-weight: 600; }

/* ── details ── */
details { border-bottom: 1px solid var(--rule-2); padding: .85rem 0; }
details summary { cursor: pointer; font-weight: 700; }
details summary::marker { color: var(--accent); }

/* ── footer ── */
footer {
  margin-top: 4.5rem; padding-top: 1.5rem; border-top: 2px solid var(--ink);
  font-size: .8rem; color: var(--ink-3);
}
footer p { max-width: none; margin: .5rem 0; }
footer a { color: var(--ink-2); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

[hidden] { display: none !important; }

/* ── results explorer (results.html) ── */
.crumbs {
  font-size: .82rem; font-weight: 600; margin: 1.6rem 0 0;
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: center;
}
.crumbs a { text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumbs span:not(.crumb-sep) { color: var(--ink-2); }
.crumb-sep { color: var(--ink-3); }

.view { animation: viewin .22s ease; }
@keyframes viewin { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

svg.clickable-map path { cursor: pointer; }
svg.clickable-map path:focus-visible { outline: none; stroke: var(--accent); stroke-width: 2.5; }

/* published-vs-declared dual bars: declared is the grey extent underneath,
   ours the solid colour laid over it — the gap is visible, not computed */
.dualset { margin-top: .6rem; }
.dualrow { padding: .55rem 0; border-bottom: 1px solid var(--rule-2); }
.duallabel {
  display: flex; justify-content: space-between; gap: 1rem;
  font-size: .92rem; margin-bottom: .4rem;
}
.dualnums { font-variant-numeric: tabular-nums; }
.dualtrack { position: relative; height: 14px; background: var(--paper-2); border-radius: 3px; }
.dualdeclared {
  position: absolute; top: 0; bottom: 0; left: 0;
  background: color-mix(in srgb, var(--ink) 14%, transparent);
  border-right: 2px solid var(--ink-3); border-radius: 3px 0 0 3px;
}
.dualours {
  position: absolute; top: 3px; bottom: 3px; left: 0; border-radius: 2px;
  transition: width .5s cubic-bezier(.2,.7,.3,1);
}
.duallegend {
  display: flex; flex-wrap: wrap; gap: 1.2rem; margin-top: .8rem;
  font-size: .78rem; color: var(--ink-2);
}
.duallegend .key { display: inline-flex; align-items: center; gap: .45rem; }
.chip { display: inline-block; width: 14px; height: 9px; border-radius: 2px; }
.chip-ours { background: var(--accent); }
.chip-declared { background: color-mix(in srgb, var(--ink) 14%, transparent); border-right: 2px solid var(--ink-3); }
