/* vote-count: tokens and components follow flip-flop's app.css (same look across the projects). */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #17191c;
  --muted: #646b75;
  --border: #e2e5ea;
  --accent: #2459d6;
  --accent-text: #ffffff;
  --bad-bg: #fdecec;  --bad: #a1251f;
  --info-bg: #eaf0fd; --info: #2a4ea8;
  --radius: 10px;
  /* map: no data, then five classes of one blue ramp (light -> dark); highlighted members get an orange edge */
  --map-0: #e9ebee; --map-1: #b7d3f6; --map-2: #86b6ef; --map-3: #5598e7; --map-4: #2a78d6; --map-5: #184f95;
  --map-sea: #f0f4f9; --map-mark: #eb6834;
  /* categories (voting systems): three hues (validated all-pairs for colour-blind reading), then two greys */
  --map-k1: #2a78d6; --map-k2: #eb6834; --map-k3: #1baf7a; --map-k4: #9aa1ab; --map-k5: #5f6670;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
/* Night: chosen with the Day/Night toggle (data-theme), or the system setting when no choice is saved. */
:root[data-theme="dark"] {
  --bg: #111317; --surface: #191c21; --text: #e8eaee; --muted: #9aa1ab; --border: #2a2f37;
  --accent: #6d95ff; --accent-text: #0b1020;
  --bad-bg: #3a1716; --bad: #ff9c94; --info-bg: #182540; --info: #9db8ff;
  --map-0: #2c3038; --map-1: #184f95; --map-2: #256abf; --map-3: #3987e5; --map-4: #6da7ec; --map-5: #b7d3f6;
  --map-sea: #14171c; --map-mark: #f08a5d;
  --map-k1: #3987e5; --map-k2: #d95926; --map-k3: #199e70; --map-k4: #6b727c; --map-k5: #a3a9b2;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111317; --surface: #191c21; --text: #e8eaee; --muted: #9aa1ab; --border: #2a2f37;
    --accent: #6d95ff; --accent-text: #0b1020;
    --bad-bg: #3a1716; --bad: #ff9c94; --info-bg: #182540; --info: #9db8ff;
    --map-0: #2c3038; --map-1: #184f95; --map-2: #256abf; --map-3: #3987e5; --map-4: #6da7ec; --map-5: #b7d3f6;
    --map-sea: #14171c; --map-mark: #f08a5d;
    --map-k1: #3987e5; --map-k2: #d95926; --map-k3: #199e70; --map-k4: #6b727c; --map-k5: #a3a9b2;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; }
h1, h2 { margin: 0 0 .6rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; margin: 1rem 0 .3rem; }
a { color: var(--accent); }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: .82rem; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 1rem; padding: .7rem 16px; background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.brand { font-weight: 700; letter-spacing: .01em; flex: 1; }
.brand .muted { font-weight: 400; margin-left: .4rem; }
.theme-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; padding: 2px; background: var(--bg); }
.theme-toggle button { font: inherit; font-size: .82rem; border: 0; background: transparent; color: var(--muted); padding: .25rem .65rem; border-radius: 999px; cursor: pointer; }
.theme-toggle button[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 0 0 1px var(--border); }

/* layout */
.page { max-width: 1200px; margin: 0 auto; padding: 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.page > * { min-width: 0; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.alert { padding: .7rem .9rem; border-radius: var(--radius); background: var(--info-bg); color: var(--info); }
.alert-bad { background: var(--bad-bg); color: var(--bad); }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 16px; align-items: start; }

/* controls */
.chart-controls { display: flex; flex-wrap: wrap; gap: .5rem .75rem; margin-bottom: .9rem; align-items: center; }
label.inline { display: inline-flex; align-items: center; gap: .4rem; margin: 0; }
select { font: inherit; padding: .4rem .55rem; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); max-width: 100%; }
.btn { font: inherit; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; padding: .45rem .9rem; cursor: pointer; }
.btn-small { padding: .2rem .6rem; font-size: .8rem; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .4rem .55rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.pick { cursor: pointer; }
tr.pick:hover td { background: var(--bg); }
tr.pick.on td { background: var(--info-bg); }
td .sub { display: block; color: var(--muted); font-size: .8rem; }

/* world map (public/worldmap.js) */
.worldmap { position: relative; }
.worldmap svg { display: block; width: 100%; height: auto; background: var(--map-sea); border-radius: 8px; touch-action: auto; cursor: grab; }
.worldmap svg.zoomed { touch-action: none; }
.worldmap svg.dragging { cursor: grabbing; }
.worldmap .unit { stroke: var(--surface); stroke-width: .6; vector-effect: non-scaling-stroke; cursor: pointer; fill-rule: evenodd; }
.worldmap .unit.dot { stroke-width: 1; }
.worldmap .unit:hover, .worldmap .unit:focus { stroke: var(--text); stroke-width: 1.5; outline: none; }
.worldmap .unit.dim { opacity: .3; }
.worldmap .unit.member { stroke: var(--map-mark); stroke-width: 1.2; }
.worldmap .unit.selected { stroke: var(--text); stroke-width: 2.2; }
.map-zoom { position: absolute; right: 8px; top: 8px; display: flex; flex-direction: column; gap: 4px; }
.map-zoom button { font: inherit; width: 30px; height: 30px; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); cursor: pointer; font-size: 1rem; line-height: 1; }
.map-zoom button.reset { font-size: .7rem; }
.map-c0 { fill: var(--map-0); background: var(--map-0); }
.map-c1 { fill: var(--map-1); background: var(--map-1); }
.map-c2 { fill: var(--map-2); background: var(--map-2); }
.map-c3 { fill: var(--map-3); background: var(--map-3); }
.map-c4 { fill: var(--map-4); background: var(--map-4); }
.map-c5 { fill: var(--map-5); background: var(--map-5); }
.map-k1 { fill: var(--map-k1); background: var(--map-k1); }
.map-k2 { fill: var(--map-k2); background: var(--map-k2); }
.map-k3 { fill: var(--map-k3); background: var(--map-k3); }
.map-k4 { fill: var(--map-k4); background: var(--map-k4); }
.map-k5 { fill: var(--map-k5); background: var(--map-k5); }
.kinds { display: flex; flex-wrap: wrap; gap: .3rem .9rem; font-size: .88rem; }
.kinds label { display: inline-flex; align-items: center; gap: .3rem; }
.chart-controls.sub { margin-top: -.4rem; }
select:disabled { opacity: .5; }
.map-legend { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .3rem .9rem; margin-top: .5rem; font-size: .8rem; color: var(--muted); }
.map-legend .sw { display: inline-block; width: 16px; height: 10px; border-radius: 2px; margin-right: .3rem; vertical-align: -1px; }
.chart-tip { position: absolute; transform: translateX(-50%); pointer-events: none; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .4rem .6rem; font-size: .82rem; box-shadow: 0 4px 14px rgba(0,0,0,.12); white-space: nowrap; color: var(--text); z-index: 5; }
.chart-tip .tip-head { font-weight: 600; margin-bottom: .15rem; }

/* details */
.facts { margin: .2rem 0 .6rem; }
.tag { display: inline-block; padding: .05rem .5rem; border-radius: 999px; background: var(--info-bg); color: var(--info); font-size: .78rem; font-weight: 600; margin-right: .3rem; }
.sources li { margin-bottom: .4rem; }
.sources .sub { display: block; font-size: .8rem; }

@media (max-width: 600px) {
  .brand .muted { display: block; margin-left: 0; }
  .chart-controls label.inline { width: 100%; justify-content: space-between; }
}
