/* SafeZone demo — mobile-first, touch-friendly, safe-area aware */

:root {
  --bg: #0f1c24;
  --bg-2: #15262f;
  --panel: #17303c;
  --panel-2: #1c3a48;
  --line: rgba(244, 241, 234, 0.14);
  --text: #f4f1ea;
  --muted: #c8c2b6;
  --accent: #2a9d8f;
  --accent-2: #1f7a70;
  --warn: #e9c46a;
  --warn-bg: #3d3414;
  --alert: #f4a261;
  --alert-bg: #4a2a16;
  --alert-text: #ffefdf;
  --child: #4da3ff;
  --sample: #e9a825;
  --danger: #e76f51;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --radius: 14px;
  --tap: 48px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
}

a {
  color: #7ed6cb;
  text-decoration: underline;
  text-underline-offset: 2px;
}
a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.page {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  min-height: 100svh;
  padding-left: var(--safe-l);
  padding-right: var(--safe-r);
}

.page-map {
  height: 100dvh;
  height: 100svh;
  overflow: hidden;
}

/* Sample data banner — always visible, never hover-only */
.sample-banner {
  flex: 0 0 auto;
  background: var(--warn);
  color: #1a1404;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-align: center;
  padding: 0.55rem 0.75rem;
  padding-top: calc(0.55rem + var(--safe-t));
  font-size: 0.92rem;
  z-index: 20;
}

.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.45rem 0.85rem;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  min-width: 0;
}
.brand h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 750;
}
.brand .tag {
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.nav {
  display: flex;
  gap: 0.35rem;
}
.nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.35rem 0.75rem;
  color: var(--text);
  text-decoration: none;
  border-radius: 999px;
  background: transparent;
  font-weight: 600;
}
.nav a[aria-current="page"],
.nav a:active {
  background: var(--panel);
}
.nav a:focus-visible {
  outline: 3px solid var(--accent);
}

.map-wrap {
  flex: 1 1 auto;
  min-height: 32vh;
  position: relative;
  background: #0a1419;
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Leaflet tweaks for fat fingers */
.leaflet-control-zoom a {
  width: 44px !important;
  height: 44px !important;
  line-height: 44px !important;
  font-size: 20px !important;
}
.leaflet-touch .leaflet-control-zoom a {
  width: 44px !important;
  height: 44px !important;
}

.marker-child, .marker-sample {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 800;
  color: #0f1c24;
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.45);
  user-select: none;
}
.marker-child {
  background: var(--child);
  font-size: 11px;
}
.marker-sample {
  background: var(--sample);
  font-size: 12px;
}

.alert-banner {
  display: none;
  position: absolute;
  left: 8px;
  right: 8px;
  top: 8px;
  bottom: auto;
  z-index: 12;
  background: var(--alert-bg);
  color: var(--alert-text);
  border: 2px solid var(--alert);
  border-radius: var(--radius);
  padding: 0.7rem 0.85rem;
  box-shadow: var(--shadow);
  max-height: calc(100% - 16px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.alert-banner.is-on {
  display: flex;
  flex-direction: column;
}
.alert-banner .alert-actions {
  flex: 0 0 auto;
  margin-top: 0.55rem;
}
.alert-banner h2 {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
}
.alert-banner p {
  margin: 0;
  font-size: 0.95rem;
}
.alert-banner .alert-actions {
  margin-top: 0.6rem;
}

.panel {
  flex: 0 0 auto;
  max-height: 48%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--panel);
  border-top: 1px solid var(--line);
  padding: 0.65rem 1rem 0.5rem;
  padding-bottom: calc(0.5rem + var(--safe-b));
}

.panel h2 {
  margin: 0 0 0.35rem;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
}

.control-block + .control-block {
  margin-top: 0.7rem;
}

.slider-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
}
.slider-row label {
  font-weight: 650;
}
#radius-value {
  font-variant-numeric: tabular-nums;
  font-weight: 750;
  color: var(--warn);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 44px;
  background: transparent;
  margin: 0;
}
input[type="range"]:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 10px;
  background: var(--panel-2);
  border-radius: 999px;
  border: 1px solid var(--line);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 32px;
  height: 32px;
  margin-top: -11px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid #fff;
  box-shadow: 0 1px 6px rgba(0,0,0,0.4);
}
input[type="range"]::-moz-range-track {
  height: 10px;
  background: var(--panel-2);
  border-radius: 999px;
  border: 1px solid var(--line);
}
input[type="range"]::-moz-range-thumb {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid #fff;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

button, .btn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  min-height: var(--tap);
  padding: 0.6rem 0.9rem;
  font: inherit;
  font-weight: 700;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  cursor: pointer;
  touch-action: manipulation;
}
button.primary {
  background: var(--accent-2);
  border-color: var(--accent);
}
button.primary[aria-pressed="true"] {
  background: var(--accent);
  color: #0b1614;
}
button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
button:focus-visible, .btn:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-height: var(--tap);
  padding: 0.15rem 0;
}
.toggle input {
  width: 24px;
  height: 24px;
  accent-color: var(--accent);
  flex: 0 0 auto;
}
.toggle span { flex: 1 1 auto; }

.status {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}
.status.ok { color: #8ee0d4; }
.status.warn { color: var(--alert); }

.footer {
  flex: 0 0 auto;
  padding: 0.65rem 1rem;
  padding-bottom: calc(0.65rem + var(--safe-b));
  background: var(--bg);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
}
.footer p { margin: 0 0 0.4rem; }
.footer p:last-child { margin: 0; }

/* About page (scrollable document) */
.page-about {
  background: var(--bg);
}
.about-wrap {
  max-width: 42rem;
  margin: 0 auto;
  padding: 1rem 1.1rem 2.5rem;
  padding-bottom: calc(2.5rem + var(--safe-b));
}
.about-wrap h1 { font-size: 1.6rem; margin: 0.4rem 0 0.6rem; }
.about-wrap h2 { font-size: 1.15rem; margin: 1.4rem 0 0.45rem; }
.about-wrap p, .about-wrap li { color: #ebe6db; }
.about-wrap ul { padding-left: 1.15rem; }
.callout {
  background: var(--panel);
  border-left: 4px solid var(--accent);
  border-radius: 0 12px 12px 0;
  padding: 0.85rem 1rem;
  margin: 1rem 0;
}
.callout.emergency {
  border-left-color: var(--danger);
  background: #3a1f1a;
}

@media (min-width: 800px) {
  .page-map {
    display: grid;
    grid-template-columns: minmax(320px, 400px) 1fr;
    grid-template-rows: auto auto 1fr auto auto;
    height: 100dvh;
  }
  .sample-banner { grid-column: 1 / -1; }
  .topbar { grid-column: 1 / -1; }
  .map-wrap {
    grid-column: 2;
    grid-row: 3 / 5;
    min-height: 0;
  }
  .panel {
    grid-column: 1;
    grid-row: 3;
    max-height: none;
    overflow: auto;
  }
  .page-map .footer {
    grid-column: 1;
    grid-row: 4;
  }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}

.footer details summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--text);
  min-height: 44px;
  display: flex;
  align-items: center;
  list-style: none;
}
.footer details summary::-webkit-details-marker { display: none; }
.footer details summary::before {
  content: "▸";
  display: inline-block;
  width: 1.1em;
  color: var(--accent);
}
.footer details[open] summary::before { content: "▾"; }
.footer details[open] summary { margin-bottom: 0.4rem; }

#use-location[hidden] {
  display: none !important;
}
