/* Erusea State Duma 2008 — "briefing room" look: ink on off-white, thin rules instead of cards, one crimson accent
   (the Erusean rose). Dark theme keeps the pastel states lit on a dark sea. Colours live in variables; the map SVG
   reads them too, so both themes come from this file. */
:root, [data-theme="light"] {
  --bg: #f5f5f2;
  --surface: #fbfbf9;
  --ink: #16181d;
  --ink-2: #444a55;
  --muted: #6b717c;
  --rule: #dddcd5;
  --rule-strong: #b9b8b0;
  --accent: #a4262c;
  --accent-soft: #f3e2e1;
  --good: #2f7d4f;
  --bad: #b3352f;
  --neutral: #a8a49a;
  --focus: #1f5fbf;
  /* map */
  --map-bg: #fbfbf9;
  --sea: #dfe9f0;
  --grid: #c7d6e0;
  --coast: #3d5568;
  --coast-foreign: #9aa8b2;
  --border-state: #6f6a62;
  --border-nation: #2e2a26;
  --label: #1d1f24;
  --label-halo: rgba(255, 255, 255, .92);
  --label-sub: #464b55;
  --foreign-label: #7d7a72;
  --sea-label: #557189;
  --select: #a4262c;
  --select-halo: #ffffff;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #12161c;
  --surface: #171c23;
  --ink: #ece9e2;
  --ink-2: #c4c1b9;
  --muted: #8d939c;
  --rule: #2a313b;
  --rule-strong: #3b4451;
  --accent: #e0676c;
  --accent-soft: #3a2326;
  --good: #5fb886;
  --bad: #e07a73;
  --neutral: #6f6b63;
  --focus: #7fb0ff;
  --map-bg: #151a21;
  --sea: #1b2734;
  --grid: #24323f;
  --coast: #9fb6c8;
  --coast-foreign: #4d5966;
  --border-state: #3f3a35;
  --border-nation: #e6ded2;
  --label: #14161a;
  --label-halo: rgba(255, 255, 255, .78);
  --label-sub: #2f333a;
  --foreign-label: #8d939c;
  --sea-label: #7f9ab0;
  --select: #ff6b70;
  --select-halo: #12161c;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.5 "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- top bar ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 14px clamp(16px, 3vw, 32px);
  border-bottom: 1px solid var(--rule);
}
.brand { display: flex; align-items: baseline; gap: 14px; min-width: 0; }
.wordmark { font-weight: 800; font-stretch: 125%; letter-spacing: .32em; font-size: 20px; }
.brand-sub { color: var(--muted); font-size: 14px; white-space: nowrap; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.status { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; }
.status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--neutral); }
.status.live .dot { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 22%, transparent); }
.text-btn, .icon-btn {
  border: 1px solid var(--rule-strong); background: transparent; border-radius: 6px;
  height: 34px; padding: 0 12px; font-size: 13.5px; font-weight: 600;
}
.icon-btn { width: 34px; padding: 0; display: inline-grid; place-items: center; }
.text-btn:hover, .icon-btn:hover { border-color: var(--ink-2); }
.icon-btn svg { width: 17px; height: 17px; }

/* ---------- layout ---------- */
.layout {
  display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(320px, 1fr);
  gap: 0; align-items: start;
}
.map-col { padding: 18px clamp(16px, 3vw, 32px) 24px; border-right: 1px solid var(--rule); min-width: 0; }
.panel { position: sticky; top: 0; max-height: 100vh; overflow-y: auto; min-width: 0; }

/* ---------- map controls ---------- */
.map-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.segmented { display: inline-flex; border: 1px solid var(--rule-strong); border-radius: 7px; padding: 2px; gap: 2px; }
.seg { border: 0; background: transparent; padding: 6px 13px; border-radius: 5px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.seg:hover { color: var(--ink); }
.seg.active { background: var(--ink); color: var(--bg); }
.map-sub { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); min-width: 0; }
.map-sub select, .state-nav select {
  background: var(--surface); border: 1px solid var(--rule-strong); border-radius: 6px; height: 34px; padding: 0 8px; min-width: 0; max-width: 100%;
}

.map-stage { position: relative; }
.map-stage svg { display: block; width: 100%; height: auto; }
.state-group { cursor: pointer; outline: none; }
.state-group .hex { transition: filter .12s ease; }
.state-group:hover .hex, .state-group:focus-visible .hex { filter: brightness(1.07) saturate(1.15); }
[data-theme="dark"] .state-group:hover .hex { filter: brightness(1.12); }
.state-group:focus-visible .hex { stroke: var(--focus); stroke-width: 2; }

/* map text (SVG) */
.lbl-state { font-size: 15px; font-weight: 700; letter-spacing: .06em; fill: var(--label); paint-order: stroke; stroke: var(--label-halo); stroke-width: 3.5px; }
.lbl-sub { font-size: 12.5px; font-weight: 600; fill: var(--label-sub); paint-order: stroke; stroke: var(--label-halo); stroke-width: 3px; }
.lbl-out { fill: var(--ink); stroke: var(--sea); }
.lbl-foreign { font-size: 16px; letter-spacing: .3em; fill: var(--foreign-label); }
.lbl-city, .lbl-note { font-size: 13px; font-style: italic; fill: #3d4048; }
.lbl-sea { font-size: 17px; font-style: italic; letter-spacing: .28em; fill: var(--sea-label); }
.lbl-bay { font-size: 14px; font-style: italic; fill: var(--sea-label); }
.tick { font-size: 12px; fill: var(--muted); }

.tooltip {
  position: absolute; z-index: 5; pointer-events: none; max-width: 260px;
  background: var(--ink); color: var(--bg); border-radius: 7px; padding: 9px 11px;
  font-size: 13px; line-height: 1.4; box-shadow: 0 6px 20px rgba(0,0,0,.18);
}
.tt-title { font-weight: 700; font-size: 14px; }
.tt-meta { opacity: .78; }
.tt-focus { margin-top: 3px; font-weight: 600; }

.legend { display: flex; align-items: center; gap: 8px 18px; flex-wrap: wrap; margin-top: 10px; font-size: 13px; color: var(--ink-2); }
.legend-item { display: inline-flex; align-items: center; gap: 7px; }
.sw { display: inline-block; width: 13px; height: 13px; border-radius: 3px; border: 1px solid color-mix(in srgb, var(--ink) 18%, transparent); flex: none; }
.sw.round { border-radius: 50%; }
.sw.hatch { background: repeating-linear-gradient(45deg, #a29e94 0 2px, transparent 2px 6px); }
.ramp { display: inline-flex; align-items: center; gap: 8px; }
.ramp-bar { display: inline-flex; border-radius: 3px; overflow: hidden; border: 1px solid color-mix(in srgb, var(--ink) 15%, transparent); }
.ramp-bar span { width: 26px; height: 11px; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 600; font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- panel ---------- */
.tabs { display: flex; position: sticky; top: 0; z-index: 2; background: var(--bg); border-bottom: 1px solid var(--rule); padding: 0 clamp(16px, 2.4vw, 28px); gap: 22px; }
.tab { border: 0; background: none; padding: 16px 0 13px; font-size: 15px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--accent); }
.panel-body { padding: 18px clamp(16px, 2.4vw, 28px) 32px; }

.state-nav { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.state-nav select { flex: 1 1 160px; }
.nav-btn { border: 1px solid var(--rule-strong); background: transparent; border-radius: 6px; height: 34px; min-width: 34px; padding: 0 10px; font-size: 14px; font-weight: 600; }
.nav-btn:hover { border-color: var(--ink-2); }
.nav-btn.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.state-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.state-head h2 { margin: 0; font-size: 30px; line-height: 1.1; font-weight: 750; font-stretch: 110%; letter-spacing: -.01em; }
.tag { font-size: 12px; color: var(--muted); border: 1px solid var(--rule-strong); border-radius: 99px; padding: 2px 9px; white-space: nowrap; }
.note { color: var(--ink-2); margin: 8px 0 18px; max-width: 60ch; }

.figures { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); margin-bottom: 22px; }
.figures.six { grid-template-columns: repeat(3, 1fr); }
.fig { padding: 11px 0 12px; }
.fig + .fig { padding-left: 14px; border-left: 1px solid var(--rule); }
.figures.six .fig:nth-child(3n + 1) { padding-left: 0; border-left: 0; }
.figures.six .fig:nth-child(n + 4) { border-top: 1px solid var(--rule); }
.fig-num { display: block; font-size: 24px; font-weight: 700; line-height: 1.15; }
.fig-label { display: block; font-size: 12.5px; color: var(--muted); }
.fig-num.warn { color: var(--bad); }

h3.section { font-size: 13px; font-weight: 700; color: var(--ink-2); margin: 24px 0 10px; display: flex; justify-content: space-between; gap: 10px; }
h3.section span { font-weight: 500; color: var(--muted); }

.mix-bar { display: flex; height: 12px; border-radius: 3px; overflow: hidden; margin-bottom: 6px; }
.group { display: grid; grid-template-columns: 13px 1fr auto; gap: 4px 10px; align-items: baseline; width: 100%; text-align: left;
  border: 0; border-bottom: 1px solid var(--rule); background: none; padding: 11px 0; }
.group:hover .group-name { color: var(--accent); }
.group .sw { align-self: center; }
.group-name { font-weight: 650; }
.group-pct { font-weight: 700; }
.group-traits { grid-column: 2 / 4; color: var(--muted); font-size: 13.5px; }
.group-traits b { color: var(--ink-2); font-weight: 600; }

.state-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.state-table th { text-align: left; font-size: 12.5px; color: var(--muted); font-weight: 600; padding: 6px 6px 6px 0; border-bottom: 1px solid var(--rule-strong); }
.state-table td { padding: 8px 6px 8px 0; border-bottom: 1px solid var(--rule); }
.state-table .num { text-align: right; }
.state-table tbody tr { cursor: pointer; }
.state-table tbody tr:hover td { color: var(--accent); }
.state-table tr.selected td { font-weight: 700; }

/* parties */
.hemicycle svg { display: block; width: 100%; max-width: 520px; margin: 0 auto; }
.hemi-total { fill: var(--ink); font-size: 26px; font-weight: 750; }
.hemi-sub { fill: var(--muted); font-size: 13px; }
.bloc-bar { position: relative; display: flex; height: 14px; border-radius: 3px; overflow: hidden; margin: 4px 0 8px; background: var(--rule); }
.majority-mark { position: absolute; top: -3px; bottom: -3px; left: 50.13%; width: 2px; background: var(--ink); }
.bloc-row { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; font-size: 14px; }
.bloc-row .short-of { color: var(--muted); }
.filter { width: 100%; height: 38px; border: 1px solid var(--rule-strong); border-radius: 6px; background: var(--surface); padding: 0 11px; margin-bottom: 4px; }
.party { border-bottom: 1px solid var(--rule); padding: 12px 0 12px 12px; border-left: 3px solid var(--party, var(--rule-strong)); }
.party-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.party-name { font-weight: 700; }
.party-short { color: var(--muted); font-weight: 600; margin-left: 6px; }
.party-en { color: var(--ink-2); font-size: 14px; }
.party-seats { font-weight: 750; white-space: nowrap; }
.party-meta { color: var(--muted); font-size: 13.5px; margin-top: 3px; }

/* country */
.crisis { border-left: 3px solid var(--bad); background: color-mix(in srgb, var(--bad) 8%, transparent); padding: 9px 12px; margin-bottom: 18px; font-size: 14px; }
.open-bill { border: 1px solid var(--rule-strong); border-radius: 7px; padding: 12px 14px; margin: 4px 0 8px; }
.open-bill .eyebrow { font-size: 12.5px; color: var(--accent); font-weight: 700; }
.open-bill .title { font-weight: 700; font-size: 16px; margin: 2px 0 4px; }
.open-bill p { margin: 0; color: var(--ink-2); font-size: 14px; }
.bill-row { padding: 11px 0; border-bottom: 1px solid var(--rule); }
.bill-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.bill-title { font-weight: 650; }
.bill-seq { color: var(--muted); font-weight: 600; margin-right: 6px; }
.verdict { font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.verdict.pass { color: var(--good); }
.verdict.fail { color: var(--bad); }
.bill-bar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--rule); margin: 7px 0 4px; }
.bill-meta { color: var(--muted); font-size: 13px; }
.empty { color: var(--muted); }

.foot { padding: 18px clamp(16px, 3vw, 32px) 26px; color: var(--muted); font-size: 12.5px; border-top: 1px solid var(--rule); }

/* ---------- narrow screens ---------- */
@media (max-width: 920px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .map-col { border-right: 0; border-bottom: 1px solid var(--rule); }
  .panel { position: static; max-height: none; overflow: visible; }
  .tabs { position: sticky; top: 0; }
}
@media (max-width: 560px) {
  body { font-size: 14.5px; }
  .brand-sub { display: none; }
  .status .status-text { display: none; }
  .state-head h2 { font-size: 25px; }
  .fig-num { font-size: 20px; }
  .seg { padding: 6px 10px; font-size: 13.5px; }
  .map-sub { width: 100%; }
  .map-sub select { flex: 1; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
