/* ==========================================================================
   Politik in Zahlen – gemeinsames Stylesheet
   Gehört der Startseiten-Session. Themen-Seiten binden es nur ein
   (<link rel="stylesheet" href="style.css">) und ändern es nicht.
   Änderungswünsche bitte an den Orchestrator melden.

   DESIGN-TOKENS (in :root, hell/dunkel automatisch per prefers-color-scheme)
     --bg, --surface, --surface-2   Hintergrund, Karten, leicht abgesetzte Flächen
     --text, --muted, --border      Text, Sekundärtext, Linien
     --accent, --accent-text        Links/Hervorhebung und Text darauf
     --good, --bad                  Positiv/negativ (sparsam, nicht wertend einsetzen!)
     --chart-1 … --chart-6          Diagrammfarben (Reihenfolge = Serienreihenfolge)
     --chart-axis, --chart-grid, --chart-ink   Achsen, Gitterlinien, Achsenbeschriftung
     In JS (Chart.js) lesen: getComputedStyle(document.documentElement)
                               .getPropertyValue('--chart-1').trim()

   STARTSEITE
     .site-header / .site-intro     Kopf und Einleitung der Startseite
     .topic-grid > a.topic-card     Kachel-Raster; Karte mit .topic-icon, h2, p
     .site-footer                   Fußzeile (Quellenpflicht/Methodik)

   UNTERSEITEN (Vorlage: template.html)
     .page-header                   Kopf: a.back-link (→ index.html), h1, p.lead
     .kpi-grid > .kpi               Kennzahl-Kacheln:
         .kpi-value                 die Zahl (deutsches Format, z. B. 1.234,5)
         .kpi-label                 was gemessen wird
         .kpi-source                Quelle + Stand, z. B. „Destatis, Stand 03/2026 [1]“
     .section                       Inhaltsabschnitt (h2, Fließtext, Karten)
     .chart-card                    Rahmen für ein Diagramm: h3, dann <svg> oder
                                    <div class="chart-box"><canvas></canvas></div>,
                                    darunter <p class="chart-caption"> (Quelle/Stand)
     .table-wrap > table.data-table Tabelle; .table-wrap scrollt auf dem Handy intern.
                                    td.num = Zahlenspalte (rechtsbündig, tabellarische Ziffern)
     .source-ref                    Quellenverweis im Text: <a class="source-ref" href="#q1">[1]</a>
     ol.sources > li#qN             Nummeriertes Quellenverzeichnis; je Eintrag Titel,
                                    Herausgeber, URL, <span class="accessed">Abgerufen am …</span>
     .note                          Definition/Hinweis-Kasten; optional <strong class="note-title">
     .note.warn                     Hinweis zu Einschränkungen/Brüchen in Zeitreihen
     .placeholder                   NUR in template.html: markiert Platzhalter sichtbar
   ========================================================================== */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --text: #1b2230;
  --muted: #5a6376;
  --border: #d9dde6;
  --accent: #2456c7;
  --accent-text: #ffffff;
  --good: #1f8a5b;
  --bad: #c2413b;
  --shadow: 0 2px 10px rgba(20, 30, 60, 0.07);
  --radius: 14px;

  --chart-1: #2a78d6;
  --chart-2: #e08a1e;
  --chart-3: #2f9e6e;
  --chart-4: #8a5cc7;
  --chart-5: #d4557f;
  --chart-6: #6b7a8f;
  --chart-axis: #b9bdc7;
  --chart-grid: #e4e6eb;
  --chart-ink: #6b7280;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11141b;
    --surface: #1b1f2a;
    --surface-2: #252a38;
    --text: #e7e9f0;
    --muted: #9aa2b6;
    --border: #323849;
    --accent: #7ea2ff;
    --accent-text: #0f1219;
    --good: #4cc38a;
    --bad: #ec7a74;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.35);

    --chart-1: #4b91ea;
    --chart-2: #f0a043;
    --chart-3: #4cbb8a;
    --chart-4: #a784de;
    --chart-5: #e0799c;
    --chart-6: #8e9bb0;
    --chart-axis: #454b5a;
    --chart-grid: #2b303c;
    --chart-ink: #9aa2b6;
  }
}

/* ---------- Basis ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.55;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-wrap: break-word;
}
main { flex: 1; width: 100%; max-width: 980px; margin: 0 auto; padding: 1.5rem 1rem 2.5rem; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 0.8rem; }
a { color: var(--accent); }
img, svg, canvas { max-width: 100%; }

/* ---------- Startseite ---------- */
.site-header { text-align: center; padding: 2.5rem 1rem 0.5rem; }
.site-header .site-mark { font-size: 2.4rem; line-height: 1; }
.site-header h1 { margin-top: 0.4rem; }
.site-header .subtitle { color: var(--muted); margin: 0.4rem 0 0; }
.site-intro { max-width: 680px; margin: 0.5rem auto 2rem; text-align: center; color: var(--muted); }

.topic-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}
/* 10 Kacheln: 2 Spalten ergeben volle Reihen (kein Einzelgänger in der letzten Zeile) */
@media (min-width: 560px) {
  .topic-grid { grid-template-columns: repeat(2, 1fr); }
}
.topic-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.topic-card:hover, .topic-card:focus-visible { transform: translateY(-3px); border-color: var(--accent); }
.topic-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.topic-icon { font-size: 2.2rem; line-height: 1; }
.topic-card h2 { margin: 0.6rem 0 0.4rem; font-size: 1.2rem; }
.topic-card p { color: var(--muted); font-size: 0.95rem; margin: 0; }

.site-footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
  padding: 1.5rem 1rem;
}
.site-footer .footer-inner { max-width: 980px; margin: 0 auto; }
.site-footer h2 { font-size: 1rem; color: var(--text); margin-bottom: 0.4rem; }
.site-footer ul { margin: 0 0 0.8rem; padding-left: 1.2rem; }

/* ---------- Unterseiten: Kopf ---------- */
.page-header { max-width: 980px; width: 100%; margin: 0 auto; padding: 1.5rem 1rem 0.5rem; }
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.95rem;
  text-decoration: none;
  padding: 0.35rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
}
.back-link:hover { border-color: var(--accent); color: var(--accent); }
.page-header h1 { margin-top: 1rem; }
.page-header .lead { color: var(--muted); margin: 0.5rem 0 0; max-width: 720px; }

/* ---------- Kennzahlen ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin: 1rem 0 2rem;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.kpi-value {
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.kpi-value .unit { font-size: 1rem; font-weight: 600; color: var(--muted); margin-left: 0.2rem; }
.kpi-label { font-size: 0.95rem; }
.kpi-source { font-size: 0.8rem; color: var(--muted); margin-top: auto; }

/* ---------- Abschnitte, Diagramme ---------- */
.section { margin: 2.5rem 0; }
.section > h2 { margin-bottom: 0.8rem; padding-bottom: 0.4rem; border-bottom: 1px solid var(--border); }
.section > h3 { margin: 1.4rem 0 0.5rem; }

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow);
  margin: 1rem 0;
}
.chart-card h3 { margin-bottom: 0.7rem; }
.chart-card svg { display: block; width: 100%; height: auto; }
.chart-box { position: relative; width: 100%; height: 320px; }
.chart-caption { font-size: 0.82rem; color: var(--muted); margin: 0.7rem 0 0; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; font-size: 0.85rem; color: var(--muted); margin: 0 0 0.6rem; padding: 0; list-style: none; }
.chart-legend .swatch { display: inline-block; width: 0.8em; height: 0.8em; border-radius: 3px; margin-right: 0.35em; vertical-align: -0.05em; }

/* ---------- Tabellen ---------- */
.table-wrap { width: 100%; overflow-x: auto; margin: 1rem 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.data-table caption { caption-side: top; text-align: left; font-weight: 600; padding: 0.8rem 1rem 0.4rem; }
.data-table th, .data-table td { padding: 0.55rem 1rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.data-table thead th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
.data-table tbody tr:last-child td, .data-table tbody tr:last-child th { border-bottom: 0; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table tfoot td { font-size: 0.82rem; color: var(--muted); border-bottom: 0; }

/* ---------- Quellen ---------- */
.source-ref {
  font-size: 0.78em;
  vertical-align: super;
  line-height: 0;
  text-decoration: none;
  font-weight: 600;
  margin-left: 0.1em;
}
.source-ref:hover { text-decoration: underline; }

.sources { padding-left: 1.6rem; margin: 0.5rem 0; font-size: 0.9rem; }
.sources li { margin: 0 0 0.7rem; padding-left: 0.2rem; }
.sources li:target { background: var(--surface-2); border-radius: 6px; outline: 4px solid var(--surface-2); }
.sources .publisher { color: var(--muted); }
.sources a { word-break: break-all; }
.sources .accessed { display: block; color: var(--muted); font-size: 0.85em; }

/* ---------- Hinweise ---------- */
.note {
  background: var(--surface-2);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 0.8rem 1rem;
  margin: 1rem 0;
  font-size: 0.95rem;
}
.note p:last-child { margin-bottom: 0; }
.note .note-title { display: block; margin-bottom: 0.25rem; }
.note.warn { border-left-color: var(--chart-2); }

/* ---------- Nur Vorlage ---------- */
.placeholder {
  background: repeating-linear-gradient(45deg, transparent 0 6px, rgba(224, 138, 30, 0.12) 6px 12px);
  outline: 1px dashed var(--chart-2);
  border-radius: 3px;
}

@media (max-width: 520px) {
  h1 { font-size: 1.55rem; }
  .kpi-value { font-size: 1.6rem; }
  .chart-box { height: 260px; }
  .data-table th, .data-table td { padding: 0.5rem 0.7rem; }
}
