/* Embed-Seite der Energiegemeinschaft. Kein Framework — die Seite läuft
   in einem iframe auf fremden Websites und soll dort nichts erben und
   nichts hinterlassen.

   Farben: Die fünf Variablen unter "Farbschema" sind die Vorgabe — die
   Farben des Logos der ersten Region ("Elsbeerfarben", Vorführung vom
   16.09.2026). Je Gruppe oder Gemeinschaft kann die Datenbank andere
   setzen (gruppe.farben / eeg.farben, Migration 007); app.js liest sie
   über /info und schreibt sie in dieselben Variablen. Alles, was Farbe
   trägt, hängt an diesen fünf. */

:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --text: #1f2a30;
  --text-2: #5f6a70;
  --line: #e1e0d9;
  --warn-bg: #fff3e6;
  --warn: #a85a12;

  /* Farbschema (Vorgabe = Logo der ersten Region) */
  --eeg: #949F43;         /* Anteil, der in der Gemeinschaft bleibt — auf beiden Seiten dieselbe Farbe */
  --netz: #2569be;        /* Bezug aus dem Netz (das frühere Blau, leicht dunkler) */
  --ueberschuss: #821206; /* Abgabe ins Netz */
  --akzent: #6b7530;      /* Bedienelemente, Leitkennzahlen — dunkleres Grün, damit weiße Schrift lesbar bleibt */
  --titel: #ECE0BD;       /* Hintergrund hinter dem Namen der Gemeinschaft */
  --akzent-soft: #e7ead9; /* Akzent, stark aufgehellt; unten aus --akzent gemischt, wo der Browser das kann */
}
@supports (color: color-mix(in srgb, red, blue)) {
  :root { --akzent-soft: color-mix(in srgb, var(--akzent) 14%, white); }
}

* { box-sizing: border-box; }

/* Das hidden-Attribut muss gegen eigene display-Regeln gewinnen (.kpis ist
   ein Grid) — sonst bleiben Kennzahlen stehen, obwohl app.js sie versteckt
   hat. */
[hidden] { display: none !important; }

html, body { margin: 0; background: var(--bg); }

body {
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  padding: 16px;
}

.dash { max-width: 1040px; margin: 0 auto; display: grid; gap: 14px; }

/* Kopf: Name links, Ebenenleiste rechts. Kein Titelfeld — nur der Name
   trägt die Logofarbe als Hintergrund (Rückmeldung vom 17.09.2026: die
   volle Fläche war zu viel). */
.dash-head {
  display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between;
}
h1 {
  display: inline-block; font-size: 1.35rem; margin: 0 0 4px; font-weight: 600; letter-spacing: -0.01em;
  background: var(--titel); border-radius: 8px; padding: 4px 12px;
}
.dash-sub { color: var(--text-2); font-size: 0.85rem; }
.dash-sub a { color: inherit; }

/* Einleitung „Was ist das EEG-Dashboard?“ unter dem Namen (Rückmeldung vom
   01.10.2026): ein kleiner runder blauer Knopf mit „?“ statt des
   Dreiecks von <details> — damit sie nicht wie das Begriffe-Feld unten
   aussieht. Aufgeklappt höchstens ~55 Zeichen breit, damit die
   Ebenenleiste auf breiten Bildschirmen daneben bleibt. */
.intro { margin-top: 4px; font-size: 0.85rem; color: var(--text-2); }
.intro summary { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; list-style: none; }
.intro summary::-webkit-details-marker { display: none; }
.intro summary:hover { color: var(--netz); }
.intro summary:focus-visible { outline: 2px solid var(--netz); outline-offset: 2px; border-radius: 4px; }
.intro-q {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 18px; height: 18px; border-radius: 50%; background: var(--netz); color: #fff;
  font-size: 0.75rem; font-weight: 700; line-height: 1;
}
.intro p { margin: 6px 0 0; max-width: 55ch; color: var(--text); }

.levels { display: flex; gap: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.levels button {
  border: 0; background: transparent; color: var(--text); padding: 7px 13px; font: inherit; cursor: pointer;
  border-right: 1px solid var(--line);
}
.levels button:last-child { border-right: 0; }
.levels button[aria-selected="true"] { background: var(--akzent); color: #fff; }
.levels button:focus-visible, .nav:focus-visible, .toggles button:focus-visible { outline: 2px solid var(--akzent); outline-offset: 2px; }

.range { display: flex; align-items: center; gap: 10px; }
.nav {
  width: 36px; height: 36px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px;
  font-size: 1.25rem; line-height: 1; cursor: pointer; color: var(--text);
}
.nav:disabled { opacity: 0.35; cursor: default; }
.range-label { font-weight: 600; font-size: 1.05rem; min-width: 12ch; }
.loading { font-size: 0.85rem; color: var(--text-2); }

/* Während geladen wird: Diagramm und Kennzahlen abgeblendet lassen, statt
   sie zu leeren — so bleibt der alte Stand lesbar, bis der neue da ist. */
.dash[aria-busy="true"] .chart-wrap, .dash[aria-busy="true"] .kpis { opacity: 0.45; transition: opacity 0.2s; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.kpi-lead { border-color: var(--akzent); }
.kpi-label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-2); }
/* Zahl und Einheit bleiben zusammen (geschütztes Leerzeichen in app.js,
   nowrap hier): bricht die Notiz um, wandert der ganze Wert in die nächste
   Zeile (Rückmeldung vom 01.10.2026). */
.kpi-value { font-size: 1.6rem; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; white-space: nowrap; }
.kpi-lead .kpi-value { color: var(--akzent); }
.kpi-note { font-size: 0.82rem; color: var(--text-2); }
.kpi-note b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: center; justify-content: space-between; }
.toggles { display: flex; gap: 8px; }
.toggles button {
  border: 1px solid var(--line); background: transparent; color: var(--text); padding: 5px 12px; border-radius: 8px;
  font: inherit; cursor: pointer;
}
.toggles button[aria-pressed="true"] { background: var(--akzent-soft); color: var(--akzent); border-color: var(--akzent-soft); }

.note { background: var(--surface); color: var(--text-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; font-size: 0.88rem; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.85rem; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend i.line { height: 0; border-bottom: 2px solid currentColor; border-radius: 0; }
.legend .pairs { color: var(--text); }   /* Satz zu den Balkenpaaren, ohne Farbfeld */

.notice { background: var(--warn-bg); color: var(--warn); border-radius: 8px; padding: 8px 12px; font-size: 0.9rem; }

.chart-wrap { position: relative; width: 100%; height: 360px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.chart-wrap canvas { width: 100% !important; height: 100% !important; }
.empty { font-size: 0.9rem; color: var(--text-2); background: var(--surface); border: 1px dashed var(--line); border-radius: 8px; padding: 8px 12px; }

.hint { font-size: 0.82rem; color: var(--text-2); }

/* Mitglieder einer Gruppe: Namen als Links auf deren eigene Seite. */
.members { font-size: 0.88rem; color: var(--text-2); display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: baseline; }
.members a { color: var(--akzent); text-decoration: none; border-bottom: 1px solid var(--akzent-soft); }
.members a:hover { border-bottom-color: var(--akzent); }
.members .muted { color: var(--text-2); }

/* Begriffe für Laien, eingeklappt, damit die Seite kurz bleibt. */
.glossary { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; font-size: 0.88rem; }
.glossary summary { cursor: pointer; font-weight: 600; color: var(--text-2); }
.glossary dl { margin: 8px 0 4px; display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; }
.glossary dt { font-weight: 600; }
.glossary dd { margin: 0; color: var(--text-2); }

.dash-foot { font-size: 0.8rem; color: var(--text-2); }

/* Schmale Bildschirme (Handy im iframe): weniger Rand, engere Ebenenleiste,
   flacheres Diagramm. Alles andere bricht von selbst um.
   Der iframe hat keine eigene Scrollleiste, wenn die einbettende Seite ihm
   genug Höhe gibt — siehe docs/EINBETTEN.md. */
@media (max-width: 560px) {
  body { padding: 10px; font-size: 14px; }
  h1 { font-size: 1.2rem; padding: 3px 10px; }
  .levels button { padding: 7px 8px; font-size: 0.9rem; }
  .chart-wrap { height: 280px; padding: 8px; }
  .range-label { font-size: 0.95rem; min-width: 0; }
  .kpi-value { font-size: 1.35rem; }
  .glossary dl { grid-template-columns: 1fr; gap: 2px; }
  .glossary dd { margin-bottom: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
