/* LadeRick – Stylesheet. Farbtoken nach der validierten Referenzpalette (hell/dunkel). */

:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f3f0;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #6f6e68;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --series-1: #2a78d6;
  --series-2: #1baf7a;
  --series-1-wash: rgba(42, 120, 214, 0.1);
  --series-2-wash: rgba(27, 175, 122, 0.14);
  --future-wash: rgba(11, 11, 11, 0.05);
  --warning: #fab219;
  --critical: #d03b3b;
  --link: #1d63b8;
  --orange: #f08a2e;
  --orange-ink: #0b0b0b;
  --orange-ink-2: rgba(11, 11, 11, 0.74);
  --focus: #2a78d6;
  --shimmer: rgba(11, 11, 11, 0.06);
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #222220;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --series-1: #3987e5;
    --series-2: #199e70;
    --series-1-wash: rgba(57, 135, 229, 0.14);
    --series-2-wash: rgba(25, 158, 112, 0.18);
    --future-wash: rgba(255, 255, 255, 0.06);
    --link: #3987e5;
    --focus: #3987e5;
    --shimmer: rgba(255, 255, 255, 0.08);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #222220;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.1);
  --series-1: #3987e5;
  --series-2: #199e70;
  --series-1-wash: rgba(57, 135, 229, 0.14);
  --series-2-wash: rgba(25, 158, 112, 0.18);
  --future-wash: rgba(255, 255, 255, 0.06);
  --link: #3987e5;
  --focus: #3987e5;
  --shimmer: rgba(255, 255, 255, 0.08);
}

/* ---------- Grundlagen ---------- */

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

a { color: var(--link); }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 16px; top: -48px;
  padding: 8px 12px; background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: 8px; z-index: 10;
}
.skip-link:focus { top: 8px; }

.muted { color: var(--ink-2); }
.link { font-size: 0.9375rem; }

h1, h2, h3 { line-height: 1.25; margin: 0; }
h3 { font-size: 1.0625rem; margin-top: 1.25rem; }
p { margin: 0; }

/* ---------- Header ---------- */

.site-header { padding: 20px 0 8px; }
.header-inner { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px 16px; }
.brand { flex: 1 1 260px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 40px; height: 40px; flex: none; fill: var(--series-1); }
.brand-name { font-size: 1.75rem; letter-spacing: -0.01em; }
.tagline { color: var(--ink-2); font-size: 0.9375rem; }

.theme-toggle, .button {
  font: inherit; font-size: 0.875rem;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 12px; cursor: pointer; white-space: nowrap;
}
.theme-toggle[aria-pressed="true"] { background: var(--ink); color: var(--page); border-color: var(--ink); }
.button { border-radius: 8px; padding: 8px 14px; }
.button:hover, .theme-toggle:hover { border-color: var(--ink-2); }

/* ---------- Karten & Layout ---------- */

main { padding-bottom: 32px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 16px;
}
.card-title { font-size: 1.125rem; font-weight: 600; }

.status-msg { margin-top: 12px; color: var(--ink-2); font-size: 0.9375rem; min-height: 1.5em; }
.status-msg:empty { display: none; }
.status-meta { margin-top: 12px; font-size: 0.875rem; }

.banner {
  margin-top: 12px; padding: 10px 14px; border-radius: 8px;
  background: var(--warning); color: #0b0b0b;
  display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; font-size: 0.9375rem;
}
.banner a { color: #0b0b0b; font-weight: 600; }

.hero-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.hero-grid .card { margin-top: 0; }
.hero-grid { margin-top: 16px; }
@media (min-width: 720px) {
  .hero-grid { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
}

.pill {
  display: inline-block; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 3px 10px; border-radius: 999px; margin-bottom: 10px;
  background: var(--surface-2); color: var(--ink-2);
}
.pill-past { background: var(--series-2-wash); color: var(--ink); }
.pill-future { background: var(--future-wash); color: var(--ink); }

.hero-overline { margin-top: 10px; color: var(--ink-2); }
.card-hero, .card-outlook { container-type: inline-size; }
.hero-time {
  font-size: clamp(26px, 8.4vw, 56px); font-weight: 650; letter-spacing: -0.02em; line-height: 1.1;
  margin-top: 2px; font-variant-numeric: normal; white-space: nowrap;
}
.hero-time-small { font-size: clamp(22px, 6vw, 36px); }
@supports (font-size: 1cqi) {
  .hero-time { font-size: clamp(24px, 8.6cqi, 56px); }
  .hero-time-small { font-size: clamp(22px, 8.6cqi, 36px); }
}
.hero-time[data-dst="true"] { white-space: normal; font-size: clamp(22px, 6vw, 40px); }
@supports (font-size: 1cqi) {
  .hero-time[data-dst="true"] { font-size: clamp(22px, 6.2cqi, 40px); }
  .hero-time-small[data-dst="true"] { font-size: clamp(20px, 6cqi, 30px); }
}
.hero-price { margin-top: 10px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; }
.hero-price-label { color: var(--ink-2); }
.hero-ct { font-size: 1.75rem; font-weight: 650; letter-spacing: -0.01em; }
.hero-price-small .hero-ct { font-size: 1.375rem; }
.hero-mwh { font-size: 0.9375rem; }
.hero-compare { margin-top: 6px; }
.hero-compare:empty, .hero-meta:empty, .hero-flags:empty { display: none; }
.hero-meta { font-size: 0.9375rem; margin-top: 4px; }
.hero-flags { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-block; font-size: 0.8125rem; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--ink);
}
.chip-warn { border-color: var(--warning); }
.hero-empty { margin-top: 10px; }
.footnote { font-size: 0.8125rem; margin-top: 14px; }

/* Ladezustand: Platzhalter halten die Höhe, Text schimmert leicht */
[data-state="loading"] .hero-time, [data-state="loading"] .hero-ct, [data-state="loading"] .tile-value {
  color: transparent; background: var(--shimmer); border-radius: 6px; min-width: 6ch;
}
[data-state="loading"] .hero-time { min-height: 1.1em; }
.card-hero { min-height: 200px; }
[data-refreshing="true"] .card-hero, [data-refreshing="true"] .card-outlook, [data-refreshing="true"] .kpis, [data-refreshing="true"] .card-chart {
  opacity: 0.6; transition: opacity 0.2s;
}

/* ---------- Empfehlung (orange) ---------- */

.card-orange { background: var(--orange); border-color: transparent; color: var(--orange-ink); color-scheme: light; }
.card-orange .card-title, .card-orange .hero-ct, .card-orange .start-days { color: var(--orange-ink); }
.card-orange .hero-price-label, .card-orange .hero-mwh, .card-orange .start-window, .card-orange .start-runner,
.card-orange .footnote, .card-orange .hero-empty { color: var(--orange-ink-2); }
.start-lead { margin-top: 8px; max-width: 70ch; }
.start-time { font-size: clamp(40px, 11vw, 72px); font-weight: 750; letter-spacing: -0.02em; line-height: 1.05; margin-top: 8px; }
@supports (font-size: 1cqi) { .card-orange { container-type: inline-size; } .start-time { font-size: clamp(40px, 9cqi, 72px); } }
.start-price { margin-top: 8px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; }
.start-window { font-size: 0.9375rem; }
.start-days { margin-top: 8px; font-size: 0.9375rem; }
.start-runner { margin-top: 4px; font-size: 0.9375rem; }
.start-days:empty, .start-runner:empty { display: none; }
[data-state="loading"] .start-time { color: transparent; background: rgba(11, 11, 11, 0.12); border-radius: 8px; min-width: 5ch; min-height: 1.05em; }
[data-refreshing="true"] .card-orange { opacity: 0.6; transition: opacity 0.2s; }

/* ---------- Kennzahlen ---------- */

.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px;
}
.tile-current { grid-column: 1 / -1; }
.tile-label { font-size: 0.875rem; color: var(--ink-2); }
.tile-value { font-size: 1.5rem; font-weight: 650; letter-spacing: -0.01em; margin-top: 2px; white-space: nowrap; }
.tile-current .tile-value { font-size: 2rem; }
.tile-sub { font-size: 0.875rem; margin-top: 2px; }
.tile-sub:empty { display: none; }
@media (max-width: 419.98px) {
  .tile-value { font-size: 1.25rem; }
  .tile-current .tile-value { font-size: 1.75rem; }
}
@media (min-width: 720px) {
  .kpis { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr); }
  .tile-current { grid-column: auto; }
}

/* ---------- Chart ---------- */

.chart-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.range-picker { border: 0; padding: 0; margin: 12px 0 0; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.range-legend { float: left; padding: 0; margin: 0 4px 0 0; font-size: 0.875rem; color: var(--ink-2); }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: -1px; }
.segmented label { padding: 5px 14px; font-size: 0.875rem; color: var(--ink-2); cursor: pointer; user-select: none; }
.segmented label + input + label { border-left: 1px solid var(--border); }
.segmented input:checked + label { background: var(--ink); color: var(--page); }
.segmented input:focus-visible + label { outline: 2px solid var(--focus); outline-offset: -3px; }
.range-hint { flex: 1 1 220px; font-size: 0.8125rem; min-width: 0; }
.chart-readout {
  margin-top: 10px; min-height: 1.5em; font-size: 0.9375rem; color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.chart-readout strong { color: var(--ink); }
.chart {
  position: relative; margin-top: 8px; height: 260px; width: 100%;
  border-radius: 8px; outline-offset: 4px; touch-action: pan-y;
}
@media (min-width: 720px) { .chart { height: 320px; } .chart-readout { display: none; } }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink-2); text-align: center; padding: 16px; }

.chart .grid-line { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .axis-line { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .zero-line { stroke: var(--axis); stroke-width: 1.5; shape-rendering: crispEdges; }
.chart .y-label, .chart .x-label, .chart .x-day { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart .x-day { fill: var(--ink-2); font-weight: 600; }
.chart .area { fill: var(--series-1); fill-opacity: 0.1; }
.chart .line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line-cheapest { fill: none; stroke: var(--series-2); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.chart .band-cheapest { fill: var(--series-2-wash); }
.chart .region-future { fill: var(--future-wash); }
.chart .outlook-box { fill: none; stroke: var(--series-2); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .now-line { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .region-label { fill: var(--ink-2); font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.chart .band-label { fill: var(--ink); font-size: 11px; font-weight: 600; }
.chart .now-label { fill: var(--ink); font-size: 11px; font-weight: 600; }
.chart .crosshair { stroke: var(--ink-2); stroke-width: 1; }
.chart .marker { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.chart .marker-cheapest { fill: var(--series-2); }
.chart .hit-area { fill: transparent; cursor: crosshair; }

.chart-tooltip {
  position: absolute; z-index: 2; pointer-events: none;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12); font-size: 0.875rem; line-height: 1.35;
  min-width: 150px; max-width: 240px;
}
.chart-tooltip .tt-value { font-size: 1.125rem; font-weight: 650; }
.chart-tooltip .tt-title { color: var(--ink-2); }
.chart-tooltip .tt-tag { color: var(--ink-2); font-size: 0.8125rem; }
@media (max-width: 719.98px) { .chart-tooltip { display: none; } }

.legend {
  list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 6px 18px;
  font-size: 0.875rem; color: var(--ink-2);
}
.legend li { display: flex; align-items: center; gap: 8px; }
.swatch { display: inline-block; width: 22px; height: 12px; border-radius: 2px; flex: none; }
.swatch-line { height: 0; border-top: 2px solid var(--series-1); border-radius: 0; }
.swatch-future { background: var(--future-wash); border-top: 2px solid var(--series-1); border-radius: 0; }
.swatch-cheapest { background: var(--series-2-wash); border-top: 3px solid var(--series-2); border-radius: 0; }
.swatch-outlook { border: 1.5px dashed var(--series-2); background: transparent; }

/* ---------- Tabelle ---------- */

.table-details { margin-top: 14px; }
.table-details summary { cursor: pointer; color: var(--ink-2); }
.table-wrap { max-height: 420px; overflow: auto; margin-top: 8px; border: 1px solid var(--border); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 0.9375rem; }
caption { text-align: left; padding: 8px 10px; color: var(--ink-2); font-size: 0.875rem; caption-side: top; }
th, td { padding: 6px 10px; text-align: left; border-top: 1px solid var(--grid); white-space: nowrap; }
thead th { position: sticky; top: 0; background: var(--surface-2); border-top: 0; font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.row-cheapest td { background: var(--series-2-wash); }
tr.row-now td { font-weight: 600; }
td.neg { color: var(--ink); }

/* ---------- Fehler & Info ---------- */

.card-error { border-color: var(--critical); margin-top: 12px; }
.card-error .button { margin-top: 12px; }

.card-info p { margin-top: 8px; color: var(--ink-2); }
.card-info p strong { color: var(--ink); }
.disclaimer-note { margin-top: 6px; }
.card-info h3 { color: var(--ink); }
.source-list { margin: 8px 0 0; padding-left: 1.25rem; color: var(--ink-2); }
.source-list li { margin-top: 6px; }
.imprint { font-style: normal; margin-top: 8px; color: var(--ink); line-height: 1.5; }

.site-footer { border-top: 1px solid var(--border); padding: 20px 0 32px; font-size: 0.875rem; color: var(--ink-2); }
.site-footer p + p { margin-top: 6px; }

/* ---------- Bewegung, Druck ---------- */

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

@media print {
  .site-header .theme-toggle, .skip-link, .table-details summary, .chart-readout { display: none !important; }
  .card { break-inside: avoid; border-color: #999; }
  body { background: #fff; color: #000; }
}
