/* webcam-rheinbach.de – Basis-Styles, mobile-first, Light/Dark je Tageszeit */

/* Selbst gehostet (assets/fonts/), kein Google-Fonts-Nachladen. Nur als
   Semibold hinterlegt, daher font-weight hier fest auf 600 – nur für
   .poi-btn genutzt (siehe unten), das exakt dieses Gewicht verwendet. */
@font-face {
  font-family: "Inter";
  src: url("../fonts/Inter_18pt-SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 10px;
  --max-width: 1100px;
}

/* Tag-Theme (Standard) */
body.theme-day {
  --bg: #ffffff;
  --bg-elevated: #ffffff;
  --text: #1c2733;
  --text-muted: #55616e;
  --border: #dde3e9;
  --accent: #1d6fa5;
  --accent-contrast: #ffffff;
  --shadow: 0 1px 3px rgba(20, 30, 40, 0.08), 0 1px 2px rgba(20, 30, 40, 0.06);
}

/* Nacht-Theme */
body.theme-night {
  --bg: #000000;
  --bg-elevated: #172230;
  --text: #e7edf3;
  --text-muted: #9aa9b8;
  --border: #2a3948;
  --accent: #5fb0e8;
  --accent-contrast: #0e141b;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.5;
  transition: background-color 0.6s ease, color 0.6s ease;
}

a { color: var(--accent); }

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 16px;
}

/* ---- Kopf / Navigation ---- */
.site-header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--max-width);
  margin: 0 auto;
}

.site-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: 0.02em;
  color: #ff7b00;
}

#intro .site-title {
  font-size: 1.6rem;
  margin: 20px 0 10px;
}

/* Identischer Textstil wie der Link im Footer (.site-footer) */
.site-nav a {
  color: var(--accent);
  font-family: "Inter", ui-rounded, "Segoe UI Rounded", var(--font-sans);
  font-size: 0.72rem;
  font-weight: 600;
}

/* ---- Kamerabild, volle Breite, unverändert (kein CSS-Zuschnitt) ---- */
.webcam-wrap {
  position: relative;
  width: calc(100% - 20px);
  margin: 20px 10px 5px;
  height: 480px;
  background: var(--bg);
  line-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  /* pan-y nicht weglassen: "pan-x" allein unterdrückt vertikale Touch-Gesten
     auf dem Element komplett, statt sie an die Seite weiterzureichen – dann
     lässt sich beim Berühren des Bilds nicht mehr vertikal scrollen. */
  touch-action: pan-x pan-y;
  cursor: grab;
  /* Scrollbalken ausblenden: verschoben wird per Wisch-/Ziehgeste direkt
     auf dem Bild (Touch nativ, Maus über JS in main.js). */
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.webcam-wrap::-webkit-scrollbar {
  display: none;
}

.webcam-wrap.is-dragging {
  cursor: grabbing;
  scroll-behavior: auto;
}

/* Bild wird nie gestreckt/gestaucht: feste Höhe, Breite im Originalverhältnis.
   Ist der Container schmaler als das Bild, kann links/rechts gescrollt werden. */
.webcam-wrap img {
  height: 480px;
  width: auto;
  max-width: none;
  display: block;
  -webkit-user-drag: none;
  user-select: none;
}

/* Wartungsmodus-Overlay über dem (eingefrorenen) Kamerabild, siehe
   MaintenanceMode + api/webcam-token.php + main.js. "position: sticky;
   left: 0" statt absolute, damit das Overlay auch dann mittig im
   sichtbaren Ausschnitt bleibt, wenn .webcam-wrap horizontal gescrollt
   ist (z.B. bei einem breiteren Panoramabild); der negative margin-top
   zieht es über das Bild direkt darüber statt darunter im Fluss. */
.webcam-maintenance {
  display: none;
  position: sticky;
  left: 0;
  width: 100%;
  height: 480px;
  margin-top: -480px;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-sizing: border-box;
  padding: 30px;
  background: rgba(10, 14, 18, 0.72);
  color: #ffffff;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: pre-line;
}

.webcam-maintenance.is-visible {
  display: flex;
}

/* ---- POI-Buttons unter dem Kamerabild ---- */
/* Erst nach Ablauf des Countdowns eingeblendet, siehe initPoiButtons(). */
.poi-buttons {
  display: none;
  width: calc(100% - 20px);
  margin: 0 10px;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 8px;
}

.poi-buttons.is-visible {
  display: grid;
}

/* Wartungsmodus: Steuerung verstecken, unabhängig vom sonstigen
   Sichtbarkeits-/Countdown-Status (siehe .poi-buttons.is-visible oben). */
body.maintenance-active .poi-buttons,
body.maintenance-active .poi-status {
  display: none !important;
}

.poi-btn {
  padding: 6px 8px;
  /* Selbst gehostete Inter Semibold (siehe @font-face oben), Fallback auf
     die abgerundete Systemschrift, falls die Datei mal nicht lädt. */
  font-family: "Inter", ui-rounded, "Segoe UI Rounded", var(--font-sans);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 0;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.poi-btn:hover {
  border-color: #ff7b00;
  color: #ff7b00;
}

.poi-btn:active {
  transform: translateY(1px);
}

.poi-btn.is-active {
  color: #ff7b00;
}

.poi-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.poi-status {
  width: calc(100% - 20px);
  box-sizing: border-box;
  margin: 8px 10px 20px;
  padding: 8px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

.poi-status:empty {
  display: none;
}

.poi-status.is-error {
  color: #cc3333;
  border-color: #cc3333;
}

/* ---- Allgemeine Sektionen ---- */
section {
  padding: 28px 0;
}

section h2 {
  font-size: 1.3rem;
  margin: 0 0 14px;
  color: #ff7b00;
}

/* Identischer Textstil wie die Quellenangabe bei den Warnungen (.current-updated) */
.section-subtitle {
  font-weight: 400;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: -10px 0 14px;
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* Identischer Textstil wie die Werte-Zellen unter "Aktuelles Wetter" (.current-table td) */
.intro-text {
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 400;
}

/* ---- Vorhersage ---- */
.forecast-day {
  padding: 18px;
  margin-bottom: 16px;
}

/* Identischer Textstil wie die Kachel-Überschriften im Wetterverlauf (.chart-card h3) */
.forecast-day .date {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-muted);
}

/* Identischer Textstil wie die Werte-Zellen unter "Aktuelles Wetter" (.current-table td) */
.forecast-day-text {
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 400;
}

/* Identischer Textstil wie die Kachel-Überschriften im Wetterverlauf (.chart-card h3) */
.forecast-day-text strong {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
}

.forecast-day-text.muted {
  color: var(--text-muted);
  font-style: italic;
}

.forecast-day-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.forecast-day-summary {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
}

.forecast-day-summary .icon {
  width: 66px;
  height: 66px;
  flex: none;
  color: var(--accent);
}

.forecast-day-summary .icon svg { width: 100%; height: 100%; }

.forecast-day-summary .icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 6px;
}

.forecast-day-summary .temps {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  gap: 8px;
}
.forecast-day-summary .temps .max { font-weight: 700; font-size: 1.25rem; }
.forecast-day-summary .temps .min { color: var(--text-muted); font-size: 1.125rem; }
.forecast-day-summary .temps .min::before { content: "/ "; color: var(--text-muted); }

.forecast-day-chart {
  flex: 1;
  min-width: 0;
}

.forecast-day-chart canvas {
  width: 100% !important;
  height: 160px !important;
}

.forecast-day-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-top: 8px;
  font-size: 0.88rem;
  font-weight: 600;
}

.forecast-day-stats .stat-sun { color: #ff9900; }
.forecast-day-stats .stat-rain { color: #0099cc; }
.forecast-day-stats .stat-gust { color: #00cc33; }

@media (min-width: 640px) {
  .forecast-day-body {
    flex-direction: row;
    align-items: center;
  }
  .forecast-day-summary {
    flex: none;
    flex-direction: column;
    gap: 2px;
    width: 120px;
  }
  .forecast-day-summary .temps {
    flex-direction: column;
    align-items: center;
    gap: 6px;
  }
  .forecast-day-summary .temps .min::before {
    content: none;
  }
}

/* Ab hier passen 3 Wetterverlauf-Kacheln nebeneinander in eine Zeile
   (3 × 280px Mindestbreite + 2 × 18px Gap ≈ 876px Innenbreite, siehe
   .chart-grid) – ab hier auch bei der Vorhersage Text und Chart
   nebeneinander statt den Chart über die volle Kartenbreite zu ziehen. */
@media (min-width: 900px) {
  .forecast-day {
    display: grid;
    grid-template-columns: 38% 1fr;
    column-gap: 24px;
    align-items: start;
  }
  .forecast-day .date {
    grid-column: 1;
    grid-row: 1;
  }
  .forecast-day-text {
    grid-column: 1;
    grid-row: 2;
    min-width: 0;
    margin: 0;
  }
  .forecast-day-body {
    grid-column: 2;
    grid-row: 1 / span 2;
    margin-top: 0;
    min-width: 0;
  }
}

/* ---- DWD-Wetterwarnungen ---- */
.weather-warnings {
  padding-top: 12px;
  padding-bottom: 8px;
}

.warning-item {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  border-left-width: 6px;
  padding: 12px 16px;
  margin-bottom: 10px;
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
}

.warning-item.severity-1 { border-left-color: #f0c000; }
.warning-item.severity-2 { border-left-color: #ff9800; }
.warning-item.severity-3 { border-left-color: #e53935; }
.warning-item.severity-4 { border-left-color: #9c27b0; }

.warning-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.warning-badge {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.warning-item.severity-1 .warning-badge { color: #b38a00; }
.warning-item.severity-2 .warning-badge { color: #cc7a00; }
.warning-item.severity-3 .warning-badge { color: #e53935; }
.warning-item.severity-4 .warning-badge { color: #9c27b0; }

/* Identischer Textstil wie die Kachel-Überschriften im Wetterverlauf (.chart-card h3) */
.warning-head strong {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Identischer Textstil wie die Werte-Zellen unter "Aktuelles Wetter" (.current-table td) */
.warning-text {
  margin: 6px 0 0;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--text);
  white-space: pre-line;
}

.warning-until {
  margin: 8px 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ---- Aktuelle Werte Tabelle ---- */
.current-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
}

.current-table th, .current-table td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

.current-table tr:last-child th, .current-table tr:last-child td {
  border-bottom: none;
}

/* Identischer Textstil wie die Kachel-Überschriften im Wetterverlauf (.chart-card h3) */
.current-table th {
  color: var(--text-muted);
  font-weight: 600;
  width: 45%;
}

/* Zwei Tabellenvarianten mit identischen Werten (siehe render_helpers.php):
   "narrow" (2-spaltig, ein Label/Wert-Paar pro Zeile) für schmale Bildschirme,
   "wide" (4-spaltig, zwei Paare pro Zeile) ab 640px. Immer nur eine der
   beiden ist sichtbar. */
.current-table.wide {
  display: none;
}

@media (min-width: 640px) {
  .current-table.narrow {
    display: none;
  }
  .current-table.wide {
    display: table;
  }
  .current-table.wide th {
    width: 22%;
  }
  .current-table.wide td {
    width: 28%;
  }
  .current-table.wide th[rowspan], .current-table.wide td[rowspan] {
    vertical-align: middle;
  }
}

.current-updated {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 8px;
}

.sun-times {
  margin-top: 16px;
}

/* ---- 24h-Verlauf Charts ---- */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}

.chart-card {
  padding: 14px;
}

.chart-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0 0 8px;
}

.chart-card h3 {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 600;
}

.chart-top-stat {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1;
}

.chart-card canvas {
  width: 100% !important;
  height: 180px !important;
}

.chart-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 16px;
  margin: 8px 0 0;
  font-size: 0.88rem;
  font-weight: 600;
}

/* ---- Footer ---- */
/* Identischer Textstil wie die POI-Buttons (.poi-btn) */
.site-footer {
  padding: 4px 16px 40px;
  text-align: center;
  font-family: "Inter", ui-rounded, "Segoe UI Rounded", var(--font-sans);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
}

.site-footer p {
  margin: 4px 0;
}

/* ---- Impressum-Seite ---- */
.legal h2 {
  margin-top: 28px;
}

/* Identischer Textstil wie die Kachel-Überschriften im Wetterverlauf (.chart-card h3) */
.legal h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Identischer Textstil wie der Einleitungstext (.intro-text) */
.legal p, .legal li {
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 400;
}

.placeholder {
  background: rgba(255, 193, 7, 0.18);
  border: 1px dashed #d3a018;
  border-radius: 4px;
  padding: 0 4px;
}

.impressum-image {
  max-width: 100%;
  height: auto;
  display: block;
}

@media (min-width: 640px) {
  section h2 { font-size: 1.5rem; }
}
