/**
 * Klassisches, redaktionelles Stadtportal-Design für webcam-muenster.de
 * Automatischer Tag-/Nacht-Modus:
 * - Tag (data-theme="light"): Warmer Papier-/Sandstein-Ton (#f7f5f0), klassische Typografie, Münster-Backsteinrot (#9e2a2b)
 * - Nacht (data-theme="dark"): Ruhiges, warmes Schiefer-Anthrazit (#18181b), augenschonend passend zum Nachtbild der Webcam
 */

:root,
html[data-theme="light"] {
  --bg: #f6f4ef;
  --bg-elevated: #edeae2;
  --card-bg: #ffffff;
  --card-hover: #f9f8f5;
  --text: #1c1917;
  --text-muted: #57534e;
  --border: #dcd7cd;
  --accent: #9e2a2b;
  --accent-hover: #7c1d1e;
  --success: #15803d;
  --header-bg: rgba(246, 244, 239, 0.96);
  --shadow-soft: 0 2px 10px rgba(28, 25, 23, 0.06);
  --font-serif: Georgia, "Times New Roman", Times, serif;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

html[data-theme="dark"] {
  --bg: #161618;
  --bg-elevated: #202023;
  --card-bg: #232326;
  --card-hover: #2b2b2f;
  --text: #f5f5f4;
  --text-muted: #a8a29e;
  --border: #38383d;
  --accent: #d97757;
  --accent-hover: #e6957a;
  --success: #22c55e;
  --header-bg: rgba(22, 22, 24, 0.95);
  --shadow-soft: 0 4px 16px rgba(0, 0, 0, 0.35);
}

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

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.65;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: background-color 0.2s ease, color 0.2s ease;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--accent-hover);
}

/* Barrierefreiheit (WCAG 2.1 AA / BITV): Skip-Link, Fokus-Ringe & Reduced Motion */
.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  background: var(--accent);
  color: #ffffff;
  padding: 0.6rem 1rem;
  border-radius: 4px;
  font-weight: 600;
  z-index: 999;
  text-decoration: none;
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: 0.75rem;
  color: #ffffff;
  outline: 3px solid var(--text);
  outline-offset: 2px;
}

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

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Header & Navigation */
.site-header {
  background: var(--header-bg);
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1060px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.brand:hover {
  opacity: 0.9;
}

.brand-logo {
  height: 58px;
  width: auto;
  display: block;
  object-fit: contain;
}

html[data-theme="dark"] .brand-logo-light {
  display: none;
}

html:not([data-theme="dark"]) .brand-logo-dark {
  display: none;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.main-nav {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.nav-link {
  color: var(--text-muted);
  font-size: 0.94rem;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border-radius: 4px;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.nav-link:hover {
  color: var(--text);
  text-decoration: none;
}

.nav-link.active {
  color: var(--accent);
  font-weight: 600;
  border-bottom-color: var(--accent);
  border-radius: 0;
}

.theme-toggle-btn {
  background: var(--bg-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.32rem 0.65rem;
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.theme-toggle-btn:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

/* Main Container */
main {
  flex: 1;
  max-width: 1060px;
  width: 100%;
  margin: 0 auto;
  padding: 1.75rem 1.25rem;
}

.page-hero {
  margin-bottom: 1.35rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.page-hero h1 {
  font-family: var(--font-serif);
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 0.25rem;
  color: var(--text);
}

.page-hero p {
  color: var(--text-muted);
  font-size: 0.98rem;
}

/* Webcam Frame */
.cam-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  margin-bottom: 2rem;
}

.cam-wrapper {
  position: relative;
  background: #111;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 260px;
}

.cam-wrapper img {
  width: 100%;
  height: auto;
  max-height: 75vh;
  object-fit: contain;
  display: block;
}

.cam-meta {
  padding: 0.75rem 1.15rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.84rem;
  color: var(--text-muted);
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 0.75rem;
}

.cam-meta-group {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--text);
  font-weight: 500;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}

/* Content Sections & Editorial Grid (statt Dashboard-Kacheln) */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2.25rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.35rem 1.5rem;
  box-shadow: var(--shadow-soft);
}

.card h2 {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.6rem;
  color: var(--text);
}

.card h3 {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  margin: 1.15rem 0 0.4rem;
  color: var(--text);
}

.card p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 0.85rem;
}

.card p:last-child {
  margin-bottom: 0;
}

.card-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-weight: 600;
  font-size: 0.92rem;
  margin-top: 0.4rem;
  text-decoration: none;
}

.card-link:hover {
  text-decoration: underline;
}

/* Redaktionelle 2-Spalten-Sektion ohne schwere Kachel-Ränder */
.context-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.25rem;
  margin-bottom: 1.5rem;
}

.context-grid > .card {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0.25rem 0;
}

@media (max-width: 768px) {
  .context-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
}

.meta-list {
  list-style: none;
  margin-top: 0.85rem;
  border-top: 1px solid var(--border);
  padding-top: 0.6rem;
}

.meta-list li {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  font-size: 0.9rem;
  border-bottom: 1px dotted var(--border);
}

.meta-list li:last-child {
  border-bottom: none;
}

.meta-label {
  color: var(--text-muted);
}

.meta-value {
  color: var(--text);
  font-weight: 500;
}

/* Legal & Content Pages */
.prose-card {
  max-width: 820px;
  margin: 0 auto;
}

.prose-card h1 {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  margin-bottom: 1.25rem;
}

.prose-card h2 {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  margin: 1.5rem 0 0.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.25rem;
}

/* Footer */
.site-footer {
  max-width: 1060px;
  width: 100%;
  margin: 2rem auto 0;
  padding: 1.5rem 1.25rem 2.25rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.footer-links {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* Weather Module (Paket 2) - Klassische Wetter-Übersichtsleiste statt KPI-Kacheln */
.weather-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow-soft);
  margin-bottom: 1.75rem;
  overflow: hidden;
}

.kpi-box {
  padding: 0.95rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.kpi-box:last-child {
  border-right: none;
}

.kpi-label {
  font-size: 0.76rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-value {
  font-family: var(--font-serif);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text);
}

.kpi-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.weather-two-col {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 1.5rem;
  margin-bottom: 1.75rem;
}

@media (max-width: 860px) {
  .weather-two-col {
    grid-template-columns: 1fr;
  }
}

.current-conditions-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.current-conditions-table th,
.current-conditions-table td {
  padding: 0.5rem 0.4rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.current-conditions-table th {
  color: var(--text-muted);
  font-weight: 600;
  width: 44%;
}

.current-conditions-table td {
  color: var(--text);
  font-weight: 500;
}

.current-conditions-table tr:last-child th,
.current-conditions-table tr:last-child td {
  border-bottom: none;
}

.metar-raw-box {
  margin-top: 1rem;
  padding: 0.65rem 0.9rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.82rem;
  color: var(--text);
  word-break: break-all;
}

.chart-card {
  margin-bottom: 1.75rem;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.chart-legend {
  display: flex;
  gap: 1rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  display: inline-block;
}

.chart-container {
  position: relative;
  width: 100%;
  height: 250px;
}

.chart-container canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.forecast-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
}

.forecast-day {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.85rem;
  text-align: center;
}

.forecast-day-name {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.2rem;
}

.forecast-day-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  min-height: 2.4em;
  display: flex;
  align-items: center;
  justify-content: center;
}

.forecast-temps {
  margin-top: 0.45rem;
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 700;
}

.temp-min {
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 0.35rem;
}

.forecast-rain {
  margin-top: 0.3rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Archive Module (Paket 3) */
.archive-controls {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  margin-bottom: 1.5rem;
}

.archive-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.date-picker-group {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.date-input {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.45rem 0.75rem;
  font-size: 0.92rem;
  font-family: inherit;
}

.date-input:focus,
.search-input:focus {
  border-color: var(--accent);
}

.btn {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.45rem 0.8rem;
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  text-decoration: none;
}

.btn:hover:not(:disabled) {
  background: var(--card-hover);
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #ffffff;
}

.quick-jumps {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.quick-jumps-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-right: 0.2rem;
}

.hour-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 0.35rem;
}

@media (max-width: 720px) {
  .hour-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

.hour-btn {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.4rem 0.2rem;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: all 0.12s ease;
}

.hour-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.hour-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.hour-btn:disabled {
  opacity: 0.28;
  cursor: not-allowed;
  text-decoration: line-through;
}

.archive-status-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Webcam Map Module (Paket 4) */
.map-filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.region-tabs {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.search-input {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.45rem 0.8rem;
  font-size: 0.9rem;
  min-width: 240px;
  font-family: inherit;
}

.wmap-viewport {
  position: relative;
  width: 100%;
  height: 500px;
  background: #e5e0d5;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  user-select: none;
  cursor: grab;
  margin-bottom: 1.75rem;
  box-shadow: var(--shadow-soft);
}

.wmap-viewport.is-dragging {
  cursor: grabbing;
}

.wmap-tile-layer,
.wmap-marker-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.wmap-tile {
  position: absolute;
  top: 0;
  left: 0;
  width: 256px;
  height: 256px;
}

html[data-theme="dark"] .wmap-tile {
  filter: brightness(0.84) contrast(1.04);
}

.wmap-pin {
  position: absolute;
  top: -11px;
  left: -11px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: 2.5px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.12s ease, background-color 0.12s ease;
}

.wmap-pin:hover {
  background: var(--accent-hover);
  z-index: 20;
}

.wmap-pin-home {
  background: #15803d;
  width: 26px;
  height: 26px;
  top: -13px;
  left: -13px;
  z-index: 15;
}

.wmap-pin-active {
  background: #d97706;
  border-color: #fff;
  z-index: 30;
}

.wmap-popup {
  position: absolute;
  width: 260px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 6px;
  padding: 0.85rem 1rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  z-index: 40;
}

.wmap-popup-close {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
}

.wmap-popup-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 0.94rem;
  color: var(--text);
  padding-right: 1rem;
  margin-bottom: 0.25rem;
}

.wmap-popup-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.55rem;
}

.wmap-popup-dist {
  display: inline-block;
  color: var(--accent);
  font-weight: 600;
}

.wmap-popup-link {
  display: inline-block;
  font-size: 0.84rem;
  font-weight: 600;
}

.wmap-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 35;
}

.wmap-ctrl-btn {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}

.wmap-ctrl-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.wmap-attribution {
  position: absolute;
  bottom: 6px;
  right: 8px;
  background: var(--header-bg);
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 0.72rem;
  color: var(--text-muted);
  z-index: 35;
}

.webcam-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 0.85rem;
}

.webcam-item {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.9rem 1.1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.45rem;
}

.webcam-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.webcam-item-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 0.96rem;
  color: var(--text);
}

.webcam-dist-badge {
  font-size: 0.75rem;
  background: var(--bg-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 0.1rem 0.45rem;
  border-radius: 3px;
  white-space: nowrap;
}

.webcam-item-town {
  font-size: 0.83rem;
  color: var(--text-muted);
}

.webcam-item-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.25rem;
  font-size: 0.84rem;
}

/* DSGVO AdSense & Consent Module (Paket 6) */
.ad-slot-wrapper {
  margin: 0 auto 1.75rem;
  width: 100%;
}

.ad-slot-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  text-align: right;
}

.ad-slot-box {
  min-height: 92px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1rem;
  overflow: hidden;
}

.ad-consent-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
}

.consent-banner {
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  right: 1rem;
  max-width: 800px;
  margin: 0 auto;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 6px;
  padding: 1.15rem 1.35rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
  z-index: 200;
  display: none;
}

.consent-banner-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.consent-banner-text {
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-bottom: 0.9rem;
  line-height: 1.5;
}

.consent-banner-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  flex-wrap: wrap;
}
