/* ── Custom Properties ─────────────────────────────────── */
:root {
  --status-open: #16a34a;
  --status-open-light: #22c55e;
  --status-chains: #d97706;
  --status-chains-light: #f59e0b;
  --status-closed: #dc2626;
  --status-closed-light: #ef4444;
  --bg: #f8f9fa;
  --bg-card: #ffffff;
  --text: #1a1a1a;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --focus-ring: #2563eb;
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-heading: "Outfit", var(--font);
  --radius: 8px;
  --max-width: 960px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111214;
    --bg-card: #1e1f23;
    --text: #e5e7eb;
    --text-muted: #9ca3af;
    --border: #2d2f34;
    --focus-ring: #60a5fa;
  }
}

/* ── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; }

body {
  font-family: var(--font);
  background: linear-gradient(180deg, #f0f0f2 0%, #f8f9fa 40%, #f4f4f6 100%);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

@media (prefers-color-scheme: dark) {
  body {
    background: linear-gradient(180deg, #15161a 0%, #111214 40%, #0d0e10 100%);
  }
}

main { flex: 1; }

a { color: var(--focus-ring); }
a:hover { text-decoration: none; }

/* ── Focus ────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ── Page Load Animation ─────────────────────────────── */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeInUp 0.35s ease-out both;
}

.site-header.fade-in              { animation-delay: 0s; }
.status-banner.fade-in            { animation-delay: 0.06s; }
.condition-details.fade-in        { animation-delay: 0.12s; }
.alerts.fade-in                   { animation-delay: 0.18s; }
.cameras.fade-in                  { animation-delay: 0.24s; }

/* ── Header ───────────────────────────────────────────── */
.site-header {
  text-align: center;
  padding: 1.5rem 1rem 1rem;
}

.site-header h1 {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.route-desc {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.last-updated {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* ── Side Toggle ─────────────────────────────────────── */
.side-toggle {
  display: flex;
  justify-content: center;
  gap: 0;
  margin-top: 0.75rem;
}

.side-tab {
  padding: 0.4rem 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--font);
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.side-tab:first-child {
  border-radius: var(--radius) 0 0 var(--radius);
}

.side-tab:last-child {
  border-radius: 0 var(--radius) var(--radius) 0;
  border-left: none;
}

.side-tab.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.side-tab:hover:not(.active) {
  background: var(--border);
}

/* ── Status Banner ────────────────────────────────────── */
.status-banner {
  max-width: var(--max-width);
  margin: 1rem auto 0;
  padding: 1.5rem 1.5rem;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--text-muted);
  color: #fff;
  text-align: center;
}

.status-banner[data-status="open"] {
  background: linear-gradient(180deg, var(--status-open-light) 0%, var(--status-open) 100%);
}
.status-banner[data-status="chains"] {
  background: linear-gradient(180deg, var(--status-chains-light) 0%, var(--status-chains) 100%);
}
.status-banner[data-status="closed"] {
  background: linear-gradient(180deg, var(--status-closed-light) 0%, var(--status-closed) 100%);
}

#status-title {
  font-family: var(--font-heading);
  font-size: clamp(1.5rem, 5vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.01em;
}


/* ── Condition Details (card below banner) ───────────── */
.condition-details {
  max-width: var(--max-width);
  margin: 0 auto 1rem;
  padding: 0.75rem 1.5rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
}

#status-detail {
  font-size: 0.875rem;
  color: var(--text);
}

/* ── Condition Groups ─────────────────────────────────── */
.condition-group {
  margin-top: 0.625rem;
}

.condition-group:first-child {
  margin-top: 0;
}

.condition-group strong {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.condition-segments {
  list-style: none;
  padding: 0;
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
}

.condition-segments li {
  padding: 0.15rem 0;
}

.condition-segments li::before {
  content: "\2022 ";
  color: var(--text-muted);
}

/* ── Sections shared ──────────────────────────────────── */
.alerts, .cameras {
  max-width: var(--max-width);
  margin: 1.5rem auto;
  padding: 0 1rem;
}

.alerts h2, .cameras h2 {
  font-family: var(--font-heading);
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

/* ── Alerts ───────────────────────────────────────────── */
#alerts-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#alerts-list li {
  background: var(--bg-card);
  border-left: 4px solid var(--status-chains);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

/* Alert severity variants */
#alerts-list li[data-severity="critical"] {
  border-left-color: var(--status-closed);
}

#alerts-list li[data-severity="info"] {
  border-left-color: var(--focus-ring);
}

/* ── Camera Grid ──────────────────────────────────────── */
.camera-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

@media (min-width: 600px) {
  .camera-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 900px) {
  .camera-grid { grid-template-columns: repeat(3, 1fr); }
}

.camera-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.camera-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.camera-card img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
}

.camera-card .camera-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 1.5rem 0.75rem 0.5rem;
  font-size: 0.8rem;
  color: #fff;
  background: linear-gradient(to top, rgba(0,0,0,0.65) 0%, rgba(0,0,0,0) 100%);
}

.cameras-loading {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ── Dialog / Modal ───────────────────────────────────── */
#camera-modal {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  max-width: min(90vw, 800px);
  max-height: 90vh;
  background: var(--bg-card);
  color: var(--text);
  box-shadow: 0 16px 48px rgba(0,0,0,0.25);
}

#camera-modal::backdrop {
  background: rgba(0,0,0,0.6);
}

.modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: rgba(0,0,0,0.5);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 2rem;
  height: 2rem;
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.modal-close:hover { background: rgba(0,0,0,0.7); }

#modal-video, #modal-image {
  width: 100%;
  display: block;
}

#modal-video {
  background: #000;
  aspect-ratio: 16 / 9;
}

#modal-caption {
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ── Footer ───────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 2rem 1rem 1.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── Stale Notice ─────────────────────────────────────── */
.stale-notice {
  text-align: center;
  font-size: 0.8rem;
  color: var(--status-chains);
  padding: 0.5rem;
}
