/* ============================================================
   Gemeinsames Design für alle Seiten auf verstehen.io
   Quelle: @Vorlage_Design (design_regeln.md). Aufbau:
     1. Schriften   2. Farben   3. Seite   4. Fenster
     5. Fußzeile    6. Knöpfe oben rechts   7. Druck
   ============================================================ */

/* ---------- 1. SCHRIFTEN (lokal aus data/fonts, nur Latein) ----------
   Genau drei Rollen:
     --font-comic  Überschriften
     --font-text   normaler Text
     --font-code   Code-artiges (hier: Platzhalter-Hinweise)
   Fehlt eine Datei, greift die Ersatzschrift dahinter. */
@font-face { font-family: 'Comic Relief'; font-weight: 400; font-display: swap;
  src: url('../fonts/comic-relief/comic-relief-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Comic Relief'; font-weight: 700; font-display: swap;
  src: url('../fonts/comic-relief/comic-relief-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'M PLUS Rounded 1c'; font-weight: 400; font-display: swap;
  src: url('../fonts/m-plus-rounded-1c/m-plus-rounded-1c-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'M PLUS Rounded 1c'; font-weight: 500; font-display: swap;
  src: url('../fonts/m-plus-rounded-1c/m-plus-rounded-1c-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'M PLUS Rounded 1c'; font-weight: 700; font-display: swap;
  src: url('../fonts/m-plus-rounded-1c/m-plus-rounded-1c-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 400; font-display: swap;
  src: url('../fonts/ibm-plex-mono/ibm-plex-mono-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 500; font-display: swap;
  src: url('../fonts/ibm-plex-mono/ibm-plex-mono-latin-500-normal.woff2') format('woff2'); }

:root {
  --font-comic: 'Comic Relief', 'Comic Sans MS', sans-serif;
  --font-text:  'M PLUS Rounded 1c', 'Segoe UI', sans-serif;
  --font-code:  'IBM Plex Mono', Consolas, monospace;

  /* ---------- 2. FARBROLLEN (Light = Standardwerte) ----------
     Light: --bg ist identisch mit --card-bg. Die Fenster heben sich über
     Rahmen und Schatten nach außen ab. */
  --card-bg: #FFF9E5;         /* Fenster, Felder, Buttons */
  --bg: var(--card-bg);       /* Seitenhintergrund (Light = wie Fenster) */
  --text-primary: #333333;
  --text-secondary: #73736D;
  --text-emphasis: #333333;   /* im Light-Modus identisch mit --text-primary */
  --border: #E0E0E0;
  --stroke: #0A0A0A;          /* Icons */

  --mix-target: black;        /* Mischrichtung für Hover/Fokus: Light = Richtung Schwarz */
  --focus-amount: 20%;
  --window-shadow: 0 0 12px color-mix(in srgb, var(--card-bg), black 20%);  /* nur Light */
}
:root[data-theme="dark"] {
  --bg: #121212;              /* NUR Seitenhintergrund, nie in Fenstern */
  --card-bg: #1E1E1E;
  --text-primary: #B5B5B5;
  --text-secondary: #A0A0A0;
  --text-emphasis: #CBCBCB;
  --border: #454545;
  --stroke: #E6E6E2;

  --mix-target: white;        /* Dark = Richtung Weiß */
  --window-shadow: none;
}

/* Schriftstärke: Dunkle Schrift auf hellem Grund wirkt dünner.
   Fest: Light = 500, Dark = 400. */
:root { --weight-text: 500; --weight-code: 500; }
:root[data-theme="dark"] { --weight-text: 400; --weight-code: 400; }

/* ---------- 3. SEITE ---------- */
body {
  margin: 0; padding: 24px 16px 56px;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-text);
  font-size: 16px; line-height: 1.5;
  font-weight: var(--weight-text);
}
h1, h2, h3 { font-family: var(--font-comic); color: var(--text-emphasis); margin: 0; }
h1 { font-size: 26px; text-align: center; margin-bottom: 6px; }
h2 { font-size: 18px; margin: 22px 0 8px; }
h3 { font-size: 16px; margin: 16px 0 6px; }
.subtitle { text-align: center; color: var(--text-secondary); margin: 0 0 24px; }
a { color: var(--text-emphasis); }
/* Link im Fließtext in Hervorhebungsfarbe, aber ohne Unterstreichung */
a.ohne-linie { text-decoration: none; }
/* Link im Fließtext: normale Textfarbe, fein gepunktet unterstrichen (Test) */
a.punkt-linie { color: inherit; text-decoration: underline dotted; text-underline-offset: 3px; }
.subtitle a { color: var(--text-secondary); text-decoration: none; }
.subtitle a:hover { color: var(--text-emphasis); }
/* Link zur Hauptseite oben auf allen Unterseiten: Schriftgröße wie die Fußzeile, direkt unter der Überschrift (gleicher Block, kein extra Abstand) */
.subtitle.kopflink { font-size: 14px; margin: 0; }

/* ---------- Kopfbereich der Hauptseite: Panda links, Titel rechts ----------
   Schmaler Bildschirm: Titel zuerst, darunter der Panda über der ersten Karte.
   "Pandas" in Comic-Überschriftenschrift, "PDA verstehen" in normaler Textgröße. */
.kopf { display: grid; grid-template-columns: 1fr 1fr; gap: 0; align-items: center; }
/* Seitenrand 21px = Innenabstand der Karte (20px) + Rahmen (1px): die Linie links schließt bündig mit dem Kartentext ab */
.kopf-panda { padding: 0 21px; }
.kopf-panda svg { display: block; width: 100%; height: auto; color: var(--text-primary); }
.kopf-titel { --s: clamp(18px, 4.2vw, 30px); justify-self: center; text-align: center; }
.kopf-titel h1 { font-size: calc(var(--s) * 1.65); line-height: 1; margin: 0; }
.kopf-titel .subtitle { font-size: 16px; line-height: 1.2; margin: 2px 0 0; white-space: nowrap; }
@media (max-width: 600px) {
  .kopf { grid-template-columns: 1fr; gap: 12px; }
  .kopf-titel { --s: clamp(22px, 7vw, 30px); order: -1; }
}

/* ---------- 4. FENSTER (Karten) ---------- */
.stack { max-width: 760px; margin: 0 auto; display: grid; gap: 20px; }
.window {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--window-shadow, none);
}
/* Langer Fließtext im Blocksatz (Seite hat lang="de" für die Silbentrennung) */
.window p { margin: 0 0 10px; text-align: justify; hyphens: auto; }
.window p:last-child { margin-bottom: 0; }
.window h2:first-child { margin-top: 0; }
.window ul { margin: 0 0 10px; padding-left: 22px; }
.window li { margin: 0 0 4px; }
/* "Weiterlesen": dezent, rechts unten, Zweitfarbe, ohne Unterstreichung */
.window p.weiter { text-align: right; font-size: 14px; margin-top: 6px; }
.window p.weiter a { color: var(--text-secondary); text-decoration: none; }
.window p.weiter a:hover { color: var(--text-emphasis); }

/* Autor als zweite Zeile unter dem Buchtitel (nur auf den ausführlichen Buchseiten):
   gleiche Schrift und Farbe wie die H1, etwas kleiner, mittig. */
.titel-autor { font-family: var(--font-comic); font-size: 18px; color: var(--text-emphasis); text-align: center; margin: 0; }

/* Büchersteckbrief: Bewertung links, Details rechts in einer Zeile.
   wrap-reverse: Passen beide nicht nebeneinander, bricht der zweite Block nach OBEN um
   (Details zuerst, Bewertung darunter). space-between: nebeneinander ganz links und ganz
   rechts, untereinander jeweils linksbündig. Keine feste Breitengrenze nötig. */
.buch-zeile {
  display: flex; flex-wrap: wrap-reverse; justify-content: space-between;
  gap: 4px 20px; margin: 0 0 14px;
  font-size: 14px; color: var(--text-secondary);
}

/* Platzhalter, die du noch ausfüllen musst: Code-Schrift, gut sichtbar */
.platzhalter {
  font-family: var(--font-code); font-weight: var(--weight-code);
  font-size: 14px; color: var(--text-emphasis);
  border: 1px dashed var(--border); border-radius: 4px; padding: 0 4px;
}

/* ---------- 5. FUSSZEILE ---------- */
footer { max-width: 760px; margin: 20px auto 0; text-align: center; font-size: 14px; color: var(--text-secondary); }
/* Links nebeneinander, ohne Unterstreichung, mit Punkt dazwischen; beim Drübergehen betonte Farbe */
footer a { color: inherit; text-decoration: none; }
footer a:hover { color: var(--text-emphasis); }
/* Abstand um die Punkte: ab 1200px Breite 8px, darunter stufenlos weniger,
   bei 500px und schmaler 0px. So bleibt die Fußzeile auf dem Handy in einer Zeile. */
footer span { margin: 0 clamp(0px, calc((100vw - 500px) * 0.01143), 8px); }

/* ---------- 6. TAG/NACHT-KNOPF (einziger Umschalter) ---------- */
/* Untereinander: oben Tag/Nacht (im HTML zuletzt), darunter Hauptseite, dann Lesestoff */
.knoepfe { position: fixed; top: 14px; right: 18px; display: flex; flex-direction: column-reverse; align-items: flex-end; gap: 8px; }
.theme-toggle {
  width: 34px; height: 34px; padding: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--card-bg); color: var(--text-primary);
  border: 1px solid var(--border); font-size: 16px; cursor: pointer;
  text-decoration: none; box-sizing: border-box;
}
.theme-toggle svg { width: 18px; height: 18px; display: block; }
/* Drei-Punkte-Knopf (wird vom Skript angelegt): nur auf schmalen Fenstern.
   Dort sind die Knöpfe versteckt und erscheinen erst nach Klick darauf. */
.theme-toggle.menue-knopf { display: none; }
.menue-knopf svg { fill: currentColor; }
@media (max-width: 599px) {
  .theme-toggle.menue-knopf { display: flex; }
  .knoepfe > .theme-toggle:not(.menue-knopf) { display: none; }
  .knoepfe.offen > .theme-toggle { display: flex; }
}
/* Haus-Linien auf ca. 0,9px (wie die Bücher): Rand in Knopffarbe nimmt etwas weg */
.theme-toggle svg.haus path { stroke: var(--card-bg); stroke-width: 0.45; }
.theme-toggle:hover {
  border-width: 2px;
  border-color: color-mix(in srgb, var(--border), var(--mix-target) var(--focus-amount));
}

/* ---------- 7. DRUCK: strikt Schwarz/Weiß, unabhängig vom Theme ---------- */
@media print {
  :root, :root[data-theme="dark"] {
    --bg: #fff; --card-bg: #fff; --text-primary: #000; --text-secondary: #000;
    --text-emphasis: #000; --border: #000; --window-shadow: none;
  }
  .knoepfe { display: none !important; }
}
