/* Wahlatlas Ammerland – Gestaltung wie die Vereinsseite des Buntes Ammerland e.V. (/style.css) */
:root {
  /* Vereinsfarben */
  --beige: #fefce6;
  --grau: #303034;
  --rot: #e66073;
  --gelb: #fdb50b;
  --gruen: #6dbf5f;
  --lila: #9b84c4;

  --bg: var(--beige);
  --panel: #ffffff;
  --ink: var(--grau);
  --ink-2: #4a4a50;
  --ink-3: #6e6e74;
  --line: #ebe8d6;
  --cell-empty: #f3f1e4;
  --accent: #c8435a;          /* Vereinsrot, abgedunkelt für Text auf Weiß */
  --focus: var(--grau);
  --gain: #2a78d6;
  --loss: #d95926;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow-card: 0 1px 2px rgba(48, 48, 52, .06), 0 8px 24px rgba(48, 48, 52, .08);
  --shadow-tip: 0 2px 4px rgba(48, 48, 52, .08), 0 16px 40px rgba(48, 48, 52, .14);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-cond: var(--font);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); font-family: var(--font); -webkit-font-smoothing: antialiased; }
/* Inhalt des Wahlatlas; Kopf und Fuß kommen von der Vereinsseite (inc/layout.php im Hauptordner) */
.wahlatlas {
  width: min(1160px, 100% - 32px);
  margin: 0 auto;
  padding-block: clamp(2.5rem, 6vw, 4rem) 56px;   /* wie .page-head der Vereinsseite */
  display: grid;
  gap: 22px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
}
.wahlatlas section { padding: 0; }
.wahlatlas h2, .wahlatlas h3, .wahlatlas h4 { line-height: 1.25; }
.wahlatlas p, .wahlatlas ul { margin: 0; }
.wahlatlas .leaflet-container { z-index: 0; }   /* unter dem festen Seitenkopf bleiben */
.wa-head { display: grid; gap: 6px; }
.eyebrow {
  font-weight: 800;
  font-size: 0.8rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--rot);
}
.wahlatlas h1 {
  margin: 0;
  font-weight: 900;
  letter-spacing: -0.035em;
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 1.05;
  max-width: 22em;
  text-wrap: balance;
}

/* controls */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 22px;
  align-items: end;
}
.ctl { display: grid; gap: 6px; }
.ctl-label {
  font-family: var(--font-cond);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.seg {
  display: inline-flex;
  flex-wrap: wrap;
  border-radius: 22px;
  background: var(--panel);
  box-shadow: var(--shadow-card);
  padding: 4px;
  gap: 2px;
}
.seg button {
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  padding: 6px 13px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.seg button:hover { color: var(--ink); background: var(--cell-empty); }
.seg button:focus-visible, select:focus-visible, th button:focus-visible, td:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
select {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
}

/* findings */
.findings {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr));
  gap: 12px;
}
.find {
  background: var(--panel);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
  padding: 14px 16px;
  display: grid;
  gap: 2px;
  align-content: start;
}
.find .k {
  font-family: var(--font-cond);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.find .v {
  font-family: var(--font-cond);
  font-weight: 700;
  font-size: 28px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.find .s { color: var(--ink-2); font-size: 14px; }
.up { color: var(--gain); }
.down { color: var(--loss); }

/* table */
.grid-card, .map-card, .guv-card, .seats-card {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.grid-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px 20px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.grid-title { font-weight: 800; font-size: 19px; letter-spacing: -0.01em; margin: 0; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; font-size: 13px; color: var(--ink-2); }
.ramp { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.ramp i { display: block; width: 110px; height: 10px; border-radius: 3px; }
.scroller { overflow-x: auto; }
table {
  border-collapse: separate;
  border-spacing: 2px;
  width: 100%;
  font-variant-numeric: tabular-nums;
  padding: 6px;
}
th, td { white-space: nowrap; }
thead th {
  font-family: var(--font-cond);
  font-weight: 600;
  font-size: 13px;
  color: var(--ink-2);
  vertical-align: bottom;
  padding: 0;
}
thead th button {
  font: inherit;
  color: inherit;
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 6px 4px;
  width: 100%;
  display: grid;
  gap: 1px;
  justify-items: center;
  line-height: 1.15;
  border-radius: 5px;
}
thead th button:hover { background: var(--cell-empty); color: var(--ink); }
thead th .yr { font-size: 12px; color: var(--ink-3); font-weight: 500; }
thead th[aria-sort="ascending"] button::after { content: "▲"; font-size: 9px; color: var(--ink); }
thead th[aria-sort="descending"] button::after { content: "▼"; font-size: 9px; color: var(--ink); }
thead th.first button { justify-items: start; }
th.sep, td.sep { width: 10px; padding: 0; }
tbody th {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--panel);
  text-align: left;
  font-weight: 500;
  font-size: 14px;
  padding: 0 12px 0 6px;
  max-width: 230px;
  overflow: hidden;
  text-overflow: ellipsis;
}
tbody th .nr {
  display: inline-block;
  min-width: 22px;
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 600;
}
td.c {
  min-width: 64px;
  height: 30px;
  text-align: center;
  font-size: 14px;
  font-weight: 500;
  border-radius: 4px;
  cursor: default;
  background: var(--cell-empty);
}
td.c.na { color: var(--ink-3); font-weight: 400; }
tr.agg th { font-weight: 700; }
tr.agg td.c { font-weight: 700; }
tr.agg-first th, tr.agg-first td { border-top: 0; }
tr.gap td, tr.gap th { height: 8px; padding: 0; background: transparent; }
tbody tr:hover th { color: var(--accent); }
.notes { color: var(--ink-2); font-size: 13.5px; display: grid; gap: 6px; }
.notes p { margin: 0; }
.notes a { color: var(--ink); }

/* map */
/* Karte füllt die ganze Kartenbreite; Höhe nach Fenster, damit eine ganze Gemeinde passt */
#map { width: 100%; height: clamp(360px, 75vh, 680px); background: var(--cell-empty); }
.leaflet-container { font-family: var(--font); }
.pin {
  display: grid;
  place-items: center;
  width: 42px;
  height: 26px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 2px var(--panel), 0 2px 6px rgba(0,0,0,.35);
  transition: transform .15s ease;
}
.pin.na { background: var(--cell-empty); color: var(--ink-3); }
.pin.hot { transform: scale(1.25); box-shadow: 0 0 0 3px var(--ink), 0 2px 8px rgba(0,0,0,.4); }
.leaflet-tooltip.maptip {
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-tip);
  font-size: 13px;
  padding: 6px 9px;
}
.leaflet-tooltip.maptip::before { display: none; }
.map-hint { font-size: 13px; color: var(--ink-2); }
tr.hot th { color: var(--accent); }
tr.hot td.c { box-shadow: inset 0 0 0 2px var(--ink); }
thead th.mapcol button { box-shadow: inset 0 -3px 0 var(--accent); }

/* tooltip */
.tip {
  position: fixed;
  z-index: 10;
  pointer-events: none;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-tip);
  padding: 10px 12px;
  font-size: 13.5px;
  min-width: 220px;
  max-width: 300px;
  display: grid;
  gap: 4px;
}
.tip .t1 { font-weight: 700; font-size: 14.5px; }
.tip .t2 { color: var(--ink-3); font-size: 12.5px; }
.tip .row { display: flex; justify-content: space-between; gap: 14px; font-variant-numeric: tabular-nums; }
.tip .row span:first-child { color: var(--ink-2); }
.tip .big { font-family: var(--font-cond); font-weight: 700; font-size: 22px; }

@media (max-width: 560px) {
  tbody th { max-width: 150px; }
  td.c { min-width: 54px; font-size: 13px; }
}
@media (prefers-reduced-motion: no-preference) {
  td.c { transition: background-color .25s ease; }
}


/* profit & loss chart */
.guv-body { padding: 14px 16px 18px; display: grid; gap: 16px; }
.guv-meta { display: flex; flex-wrap: wrap; gap: 8px 26px; font-size: 14px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.guv-meta b { color: var(--ink); font-weight: 600; }
.guv { display: grid; grid-template-columns: minmax(96px, max-content) 1fr 84px; gap: 10px 14px; align-items: center; }
.guv-party { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14.5px; }
.guv-party small { font-weight: 500; color: var(--ink-3); font-size: 12px; }
.guv-bars { display: grid; gap: 3px; min-width: 0; }
.guv-bar { display: flex; align-items: center; gap: 8px; font-size: 13px; font-variant-numeric: tabular-nums; color: var(--ink-2); min-width: 0; }
.guv-bar i { display: block; height: 12px; border-radius: 0 4px 4px 0; flex: none; min-width: 2px; }
.guv-bar.y26 { color: var(--ink); font-weight: 600; }
.guv-bar.y26 i { height: 16px; }
.guv-bar .yl { width: 32px; flex: none; color: var(--ink-3); font-size: 11.5px; font-weight: 600; }
.guv-delta {
  justify-self: end;
  font-family: var(--font-cond);
  font-weight: 700;
  font-size: 19px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  line-height: 1.1;
}
.guv-delta small { display: block; font-family: var(--font); font-size: 11.5px; font-weight: 500; color: var(--ink-3); }
.guv-key { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: var(--ink-2); align-items: center; }
.guv-key span { display: inline-flex; align-items: center; gap: 6px; }
.guv-key i { display: inline-block; width: 22px; height: 10px; border-radius: 0 3px 3px 0; background: var(--ink-3); }
.guv-key i.old { opacity: .38; }
.area-select { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.link-btn {
  font: inherit; font-size: 13px; border: 1px solid var(--line); background: var(--panel); color: var(--ink-2);
  border-radius: 6px; padding: 4px 10px; cursor: pointer;
}
.link-btn:hover { color: var(--ink); }
tbody th.pick { cursor: pointer; }
tbody th.pick:hover { text-decoration: underline; text-underline-offset: 3px; }
tr.sel th { color: var(--accent); }
tr.sel th::before { content: "▸ "; }
thead th .tag { font-size: 10.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); }
@media (max-width: 560px) {
  .guv { grid-template-columns: minmax(70px, max-content) 1fr 64px; gap: 8px 10px; }
  .guv-delta { font-size: 17px; }
}

/* ---------- v2: seats, small districts, map picker, councillors ---------- */
.seats-body { padding: 14px 16px 18px; display: grid; gap: 18px; }
.seat-rows { display: grid; gap: 10px; }
.seat-row { display: grid; grid-template-columns: 44px 1fr; gap: 12px; align-items: center; }
.seat-row .yl { font-family: var(--font-cond); font-weight: 700; font-size: 15px; color: var(--ink-2); }
.seat-strip { display: flex; flex-wrap: wrap; gap: 3px; }
.seat-strip i { display: block; width: 18px; height: 18px; border-radius: 4px; }
.seat-table { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 14px; }
.seat-cell { display: flex; align-items: baseline; gap: 8px; font-variant-numeric: tabular-nums; font-size: 14px; }
.seat-cell .p { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; min-width: 0; }
.seat-cell .n { color: var(--ink-2); }
.seat-cell .d { font-family: var(--font-cond); font-weight: 700; font-size: 16px; margin-left: auto; }
.seat-cell .d.zero { color: var(--ink-3); }
.fine { font-size: 13px; color: var(--ink-2); margin: 0; }

tbody th .size { color: var(--ink-3); font-size: 12px; font-weight: 500; margin-left: 6px; }
td.c.small { opacity: .55; }
td.c.small::after { content: "*"; font-size: 10px; vertical-align: super; margin-left: 1px; }
.pin.small { opacity: .5; }


.find ul { margin: 2px 0 0; padding: 0; list-style: none; display: grid; gap: 2px; font-size: 14px; color: var(--ink-2); }
.find li { display: flex; justify-content: space-between; gap: 10px; font-variant-numeric: tabular-nums; }
.find li .tagnew { color: var(--gain); font-weight: 600; font-size: 12px; }
.find li .tagout { color: var(--loss); font-weight: 600; font-size: 12px; }
.find li .tagswitch { color: var(--ink-2); font-weight: 600; font-size: 12px; font-style: italic; }
.find.wide { grid-column: span 2; }
@media (max-width: 560px) { .find.wide { grid-column: auto; } }
.councillors { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.councillors h4 { margin: 0 0 4px; font-family: var(--font-cond); font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }

/* candidates */
table.cand { border-spacing: 0; padding: 0 6px 6px; }
table.cand th, table.cand td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; }
table.cand thead th { font-family: var(--font-cond); font-weight: 600; font-size: 13px; color: var(--ink-2); padding-top: 10px; }
table.cand tbody th { position: static; font-weight: 600; max-width: none; background: transparent; padding-left: 10px; }
table.cand tbody tr:last-child th, table.cand tbody tr:last-child td { border-bottom: 0; }
table.cand .num { text-align: right; font-variant-numeric: tabular-nums; }
table.cand .muted, .cand .muted { color: var(--ink-3); }
.vbar { display: inline-block; width: 70px; height: 8px; margin-right: 8px; vertical-align: middle; background: var(--cell-empty); border-radius: 2px; overflow: hidden; }
.vbar i { display: block; height: 100%; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.pill.in { background: var(--ink); color: var(--bg); }
.pill.other { border: 1px solid var(--line); color: var(--ink-2); }
.cand-note { padding: 0 16px 14px; }

/* area / election picker */
.picker { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }   /* Wahl über Gebiet */
.seg-link {
  font: inherit; font-weight: 700; font-size: 14px; color: var(--ink); text-decoration: none;
  padding: 6px 14px; border-radius: 999px; display: inline-block;
}
.seg-link:hover { background: rgba(48, 48, 52, .07); }
.seg-link[aria-current="page"] { background: var(--grau); color: var(--beige); }
.seg-link.disabled { color: var(--ink-3); opacity: .5; cursor: not-allowed; }
.seg-link:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.seg button[aria-pressed="true"] { background: var(--grau); color: var(--beige); }

/* Ersatzrahmen, nur wenn die Vereinsseite (inc/layout.php im Hauptordner) nicht gefunden wird, z. B. lokal */
.wa-stripe { display: flex; height: 5px; }
.wa-stripe i { flex: 1; }
.wa-stripe i:nth-child(1) { background: var(--rot); }
.wa-stripe i:nth-child(2) { background: var(--gelb); }
.wa-stripe i:nth-child(3) { background: var(--gruen); }
.wa-stripe i:nth-child(4) { background: var(--lila); }

/* ---------- Ansicht Landrat (?wahl=landrat), auch von ../buergermeister/ genutzt ---------- */

/* duel card */
.duel { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); gap: 18px 28px; }
.duel-col { display: grid; gap: 8px; align-content: start; }
.duel-col h3 { margin: 0 0 2px; font-family: var(--font-cond); font-size: 17px; font-weight: 700; }
.duel-col h3 small { font-family: var(--font); font-weight: 500; font-size: 12.5px; color: var(--ink-3); margin-left: 6px; }
.duel-row { display: grid; grid-template-columns: 118px 1fr 76px; gap: 10px; align-items: center; }
.duel-name { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; font-size: 14.5px; }
.duel-name small { color: var(--ink-3); font-weight: 500; font-size: 12px; }
.duel-bar { display: block; height: 16px; background: var(--cell-empty); border-radius: 0 4px 4px 0; overflow: hidden; }
.duel-bar i { display: block; height: 100%; border-radius: 0 4px 4px 0; }
.duel-val { text-align: right; font-variant-numeric: tabular-nums; line-height: 1.15; }
.duel-val b { font-family: var(--font-cond); font-size: 18px; }
.duel-val small { display: block; color: var(--ink-3); font-size: 12px; }
.duel-win { margin: 2px 0 0; font-size: 14px; color: var(--ink-2); }
.duel-delta { border-left: 1px solid var(--line); padding-left: 24px; }
.duel-d { display: grid; grid-template-columns: 1fr auto; gap: 0 12px; align-items: baseline; }
.duel-d b { font-family: var(--font-cond); font-size: 24px; font-variant-numeric: tabular-nums; text-align: right; }
.duel-d small { grid-column: 2; text-align: right; color: var(--ink-3); font-size: 12.5px; font-variant-numeric: tabular-nums; }
@media (max-width: 900px) { .duel-delta { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 12px; } }

/* tables */
table.lr thead tr.grp th {
  font-family: var(--font-cond); font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-3); text-align: center; padding: 8px 4px 2px; border-bottom: 1px solid var(--line);
}
table.lr thead .hl { display: block; padding: 6px 4px; text-align: center; }
table.lr thead th.first .hl { text-align: left; }
table.lr thead .hc { display: inline-flex; align-items: center; gap: 5px; }
table.lr td.c.plain { background: transparent; color: var(--ink-2); font-weight: 500; }
table.lr td.c.win { background: transparent; min-width: 96px; }
table.lr tr.pickable { cursor: pointer; }
table.lr tr.pickable:hover th, table.lr tr.sel th { color: var(--accent); }
table.lr tr.total th, table.lr tr.total td.c { font-weight: 700; }
table.lr tr.gem-head th {
  position: static; background: transparent; font-family: var(--font-cond); font-size: 18px; font-weight: 700;
  padding: 16px 6px 4px; color: var(--ink); max-width: none;
}
table.lr tr.gem-head th small { font-family: var(--font); font-size: 12.5px; font-weight: 500; color: var(--ink-3); margin-left: 6px; }
table.lr tr.brief th { font-style: italic; color: var(--ink-2); }
.flip {
  display: inline-block; margin-left: 6px; font-size: 10.5px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--accent);
}

/* turnout */
.turn-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr)); gap: 12px; padding: 14px 16px 4px; }
.turn-note { padding: 4px 16px 14px; }
table.lr td.c.t { min-width: 58px; }


/* Kickerzeile über der Auswahl (wie .kicker auf der Vereinsseite) */
.wahlatlas > .eyebrow { margin-bottom: 0; }
.wa-head { margin-top: 0.75rem; }
