/* ParlStats — design tokens (light / dark) and layout.
   Quiet, editorial style; charts after ggplot2's theme_grey (grey panel, white grid).
   Party colours stay (they carry meaning). One project colour (--brand, no party uses
   it) carries the identity: masthead, footer, headings, numbers, active controls, tiles.
   Project colour: Nachtblau #1e2463 (chosen 04.12.2026, intern/marke.md). */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f2f2f0;
  --border: #e3e3e0;
  --text: #141414;
  --text-2: #4a4a4a;
  --text-3: #737373;
  --brand: #1e2463;
  --brand-tint: color-mix(in oklab, var(--brand) 6%, #ffffff);
  --brand-soft: color-mix(in oklab, var(--brand) 55%, #ffffff);
  --brand-text: var(--brand);   /* project colour as text on the page background */
  --accent: var(--brand);
  --accent-ink: #ffffff;
  --panel: #ebebeb;
  --grid: #ffffff;
  --bar: var(--brand-soft);
  --f0: #4a4f5e; /* CDU/CSU — conventional dark grey, see intern/konzept.md */
  --f1: #d71f2c; /* SPD */
  --f2: #1f86cc; /* AfD */
  --f3: #c79600; /* FDP */
  --f4: #2e9446; /* GRÜNE */
  --f5: #b0257a; /* LINKE */
  --f6: #6a4cc7; /* BSW */
  --f7: #8a8f98; /* fraktionslos */
  --radius: 4px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #151515;
    --surface: #151515;
    --surface-2: #222221;
    --border: #2e2e2d;
    --text: #ededec;
    --text-2: #bdbdbb;
    --text-3: #8c8c8a;
    --brand-tint: color-mix(in oklab, var(--brand) 22%, #151515);
    --brand-soft: color-mix(in oklab, var(--brand) 45%, #8c8c8a);
    --brand-text: color-mix(in oklab, var(--brand) 35%, #ffffff);
    --accent: var(--brand-text);
    --accent-ink: #111111;
    --panel: #252524;
    --grid: #343433;
    --bar: var(--brand-soft);
    --f0: #9aa0b0;
    --f1: #f0505a;
    --f2: #3d97dc;
    --f3: #d9ab1f;
    --f4: #3faa5a;
    --f5: #e05aae;
    --f6: #8e6bff;
    --f7: #8a8f98;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 "Inter", system-ui, sans-serif;
}
a { color: var(--brand-text); }
h1, h2, h3 { font-family: "Inter", system-ui, sans-serif; font-weight: 700; letter-spacing: -0.025em; line-height: 1.1; margin: 0; }
h2 { font-size: clamp(1.4rem, 2.4vw, 1.75rem); color: var(--brand-text); }
/* one content width for everything: masthead, filters, sections, footer */
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
section { margin: 64px 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
#highlights h2 { margin-bottom: 16px; }

/* masthead */
.hero { background: var(--brand); color: #ffffff; padding: 64px 0 40px; }
/* brand lockup: mark on the wordmark's baseline, claim below; see intern/marke.md */
.brand { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: clamp(12px, 2.4vw, 24px); align-items: end; }
.brand-mark { grid-row: 1; color: inherit; }
.brand-mark svg { display: block; height: clamp(46px, 10vw, 112px); width: auto; }
.hero .brand h1.wordmark { grid-row: 1; font: 760 clamp(2.7rem, 9vw, 5.4rem)/0.86 "ParlStats Serif", Georgia, serif; letter-spacing: -0.012em; }
.brand .claim { grid-column: 2; margin: 10px 0 0; font: 500 clamp(0.95rem, 1.7vw, 1.2rem)/1.3 "Inter", sans-serif; opacity: 0.85; }
.lede { max-width: 640px; font-size: 1.1rem; opacity: 0.85; margin: 16px 0 0; }

/* filters: a full-width row; the period note sits above the bar's bottom rule */
.filters { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.filter-row { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr) auto; gap: 12px 16px; align-items: end; padding-top: 10px; padding-bottom: 12px; }
.fgroup { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.flabel { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.02em; color: var(--text-3); }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 6px; padding: 3px; height: 38px; }
.seg button { border: 0; background: transparent; color: var(--text-2); font: 600 0.88rem "Inter", sans-serif; padding: 0 14px; border-radius: 4px; cursor: pointer; white-space: nowrap; }
.seg button[aria-checked="true"] { background: var(--brand); color: #ffffff; }
.fgroup select { appearance: none; -webkit-appearance: none; width: 100%; height: 38px; font: 500 0.92rem "Inter", sans-serif; color: var(--text); background-color: var(--surface);
  border: 1px solid var(--border); border-radius: 4px; padding: 0 34px 0 12px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 17px) 16px, calc(100% - 12px) 16px; background-size: 5px 5px; background-repeat: no-repeat; }
.fgroup select:disabled { opacity: 0.5; cursor: not-allowed; }
.pill-check { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px 0 12px; border: 1px solid var(--border); border-radius: 4px;
  background: var(--surface); font: 500 0.9rem "Inter", sans-serif; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.pill-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--brand); }
.period-note { margin: -4px 0 0; padding-bottom: 10px; font-size: 0.85rem; color: var(--text-2); }
.period-note[hidden] { display: none; }
.field { display: inline-flex; flex-direction: column; gap: 2px; font-size: 0.75rem; color: var(--text-3); font-weight: 600; }
.field select, .field textarea { font: 500 0.95rem "Inter", sans-serif; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 7px 10px; }
.field textarea { resize: vertical; width: 100%; }
.note { background: var(--brand-tint); border-left: 3px solid var(--brand); padding: 10px 14px; color: var(--text-2); margin-top: 24px; }

/* cards: four per row on wide screens */
.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.card { position: relative; color: var(--text); background: var(--brand-tint); border-top: 3px solid var(--brand); border-radius: var(--radius); padding: 22px 22px 18px; min-height: 190px; display: flex; flex-direction: column; overflow: hidden; }
.card .k { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600; color: var(--text-3); }
.card .h { font: 600 1.02rem/1.3 "Inter", sans-serif; margin-top: 6px; }
.card .big { font: 700 clamp(2.2rem, 5vw, 2.9rem)/1 "Inter", sans-serif; color: var(--brand-text); margin-top: auto; padding-top: 14px; letter-spacing: -0.04em; font-variant-numeric: tabular-nums;
  display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 8px; row-gap: 2px; }
.card .big small { font-size: 0.4em; font-weight: 600; letter-spacing: 0; color: var(--text-3); }
.card .sub { font-size: 0.95rem; color: var(--text-2); margin-top: 6px; padding-right: 70px; }
.card .card-share { position: absolute; right: 12px; bottom: 12px; z-index: 1; }

/* share buttons: icon-only with the share symbol (share.js) */
.share-btn, .card-share { cursor: pointer; font: 600 0.85rem "Inter", sans-serif; border-radius: 4px; }
.share-btn { background: transparent; color: var(--brand-text); border: 1px solid var(--brand-text); padding: 7px 12px; }
.share-btn:hover, .share-btn:focus-visible { background: var(--brand); border-color: var(--brand); color: #ffffff; }
.card-share { background: transparent; color: var(--text-2); border: 1px solid var(--border); }
.card-share:hover, .card-share:focus-visible { background: var(--surface-2); color: var(--text); }
.share-icon { display: block; width: 20px; height: 20px; }
.share-btn.icon, .card-share { display: inline-flex; align-items: center; justify-content: center; padding: 0; width: 40px; height: 40px; }
.card-share { width: 36px; height: 36px; }

/* chips: all metrics in one row */
.chips { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: thin; }  /* one row on desktop */
.chips button { flex: 1 0 auto; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); border-radius: 4px; padding: 7px 6px; font: 600 0.85rem "Inter", sans-serif; cursor: pointer; white-space: nowrap; }
.chips button[aria-selected="true"] { background: var(--brand); color: #ffffff; border-color: var(--brand); }
.metric-desc { color: var(--text-3); font-size: 0.9rem; margin: 12px 0; }

/* ranking: a list, not a stack of boxes */
.ranking { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; border-top: 2px solid var(--brand); }
.ranking li { display: grid; grid-template-columns: 2rem minmax(0, 1fr) auto; align-items: center; gap: 4px 12px; padding: 12px 4px; border-bottom: 1px solid var(--border); }
.ranking .pos { font: 700 0.95rem "Inter", sans-serif; font-variant-numeric: tabular-nums; color: var(--brand-text); }
.ranking .who { min-width: 0; }
.ranking .name { font-weight: 600; }
.ranking .meta { color: var(--text-3); font-size: 0.85rem; }
.ranking .val { font: 700 1.05rem "Inter", sans-serif; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.ranking .val small { display: block; font: 500 0.75rem "Inter", sans-serif; color: var(--text-3); }
.ranking .track { grid-column: 2 / 4; height: 6px; background: var(--panel); overflow: hidden; }
.ranking .track i { display: block; height: 100%; background: var(--fc, var(--bar)); }
.fdot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: 0; background: var(--fc); }
.empty { color: var(--text-3); padding: 12px; }

/* KPIs: numbers on a rule, all in one row */
.kpis { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi { border-top: 2px solid var(--brand); padding: 12px 0 4px; }
.kpi .v { font: 700 1.5rem/1.1 "Inter", sans-serif; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; color: var(--brand-text); white-space: nowrap; }
.kpi .l { color: var(--text-2); font-size: 0.85rem; line-height: 1.3; margin-top: 2px; }

/* charts: ggplot2 theme_grey — grey panel, white grid, no frame */
.chart-card { margin: 0 0 16px; }
.chart-card figcaption { display: flex; flex-direction: column; margin-bottom: 12px; }
.chart-card figcaption span { color: var(--text-3); font-size: 0.85rem; }
.timeline { position: relative; width: 100%; height: 220px; }
.timeline svg { display: block; width: 100%; height: 100%; }
.timeline .axis text { fill: var(--text-3); font-size: 11px; }
.timeline .panel { fill: var(--panel); }
.timeline .grid line { stroke: var(--grid); stroke-width: 1.2; }
.timeline rect.b { fill: var(--bar); rx: 0; }
.timeline rect.b.hi { fill: var(--brand-text); }
.legend { display: flex; gap: 16px; font-size: 0.85rem; color: var(--text-2); margin-bottom: 8px; }
.sw { display: inline-block; width: 14px; height: 10px; border-radius: 2px; margin-right: 6px; }
.sw-solid { background: var(--text-2); }
.sw-seat { background: repeating-linear-gradient(135deg, var(--text-3) 0 2px, transparent 2px 5px); border: 1px solid var(--text-3); }
.bs-chart { display: grid; gap: 10px; }
.bs-row { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: 10px; align-items: center; }
.bs-label { font-weight: 600; font-size: 0.9rem; }
.bs-bars { display: grid; gap: 2px; background: var(--panel); padding: 3px 0;
  background-image: repeating-linear-gradient(90deg, var(--grid) 0 1px, transparent 1px 20%); }
.bs-bar { position: relative; height: 16px; display: flex; align-items: center; }
.bs-bar i { display: block; height: 100%; }
.bs-bar.speech i { background: var(--fc); }
.bs-bar.seat i { background: repeating-linear-gradient(135deg, var(--fc) 0 2px, transparent 2px 5px); border: 1px solid var(--fc); border-left: 0; }
.bs-bar span { font-size: 0.78rem; color: var(--text-2); margin-left: 6px; white-space: nowrap; }

/* table */
.table-wrap { overflow-x: auto; margin-bottom: 16px; border-top: 2px solid var(--brand); }
table.data { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
table.data th, table.data td { padding: 9px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--border); }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data th { color: var(--text-3); font-weight: 600; font-size: 0.78rem; }
table.data tr:last-child td { border-bottom: 0; }

/* tooltip */
.tooltip { position: fixed; z-index: 50; pointer-events: none; background: var(--text); color: var(--bg); font-size: 0.82rem; padding: 6px 10px; border-radius: 4px; max-width: 260px; box-shadow: 0 4px 12px rgb(0 0 0 / 0.2); }

/* prose / footer */
.prose { color: var(--text-2); }
.prose li { margin-bottom: 8px; }
/* legal pages (impressum.html, datenschutz.html) */
.hero-slim { padding: 28px 0 24px; }
.home-link img { display: block; max-width: 70vw; height: auto; }
.legal { padding-top: 32px; padding-bottom: 48px; }
.legal h2 { margin-bottom: 16px; }
.legal h3 { font: 600 1rem/1.3 "Inter", sans-serif; margin: 24px 0 4px; }
.legal p, .legal li { color: var(--text-2); }
.legal .todo { background: #fff3c4; color: #5c4400; padding: 6px 10px; }
.legal span.todo { padding: 0 4px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.site-foot { background: var(--brand); color: rgb(255 255 255 / 0.85); font-size: 0.85rem; padding: 24px 0 40px; }
.site-foot a { color: #ffffff; }

/* dialog */
dialog { border: 0; border-radius: 6px; padding: 0; background: var(--surface); color: var(--text); width: min(960px, calc(100vw - 24px)); max-height: calc(100vh - 24px); }
dialog::backdrop { background: rgb(0 0 0 / 0.55); }
.dialog-inner { padding: 20px; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.icon-btn { border: 0; background: var(--surface-2); color: var(--text); width: 36px; height: 36px; border-radius: 4px; cursor: pointer; font-size: 1rem; }
.dialog-body { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 20px; }
.preview { background: var(--surface-2); border-radius: 4px; display: flex; justify-content: center; align-items: center; padding: 12px; min-height: 280px; }
.preview canvas { max-width: 100%; max-height: 62vh; height: auto; }
.preview canvas, .gallery canvas { border-radius: 2px; box-shadow: 0 1px 2px rgb(0 0 0 / 0.08), 0 4px 14px rgb(0 0 0 / 0.08); }
.dialog-side { display: flex; flex-direction: column; gap: 14px; }
.dialog-side .field input { font: 500 0.9rem "Inter", sans-serif; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 7px 10px; width: 100%; }
.formats { border: 0; padding: 0; margin: 0; display: grid; gap: 6px; }
.formats legend { font-size: 0.75rem; color: var(--text-3); font-weight: 600; margin-bottom: 4px; }
.formats label { display: flex; gap: 8px; font-size: 0.9rem; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.dialog-actions button { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 4px; padding: 9px 16px; font: 600 0.9rem "Inter", sans-serif; cursor: pointer; }
.dialog-actions button.primary { background: var(--brand); color: #ffffff; border-color: var(--brand); }
.dialog-actions button.share-main { display: inline-flex; align-items: center; justify-content: center; padding: 0; width: 48px; }
.dialog-actions button.share-main .share-icon { width: 22px; height: 22px; }
.tile-status { margin: 0; min-height: 1.3em; font-size: 0.9rem; color: var(--text-2); }
.tile-report { margin: 0; font-size: 0.85rem; color: var(--text-3); }

button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* tile gallery */
.gallery-controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 16px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.gallery canvas { width: 100%; height: auto; cursor: pointer; }

/* MdB list and profile ("Steckbrief") */
body.view-profile main > section:not(#profile) { display: none; }
.field.search input { font: 500 1rem "Inter", sans-serif; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 9px 12px; width: min(420px, 100%); }
.person-list { list-style: none; margin: 12px 0 0; padding: 8px; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 2px 16px; max-height: 440px; overflow-y: auto; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); }
.person-list a { display: flex; flex-direction: column; padding: 6px 8px; border-radius: 2px; color: var(--text); text-decoration: none; }
.person-list a:hover, .person-list a:focus-visible { background: var(--surface-2); }
.person-list .pn { font-weight: 600; }
.person-list .pm { font-size: 0.8rem; color: var(--text-3); }
.ranking .name a { color: inherit; text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px; }
.ranking .name a:hover { text-decoration-color: currentColor; }
.back { display: inline-block; font-weight: 600; font-size: 0.9rem; text-decoration: none; margin: 24px 0 12px; }
.profile-head h2 { font-size: clamp(2rem, 5vw, 3rem); letter-spacing: -0.035em; display: flex; align-items: center; gap: 12px; }
.profile-head h2 .fdot { width: 16px; height: 16px; }
.profile-meta { color: var(--text-2); margin: 10px 0 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 0.95rem; }
.profile-actions { margin-top: 16px; display: flex; gap: 8px; flex-wrap: wrap; }
.pm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; margin-top: 16px; }
.pm-card { border-top: 2px solid var(--brand); padding: 12px 0 8px; }
.pm-card .l { color: var(--text-2); font-size: 0.85rem; font-weight: 600; }
.pm-card .v { font: 700 1.7rem/1.1 "Inter", sans-serif; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; color: var(--brand-text); margin-top: 4px; }
.pm-card .v small { font-size: 0.45em; color: var(--text-3); font-weight: 700; margin-left: 6px; }
.pm-rank { font-size: 0.85rem; color: var(--text-2); margin-top: 6px; }
.pstrip { position: relative; height: 18px; margin: 12px 6px 4px; }
.pstrip .ptrack { position: absolute; left: 0; right: 0; top: 7px; height: 4px; background: var(--panel); }
.pstrip .pmed, .pstrip .pfac { position: absolute; top: 1px; width: 2px; height: 16px; transform: translateX(-1px); }
.pstrip .pmed { background: var(--text-3); }
.pstrip .pfac { background: var(--fc); }
.pstrip .pdot { position: absolute; top: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--fc); border: 2px solid var(--surface); transform: translateX(-7px); }
.pm-legend { font-size: 0.75rem; color: var(--text-3); display: flex; justify-content: space-between; gap: 8px; }
.pm-legend i { display: inline-block; width: 2px; height: 10px; margin-right: 4px; vertical-align: -1px; }
.sub-h { font-size: 1.2rem; margin: 32px 0 0; }
.speech-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 4px; }
.speech-list li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 4px; }
.speech-list .sd { font-weight: 600; }
.speech-list .sm { color: var(--text-3); font-size: 0.85rem; }

@media (max-width: 1040px) {
  /* tidy grid instead of ragged wrapping: type | period + faction | government */
  .filter-row { grid-template-columns: 1fr 1fr; }
  .fg-type { grid-column: 1 / -1; }
  .fg-type .seg { display: flex; }
  .fg-type .seg button { flex: 1; padding: 0 8px; }
  .pill-check { align-self: flex-start; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis { grid-auto-flow: row; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .chips { flex-wrap: wrap; overflow: visible; }
}
@media (max-width: 720px) {
  .filters { position: static; }
  .dialog-body { grid-template-columns: 1fr; }
  .bs-row { grid-template-columns: 5.5rem minmax(0, 1fr); }
  .seg button { font-size: 0.82rem; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  section { margin: 40px 0; }
}
@media (max-width: 520px) {
  .cards { grid-template-columns: 1fr; }
}
