/* =============================================================
   wirdigital.at/essen — Datenkompetenz am Beispiel Ernährung
   Setzt design-system.css voraus; handout-theme.css wird danach geladen
   und gibt Kopf, Einstieg, Navigation und Fuß das Aussehen der Handouts.
   Diagrammfarben nach der geprüften Referenzpalette (dataviz).
   ============================================================= */

:root {
  color-scheme: light;
  /* Diagramm-Oberfläche und Tinte */
  --es-flaeche: #ffffff;
  --es-tinte: #0b0b0b;
  --es-tinte-2: #52514e;
  --es-tinte-3: #6b6a66;
  --es-gitter: #e1e0d9;
  --es-achse: #c3c2b7;
  /* Kategorien (Verlauf: Land, Region, Welt) */
  --es-reihe-1: #2a78d6;
  --es-reihe-2: #eb6834;
  --es-reihe-3: #1baf7a;
  /* Sequenzielle Skala (Karte), eine Farbe von hell nach dunkel */
  --es-seq-1: #cde2fb;
  --es-seq-2: #9ec5f4;
  --es-seq-3: #6da7ec;
  --es-seq-4: #3987e5;
  --es-seq-5: #256abf;
  --es-seq-6: #184f95;
  --es-seq-7: #0d366b;
  /* Ordinale Skala (Wohlstandsgruppen) */
  --es-ord-1: #86b6ef;
  --es-ord-2: #3987e5;
  --es-ord-3: #1c5cab;
  --es-ord-4: #0d366b;
  --es-ohne: #ecebe6;
}

/* ---------- Grundlayout (wie die anderen Unterseiten) ---------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--space-5);
}
@media (max-width: 520px) {
  .container { padding-inline: var(--space-4); }
}
.section { padding-block: clamp(56px, 8vw, 88px); }
.section--alt { background: var(--bg-info); }
.section-title { text-align: center; margin-bottom: clamp(var(--space-6), 4vw, var(--space-7)); }
.section-title::after {
  content: '';
  display: block;
  width: 48px;
  height: 3px;
  background: var(--accent);
  border-radius: var(--radius-pill);
  margin: var(--space-4) auto 0;
}

.es-skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 200;
  padding: var(--space-2) var(--space-4);
  background: var(--brand);
  color: #fff;
}
.es-skip:focus { left: var(--space-4); top: var(--space-4); }

/* Kopf */
.ob-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.ob-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: 64px;
  padding-block: var(--space-3);
  flex-wrap: wrap;
}
.ob-header-brand img { height: 40px; width: auto; }
.ob-header-label {
  font-size: var(--fs-small);
  font-weight: var(--fw-bold);
  color: var(--brand);
  white-space: nowrap;
}
.ob-header-actions { display: flex; gap: var(--space-3); flex-wrap: wrap; }
@media (max-width: 560px) {
  .ob-header-label { display: none; }
  .ob-header-brand img { height: 32px; }
}

/* Einstieg */
.ob-hero { padding-block: clamp(48px, 7vw, 72px); }
.ob-hero-eyebrow {
  display: inline-block;
  font-size: var(--fs-small);
  font-weight: var(--fw-bold);
  letter-spacing: .08em;
  text-transform: uppercase;
  margin: 0 0 var(--space-3);
}
.ob-meta-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-6);
  list-style: none;
  margin: 0 0 var(--space-5);
  padding: 0;
}
.ob-meta-list li { font-size: var(--fs-small); }
.ob-meta-list strong { display: block; }
.ob-stand { display: inline-block; }

/* Navigation */
.ob-toc { display: flex; flex-wrap: wrap; }
.ob-toc a { display: inline-block; text-decoration: none; }

/* Fuß */
.ob-footer { padding-block: var(--space-7); }
.ob-footer p { margin: 0 0 var(--space-4); max-width: none; }
.ob-footer-copy { display: block; margin-top: var(--space-5); font-size: var(--fs-caption); }

/* ---------- Text ---------- */
.es-text { max-width: 760px; margin-inline: auto; }
.es-text h2 { margin-bottom: var(--space-5); }
.es-text h3 { margin: var(--space-6) 0 var(--space-3); font-size: var(--fs-h3); }
.es-einleitung {
  max-width: 68ch;
  margin: 0 auto var(--space-6);
  text-align: center;
  color: var(--fg-muted);
}
.es-liste { padding-left: 1.2em; margin: 0 0 var(--space-4); }
.es-liste li { margin-bottom: var(--space-3); }
.es-liste li:last-child { margin-bottom: 0; }

.es-vorab { padding-block: clamp(40px, 6vw, 64px); }
.es-zwei {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-4);
}

.es-hinweis {
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  margin: var(--space-5) 0;
}
.es-zwei .es-hinweis { margin: 0; }
.es-hinweis h3 { margin: 0 0 var(--space-2); font-size: 1.05rem; }
.es-hinweis p:last-child, .es-hinweis ul:last-child { margin-bottom: 0; }
.es-hinweis--frage { border-left-color: var(--accent); background: var(--bg-accent); }
.es-hinweis--ki { border-left-color: var(--success); background: var(--bg-success); }
.es-hinweis--warnung { border-left-color: var(--accent); margin-top: var(--space-5); }

/* ---------- Diagramm-Rahmen ---------- */
.es-figur, .es-karte-figur {
  margin: 0 0 var(--space-5);
  background: var(--es-flaeche);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}
@media (max-width: 520px) {
  .es-figur, .es-karte-figur { padding: var(--space-4) var(--space-3); }
}
.es-figur-kopf { display: block; margin: var(--space-4) 0 var(--space-3); }
.es-figur-titel { display: block; font-weight: var(--fw-bold); color: var(--es-tinte); font-size: 1.05rem; }
.es-figur-unter { display: block; color: var(--es-tinte-2); font-size: var(--fs-small); }
.es-quelle { margin: var(--space-3) 0 0; color: var(--es-tinte-3); font-size: var(--fs-caption); line-height: 1.5; }
.es-diagramm { position: relative; width: 100%; }
.es-diagramm svg { display: block; width: 100%; height: auto; overflow: visible; }

/* ---------- Steuerung (eine Zeile über dem Diagramm) ---------- */
.es-steuerung {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4) var(--space-6);
  align-items: flex-end;
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--es-gitter);
}
.es-steuerung--schmal { border-bottom: 0; padding-bottom: var(--space-3); }
.es-feld { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.es-feld--jahr { flex: 1 1 260px; }
.es-feld-label { font-size: var(--fs-small); font-weight: var(--fw-bold); color: var(--es-tinte-2); }
.es-feld-label output { color: var(--es-tinte); font-variant-numeric: tabular-nums; margin-left: var(--space-1); }
.es-jahr-zeile { display: flex; align-items: center; gap: var(--space-3); }
.es-jahr-zeile input[type="range"] { flex: 1; min-width: 120px; accent-color: var(--brand); height: 32px; }
.es-abspielen { min-width: 104px; }

.es-segment {
  display: inline-flex;
  flex-wrap: wrap;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg);
}
.es-segment button {
  border: 0;
  border-right: 1px solid var(--border-strong);
  background: transparent;
  padding: var(--space-2) var(--space-3);
  font: inherit;
  font-size: var(--fs-small);
  color: var(--es-tinte);
  cursor: pointer;
  min-height: 40px;
}
.es-segment button:last-child { border-right: 0; }
.es-segment button:hover { background: var(--lavendel); }
.es-segment button[aria-checked="true"] { background: var(--brand); color: #fff; }
.es-segment button:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }

select {
  font: inherit;
  font-size: var(--fs-small);
  min-height: 40px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--es-tinte);
  max-width: 100%;
}

/* ---------- Karte ---------- */
.es-karte-flaeche { position: relative; }
.es-karte-flaeche svg { display: block; width: 100%; height: auto; touch-action: pan-y; }
.es-land { stroke: var(--es-flaeche); stroke-width: .6; cursor: pointer; transition: fill var(--dur-base) var(--ease-standard); }
.es-land:hover, .es-land.ist-aktiv { stroke: var(--es-tinte); stroke-width: 1.2; }
.es-land.ist-gewaehlt { stroke: var(--accent); stroke-width: 1.8; }
.es-schraffur { pointer-events: none; }

/* Legende */
.es-legende {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  margin-top: var(--space-3);
  font-size: var(--fs-caption);
  color: var(--es-tinte-2);
}
.es-legende-skala { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0; }
.es-legende-stufe { display: flex; flex-direction: column; gap: 4px; min-width: 52px; }
.es-legende-stufe span:first-child { display: block; height: 12px; margin-right: 2px; }
.es-legende-stufe:first-child span:first-child { border-radius: 4px 0 0 4px; }
.es-legende-stufe:last-child span:first-child { border-radius: 0 4px 4px 0; }
.es-legende-eintrag { display: inline-flex; align-items: center; gap: var(--space-2); }
.es-legende-eintrag i { display: inline-block; width: 14px; height: 12px; border-radius: 3px; }
.es-legende--gruppen { margin: 0 0 var(--space-3); }
.es-legende--gruppen button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  font: inherit;
  font-size: var(--fs-small);
  color: var(--es-tinte);
  cursor: pointer;
  min-height: 36px;
}
.es-legende--gruppen button i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.es-legende--gruppen button[aria-pressed="false"] { opacity: .45; }
.es-legende--gruppen button:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* Verlauf */
.es-verlauf { margin-bottom: var(--space-5); }

/* Kennzahl-Kacheln */
.es-kacheln {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-4);
}
.es-kachel {
  border: 1px solid var(--es-gitter);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  background: var(--bg);
}
.es-kachel-label { display: flex; align-items: center; gap: var(--space-2); font-size: var(--fs-caption); color: var(--es-tinte-2); line-height: 1.4; }
.es-kachel-label i { flex: none; width: 10px; height: 10px; border-radius: 50%; }
.es-kachel-wert { display: block; font-size: 1.6rem; font-weight: var(--fw-semibold); color: var(--es-tinte); line-height: 1.2; margin-top: 2px; }
.es-kachel-zusatz { display: block; font-size: var(--fs-caption); color: var(--es-tinte-3); }
.es-kachel--haupt { background: var(--lavendel); border-color: transparent; }

/* Tooltip */
.es-tooltip {
  position: fixed;
  z-index: 300;
  pointer-events: none;
  background: var(--es-flaeche);
  color: var(--es-tinte);
  border: 1px solid rgba(11, 11, 11, .12);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(11, 11, 11, .12);
  padding: var(--space-2) var(--space-3);
  font-size: var(--fs-small);
  line-height: 1.4;
  max-width: 280px;
}
.es-tooltip strong { display: block; font-size: 1rem; }
.es-tooltip .es-tt-name { color: var(--es-tinte-2); display: block; }
.es-tooltip .es-tt-zeile { display: flex; align-items: center; gap: var(--space-2); justify-content: space-between; }
.es-tooltip .es-tt-zeile i { display: inline-block; width: 12px; height: 2px; border-radius: 1px; flex: none; }
.es-tooltip .es-tt-zeile span { color: var(--es-tinte-2); flex: 1; }
.es-tooltip .es-tt-zeile b { font-variant-numeric: tabular-nums; }
.es-tooltip .es-tt-hinweis { display: block; color: var(--es-tinte-3); font-size: var(--fs-caption); margin-top: 2px; }

/* SVG-Bausteine */
.es-gitterlinie { stroke: var(--es-gitter); stroke-width: 1; shape-rendering: crispEdges; }
.es-achsenlinie { stroke: var(--es-achse); stroke-width: 1; shape-rendering: crispEdges; }
.es-achsentext { fill: var(--es-tinte-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.es-achsentitel { fill: var(--es-tinte-2); font-size: 12px; font-weight: 700; }
.es-linie { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.es-endlabel { font-size: 12px; fill: var(--es-tinte); }
.es-band { fill: var(--lavendel); }
.es-bandtext { font-size: 11px; fill: var(--es-tinte-2); }
.es-fadenkreuz { stroke: var(--es-tinte-3); stroke-width: 1; }
.es-punkt { stroke: var(--es-flaeche); stroke-width: 1.5; }
.es-punkt.ist-hervorgehoben { stroke: var(--es-tinte); stroke-width: 2.5; }
.es-punktlabel { font-size: 12px; font-weight: 700; fill: var(--es-tinte); paint-order: stroke; stroke: var(--es-flaeche); stroke-width: 4px; stroke-linejoin: round; }

/* ---------- Tabelle ---------- */
.es-tabelle-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
}
.es-tabelle-box summary { cursor: pointer; font-weight: var(--fw-bold); color: var(--brand); }
.es-tabelle-werkzeug {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-4) 0 var(--space-3);
  font-size: var(--fs-small);
  color: var(--es-tinte-2);
}
.es-tabelle-werkzeug p { margin: 0; }
.es-tabelle-wrap { overflow: auto; max-height: 520px; border: 1px solid var(--es-gitter); border-radius: var(--radius-md); }
.es-tabelle { width: 100%; border-collapse: collapse; font-size: var(--fs-small); min-width: 640px; }
.es-tabelle th, .es-tabelle td { padding: 6px 10px; text-align: right; border-bottom: 1px solid var(--es-gitter); white-space: nowrap; }
.es-tabelle th:first-child, .es-tabelle td:first-child,
.es-tabelle th:nth-child(2), .es-tabelle td:nth-child(2) { text-align: left; }
.es-tabelle td { font-variant-numeric: tabular-nums; }
.es-tabelle thead th { position: sticky; top: 0; background: var(--grau-100); z-index: 1; }
.es-tabelle thead button {
  border: 0;
  background: none;
  font: inherit;
  font-weight: var(--fw-bold);
  color: var(--es-tinte);
  cursor: pointer;
  padding: 0;
}
.es-tabelle thead button:focus-visible { outline: 2px solid var(--focus-ring); }
.es-tabelle .es-leer { color: var(--es-tinte-3); }

/* ---------- Fünf Fragen ---------- */
.es-fragen {
  list-style: none;
  counter-reset: frage;
  padding: 0;
  margin: 0 auto var(--space-6);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: var(--space-4);
}
.es-fragen li {
  counter-increment: frage;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}
.es-fragen li::before {
  content: counter(frage);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--lavendel);
  color: var(--brand);
  font-weight: var(--fw-bold);
  margin-bottom: var(--space-3);
}
.es-fragen h3 { font-size: 1.05rem; margin: 0 0 var(--space-2); }
.es-fragen p { margin: 0; font-size: var(--fs-small); color: var(--es-tinte-2); }

.es-quellen { padding-left: 1.2em; font-size: var(--fs-small); }
.es-quellen li { margin-bottom: var(--space-2); overflow-wrap: anywhere; }

@media (prefers-reduced-motion: reduce) {
  .es-land { transition: none; }
}

@media print {
  .ob-header, .ob-toc, .es-steuerung, .es-abspielen, .es-tabelle-box { display: none !important; }
  .es-figur, .es-karte-figur { break-inside: avoid; }
}

/* Nachträge: Legende auf schmalen Bildschirmen, Sprungziele unter dem festen Kopf */
.es-legende-skala { flex: 1 1 100%; max-width: 560px; flex-wrap: nowrap; }
.es-legende-stufe { flex: 1 1 0; min-width: 0; }
.es-legende-stufe span:last-child { white-space: nowrap; font-size: 11px; }
@media (max-width: 420px) {
  .es-legende-stufe span:last-child { font-size: 10px; letter-spacing: -0.01em; }
}
section[id] { scroll-margin-top: 72px; }
.es-kacheln { margin: var(--space-4) 0 0; }

/* Ausnahmejahre: hohler Punkt in der Farbe der Reihe */
.es-punkt.es-punkt--ausnahme { stroke: var(--es-ring, var(--es-tinte-2)); stroke-width: 2.5; }
.es-punkt.es-punkt--ausnahme.ist-hervorgehoben { stroke: var(--es-tinte); }

/* ---------- Infofelder zu Begriffen ---------- */
.es-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin: 0 0 0 6px;
  padding: 0;
  border: 1.5px solid var(--brand);
  border-radius: 50%;
  background: var(--bg);
  color: var(--brand);
  font: italic 700 12px/1 Georgia, "Times New Roman", serif;
  vertical-align: 2px;
  cursor: pointer;
  position: relative;
  flex: none;
}
.es-info::after { content: ''; position: absolute; inset: -6px; } /* Trefferfläche mindestens 32 px */
.es-info:hover, .es-info[aria-expanded="true"] { background: var(--brand); color: #fff; }
.es-info:focus-visible, .es-begriff:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.es-begriff {
  display: inline;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-decoration: underline dotted var(--brand) 2px;
  text-underline-offset: 3px;
  cursor: help;
}
.es-begriff:hover, .es-begriff[aria-expanded="true"] { color: var(--brand); }
.es-infofeld {
  position: absolute;
  z-index: 400;
  background: var(--es-flaeche);
  color: var(--es-tinte);
  border: 1px solid var(--border);
  border-top: 3px solid var(--brand);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgba(11, 11, 11, .16);
  padding: var(--space-3) var(--space-4) var(--space-4);
  font-size: var(--fs-small);
  line-height: 1.55;
}
.es-infofeld-kopf { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-2); }
.es-infofeld-kopf strong { font-size: 1rem; color: var(--es-tinte); }
.es-infofeld-zu {
  border: 0; background: none; font-size: 22px; line-height: 1; color: var(--es-tinte-2);
  cursor: pointer; min-width: 32px; min-height: 32px; margin: -6px -8px 0 0;
}
.es-infofeld p { margin: 0 0 var(--space-2); max-width: none; }
.es-infofeld p:last-child { margin-bottom: 0; }
.es-legende-titel { display: inline-flex; align-items: center; font-size: var(--fs-small); font-weight: var(--fw-bold); color: var(--es-tinte-2); margin-right: var(--space-2); }
.es-legende-eintrag .es-info { margin-left: 2px; }
.es-figur-titel .es-info { vertical-align: 1px; }
.es-kachel-label .es-info { width: 18px; height: 18px; font-size: 11px; margin-left: 4px; }
