:root {
  --ink: #0b1220;
  --muted: rgba(11, 18, 32, 0.62);
  --accent: #e11d48;
  --hud-bg: rgba(255, 255, 255, 0.72);
  --hud-border: rgba(11, 18, 32, 0.12);
  --shadow: 0 18px 50px rgba(11, 18, 32, 0.18);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  color: var(--ink);
  background: #f8fafc;
  overflow: hidden;
}

#map { height: 100%; width: 100%; }
#map::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 600px at 18% 14%, rgba(225, 29, 72, 0.08), transparent 60%),
    radial-gradient(900px 700px at 84% 78%, rgba(2, 132, 199, 0.06), transparent 62%),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0));
  mix-blend-mode: multiply;
}

#topbar {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top));
  left: calc(14px + env(safe-area-inset-left));
  right: calc(14px + env(safe-area-inset-right));
  z-index: 1000;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 12px;
  pointer-events: none;
}

#brand,
#hud {
  pointer-events: auto;
}

#brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 16px;
  background: var(--hud-bg);
  border: 1px solid var(--hud-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  user-select: none;
  animation: hudIn 520ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.brand-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.brand-icon {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  display: block;
}

#hud {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 16px;
  background: var(--hud-bg);
  border: 1px solid var(--hud-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  user-select: none;
  animation: hudIn 520ms cubic-bezier(0.2, 0.8, 0.2, 1) 80ms both;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  position: relative;
  --toggle-on: var(--accent);
  --toggle-on-border: rgba(225, 29, 72, 0.22);
}

.toggle.toggle--ter {
  --toggle-on: rgba(11, 18, 32, 0.62);
  --toggle-on-border: rgba(11, 18, 32, 0.18);
}

.toggle.toggle--parks {
  --toggle-on: rgba(22, 163, 74, 0.78);
  --toggle-on-border: rgba(22, 163, 74, 0.22);
}

.toggle.toggle--unesco {
  --toggle-on: rgba(245, 158, 11, 0.88);
  --toggle-on-border: rgba(245, 158, 11, 0.26);
}

.toggle.toggle--relief {
  --toggle-on: rgba(71, 85, 105, 0.78);
  --toggle-on-border: rgba(71, 85, 105, 0.22);
}

.toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-ui {
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: rgba(11, 18, 32, 0.12);
  border: 1px solid rgba(11, 18, 32, 0.10);
  position: relative;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.toggle-ui::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 14px 24px rgba(11, 18, 32, 0.18), 0 2px 6px rgba(11, 18, 32, 0.14);
  transition: transform 180ms cubic-bezier(0.2, 0.9, 0.2, 1);
}

.toggle input:checked + .toggle-ui {
  background: var(--toggle-on);
  border-color: var(--toggle-on-border);
}

.toggle input:checked + .toggle-ui::after {
  transform: translateX(18px);
}

.toggle input:focus-visible + .toggle-ui {
  outline: 3px solid rgba(225, 29, 72, 0.28);
  outline-offset: 3px;
}

.toggle-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.station-dot {
  display: block;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--c);
  border: 2px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 22px rgba(11, 18, 32, 0.18), 0 2px 6px rgba(11, 18, 32, 0.14);
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.station-icon.is-focused .station-dot {
  transform: scale(1.25);
  box-shadow: 0 16px 38px rgba(225, 29, 72, 0.25), 0 8px 22px rgba(11, 18, 32, 0.18);
}

.net-line,
.hl-core {
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Leaflet controls */
.leaflet-control-zoom {
  border: 0;
  box-shadow: none;
}

.leaflet-control-zoom a {
  width: 38px;
  height: 38px;
  line-height: 36px;
  border-radius: 14px;
  border: 1px solid rgba(11, 18, 32, 0.12);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: rgba(11, 18, 32, 0.92);
  box-shadow: 0 18px 40px rgba(11, 18, 32, 0.12);
  transition: background 160ms ease, transform 160ms ease;
}

.leaflet-control-zoom a:hover {
  background: rgba(255, 255, 255, 0.88);
  transform: translateY(-1px);
}

.leaflet-control-attribution {
  margin: 12px !important;
  padding: 6px 10px !important;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.62) !important;
  border: 1px solid rgba(11, 18, 32, 0.10) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font: 11px/1.25 "Space Grotesk", ui-sans-serif, system-ui, sans-serif !important;
  color: rgba(11, 18, 32, 0.70) !important;
}

.leaflet-popup-content-wrapper {
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(11, 18, 32, 0.10);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 22px 60px rgba(11, 18, 32, 0.22);
}

.leaflet-popup-content {
  margin: 12px 14px;
  font: 14px/1.25 "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0.01em;
}

.leaflet-popup.station-popup .leaflet-popup-content {
  text-align: center;
}

.leaflet-popup.station-popup .leaflet-popup-content strong {
  display: block;
}

.leaflet-popup-tip {
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 22px 60px rgba(11, 18, 32, 0.16);
}

.leaflet-popup-close-button {
  color: rgba(11, 18, 32, 0.55) !important;
  font: 16px/14px ui-sans-serif, system-ui, sans-serif !important;
  padding: 10px 10px 0 0 !important;
}

.leaflet-tooltip.park-tooltip {
  border-radius: 12px;
  padding: 6px 10px;
  border: 1px solid rgba(11, 18, 32, 0.10);
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 18px 46px rgba(11, 18, 32, 0.18);
  font: 12px/1.2 "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0.01em;
  color: rgba(11, 18, 32, 0.90);
}

.leaflet-tooltip.unesco-tooltip {
  border-radius: 12px;
  padding: 6px 10px;
  border: 1px solid rgba(245, 158, 11, 0.24);
  background: rgba(255, 255, 255, 0.90);
  box-shadow: 0 18px 46px rgba(11, 18, 32, 0.18);
  font: 12px/1.2 "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0.01em;
  color: rgba(11, 18, 32, 0.92);
}

.unesco-site {
  filter: drop-shadow(0 10px 16px rgba(11, 18, 32, 0.18));
  background: transparent;
  border: none;
}

.unesco-site .unesco-star {
  display: block;
  width: 100%;
  height: 100%;
  transform-origin: 50% 55%;
  transition: transform 140ms cubic-bezier(0.2, 0.9, 0.2, 1);
}

.unesco-site.is-hover .unesco-star {
  transform: scale(1.22);
}

.leaflet-popup-content .unesco-meta {
  margin-top: 6px;
  font-size: 12px;
  color: rgba(11, 18, 32, 0.70);
}

.leaflet-popup-content .unesco-links {
  margin-top: 6px;
  font-size: 12px;
}

.leaflet-popup-content .unesco-links a {
  color: rgba(11, 18, 32, 0.82);
  text-decoration: underline;
  text-decoration-color: rgba(245, 158, 11, 0.6);
  text-underline-offset: 2px;
}

/* Don't show focus rectangles when clicking parks polygons (they're hover-only). */
.park-zone,
.park-zone:focus,
.park-zone:focus-visible {
  outline: none;
}

/* Relief overlay: use blend mode so it reads as shading, not as another map style. */
.leaflet-layer.relief-tiles {
  mix-blend-mode: multiply;
  filter: contrast(1.05) saturate(0.92);
}

@keyframes hudIn {
  from { opacity: 0; transform: translateY(-6px); filter: blur(4px); }
  to { opacity: 1; transform: translateY(0); filter: blur(0); }
}

@media (max-width: 640px) {
  #topbar {
    top: calc(12px + env(safe-area-inset-top));
    left: calc(12px + env(safe-area-inset-left));
    right: calc(12px + env(safe-area-inset-right));
    flex-direction: column;
    align-items: stretch;
  }

  #hud {
    margin-left: 0;
    justify-content: flex-start;
  }
}
