/* ============================================================
   SCHRIFT — Source Sans 3, self-hosted
   ============================================================ */
/* SIL Open Font License 1.1 (siehe static/fonts/OFL.txt). Bezug und
   Herkunft: static/fonts/SOURCE.txt. Variable Schrift (wght 200–900),
   latin-Subset; die drei Regeln decken die genutzten Gewichte ab. */
@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/source-sans-3-latin-var.woff2") format("woff2");
}
@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/fonts/source-sans-3-latin-var.woff2") format("woff2");
}
@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/static/fonts/source-sans-3-latin-var.woff2") format("woff2");
}

/* ============================================================
   DESIGN TOKENS — Bochum Design Language
   ============================================================ */
:root {
  --cyan: #0AB4FF;
  --blue: #0F2864;
  --orange: #F49100;
  --green: #76B729;
  --red: #E61937;
  --bg: #F6F6F6;
  --card-bg: #FFFFFF;
  --text: #1A1A1A;
  --text-secondary: #4A5568;
  --text-muted: #5A6472;
  --border-light: #E2E8F0;
  --radius: 12px;
  --shadow-card: 0 2px 16px rgba(0,0,0,0.08);
  --shadow-card-hover: 0 8px 32px rgba(0,0,0,0.14);

  /* Farben für Diagramme. Regel (siehe README, Regel 11):
     - zwei Balken oder zwei Linien im Vergleich: --blue und --cyan
     - negative Zahlen (Defizit, Ausgaben): --red (Bochum-Pinkrot)
     - positive Zahlen (Überschuss, Einnahmen): --green (helleres Bochum-Grün)
     - mehr als zwei Reihen: die Bochumer Reihe in dieser Folge:
       green, cyan, blue, orange, red, #7A5EA8, #0E7C86, #B4531F
     - Jahre ohne veröffentlichten Wert: #B9C2CC (hell), nie geschätzt */
  --chart-series-1: var(--blue);
  --chart-series-2: var(--cyan);
  --chart-deficit: var(--red);
  --chart-surplus: var(--green);
  --chart-missing: #B9C2CC;

  /* Zählreihen werden nach WERT eingefärbt, nie einfarbig (Regel 11 der
     Vorlage, bewusste Ergänzung der Bochumer Palette): Hitze-Größen in
     einer warmen Skala (Gelb -> Orange -> Rot), Frost/Eis/Regen in einer
     kalten (Cyan -> Dunkelblau). Die Skala folgt dem Wertebereich der Reihe,
     0 Tage sind hell/neutral. Gerechnet wird an einer Stelle in
     app/kennwerte.py (FARBEN); diese Tokens halten dieselben Werte fürs
     Styling bereit (tests/test_farbskala.py hält beide zusammen). */
  --chart-neutral: #F1F1F1;
  --chart-warm-1: #F5C400;
  --chart-warm-2: #F49100;
  --chart-warm-3: #E61937;
  --chart-cold-1: #0AB4FF;
  --chart-cold-2: #0F2864;
}

[data-theme="dark"] {
  --bg: #12161C;
  --card-bg: #1A1F27;
  --text: #E6EDF5;
  --text-secondary: #A8B3C1;
  --text-muted: #7D8896;
  --border-light: #2A313B;
}

* { box-sizing: border-box; }
/* Der Kopf ist 100vw breit und um calc(-50vw + 50%) nach links gezogen. Mit
   vertikaler Scrollbar ist 100vw um die Scrollbar-Breite breiter als der
   sichtbare Bereich, der Kopf ragt daher rechts ~8px heraus — ohne Clipping
   entsteht eine horizontale Scrollbar (gemessen: scrollWidth 1273 statt 1265).
   Mikromobilität nutzt hier overflow-x: hidden. hidden macht html/body aber
   zum Scroll-Container und schaltet damit den klebenden Kopf ab; clip clipst
   genauso, ohne den Sticky-Kontext zu zerstören. hidden bleibt als Fallback
   für alte Browser. */
html { height: 100%; -webkit-text-size-adjust: 100%;
       overflow-x: hidden; overflow-x: clip; }
body { margin: 0; background: var(--bg); color: var(--text);
       /* Arial-Test (offizieller Fallback der Stadt Bochum). Die
          Source-Sans-3-@font-face-Regeln oben bleiben absichtlich stehen,
          für einen leichten Rückbau. */
             font-family: "Source Sans 3", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
       font-size: 16px; line-height: 1.5;
       overflow-x: hidden; overflow-x: clip;
       -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

/* Globale Linkfarbe. ACHTUNG: sie ist der Grund, warum Header und Footer
   weiter unten eigene Regeln brauchen — Cyan auf cyanem Grund ist
   unlesbar, und genau daran sind schon zwei Footer zerbrochen. */
a { color: var(--cyan); text-decoration: none; }

#app { display: flex; flex-direction: column; min-height: 100vh;
       max-width: 1440px; margin: 0 auto; padding: 0 16px; }

/* Luft zwischen Inhalt und Footer. Der Abstand haengt am Inhalt, nicht am
   Footer: dessen margin-top: auto soll ihn bei kurzen Seiten nach unten
   druecken, und ein padding-top dort waere cyan eingefaerbt. */
.view { padding-bottom: 32px; }

/* ============================================================
   HEADER — cyan mit dunkler Schrift
   ============================================================ */
.app-header { position: sticky; top: 0; z-index: 1000; height: 70px;
              background: var(--cyan); border-bottom: 0; margin-bottom: 16px;
              flex-shrink: 0; box-shadow: 0 1px 4px rgba(0,0,0,0.08);
              width: 100vw; margin-left: calc(-50vw + 50%); }
.header-inner { max-width: 1440px; margin: 0 auto; padding: 0 24px; height: 70px;
                display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.header-left { display: flex; align-items: center; gap: 20px; }
.header-logo { height: 36px; width: auto; display: block; }
.header-title { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.02em;
                color: #1A1A1A; white-space: nowrap; }
/* Dunkel, nicht weiss: der Grund ist cyan. */
.header-meta { font-size: 0.8rem; color: #1A1A1A; display: flex; align-items: center;
               gap: 8px; white-space: nowrap; font-weight: 500; }
/* Rechts im Kopf stehen Datenstand-Hinweis und der Theme-Umschalter. */
.header-right { display: flex; align-items: center; gap: 10px; }
/* Umschalter für den dunklen Modus: reines Icon wie in allen anderen
   Dashboards der Plattform. Der Kopf bleibt cyan, deshalb dunkle Schrift
   wie der übrige Kopf. */
.theme-toggle { width: 36px; height: 36px; display: flex; align-items: center;
                justify-content: center; border: 0; border-radius: 999px;
                background: rgba(26,26,26,0.10); color: #1A1A1A;
                cursor: pointer; transition: background 0.15s; flex-shrink: 0; }
.theme-toggle:hover { background: rgba(26,26,26,0.18); }
.theme-icon { width: 20px; height: 20px; }
[data-theme="dark"] .theme-toggle { background: rgba(255,255,255,0.15); color: #1A1A1A; }
[data-theme="dark"] .theme-toggle:hover { background: rgba(255,255,255,0.25); }
.theme-toggle:focus-visible { outline: 2px solid #1A1A1A; outline-offset: 2px; }

/* ============================================================
   FOOTER — cyan mit dunkler Schrift, wie der Header
   ============================================================ */
.app-footer { margin-top: auto; padding: 24px 0; background: var(--cyan);
              width: 100vw; margin-left: calc(-50vw + 50%); }
.footer-inner { max-width: 1440px; margin: 0 auto; padding: 0 16px; display: flex;
                flex-direction: column; align-items: center; gap: 10px; }
.footer-main { font-size: 0.85rem; color: #1A1A1A; text-align: center; }
.footer-brand { font-weight: 700; }
.footer-data { display: block; font-size: 0.78rem; margin-top: 2px; color: rgba(26,26,26,0.75); }
/* Ohne diese beiden Regeln erben die Links die globale Cyan-Farbe und
   verschwinden auf dem cyanen Grund. Gilt fuer JEDEN Link im Footer. */
.footer-main a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.footer-main a:hover { color: rgba(26,26,26,0.7); }
.footer-links { margin-top: 4px; font-size: 0.78rem; }
.footer-links a { color: #1A1A1A; text-decoration: underline; }
.footer-links a:hover { color: rgba(26,26,26,0.7); }

.hint-banner { display: flex; align-items: center; gap: 8px; font-size: 0.78rem;
               color: #8D6E00; background: #FFF8E1; border: 1px solid #FFE082;
               border-radius: 8px; padding: 8px 14px; max-width: 680px; }

/* Header und Footer bleiben im Dark Mode cyan mit dunklem Text. */
[data-theme="dark"] .app-header, [data-theme="dark"] .app-footer { color: #1A1A1A; }

/* Regel 9: Bochum-Dunkelblau #0F2864 ist auf dunklem Grund praktisch
   unsichtbar. Betroffen sind die großen Kernzahlen und der i-Button; sie
   nehmen im Dark Mode einen hellen Ton an. */
[data-theme="dark"] .kernzahl-zahl { color: var(--cyan); }
[data-theme="dark"] .info-btn { background: var(--cyan); color: #1A1A1A; }
[data-theme="dark"] .info-btn:hover,
[data-theme="dark"] .info-btn:focus-visible { background: #FFFFFF; color: #1A1A1A; }

/* ============================================================
   KLIMAKOMPASS — Inhalt (Übersicht)
   Nur die Bochumer Farben aus :root, keine eigenen Töne.
   ============================================================ */
.content { display: flex; flex-direction: column; gap: 16px; }

.card { background: var(--card-bg); border-radius: var(--radius);
        box-shadow: var(--shadow-card); border: 1px solid var(--border-light);
        padding: 20px 22px; }
.card h2 { margin: 0 0 6px; font-size: 1.1rem; }
.lead { margin: 0 0 14px; color: var(--text-secondary); font-size: 0.9rem; }
.note { margin: 10px 0 0; color: var(--text-muted); font-size: 0.8rem; }

/* Fließtext der Einordnung. Links dunkelblau statt global cyan: auf weißer
   Karte ist Cyan kaum lesbar. Im Dark Mode zurück auf Cyan (sonst zu dunkel). */
.fliess p { margin: 0; color: var(--text-secondary); font-size: 0.92rem; line-height: 1.6; }
.card a { color: var(--blue); text-decoration: underline; text-underline-offset: 2px; }
[data-theme="dark"] .card a { color: var(--cyan); }

/* Kernzahlen des laufenden Jahres — acht Zählgrößen plus das Jahresmittel,
   die Hitze-Größen zuerst. Auto-fit, damit die neun Pillen umbrechen statt
   zu quetschen. */
.kernzahlen { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.kernzahl { position: relative; min-width: 0; background: var(--card-bg); border-radius: var(--radius);
            box-shadow: var(--shadow-card); border: 1px solid var(--border-light);
            padding: 16px 18px; transition: transform 0.15s ease, box-shadow 0.15s ease; }
.kernzahl:hover { transform: translateY(-3px); box-shadow: var(--shadow-card-hover); }
.kernzahl-zahl { font-size: 1.9rem; font-weight: 700; color: var(--blue);
                 line-height: 1.2; font-variant-numeric: tabular-nums; }
/* Kleines Label unter der Zahl, wie .kpi-label der Geschwister-Dashboards.
   Lange Komposita ("Jahresmitteltemperatur") müssen in der Pille umbrechen
   dürfen, statt seitlich herauszulaufen — deshalb overflow-wrap und
   Silbentrennung. */
.kernzahl-name { margin-top: 2px; max-width: 100%; color: var(--text-muted);
                 font-size: 0.7rem; font-weight: 600; line-height: 1.3;
                 text-transform: uppercase; letter-spacing: 0.04em;
                 overflow-wrap: anywhere; word-break: break-word;
                 hyphens: auto; -webkit-hyphens: auto; }
/* Unterschrift: Zeitfenster und Station. Steht EINMAL über der Pillen-Reihe,
   nicht in jeder Pille; der Vergleichstext steht im i-Panel. */
.kernzahlen .kernzahl-signatur { grid-column: 1 / -1; margin: 0; color: var(--text-muted);
                                 font-size: 0.78rem; }
.kernzahl-pfeil { font-size: 1.2rem; margin-left: 6px; vertical-align: 0.15em; }

/* Kleines rundes "i" für die Erklärung eines Indikators. In der Pille sitzt
   es oben rechts, nicht mitten in der Beschriftung. Der sichtbare Kreis
   bleibt klein; ein unsichtbarer Rahmen vergrößert die Trefferfläche auf
   Touch-Geräten. */
.info-btn { position: relative; display: inline-flex; align-items: center; justify-content: center;
            width: 17px; height: 17px; margin-left: 6px; padding: 0;
            border: 0; border-radius: 50%; background: var(--blue); color: #FFFFFF;
            font-size: 0.7rem; font-weight: 700; line-height: 1; cursor: pointer;
            vertical-align: middle; }
.kernzahl .info-btn { position: absolute; top: 12px; right: 12px; margin-left: 0; }
.info-btn::before { content: ''; position: absolute; inset: -6px; }
.info-btn:hover, .info-btn:focus-visible { background: var(--cyan); color: #1A1A1A; }
.info-popup { position: absolute; z-index: 50; max-width: 320px;
              background: var(--card-bg); color: var(--text);
              border: 1px solid var(--border-light); border-radius: 8px;
              box-shadow: var(--shadow-card); padding: 10px 12px; font-size: 0.82rem;
              line-height: 1.5; }
.info-popup p { margin: 0; }
.info-popup .info-vergleich { margin-top: 6px; }
.info-popup .info-quelle { margin-top: 6px; color: var(--text-muted); font-size: 0.78rem; }
.info-popup .info-quelle a { color: var(--blue); text-decoration: underline; }
[data-theme="dark"] .info-popup .info-quelle a { color: var(--cyan); }

/* Reihen-Auswahl des Zeitstrahls. Kein i-Button an den Reihen — die
   Erklärung hängt an der jeweiligen Pille. */
.reihen-auswahl { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.reihe-wahl { border: 1px solid var(--border-light); background: transparent;
              color: var(--text-secondary); border-radius: 999px;
              padding: 4px 12px; cursor: pointer; font-size: 0.82rem; }
.reihe-wahl:hover { border-color: var(--blue); color: var(--text); }
.reihe-wahl[aria-pressed="true"] { background: var(--blue); border-color: var(--blue); color: #FFFFFF; }

/* Zeitstrahl */
.chart-wrap { position: relative; height: 360px; }
.legende { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 12px;
           font-size: 0.8rem; color: var(--text-secondary); }
.legende-eintrag { display: inline-flex; align-items: center; gap: 6px; }
.legende-eintrag i { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
/* Farbverlauf der wertabhängigen Skala einer Zählreihe. */
.legende-eintrag .legende-skala { width: 90px; }

/* Zahlen zum Nachlesen: aufklappbare Tabelle je Diagramm — zugleich die
   Textalternative zum Canvas. */
.zahlen { margin-top: 12px; }
.zahlen summary { cursor: pointer; font-size: 0.85rem; font-weight: 600;
                  color: var(--text-secondary); }
.zahlen summary:hover { color: var(--text); }
.zahlen summary:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.tabelle-scroll { overflow: auto; max-height: 320px; margin-top: 8px;
                  border: 1px solid var(--border-light); border-radius: 8px; }
.zahlen table { border-collapse: collapse; width: 100%; font-size: 0.82rem; }
.zahlen caption { text-align: left; padding: 8px 10px; color: var(--text-muted); }
.zahlen th, .zahlen td { text-align: right; padding: 5px 10px;
                         border-bottom: 1px solid var(--border-light); white-space: nowrap; }
.zahlen th:first-child, .zahlen td:first-child { text-align: left; }
.zahlen thead th { position: sticky; top: 0; background: var(--card-bg);
                   color: var(--text-secondary); }
.zahlen tbody tr:nth-child(even) { background: rgba(0,0,0,0.02); }
[data-theme="dark"] .zahlen tbody tr:nth-child(even) { background: rgba(255,255,255,0.03); }

/* Stationsangaben */
.station { padding: 10px 0; border-top: 1px solid var(--border-light); }
.station:first-child { border-top: 0; }
.station-meta { color: var(--text-muted); font-size: 0.82rem; }

@media (max-width: 900px) {
  .kernzahlen { grid-template-columns: repeat(2, 1fr); }
}

