/* ============================================================================
   Gemeinsame Shell fuer alle Seiten der Wetterstation.
   Vorher hatte jede der drei Seiten eigenen Kopf, eigene Navigation und
   eigenes Farbschema; hier liegt das einmal.
   ========================================================================== */

/* --- Farb-Tokens ---------------------------------------------------------
   Vollstaendige helle Palette auf :root, im Dunkelmodus werden nur die
   Rollen neu belegt. Der manuelle Umschalter (data-theme) gewinnt in beide
   Richtungen gegen die Systemeinstellung.                                  */
:root {
  color-scheme: light;
  --bg:          #f4f6f5;
  --surface:     #ffffff;
  --surface-2:   #eef1f0;
  --border:      #dde3e1;
  --text:        #16211f;
  --text-muted:  #5f736e;
  --text-faint:  #8b9c97;
  --accent:      #0f7b6c;
  --accent-soft: #d7ece8;
  --shadow:      0 1px 2px rgba(16,33,31,.06), 0 4px 16px rgba(16,33,31,.05);

  /* Messgroessen - jede Reihe hat ihre feste Farbe, quer ueber alle Seiten */
  --c-temp:     #e4572e;
  --c-indoor:   #2d7dd2;
  --c-ch1:      #8e6cc4;
  --c-ch2:      #d98e04;
  --c-ch3:      #17998a;
  --c-rain:     #3a86c8;
  --c-solar:    #e8a33d;
  --c-uv:       #a4508b;
  --c-wind:     #5b8c85;
  --c-pressure: #7a8b99;
  --c-dew:      #7fb069;

  --ok:   #2e8b57;
  --warn: #c77800;
  --bad:  #c0392b;

  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 20px;
  --gap: 16px;
  --maxw: 1240px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg:          #0e1413;
    --surface:     #161e1d;
    --surface-2:   #1d2726;
    --border:      #2a3735;
    --text:        #e8efed;
    --text-muted:  #9aaba7;
    --text-faint:  #6c807b;
    --accent:      #4fd1b8;
    --accent-soft: #16302c;
    --shadow:      0 1px 2px rgba(0,0,0,.4), 0 4px 20px rgba(0,0,0,.3);

    --c-temp:     #ff7f5c;
    --c-indoor:   #5fa8e8;
    --c-ch1:      #b18ee6;
    --c-ch2:      #f0b03e;
    --c-ch3:      #35c9b7;
    --c-rain:     #5aa9e6;
    --c-solar:    #f2bb5c;
    --c-uv:       #c97cb0;
    --c-wind:     #86b3ab;
    --c-pressure: #9aa9b6;
    --c-dew:      #9dc97f;

    --ok:   #4caf7d;
    --warn: #e0a33c;
    --bad:  #e57368;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:          #0e1413;
  --surface:     #161e1d;
  --surface-2:   #1d2726;
  --border:      #2a3735;
  --text:        #e8efed;
  --text-muted:  #9aaba7;
  --text-faint:  #6c807b;
  --accent:      #4fd1b8;
  --accent-soft: #16302c;
  --shadow:      0 1px 2px rgba(0,0,0,.4), 0 4px 20px rgba(0,0,0,.3);

  --c-temp:     #ff7f5c;
  --c-indoor:   #5fa8e8;
  --c-ch1:      #b18ee6;
  --c-ch2:      #f0b03e;
  --c-ch3:      #35c9b7;
  --c-rain:     #5aa9e6;
  --c-solar:    #f2bb5c;
  --c-uv:       #c97cb0;
  --c-wind:     #86b3ab;
  --c-pressure: #9aa9b6;
  --c-dew:      #9dc97f;

  --ok:   #4caf7d;
  --warn: #e0a33c;
  --bad:  #e57368;
}

/* --- Grundlagen ---------------------------------------------------------- */
* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.011em; }
a { color: var(--accent); }

/* Zahlen tabellarisch, damit tickende Werte nicht springen */
.num { font-variant-numeric: tabular-nums; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px 56px; }

/* --- Kopf und Navigation -------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto;
  padding: 10px 20px;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.brand { font-size: 15px; font-weight: 680; letter-spacing: -.02em; white-space: nowrap; }
.brand small { display: block; font-weight: 450; font-size: 11.5px; color: var(--text-faint); letter-spacing: 0; }

nav.tabs { display: flex; gap: 2px; margin-left: auto; flex-wrap: wrap; }
nav.tabs a {
  padding: 7px 13px; border-radius: 999px; text-decoration: none;
  color: var(--text-muted); font-size: 13.5px; font-weight: 550;
  white-space: nowrap;
}
nav.tabs a:hover { background: var(--surface-2); color: var(--text); }
nav.tabs a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }

.icon-btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text-muted);
  width: 34px; height: 34px; border-radius: 999px; cursor: pointer;
  display: grid; place-items: center; font-size: 15px; line-height: 1;
}
.icon-btn:hover { color: var(--text); border-color: var(--text-faint); }

/* --- Live-Anzeige --------------------------------------------------------- */
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.dot { width: 7px; height: 7px; border-radius: 999px; background: var(--text-faint); flex: none; }
.dot.on   { background: var(--ok); box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 70%, transparent); animation: pulse 2.4s ease-out infinite; }
.dot.warn { background: var(--warn); }
.dot.off  { background: var(--bad); }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 55%, transparent); }
  70%  { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@media (prefers-reduced-motion: reduce) { .dot.on { animation: none; } }

/* --- Karten --------------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); box-shadow: var(--shadow);
  padding: 18px;
}
.card > header {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  margin: -2px 0 14px;
}
.card > header h2 { font-size: 14px; font-weight: 620; letter-spacing: .01em; }
.card > header .sub { font-size: 12.5px; color: var(--text-faint); }
.card > header .spacer { margin-left: auto; }

.grid { display: grid; gap: var(--gap); }

/* --- Hero ----------------------------------------------------------------- */
.hero { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 24px; align-items: center; }
.hero-temp { display: flex; align-items: baseline; gap: 10px; }
.hero-temp .val { font-size: clamp(56px, 11vw, 88px); font-weight: 300; letter-spacing: -.04em; line-height: .95; }
.hero-temp .unit { font-size: clamp(22px, 4vw, 30px); font-weight: 300; color: var(--text-muted); }
.hero-line { margin-top: 8px; font-size: 15px; color: var(--text-muted); }
.hero-line b { color: var(--text); font-weight: 600; }
.hero-meta { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 12px; font-size: 13px; color: var(--text-muted); }

.range-badge {
  display: inline-flex; flex-direction: column; align-items: flex-end; gap: 3px;
  padding: 12px 16px; border-radius: var(--r-md); background: var(--surface-2);
  font-size: 13px; color: var(--text-muted); white-space: nowrap;
}
.range-badge .hi { color: var(--c-temp); font-weight: 640; font-size: 17px; }
.range-badge .lo { color: var(--c-indoor); font-weight: 640; font-size: 17px; }

.trend { font-size: 13px; font-weight: 600; }
.trend.up   { color: var(--c-temp); }
.trend.down { color: var(--c-indoor); }
.trend.flat { color: var(--text-faint); }

/* --- Kachelraster --------------------------------------------------------- */
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); }
.tile {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 13px 15px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 3px; min-width: 0;
}
.tile .k { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); font-weight: 600; }
.tile .v { font-size: 25px; font-weight: 560; letter-spacing: -.02em; line-height: 1.15; }
.tile .v small { font-size: 14px; font-weight: 500; color: var(--text-muted); margin-left: 2px; }
.tile .s { font-size: 12px; color: var(--text-muted); }

/* farbiger Akzentstrich je Messgroesse */
.tile[data-c] { border-left: 3px solid var(--border); }
.tile[data-c="temp"]     { border-left-color: var(--c-temp); }
.tile[data-c="rain"]     { border-left-color: var(--c-rain); }
.tile[data-c="wind"]     { border-left-color: var(--c-wind); }
.tile[data-c="solar"]    { border-left-color: var(--c-solar); }
.tile[data-c="uv"]       { border-left-color: var(--c-uv); }
.tile[data-c="pressure"] { border-left-color: var(--c-pressure); }
.tile[data-c="indoor"]   { border-left-color: var(--c-indoor); }
.tile[data-c="ch1"]      { border-left-color: var(--c-ch1); }
.tile[data-c="ch2"]      { border-left-color: var(--c-ch2); }
.tile[data-c="ch3"]      { border-left-color: var(--c-ch3); }

/* --- Segmentierte Umschalter ---------------------------------------------- */
.seg { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button {
  border: 0; background: transparent; color: var(--text-muted);
  padding: 5px 11px; border-radius: 999px; cursor: pointer;
  font: inherit; font-size: 12.5px; font-weight: 550;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* --- Diagramme ------------------------------------------------------------ */
.chart-host { width: 100%; min-height: 60px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-muted); }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 6px; vertical-align: -1px; }

.u-tooltip {
  position: absolute; pointer-events: none; z-index: 10;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm);
  box-shadow: var(--shadow); padding: 8px 10px; font-size: 12.5px; white-space: nowrap;
  transform: translate(-50%, -115%); opacity: 0; transition: opacity .1s;
}
.u-tooltip .tt-t { color: var(--text-faint); margin-bottom: 4px; font-size: 11.5px; }
.u-tooltip .tt-r { display: flex; gap: 8px; align-items: center; }
.u-tooltip .tt-r span:last-child { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }

/* --- Tabellen ------------------------------------------------------------- */
.tbl-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-faint); font-weight: 600; padding: 8px 10px;
  border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface);
}
table.data td { padding: 9px 10px; border-bottom: 1px solid var(--border); }
table.data tr:last-child td { border-bottom: 0; }
table.data td.n { text-align: right; font-variant-numeric: tabular-nums; }
table.data .muted { color: var(--text-faint); font-size: 12px; }

/* --- Zustaende ------------------------------------------------------------ */
.empty { color: var(--text-faint); font-size: 13.5px; padding: 22px; text-align: center; }
.banner {
  display: none; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: var(--r-sm); margin-bottom: var(--gap);
  background: color-mix(in srgb, var(--warn) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--warn) 35%, var(--border));
  color: var(--text); font-size: 13.5px;
}
.banner.show { display: flex; }

.skel { background: var(--surface-2); border-radius: 6px; color: transparent !important; animation: sk 1.4s ease-in-out infinite; }
@keyframes sk { 0%,100% { opacity: .55; } 50% { opacity: .9; } }

.foot { margin-top: 28px; font-size: 12.5px; color: var(--text-faint); display: flex; gap: 14px; flex-wrap: wrap; }

@media (max-width: 640px) {
  .wrap { padding: 0 14px 40px; }
  .hero { grid-template-columns: 1fr; gap: 14px; align-items: start; }
  .range-badge { flex-direction: row; align-items: baseline; gap: 14px; align-self: start; }
  .topbar-inner { padding: 9px 14px; gap: 10px; }
  .brand small { display: none; }
}
