/* =========================================================
   Design tokens — light & dark
   ========================================================= */
:root {
  --bg: #f6f7fb;
  --bg-elev: #ffffff;
  --bg-sunken: #eef0f7;
  --surface: #ffffff;
  --border: #e3e7ef;
  --border-strong: #d4d9e4;
  --text: #0f172a;
  --text-muted: #5b6478;
  --text-subtle: #8a93a6;
  --brand: #2563eb;
  --brand-hover: #1d4ed8;
  --brand-soft: #dbeafe;
  --brand-text: #1e40af;
  --accent: #06b6d4;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.05);
  --shadow: 0 6px 18px rgba(15,23,42,.06);
  --shadow-lg: 0 18px 40px rgba(15,23,42,.10);
  --radius: 14px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --transition: 180ms cubic-bezier(.4,0,.2,1);
}
[data-theme="dark"] {
  --bg: #0a1024;
  --bg-elev: #131a35;
  --bg-sunken: #0a0f1e;
  --surface: #161e3e;
  --border: #242d52;
  --border-strong: #2f3a6b;
  --text: #e6eaf6;
  --text-muted: #9ea7c2;
  --text-subtle: #7280a3;
  --brand: #60a5fa;
  --brand-hover: #93c5fd;
  --brand-soft: #1e2750;
  --brand-text: #c7d8ff;
  --accent: #22d3ee;
  --success: #4ade80;
  --success-soft: #052e1a;
  --danger: #f87171;
  --danger-soft: #3a1414;
  --warning: #fbbf24;
  --warning-soft: #3b2510;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.35);
  --shadow: 0 6px 18px rgba(0,0,0,.4);
  --shadow-lg: 0 18px 40px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition), color var(--transition);
}
a { color: var(--brand); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--brand-hover); }
img, video { max-width: 100%; display: block; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-subtle); }

/* =========================================================
   Navbar
   ========================================================= */
.nav {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in oklab, var(--bg-elev) 88%, transparent);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
  transition: background var(--transition), border-color var(--transition);
}
.nav-inner {
  max-width: 1280px; margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex; align-items: center; gap: 1rem;
}
.brand {
  display: flex; align-items: center; gap: 0.65rem;
  font-weight: 700; color: var(--text);
  font-size: 1.1rem; letter-spacing: -0.01em;
}
.brand-logo {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
  display: grid; place-items: center;
  box-shadow: var(--shadow-sm);
}
.brand .brand-accent {
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.nav-links {
  display: flex; gap: 0.25rem; margin-left: 1rem;
  list-style: none; padding: 0;
}
.nav-links a {
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.9rem; font-weight: 500;
  transition: all var(--transition);
}
.nav-links a:hover { background: var(--bg-sunken); color: var(--text); }
.nav-actions { margin-left: auto; display: flex; align-items: center; gap: 0.6rem; }

/* Search */
.search-wrap {
  position: relative; display: flex; align-items: center;
}
.search-wrap svg.search-icon {
  position: absolute; left: 0.75rem; color: var(--text-subtle); pointer-events: none;
}
.search-wrap .input {
  padding-left: 2.4rem;
  width: 240px;
}
@media (max-width: 768px) {
  .search-wrap .input { width: 100%; }
  .nav-links { display: none; }
}

/* =========================================================
   Inputs / Buttons
   ========================================================= */
.input {
  padding: 0.55rem 0.9rem;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  color: var(--text);
  transition: all var(--transition);
  font-family: inherit;
}
.input::placeholder { color: var(--text-subtle); }
.input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 0.92rem; font-weight: 500;
  cursor: pointer; line-height: 1.2;
  transition: all var(--transition);
  background: transparent; color: var(--text);
  text-decoration: none;
}
.btn-primary {
  background: var(--brand); color: #fff; border-color: var(--brand);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); color: #fff; }
.btn-secondary {
  background: var(--bg-elev); color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--bg-sunken); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg-sunken); color: var(--text); }
.btn-sm { padding: 0.4rem 0.7rem; font-size: 0.85rem; }
.btn-icon { width: 38px; height: 38px; padding: 0; border-radius: 50%; }

.theme-toggle {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
}
.theme-toggle:hover { background: var(--bg-sunken); color: var(--text); }
.theme-toggle .sun { display: none; }
.theme-toggle .moon { display: block; }
[data-theme="dark"] .theme-toggle .sun { display: block; }
[data-theme="dark"] .theme-toggle .moon { display: none; }

/* =========================================================
   Layout
   ========================================================= */
.container { max-width: 1280px; margin: 0 auto; padding: 0 1.5rem; }
section { padding: 4rem 0; }
section.alt { background: var(--bg-elev); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section-head { max-width: 720px; margin: 0 auto 2.5rem; text-align: center; }
.section-eyebrow {
  display: inline-block;
  font-size: 0.75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  background: var(--brand-soft); color: var(--brand-text);
  padding: 0.35rem 0.75rem; border-radius: 999px;
  margin-bottom: 0.75rem;
}
.section-title {
  font-size: clamp(1.6rem, 2.6vw, 2.1rem);
  font-weight: 700; margin: 0 0 0.6rem 0;
  letter-spacing: -0.02em;
}
.section-sub { color: var(--text-muted); font-size: 1rem; margin: 0; line-height: 1.6; }

/* =========================================================
   Hero
   ========================================================= */
.hero {
  position: relative;
  padding: 4.5rem 0 3.5rem;
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 20% 20%, var(--brand-soft), transparent 70%),
    radial-gradient(ellipse 50% 40% at 80% 60%, color-mix(in oklab, var(--accent) 25%, transparent), transparent 70%);
  pointer-events: none;
  opacity: 0.7;
}
.hero-inner { position: relative; display: grid; grid-template-columns: 1fr; gap: 2.5rem; align-items: center; }
@media (min-width: 900px) { .hero-inner { grid-template-columns: 1.1fr 1fr; } }
.hero-title {
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1.1; letter-spacing: -0.025em;
  font-weight: 800; margin: 0 0 1rem 0;
}
.hero-title .accent {
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero-sub {
  font-size: 1.1rem; color: var(--text-muted);
  margin: 0 0 1.5rem 0; max-width: 540px; line-height: 1.6;
}
.hero-cta { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.hero-stats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem; margin-top: 2rem; max-width: 540px;
}
.hero-stats .stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow-sm);
}
.hero-stats .stat-val { font-size: 1.5rem; font-weight: 700; line-height: 1; }
.hero-stats .stat-lbl { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.25rem; }
.hero-visual {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  aspect-ratio: 4/3;
  background: var(--bg-elev);
}
.hero-visual img { width: 100%; height: 100%; object-fit: cover; }

/* =========================================================
   Cards / grids
   ========================================================= */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.card-body { padding: 1.25rem; }
.grid {
  display: grid; gap: 1.25rem;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* =========================================================
   Camera cards
   ========================================================= */
.cam-card { display: flex; flex-direction: column; }
.cam-video {
  aspect-ratio: 16/10;
  background: #000;
  position: relative;
  overflow: hidden;
}
.cam-video video { width: 100%; height: 100%; object-fit: cover; }
.cam-live {
  position: absolute; top: 0.75rem; left: 0.75rem;
  display: inline-flex; align-items: center; gap: 0.35rem;
  background: rgba(220, 38, 38, 0.92);
  color: white;
  padding: 0.2rem 0.55rem;
  font-size: 0.72rem; font-weight: 700;
  border-radius: 4px;
  letter-spacing: 0.04em;
  z-index: 2;
}
.cam-live::before {
  content: "";
  width: 6px; height: 6px;
  background: white;
  border-radius: 50%;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}
.cam-meta {
  padding: 0.85rem 1rem;
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  border-top: 1px solid var(--border);
}
.cam-name { font-weight: 600; font-size: 0.95rem; }
.cam-loc { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.15rem; }
.cam-id {
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  background: var(--bg-sunken);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  color: var(--text-muted);
}

/* =========================================================
   Traffic light cards
   ========================================================= */
.traffic-card {
  display: flex; flex-direction: column; align-items: center;
  padding: 1.5rem 1rem 1.2rem;
}
.traffic-housing {
  background: #1a1f2e;
  border-radius: 14px;
  padding: 0.7rem 0.5rem;
  display: flex; flex-direction: column; gap: 0.4rem;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.6), var(--shadow-sm);
}
.traffic-light {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: #2a3142;
  position: relative;
  transition: all var(--transition);
}
.traffic-light.on.red {
  background: radial-gradient(circle at 35% 30%, #ff5252, #c40000);
  box-shadow: 0 0 18px rgba(255, 0, 0, 0.65), inset 0 0 10px rgba(255, 200, 200, 0.5);
}
.traffic-light.on.yellow {
  background: radial-gradient(circle at 35% 30%, #ffd84a, #b8860b);
  box-shadow: 0 0 18px rgba(255, 200, 0, 0.65), inset 0 0 10px rgba(255, 230, 130, 0.5);
}
.traffic-light.on.green {
  background: radial-gradient(circle at 35% 30%, #4ade80, #16a34a);
  box-shadow: 0 0 18px rgba(0, 200, 0, 0.65), inset 0 0 10px rgba(200, 255, 200, 0.5);
}
.traffic-meta { text-align: center; margin-top: 1rem; }
.traffic-name { font-weight: 600; font-size: 0.95rem; }
.traffic-loc { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.15rem; }
.traffic-time {
  margin-top: 0.6rem;
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-size: 0.78rem; font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-sunken);
  padding: 0.25rem 0.65rem; border-radius: 999px;
}

/* =========================================================
   Map
   ========================================================= */
#map {
  height: 480px;
  width: 100%;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
  z-index: 1;
}
.map-legend {
  display: flex; gap: 1rem; flex-wrap: wrap;
  justify-content: center;
  margin-top: 1.25rem;
}
.legend-item {
  display: inline-flex; align-items: center; gap: 0.45rem;
  font-size: 0.85rem; color: var(--text-muted);
  background: var(--surface);
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.legend-dot { width: 12px; height: 12px; border-radius: 50%; }
.legend-dot.ambulance { background: var(--danger); }
.legend-dot.hospital { background: var(--success); }
.legend-dot.station  { background: var(--brand); }
[data-theme="dark"] .leaflet-tile { filter: brightness(0.8) contrast(1.05) hue-rotate(180deg) invert(0.95); }

/* =========================================================
   Contact section
   ========================================================= */
.contact-grid { display: grid; gap: 1.5rem; grid-template-columns: 1fr; }
@media (min-width: 900px) { .contact-grid { grid-template-columns: 1.1fr 0.9fr; } }
.contact-info { display: flex; flex-direction: column; gap: 1rem; }
.contact-item {
  display: flex; gap: 1rem; align-items: flex-start;
  padding: 1rem; border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}
.contact-item .icon {
  flex-shrink: 0;
  width: 40px; height: 40px;
  background: var(--brand-soft); color: var(--brand-text);
  border-radius: 10px;
  display: grid; place-items: center;
}
.contact-item .label { font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.contact-item .value { font-weight: 500; margin-top: 0.15rem; }
.contact-form .field { margin-bottom: 0.85rem; }
.contact-form .field label {
  display: block; font-size: 0.85rem; font-weight: 500;
  margin-bottom: 0.35rem;
}
.contact-form .input, .contact-form textarea {
  width: 100%;
  padding: 0.7rem 0.9rem;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  color: var(--text);
  font-family: inherit;
  resize: vertical;
}
.contact-form textarea { min-height: 110px; }
.contact-form .input:focus, .contact-form textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

/* =========================================================
   Empty / no-results state
   ========================================================= */
.no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.no-results .icon {
  width: 56px; height: 56px;
  background: var(--brand-soft); color: var(--brand);
  border-radius: 50%;
  margin: 0 auto 0.75rem;
  display: grid; place-items: center;
}

/* =========================================================
   Footer
   ========================================================= */
.footer {
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
  padding: 2rem 0 1.25rem;
  margin-top: 2rem;
  transition: background var(--transition), border-color var(--transition);
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 2rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 700px) { .footer-grid { grid-template-columns: 1fr; } }
.footer h4 {
  font-size: 0.85rem;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); margin: 0 0 0.65rem 0;
  font-weight: 700;
}
.footer ul { list-style: none; padding: 0; margin: 0; }
.footer ul li { margin-bottom: 0.4rem; }
.footer ul a { color: var(--text-muted); font-size: 0.9rem; }
.footer ul a:hover { color: var(--text); }
.footer-tagline { color: var(--text-muted); font-size: 0.92rem; line-height: 1.5; margin-top: 0.6rem; }
.footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* =========================================================
   Utilities
   ========================================================= */
.hidden { display: none !important; }
.flex-row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.gap-2 { gap: 0.5rem; }
.muted { color: var(--text-muted); }

@media (max-width: 640px) {
  section { padding: 2.5rem 0; }
  .hero { padding: 2.5rem 0 2rem; }
  .nav-inner { padding: 0.75rem 1rem; }
  .search-wrap { display: none; }
  .nav-actions .search-wrap.mobile { display: flex; width: 100%; }
}
