/* Live desk on the atlas-map system: Haust paper, EB Garamond for geography,
   Roboto Condensed for figures, a neatline round the map. Rowan = Lula, glacial = Bolsonaro,
   as on the Two Brazils plate. */
:root {
  --paper: #F6F8FA;
  --land: #F1ECDA;
  --water: #C6DCDF;
  --fissure: #1F1D18;
  --basalt: #3E3B34;
  --lichen: #6B6156;
  --rowan: #B95A1F;
  --silfra: #405664;
  --chart-grid: #C9D4DE;
  --lula: #B95A1F;
  --lula-soft: #EEBE94;
  --bols: #2F6B73;
  --bols-soft: #7BBAC0;
  --serif: 'EB Garamond', 'Hoefler Text', Garamond, Georgia, serif;
  --cond: 'Roboto Condensed', 'Avenir Next Condensed', 'Arial Narrow', sans-serif;
  --panel-w: 420px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--paper); color: var(--fissure); font-family: var(--serif); -webkit-font-smoothing: antialiased; }
a { color: var(--bols); }
a:hover { color: var(--rowan); }

.am { display: flex; height: 100vh; height: 100dvh; }
.am-panel {
  width: var(--panel-w); flex: 0 0 var(--panel-w);
  overflow-y: auto; overscroll-behavior: contain;
  padding: 18px 26px 32px;
  border-right: 1px solid var(--silfra);
  box-shadow: 3px 0 0 -2px var(--rowan);
  background: var(--paper); position: relative; z-index: 2;
}
.am-map-wrap { position: relative; flex: 1 1 auto; min-width: 0; }
#map { position: absolute; inset: 0; background: var(--water); }
.am-neat {
  position: absolute; inset: 10px; pointer-events: none; z-index: 1;
  border: 1px solid var(--silfra);
  box-shadow: inset 0 0 0 3px rgba(246, 248, 250, 0.55), inset 0 0 0 4px var(--rowan);
}

.am-top {
  display: flex; justify-content: space-between; align-items: baseline;
  padding-bottom: 10px; margin-bottom: 18px; border-bottom: 1px solid var(--fissure);
  font-family: var(--cond); font-size: 0.78rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--basalt);
}
.am-logo { font-family: var(--serif); font-size: 1.15rem; letter-spacing: 0.02em; text-transform: none; font-weight: 600; color: var(--fissure); }
.am-logo span { color: var(--rowan); }
.am-kicker {
  font-family: var(--cond); font-weight: 600; font-size: 0.74rem;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--rowan);
  display: flex; align-items: center; gap: 7px;
}
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--rowan); animation: pulse 2s ease-in-out infinite; }
.is-final .live-dot { animation: none; background: var(--fissure); }
.is-stale .live-dot { animation: none; background: var(--lichen); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }
.am-panel h1 { font-family: var(--serif); font-weight: 400; font-size: 2.3rem; line-height: 1.04; margin: 6px 0 4px; }
.am-dates { font-style: italic; color: var(--basalt); margin: 0 0 16px; font-size: 1.05rem; }

/* ---------- scoreboard ---------- */
.score { margin: 0 0 22px; }
.score-row { display: flex; justify-content: space-between; gap: 16px; }
.cand { flex: 1; }
.cand.bols { text-align: right; }
.cand-name { font-family: var(--serif); font-size: 1.3rem; line-height: 1.1; }
.cand-party { font-family: var(--cond); font-size: 0.72rem; letter-spacing: 0.12em; color: var(--lichen); text-transform: uppercase; }
.cand-pct { font-family: var(--cond); font-weight: 700; font-size: 2.6rem; line-height: 1.05; margin-top: 4px; font-variant-numeric: tabular-nums; }
.cand.lula .cand-pct { color: var(--lula); }
.cand.bols .cand-pct { color: var(--bols); }
.cand-votes { font-family: var(--cond); font-size: 0.9rem; color: var(--basalt); font-variant-numeric: tabular-nums; }
.cand.lead .cand-name::after { content: " ✓"; font-family: var(--cond); font-size: 0.85rem; color: var(--fissure); }
.cand.lead.bols .cand-name::after { content: ""; }
.cand.lead.bols .cand-name::before { content: "✓ "; font-family: var(--cond); font-size: 0.85rem; }
.bar { position: relative; display: flex; height: 22px; margin-top: 10px; background: var(--land); border: 1px solid var(--fissure); }
.bar-l { background: var(--lula); width: 0; transition: width 0.8s ease; }
.bar-b { background: var(--bols); width: 0; margin-left: auto; transition: width 0.8s ease; }
.bar-half { position: absolute; left: 50%; top: -5px; bottom: -5px; width: 0; border-left: 1.5px solid var(--fissure); }
.bar-half-label { text-align: center; font-family: var(--cond); font-size: 0.7rem; color: var(--basalt); margin-top: 3px; }
.counted { margin-top: 12px; }
.counted-track { height: 5px; background: var(--chart-grid); }
.counted-fill { height: 100%; width: 0; background: var(--fissure); transition: width 0.8s ease; }
.counted-text { font-family: var(--cond); font-size: 0.88rem; color: var(--basalt); margin-top: 5px; }
.counted-text strong { color: var(--fissure); font-variant-numeric: tabular-nums; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin: 12px 0 0; border-top: 1px solid var(--chart-grid); border-bottom: 1px solid var(--chart-grid); }
.facts div { padding: 7px 0; }
.facts div + div { padding-left: 10px; border-left: 1px solid var(--chart-grid); }
.facts dt { font-family: var(--cond); font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--lichen); }
.facts dd { margin: 2px 0 0; font-family: var(--cond); font-weight: 600; font-size: 0.98rem; font-variant-numeric: tabular-nums; }
.stamp { font-family: var(--cond); font-size: 0.78rem; color: var(--lichen); margin: 8px 0 0; }
.stamp.err { color: var(--rowan); }

/* ---------- sections ---------- */
.am-h2 {
  font-family: var(--cond); font-weight: 700; font-size: 0.82rem; letter-spacing: 0.14em; text-transform: uppercase;
  margin: 0 0 8px; padding-top: 12px; border-top: 1px solid var(--fissure);
  display: flex; justify-content: space-between; align-items: baseline;
}
.h2-note { font-weight: 400; letter-spacing: 0.02em; text-transform: none; color: var(--lichen); font-size: 0.78rem; }
.am-modes { display: flex; margin: 0 0 10px; border: 1px solid var(--silfra); }
.am-mode {
  flex: 1; padding: 8px 6px; border: 0; background: transparent; cursor: pointer;
  font-family: var(--cond); font-weight: 600; font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--silfra);
}
.am-mode + .am-mode { border-left: 1px solid var(--silfra); }
.am-mode.is-active { background: var(--fissure); color: var(--paper); }
.am-caption { font-family: var(--cond); font-size: 0.86rem; line-height: 1.45; color: var(--basalt); margin: 4px 0 12px; }
.am-legend { margin: 0 0 22px; padding: 12px 14px; background: #FBFBF8; border: 1px solid var(--fissure); }
.leg-title { font-family: var(--cond); font-weight: 700; font-size: 0.8rem; margin: 0 0 6px; }
.leg-ramp { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0; }
.leg-ramp span { height: 14px; border: 0.5px solid var(--basalt); }
.leg-ramp span + span { border-left: 0; }
.leg-ends { display: flex; justify-content: space-between; font-family: var(--cond); font-size: 0.76rem; color: var(--basalt); margin-top: 4px; }
.leg-ticks { display: grid; grid-template-columns: repeat(6, 1fr); font-family: var(--cond); font-size: 0.7rem; color: var(--lichen); text-align: center; margin-top: 2px; }
.leg-extra { display: flex; gap: 14px; margin-top: 8px; font-family: var(--cond); font-size: 0.78rem; color: var(--basalt); flex-wrap: wrap; }
.leg-extra i { display: inline-block; width: 18px; height: 11px; border: 0.5px solid var(--basalt); vertical-align: -1px; margin-right: 5px; }
.leg-note { font-family: var(--cond); font-style: italic; font-size: 0.72rem; color: var(--lichen); margin: 6px 0 0; }

.chart { margin: 0 0 22px; }
.chart svg { display: block; width: 100%; height: auto; }
.chart text { font-family: var(--cond); font-size: 10.5px; fill: var(--basalt); }
.chart .empty { font-family: var(--cond); font-size: 0.82rem; color: var(--lichen); font-style: italic; }

.regions { margin: 0 0 22px; font-family: var(--cond); }
.reg { display: grid; grid-template-columns: 92px 1fr 70px; align-items: center; gap: 8px; font-size: 0.84rem; padding: 3px 0; }
.reg-track { position: relative; height: 14px; }
.reg-track::before { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; border-left: 1px solid var(--fissure); }
.reg-bar { position: absolute; top: 0; bottom: 0; transition: all 0.8s ease; }
.reg-val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

table.states { width: 100%; border-collapse: collapse; font-family: var(--cond); font-size: 0.82rem; margin: 0 0 22px; font-variant-numeric: tabular-nums; }
.states th { text-align: left; font-weight: 600; font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--lichen); padding: 0 4px 4px; border-bottom: 1px solid var(--fissure); }
.states td { padding: 4px; border-bottom: 1px solid #E3E8EC; }
.states .r { text-align: right; }
.states tr { cursor: pointer; }
.states tbody tr:hover { background: #EEF1F3; }
.states .uf { font-weight: 700; }
.states .nm { color: var(--lichen); font-size: 0.74rem; }
.states .lead-l { color: var(--lula); font-weight: 700; }
.states .lead-b { color: var(--bols); font-weight: 700; }
.mbar { position: relative; width: 70px; height: 10px; }
.mbar::before { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; border-left: 1px solid var(--basalt); }
.mbar i { position: absolute; top: 0; bottom: 0; }
.cnt { display: inline-block; width: 34px; height: 4px; background: var(--chart-grid); vertical-align: middle; margin-right: 4px; }
.cnt i { display: block; height: 100%; background: var(--fissure); }

.gov { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 0 0 22px; }
.gv { padding: 8px 10px; background: #FBFBF8; border: 1px solid var(--chart-grid); font-family: var(--cond); }
.gv-head { display: flex; justify-content: space-between; font-size: 0.78rem; color: var(--lichen); }
.gv-head strong { color: var(--fissure); font-size: 0.86rem; letter-spacing: 0.04em; }
.gv-row { display: grid; grid-template-columns: 1fr 52px; gap: 6px; align-items: center; font-size: 0.86rem; margin-top: 4px; }
.gv-row .nm small { color: var(--lichen); }
.gv-row .p { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.gv-track { grid-column: 1 / -1; height: 5px; background: var(--chart-grid); }
.gv-track i { display: block; height: 100%; background: var(--fissure); transition: width 0.8s ease; }
.gv-row.win .nm { font-weight: 700; }

.am-sources { font-family: var(--cond); font-size: 0.78rem; line-height: 1.5; color: var(--basalt); }
.am-imprint { font-family: var(--serif); font-style: italic; font-size: 0.85rem; color: var(--lichen); margin-top: 10px; }

/* ---------- map bits ---------- */
.am-tip {
  position: absolute; z-index: 3; pointer-events: none; max-width: 260px;
  background: #FBFBF8; border: 1px solid var(--fissure); padding: 8px 10px;
  font-family: var(--cond); font-size: 0.82rem; line-height: 1.35; box-shadow: 2px 2px 0 rgba(31, 29, 24, 0.15);
}
.am-tip h3 { margin: 0 0 4px; font-family: var(--serif); font-weight: 600; font-size: 1.02rem; }
.am-tip h3 small { font-family: var(--cond); font-weight: 400; color: var(--lichen); font-size: 0.75rem; letter-spacing: 0.06em; }
.am-tip table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.am-tip td { padding: 1px 0; }
.am-tip td + td { text-align: right; padding-left: 8px; }
.am-tip .sw { display: inline-block; width: 9px; height: 9px; margin-right: 5px; }
.am-tip .sub { color: var(--lichen); font-size: 0.76rem; margin-top: 4px; }
.maplibregl-ctrl-group { border-radius: 0 !important; border: 1px solid var(--fissure); box-shadow: none !important; }
.maplibregl-ctrl-top-right { top: 16px; right: 16px; }

@media (max-width: 820px) {
  .am { flex-direction: column-reverse; height: auto; }
  .am-panel { width: 100%; flex: none; border-right: 0; box-shadow: none; border-top: 1px solid var(--silfra); padding: 16px 16px 28px; overflow: visible; }
  .am-map-wrap { height: 62vh; flex: none; }
  .cand-pct { font-size: 2.2rem; }
}

/* ---------- live: dumps, banner, pulses ---------- */
.next { height: 2px; background: transparent; margin-top: 6px; overflow: hidden; }
.next i { display: block; height: 100%; width: 0; background: var(--rowan); opacity: 0.6; }
.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0% { background: #F3D9B8; } 100% { background: transparent; } }
.cand-delta { font-family: var(--cond); font-weight: 700; font-size: 0.86rem; height: 1.1em; opacity: 0; transition: opacity 0.4s; font-variant-numeric: tabular-nums; }
.cand-delta.on { opacity: 1; }
.cand.lula .cand-delta { color: var(--lula); }
.cand.bols .cand-delta { color: var(--bols); }

.dumps { list-style: none; margin: 0 0 22px; padding: 0; font-family: var(--cond); font-size: 0.84rem; max-height: 420px; overflow-y: auto; border-top: 1px solid var(--chart-grid); }
.dumps li { display: grid; grid-template-columns: 44px 1fr auto; gap: 2px 10px; padding: 7px 2px; border-bottom: 1px solid #E3E8EC; align-items: baseline; }
.dumps li.new { animation: slidein 0.6s ease-out, flash 2.4s ease-out; }
@keyframes slidein { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }
.dumps .tm { color: var(--lichen); font-variant-numeric: tabular-nums; }
.dumps .gains { font-variant-numeric: tabular-nums; }
.dumps .gains b { font-weight: 600; }
.dumps .gl { color: var(--lula); }
.dumps .gb { color: var(--bols); }
.dumps .net { font-weight: 700; padding: 1px 6px; color: var(--paper); font-variant-numeric: tabular-nums; white-space: nowrap; }
.dumps .sub { grid-column: 2 / -1; color: var(--lichen); font-size: 0.74rem; display: flex; flex-wrap: wrap; gap: 4px 8px; }
.dumps .tag { white-space: nowrap; }
.dumps .tag b { color: var(--fissure); font-weight: 600; }
.dumps .empty { display: block; color: var(--lichen); font-style: italic; border: 0; }

.banner {
  position: absolute; z-index: 3; left: 26px; top: 26px; max-width: min(440px, calc(100% - 100px));
  background: var(--fissure); color: var(--paper); padding: 10px 14px 11px;
  font-family: var(--cond); box-shadow: 3px 3px 0 rgba(185, 90, 31, 0.6);
  transition: opacity 0.6s, transform 0.6s;
}
.banner.out { opacity: 0; transform: translateY(-6px); }
.banner .k { font-size: 0.68rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--lula-soft); display: flex; gap: 8px; align-items: center; }
.banner .k i { width: 7px; height: 7px; border-radius: 50%; background: var(--lula-soft); animation: pulse 1s ease-in-out infinite; }
.banner .row { display: flex; gap: 14px; margin-top: 4px; font-size: 1.02rem; font-variant-numeric: tabular-nums; flex-wrap: wrap; }
.banner .row .l { color: var(--lula-soft); }
.banner .row .b { color: var(--bols-soft); }
.banner .netline { font-size: 1.35rem; font-weight: 700; margin-top: 2px; }
.fresh-note {
  position: absolute; z-index: 3; left: 26px; bottom: 26px; background: #FBFBF8; border: 1px solid var(--fissure);
  padding: 5px 9px; font-family: var(--cond); font-size: 0.78rem; color: var(--basalt); display: flex; gap: 7px; align-items: center;
}
.fresh-note i { width: 14px; height: 10px; border: 2px solid var(--fissure); animation: pulse 1.2s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .dumps li.new, .banner .k i, .fresh-note i { animation: none; } }

/* ---------- city labels: atlas-style, haloed so they read over any fill ---------- */
.city { pointer-events: none; white-space: nowrap; }
.city .ci { display: flex; align-items: center; gap: 5px; }
.city.flip .ci { flex-direction: row-reverse; transform: translateX(calc(-100% + 10px)); text-align: right; }
.city i { width: 6px; height: 6px; flex: 0 0 6px; border-radius: 50%; background: var(--fissure); box-shadow: 0 0 0 1.5px #FBFBF8; }
.city .cl { display: flex; flex-direction: column; line-height: 1.02; }
.city .cn {
  font-family: var(--serif); font-weight: 600; font-size: 13.5px; color: var(--fissure);
  text-shadow: 1px 0 0 #FBFBF8, -1px 0 0 #FBFBF8, 0 1px 0 #FBFBF8, 0 -1px 0 #FBFBF8, 1px 1px 0 #FBFBF8, -1px -1px 0 #FBFBF8, 1px -1px 0 #FBFBF8, -1px 1px 0 #FBFBF8, 0 0 4px #FBFBF8;
}
.city .cm {
  font-family: var(--cond); font-weight: 700; font-size: 10.5px; letter-spacing: 0.02em; font-variant-numeric: tabular-nums;
  text-shadow: 1px 0 0 #FBFBF8, -1px 0 0 #FBFBF8, 0 1px 0 #FBFBF8, 0 -1px 0 #FBFBF8, 1px 1px 0 #FBFBF8, -1px -1px 0 #FBFBF8, 1px -1px 0 #FBFBF8, -1px 1px 0 #FBFBF8, 0 0 4px #FBFBF8;
}
.city .cm:empty { display: none; }
.city.t2 .cn { font-size: 12.5px; font-weight: 500; }
.city.t3 .cn { font-size: 11.5px; font-weight: 500; font-style: italic; }
.city.t3 i { width: 4px; height: 4px; flex-basis: 4px; }

/* ---------- two panes: the vote, and who lives there ---------- */
.am-map-wrap { display: flex; }
.pane { position: relative; flex: 1 1 50%; min-width: 0; }
.pane + .pane { border-left: 1px solid var(--silfra); }
#map2 { position: absolute; inset: 0; background: var(--water); }
.pane-title {
  position: absolute; z-index: 3; top: 22px; right: 60px; background: #FBFBF8; border: 1px solid var(--fissure);
  padding: 5px 10px; font-family: var(--cond); font-weight: 700; font-size: 0.74rem; letter-spacing: 0.12em; text-transform: uppercase;
  display: flex; gap: 8px; align-items: center;
}
.pane-title select, .panel-sel {
  font-family: var(--cond); font-size: 0.8rem; letter-spacing: 0; text-transform: none; font-weight: 500;
  border: 1px solid var(--silfra); background: var(--paper); color: var(--fissure); padding: 2px 4px; max-width: 220px;
}
.panel-sel { width: 100%; max-width: none; padding: 6px; margin: 0 0 6px; }
.legend2 { position: absolute; z-index: 3; left: 24px; bottom: 24px; width: 250px; padding: 9px 11px; background: #FBFBF8; border: 1px solid var(--fissure); }
.legend2 .leg-ramp span { cursor: pointer; }
.leg-ticks.q span { text-align: left; transform: translateX(-50%); }
.leg-ticks.q span:first-child { transform: none; }
.am-tip tr.hl td { font-weight: 700; }
.groups { margin: 0 0 14px; font-family: var(--cond); }
.grp { display: grid; grid-template-columns: 14px 1fr 70px 72px; gap: 8px; align-items: center; padding: 5px 4px; font-size: 0.84rem; cursor: default; }
.grp + .grp { border-top: 1px solid #E3E8EC; }
.grp.on { background: #EEF1F3; }
.grp .sw { width: 14px; height: 14px; border: 0.5px solid var(--basalt); }
.grp .rg { display: flex; flex-direction: column; font-variant-numeric: tabular-nums; }
.grp .rg small { color: var(--lichen); font-size: 0.72rem; }
.grp .gb { position: relative; height: 12px; }
.grp .gb::before { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; border-left: 1px solid var(--basalt); }
.grp .gb i { position: absolute; top: 0; bottom: 0; }
.grp .gv { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.scatter { display: block; width: 100%; margin: 0 0 6px; }
.am-caption.note { font-style: italic; color: var(--lichen); font-size: 0.78rem; margin-bottom: 22px; }
@media (max-width: 1100px) {
  .am-map-wrap { flex-direction: column; }
  .pane + .pane { border-left: 0; border-top: 1px solid var(--silfra); }
}
@media (max-width: 820px) {
  .pane-title { top: 12px; padding: 4px 8px; font-size: 0.66rem; }
}

/* the web maps go without the printed neatline: the panes' own rules are frame enough */
.am-neat { display: none; }

/* ---------- phones: the two maps stacked in one frame, a handle swipes between them ---------- */
.split { display: none; }
@media (max-width: 820px) {
  .am-map-wrap { --split: 50%; display: block; position: relative; height: 66vh; height: 66svh; flex: none; overflow: hidden; }
  .pane { position: absolute; inset: 0; }
  .pane + .pane { border: 0; }
  #pane1 { z-index: 1; clip-path: inset(0 calc(100% - var(--split)) 0 0); }
  #pane2 { z-index: 2; clip-path: inset(0 0 0 var(--split)); }
  .maplibregl-ctrl-top-right { display: none; }               /* pinch to zoom */
  #pane1 .pane-title { left: 12px; right: auto; }
  #pane2 .pane-title { right: 12px; left: auto; }
  #pane2 .pane-title .pt-text { display: none; }               /* the menu names the measure */
  #pane2 .pane-title select { max-width: 150px; font-size: 0.74rem; }
  .legend2 { left: auto; right: 12px; bottom: 12px; width: 178px; padding: 7px 9px; }
  .legend2 .leg-note { display: none; }
  .legend2 .leg-title { font-size: 0.72rem; }
  .fresh-note { left: 12px; bottom: 12px; max-width: 46%; font-size: 0.7rem; }
  .banner { top: 48px; left: 12px; }
  .split {
    display: block; position: absolute; z-index: 4; top: 0; bottom: 0; left: var(--split); width: 0;
    border-left: 2px solid #FBFBF8; box-shadow: 0 0 0 0.5px var(--fissure);
    touch-action: none; cursor: ew-resize;
  }
  .split::before { content: ""; position: absolute; top: 0; bottom: 0; left: -22px; width: 44px; }   /* a thumb-sized grip */
  .split .knob {
    position: absolute; top: 50%; left: 0; transform: translate(-50%, -50%);
    width: 40px; height: 40px; border-radius: 50%; background: var(--fissure); color: var(--paper);
    display: flex; align-items: center; justify-content: center; gap: 2px;
    font-family: var(--cond); font-size: 0.7rem; box-shadow: 0 1px 4px rgba(31, 29, 24, 0.35);
  }
  .split:focus-visible .knob { outline: 2px solid var(--rowan); outline-offset: 2px; }
}

.fresh-note[hidden], .banner[hidden] { display: none; }
