/* style.css — Globales Basis-Layout + Komponenten
   - Theme-Variablen (Tag/Nacht)
   - Reset, Grundtypografie
   - Header (Menükachel) – inkl. Desktop-Kachel-Frame
   - Generisches Grid/Karten-Layout
   - Wind-/Regen-/Druck-Kachel-Basics
   - Sky-Icon + Status-Dot + Burger
   - Globale Chart-Basics (Goldener Schnitt mobil)
   - Footer + rechtlicher Hinweis
*/

/* ------------------------------------------------------ */
/*  Theme-Variablen                                       */
/* ------------------------------------------------------ */

:root {
  /* Default-Werte (Light), gleichzeitig Basis-Variablen */
  --bg: #f2f2f7;
  --card: #ffffff;
  /* Gemeinsame Kartenoberfläche: unveränderte Referenz „Wetter aktuell“. */
  --card-radius: 12px;
  --card-border: 0;
  --card-gap: .85rem;
  --chart-card-gap: .9rem;
  --card-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  --text: #111111;
  --accent: #0a84ff;

  /* Gemeinsame Typografie nach den Kacheln von „Wetter aktuell“. */
  --type-page-title: 1.3rem;
  --type-chart-title: 1.17rem;
  --type-chart-tracking: -.2px;
  --type-card-label: .88rem;
  --type-card-value: 1.55rem;
  --type-card-detail: .88rem;
  --type-card-meta: .78rem;
  --type-card-time: .74rem;
  --type-observation: .72rem;
  --type-chart-capt: .85rem;
  --type-chart-meta: .7rem;
  --type-control: .75rem;
  --type-line-value: 1.15;
  --type-line-detail: 1.2;
  --type-line-body: 1.35;
  --type-weight-medium: 500;
  --type-weight-semibold: 600;

  /* Wind-Kachel: feste Pfeilbox + Abstand */
  --wind-dir-size: 30px;    /* Box für Pfeil/Punkt */
  --wind-arrow-top: -2px;   /* leicht anheben über der „Uhr“-Zeile */
  --gust-gap: 6px;          /* Abstand Zahl ↔ Pfeil */

  /* Theme-Tokens */
  --bg-light: #f2f2f7;
  --card-light: #ffffff;
  --text-light: #111111;
  --accent-light: #0a84ff;

  /* iOS-Style Dark Mode */
  --bg-dark: #000000;
  --card-dark: #1c1c1e;
  --text-dark: #f2f2f7;
  --accent-dark: #0a84ff;
}

/* Theme-Klassen auf <body> */
body.theme-day {
  --bg: var(--bg-light);
  --card: var(--card-light);
  --text: var(--text-light);
  --accent: var(--accent-light);
  color-scheme: light;
}

body.theme-night {
  --bg: var(--bg-dark);
  --card: var(--card-dark);
  --card-shadow: 0 1px 6px rgba(0, 0, 0, 0.8);
  --text: var(--text-dark);
  --accent: var(--accent-dark);
  color-scheme: dark;
}

/* ------------------------------------------------------ */
/*  Reset + Grundtypografie                               */
/* ------------------------------------------------------ */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ------------------------------------------------------ */
/*  HEADER (Menükachel oben)                              */
/* ------------------------------------------------------ */

.wx-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  padding: .5rem .75rem;
  background: var(--card);
  border-bottom: 1px solid rgba(0, 0, 0, 0.16);
  position: sticky;
  top: 0;
  z-index: 20;
}

body.theme-night .wx-header {
  border-bottom-color: rgba(255, 255, 255, 0.15);
}

.wx-left {
  display: flex;
  align-items: center;
  gap: .35rem;
  justify-self: start;
}

.wx-title-wrap {
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  justify-self: center;
}

.wx-title {
  font-size: 1.06rem;
  font-weight: 600;
  letter-spacing: -.32px;
  margin-bottom: .03rem;
}

.wx-subtitle {
  font-size: .82rem;
  opacity: .6;
  margin-top: 0;
}

.wx-right {
  display: flex;
  align-items: center;
  gap: .6rem;
  justify-self: end;
}

/* ------------------------------------------------------ */
/*  Grid + Karten (global)                                */
/* ------------------------------------------------------ */

.grid {
  display: grid;
  gap: .85rem;
  padding: .85rem;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.card {
  background: var(--card);
  border: var(--card-border);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  padding: .85rem;
  overflow: hidden;
}


/* Label im Kartenkopf */
.label {
  font-size: var(--type-card-label);
  opacity: .85;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Hauptwert */
.value {
  font-weight: var(--type-weight-semibold);
  font-size: var(--type-card-value);
  margin-top: .18rem;
  line-height: var(--type-line-value);
}

.card-unit {
  font-size: .68em;
  font-weight: var(--type-weight-medium);
  white-space: nowrap;
}

.card-detail,
.card-meta,
.observation-age,
.home-chart-status {
  display: block;
  font-weight: 400;
  line-height: var(--type-line-detail);
  color: var(--text);
}

.card-detail {
  font-size: var(--type-card-detail);
  margin-top: .22rem;
}

.card-meta {
  font-size: var(--type-card-meta);
  opacity: .75;
  margin-top: .25rem;
}

.observation-age,
.home-chart-status {
  font-size: var(--type-observation);
  opacity: .75;
  margin-top: .2rem;
}

[data-observation-state="stale"], [data-observation-state="missing"] { opacity: .6; }

/* Min/Max-Zeile */
.range.range-temp {
  display: flex;
  justify-content: space-between;
  margin-top: .22rem;
}

.range.range-temp .mini {
  font-size: var(--type-card-detail);
}

.range.range-temp .time {
  font-size: var(--type-card-time);
  opacity: .7;
}

/* ------------------------------------------------------ */
/*  WIND-Kachel (Basis)                                   */
/* ------------------------------------------------------ */

/* Messwert und feste Richtungsbox; wirksame Werte der bisherigen Regeln. */
#wind-card .value {
  display: grid;
  grid-template-columns: auto var(--wind-dir-size);
  column-gap: var(--gust-gap);
  align-items: start;
  min-width: 0;
}

#windBase {
  flex-shrink: 0;
  min-width: 70px;
  font-size: var(--type-card-value);
  font-weight: var(--type-weight-semibold);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: visible !important;
  text-overflow: clip !important;
}

/* Richtungspfeil / Punkt */
#windDirArrow {
  width: var(--wind-dir-size);
  height: var(--wind-dir-size);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: var(--wind-arrow-top);
  line-height: 1;
  pointer-events: none;
}

#windDirArrow > * {
  font-size: 1.6rem;
  line-height: 1;
  transition: transform .85s cubic-bezier(.4, 0, .2, 1);
  will-change: transform;
}

.wind-calm-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.2);
  display: inline-block;
  transition: opacity .35s ease, transform .35s ease;
}

body.theme-night .wind-calm-dot {
  background: rgba(255, 255, 255, 0.8);
}

/* Kleine Zusatzzeilen für Wind (2. & 3. Zeile),
   Detail-Fine-Tuning auf der Home-Seite in home.css */
.mini-wind {
  font-size: var(--type-card-meta);
  opacity: .8;
  margin-top: .20rem;
  text-align: left;
  line-height: var(--type-line-detail);
  white-space: nowrap;
}

/* Standard: auf Home blenden wir ihn über home.css extra ein/aus */
#windGustMax {
  display: none;
}

/* ------------------------------------------------------ */
/*  DRUCK + REGEN-Basics                                  */
/* ------------------------------------------------------ */

.press-trend {
  display: flex;
  gap: 6px;
  font-size: var(--type-card-detail);
  opacity: .75;
  margin-top: .32rem;
}

.mini-rain {
  font-size: var(--type-card-meta);
  opacity: .85;
  margin-top: .18rem;
  white-space: nowrap;
  line-height: var(--type-line-detail);
}

#rainEventLine,
#rainRateLine,
#disturber {
  font-size: var(--type-card-meta);
  opacity: .75;
}

/* ------------------------------------------------------ */
/*  Sky-Icon im Header                                    */
/* ------------------------------------------------------ */

#wxSkyWrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 32px;
  width: 72px;
}

#wxSkyIconWrap {
  width: 44px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#wxSkyIcon {
  white-space: nowrap;
  line-height: 1;
  font-size: 26px !important;
  color: #000 !important;
  opacity: 0;
  transition: opacity .35s ease;
}

body.wx-has-skyicon #wxSkyIcon {
  opacity: 1 !important;
}

body.theme-night #wxSkyIcon {
  color: #f5f5f7 !important;
}

.wx-skytext,
#wxSkyText {
  font-size: .62rem;
  line-height: 1.05;
  opacity: .62;
  margin-top: 4px;
  text-align: center;
  max-width: 72px;
  white-space: normal;
  /* The short weather phrase must remain complete, especially “möglich”. */
  display: block;
  word-break: break-word;
}

/* Sterne bei klarer Nacht */
.wi.wx-moon-stars::after {
  content: "\f077";
  font-family: "weathericons";
  font-size: .85em;
  margin-left: .18em;
  opacity: .85;
  vertical-align: super;
  display: inline-block;
  transform: translateY(-2px);
}

/* ------------------------------------------------------ */
/*  Live-Update + Status-Dot                              */
/* ------------------------------------------------------ */

.wx-lastupdate {
  display: flex;
  align-items: center;
  gap: .35em;
  font-size: .82rem;
  opacity: .65;
  margin-top: 2px;
}

.status-dot.small {
  width: .60em;
  height: .60em;
  border-radius: 50%;
  display: inline-block;
  margin-right: .30em;
  vertical-align: middle;
  position: relative;
  color: #bbb;
  background: currentColor;
  box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.15);
  transition:
    background-color .25s ease,
    box-shadow .25s ease,
    transform .2s ease;
}

.status-dot.small::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid currentColor;
  opacity: 0;
  transform: scale(.6);
  pointer-events: none;
}

.status-dot.small.status-offline {
  color: #ff3b30;
}

.status-dot.small.status-idle {
  color: #ff9500;
}

.status-dot.small.status-live {
  color: #32d74b;
}

.status-dot.small.status-fallback {
  color: var(--accent);
}

.status-dot.small.pulse {
  animation: dotCore 0.9s ease-out 1;
}

.status-dot.small.pulse::after {
  animation: dotWave 1.4s ease-out 1;
}

@keyframes dotCore {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.15);
  }
  50% {
    transform: scale(1.18);
    box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.12);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.07);
  }
}

@keyframes dotWave {
  0% {
    opacity: .45;
    transform: scale(.7);
  }
  70% {
    opacity: 0;
    transform: scale(1.6);
  }
  100% {
    opacity: 0;
    transform: scale(1.8);
  }
}

/* ------------------------------------------------------ */
/*  Burger-Menü                                           */
/* ------------------------------------------------------ */

.burger {
  width: 22px;
  height: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  background: none;
  border: none;
}

.burger span {
  height: 2px;
  width: 100%;
  background: #111;
  border-radius: 2px;
  transition: opacity .25s ease;
}

.burger:hover span {
  opacity: .7;
}

body.theme-night .burger span {
  background: #f5f5f7;
}

/* Fade-Effekt für Übergangswerte */
.valfade {
  opacity: .3;
  transition: opacity .2s ease;
}

/* Ladepunkte-Platzhalter */
.loading-dots {
  display: inline-block;
  animation: dotsPulse 1.4s infinite ease-in-out;
  opacity: 0.45;
}

@keyframes dotsPulse {
  0%   { opacity: 0.25; }
  40%  { opacity: 0.9;  }
  80%  { opacity: 0.4;  }
  100% { opacity: 0.25; }
}

/* ------------------------------------------------------ */
/*  CHARTS — globales Basislayout                         */
/* ------------------------------------------------------ */

.charts-section {
  margin: .9rem;
}

.chart-card {
  background: var(--card);
  padding: 1rem;
  border: var(--card-border);
  border-radius: var(--card-radius);
}

/* Goldener Schnitt mobil: Höhe ≈ Breite / φ (Viewport-Breite) */
.chart-wrapper {
  width: 100%;
  height: calc(100vw / 1.618);
  max-height: 420px;
}

/* Radiation charts let Chart.js resize the canvas and its bitmap together. */
.chart-wrapper canvas:where(:not(.page.radiation canvas)) {
  width: 100% !important;
  height: 100% !important;
}

/* Polar-Chart: nur Canvas-100% – Verhältnis kommt aus chart-wrapper */
.chart-wrapper--square {
  width: 100%;
}

.chart-wrapper--square canvas {
  width: 100% !important;
  height: 100% !important;
}

.chart-title {
  display: flex;
  justify-content: center;
  gap: 6px;
  font-size: var(--type-chart-title);
  font-weight: var(--type-weight-medium);
  letter-spacing: var(--type-chart-tracking);
  margin-bottom: .35rem;
}

.chart-title i {
  font-size: 1.05rem;
  opacity: .75;
}

/* Blitzkarte: Flash-Effekt */
#lightning-card.flash {
  animation: lightningFlash 1.3s ease-out 1;
  box-shadow: 0 0 12px 6px rgba(255, 180, 0, .55);
}

@keyframes lightningFlash {
  0%  { box-shadow: 0 0 0 0 rgba(255, 180, 0, .6); }
  40% { box-shadow: 0 0 12px 6px rgba(255, 180, 0, .45); }
  100%{ box-shadow: 0 0 0 0 rgba(255, 180, 0, 0); }
}

/* ------------------------------------------------------ */
/*  FOOTER + rechtlicher Hinweis                          */
/* ------------------------------------------------------ */

footer.wx-footer {
  text-align: center;
  padding: 0.8rem 0 0.35rem;
  font-size: .8rem;
  opacity: .7;
}

body.theme-night footer.wx-footer {
  opacity: .65;
}

.legal-note {
  font-size: 0.70rem;
  line-height: 1.35;
  opacity: 0.55;
  text-align: center;
  max-width: 640px;
  margin: 0.1rem auto 1.1rem auto;
  padding: 0 1rem;
  color: var(--text);
}

body.theme-night .legal-note {
  opacity: 0.45;
  color: var(--text-dark);
}

/* ------------------------------------------------------ */
/*  DESKTOP: Header als Kachel-Frame mit Clamp-Breite     */
/* ------------------------------------------------------ */

@media (min-width: 1024px) {

  /* Menükachel:
     - ab 1024px konstante Innenbreite von 1024px
     - ab ~1657px wächst die Breite golden-ratio-mäßig (61.8vw)
     - ab 1920px bleibt die Breite konstant (~1185px),
       der äußere Abstand links/rechts wächst weiter */
  .wx-header {
    width: clamp(1024px, 61.8vw, 1185px);
    max-width: 100%;
    margin: 0.6rem auto 0.8rem;
    border-radius: 16px;
    box-shadow:
      0 1px 3px rgba(0, 0, 0, 0.10),
      0 10px 30px rgba(0, 0, 0, 0.12);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    padding-inline: 1.1rem;
  }

  body.theme-night .wx-header {
    box-shadow:
      0 1px 3px rgba(0, 0, 0, 0.7),
      0 14px 36px rgba(0, 0, 0, 0.9);
    border-bottom-color: rgba(255, 255, 255, 0.10);
  }
}
/* StormLab nutzt dieselbe Kartenoberfläche. Zentral, damit das unabhängige
   Sensor-/Telemetrie-Stylesheet seine Tabellen und Statusfarben behält. */
.panel.panel--stormlab { padding: .9rem; }

.panel.panel--stormlab .sl-card {
  padding: 1rem;
  background: var(--card);
  border: var(--card-border);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
}

/* Nur Abstände zwischen Karten; die Home-Raster bleiben die Referenz. */
@media (min-width: 1024px) {
  :root { --card-gap: .9rem; }
  .panel.panel--stormlab { padding: .9rem 0; }
}

.panel.panel--stormlab > .sl-card + .sl-card {
  margin-top: var(--card-gap);
}

.panel.panel--stormlab > .grid2 {
  gap: var(--card-gap);
  margin-top: var(--card-gap);
}

.load-notice { margin: 1rem; }
.load-notice button { font: inherit; cursor: pointer; }
.chart-load-failed[hidden] { display: none !important; }
