/* Farbrollen nach docs/methods/007-visualisierung.md.
   Hell ist die Grundfassung; Dunkel wird zweimal deklariert, damit sowohl die
   Systemeinstellung als auch ein ausdrücklicher Umschalter greift. */
:root {
  color-scheme: light;

  --plane:            #f9f9f7;
  --surface:          #fcfcfb;
  --ink:              #0b0b0b;
  --ink-secondary:    #52514e;
  --ink-muted:        #898781;
  --grid:             #e1e0d9;
  --axis:             #c3c2b7;
  --border:           rgba(11, 11, 11, 0.10);

  --series-1:         #2a78d6;   /* operative Raumtemperatur */
  --series-2:         #008300;   /* zweiter Klimastand im Vergleich */
  --status-serious:   #ec835a;   /* Überschreitung */
  --status-good:      #0ca30c;   /* reserviert; im Diagramm gesperrt, siehe 007 */

  --radius: 8px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --plane:         #0d0d0d;
    --surface:       #1a1a19;
    --ink:           #ffffff;
    --ink-secondary: #c3c2b7;
    --ink-muted:     #898781;
    --grid:          #2c2c2a;
    --axis:          #383835;
    --border:        rgba(255, 255, 255, 0.10);
    --series-1:      #3987e5;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --plane:         #0d0d0d;
  --surface:       #1a1a19;
  --ink:           #ffffff;
  --ink-secondary: #c3c2b7;
  --ink-muted:     #898781;
  --grid:          #2c2c2a;
  --axis:          #383835;
  --border:        rgba(255, 255, 255, 0.10);
  --series-1:      #3987e5;
}

* { box-sizing: border-box; }

/* `hidden` muss gegen Klassen mit eigenem `display` gewinnen: `.trend-intro`
   und `.tile-delta` setzen `display: flex`, und das schlägt die Regel des
   Browsers für [hidden]. Ausgeblendete Elemente blieben sonst stehen. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--plane);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}

.wrap { max-width: 1100px; margin: 0 auto; padding: 24px 20px 64px; }

header { margin-bottom: 24px; position: relative; }

.theme-toggle {
  position: absolute; top: 0; right: 0;
  font: inherit; font-size: 12px;
  padding: 5px 12px; border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface); color: var(--ink-secondary);
  cursor: pointer;
}
.theme-toggle:hover { color: var(--ink); }
header h1 { font-size: 22px; font-weight: 600; margin: 0 0 4px; letter-spacing: -0.01em; }
header p { margin: 0; color: var(--ink-secondary); font-size: 14px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}

/* --- Filterzeile über den Diagrammen --- */
.filters { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-secondary); }

select, input[type="number"] {
  font: inherit;
  font-size: 14px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--axis);
  background: var(--surface);
  color: var(--ink);
  min-width: 150px;
}

/* --- Regler --- */
.controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px 28px; }
.control { display: flex; flex-direction: column; gap: 6px; }
.control-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.control-head span:first-child { font-size: 13px; color: var(--ink-secondary); line-height: 1.3; }
.control-value { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; flex: none; }

input[type="range"] { width: 100%; accent-color: var(--series-1); }

.toggle { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.toggle input { accent-color: var(--series-1); width: 16px; height: 16px; }

/* --- Kennzahlen --- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--border); border-radius: var(--radius); overflow: hidden; }
.tile { background: var(--surface); padding: 14px 16px; }
.tile-label { font-size: 12px; color: var(--ink-secondary); margin-bottom: 2px; }
.tile-value { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; }
.tile-unit { font-size: 13px; font-weight: 400; color: var(--ink-secondary); margin-left: 3px; }
.tile-note { font-size: 12px; color: var(--ink-muted); margin-top: 2px; }
/* Der Vergleichswert steht unter der Kennzahl, nicht daneben: die Kachel
   zeigt die Basis, das Delta ordnet sie ein. */
.tile-delta { font-size: 12px; margin-top: 6px; display: flex; align-items: baseline; gap: 6px; font-variant-numeric: tabular-nums; }
.tile-delta .dot { width: 8px; height: 8px; border-radius: 2px; background: var(--series-2); flex: none; align-self: center; }
.tile-delta .diff { color: var(--ink-secondary); }

/* --- Diagramm --- */
figure { margin: 0; }
figcaption { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.subcaption { font-size: 13px; color: var(--ink-secondary); margin-bottom: 14px; }

.chart-holder { position: relative; }
canvas { display: block; width: 100%; touch-action: none; }

.legend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 12px; font-size: 13px; color: var(--ink-secondary); }
.legend-item { display: flex; align-items: center; gap: 6px; }
.swatch { width: 14px; height: 3px; border-radius: 2px; flex: none; }
.swatch.area { height: 12px; border-radius: 3px; }
.swatch.dashed { height: 0; border-top: 2px dashed var(--ink-muted); }
.swatch.dotted { height: 0; border-top: 2px dotted var(--series-2); }

/* Hinweis unter der Bildunterschrift, etwa zur Vergleichbarkeit von DRY und
   Messjahr — keine Warnfarbe, aber deutlich abgesetzt. */
.note {
  margin: 0 0 14px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--ink-secondary);
  background: var(--plane);
  border-left: 3px solid var(--axis);
  border-radius: 0 4px 4px 0;
}

.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.45;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.08s;
  z-index: 2;
}
.tooltip.on { opacity: 1; }
.tooltip b { font-weight: 600; }
.tooltip .row { display: flex; justify-content: space-between; gap: 14px; font-variant-numeric: tabular-nums; }
/* Im Vergleich trennt eine Zwischenüberschrift die beiden Klimastände. */
.tooltip .head { font-weight: 600; margin-top: 6px; color: var(--ink-secondary); }
.tooltip b + .head { margin-top: 2px; }

/* --- Nachweis --- */
details { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 4px; }
summary { cursor: pointer; font-size: 14px; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 6px; }
summary::-webkit-details-marker { display: none; }
summary::before { content: "▸"; color: var(--ink-muted); font-size: 11px; transition: transform 0.12s; }
details[open] summary::before { transform: rotate(90deg); }

.proof { margin-top: 14px; font-size: 13px; }
.proof h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-muted); margin: 16px 0 6px; font-weight: 600; }
.proof h3:first-child { margin-top: 0; }

/* --- Download --- */
.downloads { margin-top: 14px; font-size: 13px; display: flex; flex-direction: column; gap: 10px; }
.download-note { margin: 0; color: var(--ink-secondary); }
.download-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.download-label { flex: 1 1 220px; }
.download {
  font: inherit; font-size: 13px;
  padding: 5px 12px; border-radius: 6px;
  border: 1px solid var(--axis);
  background: var(--surface); color: var(--ink);
  cursor: pointer;
}
.download:hover { border-color: var(--ink-muted); }
.download:disabled { opacity: 0.5; cursor: progress; }
.kv { display: grid; grid-template-columns: minmax(140px, auto) 1fr; gap: 2px 16px; }
.kv dt { color: var(--ink-secondary); }
.kv dd { margin: 0; font-family: var(--mono); font-size: 12px; word-break: break-all; }

table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 5px 8px; border-bottom: 1px solid var(--border); }
th:first-child, td:first-child { text-align: left; font-variant-numeric: normal; }
th { color: var(--ink-secondary); font-weight: 600; font-size: 12px; }
td.over { color: var(--ink); font-weight: 600; }

/* Vergleichstabelle: Gruppenkopf über seiner Gruppe, nicht am rechten Rand,
   und eine Kante zwischen den beiden Klimaständen. */
th[colspan] { text-align: center; }
th.split, td.split { border-left: 1px solid var(--border); }
.scroll { overflow-x: auto; max-height: 340px; overflow-y: auto; }

/* --- Mehrjahresverlauf --- */
.trend-intro { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; font-size: 13px; }
.trend-summary { margin: 12px 0 0; font-size: 13px; color: var(--ink-secondary); }
.swatch.dotted-secondary { height: 0; border-top: 2px dotted var(--ink-secondary); }
.swatch.dot, .swatch.ring { width: 10px; height: 10px; border-radius: 50%; }
.swatch.dot { background: var(--series-2); }
.swatch.ring { border: 2px solid var(--series-2); }

code { font-family: var(--mono); font-size: 12px; }
a { color: var(--series-1); }

.hash { font-family: var(--mono); font-size: 12px; color: var(--ink-secondary); }
.status { padding: 40px 0; text-align: center; color: var(--ink-secondary); }
.error { color: var(--status-serious); }
footer { margin-top: 28px; font-size: 12px; color: var(--ink-muted); }
