/* High Functioning — dark topo + sunset gold. Follows the phone's light/dark setting. */
:root {
  --bg: #0E1311; --surface: #151C19; --surface-2: #19221E; --line: #2A3631; --line-2: #222C27;
  --text: #E8ECE9; --muted: #A9B3AC; --faint: #6F7C75; --topo: #1F2A25;
  --gold: #E2A23B; --gold-2: #F2BE63; --on-gold: #17120A; --gold-soft: rgba(226,162,59,.14);
  --warn-bg: #2A2213; --warn-line: #5C4520; --warn-text: #F0DDB8;
  --danger: #E5735C; --ok: #6FC48A;
  --scrim: rgba(5,8,7,.62);
  --shadow: 0 10px 30px rgba(0,0,0,.45);
  --radius: 14px;
  --head: "Barlow Condensed", "Arial Narrow", sans-serif;
  --body: "Barlow", system-ui, -apple-system, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #F3F0E8; --surface: #FFFFFF; --surface-2: #F7F4EC; --line: #DCD5C6; --line-2: #E6E0D3;
    --text: #1B211E; --muted: #56605A; --faint: #8A928C; --topo: #E3DDCF;
    --gold: #C98A22; --gold-2: #A86F12; --on-gold: #17120A; --gold-soft: rgba(201,138,34,.14);
    --warn-bg: #FBF0DC; --warn-line: #E6C892; --warn-text: #5E4413;
    --scrim: rgba(20,20,15,.45); --shadow: 0 10px 30px rgba(40,30,10,.18);
    color-scheme: light;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--body); font-size: 16px; }
body { overscroll-behavior: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--gold); }
img { max-width: 100%; display: block; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

#app { position: fixed; inset: 0; display: flex; flex-direction: column; overflow: hidden; }
.topo-bg { position: absolute; inset: 0; pointer-events: none; color: var(--topo); }

/* Header */
.bar { position: relative; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(10px + var(--safe-top)) 16px 10px; }
.bar.float { position: absolute; left: 0; right: 0; top: 0; }
.wordmark { display: flex; align-items: center; gap: 8px; font-family: var(--head); font-weight: 700; font-size: 20px; letter-spacing: 1.5px; text-transform: uppercase; white-space: nowrap; }
.icon-btn { width: 44px; height: 44px; flex: none; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center; position: relative; color: var(--text); padding: 0; }
.icon-btn.ghost { border-color: transparent; background: transparent; }
.icon-btn.glass { background: color-mix(in srgb, var(--bg) 75%, transparent); border-color: transparent; backdrop-filter: blur(6px); }
.icon-btn .dot { position: absolute; top: 9px; right: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }
svg.i { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* Type */
.h1 { font-family: var(--head); font-weight: 700; font-size: 34px; line-height: 1; margin: 0; text-transform: uppercase; }
.h2 { font-family: var(--head); font-weight: 700; font-size: 24px; line-height: 1.05; margin: 0; text-transform: uppercase; }
.eyebrow { font-family: var(--head); font-weight: 600; font-size: 13px; letter-spacing: 1.5px; color: var(--muted); text-transform: uppercase; }
.eyebrow.gold { color: var(--gold); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-family: var(--head); font-weight: 700; }

/* Buttons & chips */
.btn { height: 50px; border-radius: 14px; border: 1px solid var(--line); background: transparent; color: var(--text);
  font-weight: 600; font-size: 15px; padding: 0 18px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn.primary { background: var(--gold); color: var(--on-gold); border-color: var(--gold); }
.btn.gold-line { border-color: var(--gold); color: var(--gold); }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); font-size: 14px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.chip[aria-pressed="true"] { border-color: var(--gold); background: var(--gold-soft); color: var(--gold); font-weight: 600; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.seg .chip { border-radius: 12px; justify-content: center; min-height: 44px; }
.toggle { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.toggle button { border: 0; border-radius: 999px; padding: 8px 14px; background: transparent; color: var(--muted); font-weight: 600; font-size: 13px; }
.toggle button[aria-pressed="true"] { background: var(--gold); color: var(--on-gold); }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; color: var(--muted); }
.input, select.input, textarea.input { width: 100%; min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  padding: 12px 14px; font-size: 16px; color: var(--text); }
textarea.input { min-height: 96px; resize: vertical; }
.input:focus { border-color: var(--gold); outline: none; }
.check { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; line-height: 1.4; }
.check input { width: 22px; height: 22px; accent-color: var(--gold); flex: none; margin-top: 1px; }
.err { color: var(--danger); font-size: 14px; min-height: 1em; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { background: color-mix(in srgb, var(--surface) 92%, transparent); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.stat .num { font-size: 26px; line-height: 1; }
.stat .lbl { font-size: 12px; color: var(--muted); margin-top: 4px; }
.alert { display: flex; gap: 10px; align-items: flex-start; background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-text);
  border-radius: 12px; padding: 10px 12px; font-size: 14px; line-height: 1.35; }

/* Screens */
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; overflow: hidden; background: var(--bg); }
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: calc(24px + var(--safe-bottom)); }
.pad { padding: 0 16px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 12px; }
.spread { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }

/* Map home */
#map { position: absolute; inset: 0; }
.map-top { position: absolute; z-index: 4; left: 0; right: 0; top: 0; pointer-events: none; }
.map-top > * { pointer-events: auto; }
.map-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 0 16px; }
.map-toggle { position: absolute; right: 16px; top: calc(128px + var(--safe-top)); z-index: 4; }
.locate { position: absolute; left: 16px; z-index: 4; }
.pin { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; border: 0; background: none; padding: 0; cursor: pointer; }
.pin svg { overflow: visible; filter: drop-shadow(0 2px 4px rgba(0,0,0,.4)); }
.pin.soon { width: 34px; height: 34px; }
.pin-label { position: absolute; top: 40px; left: 50%; transform: translateX(-50%); white-space: nowrap; background: var(--gold); color: var(--on-gold);
  font-size: 12px; font-weight: 600; padding: 2px 7px; border-radius: 6px; pointer-events: none; }
.maplibregl-ctrl-attrib { font-size: 10px; background: color-mix(in srgb, var(--bg) 70%, transparent) !important; color: var(--muted); }
.maplibregl-ctrl-attrib a { color: var(--muted); }

/* Bottom sheet */
.sheet-wrap { position: absolute; inset: 0; z-index: 30; display: flex; flex-direction: column; justify-content: flex-end; }
.sheet-wrap .scrim { position: absolute; inset: 0; background: var(--scrim); animation: fade .2s ease; }
.sheet { position: relative; background: var(--surface); border-top-left-radius: 24px; border-top-right-radius: 24px; border: 1px solid var(--line);
  max-height: 92%; display: flex; flex-direction: column; animation: up .25s cubic-bezier(.2,.8,.2,1); box-shadow: var(--shadow); }
.sheet .grab { width: 40px; height: 4px; background: var(--line); border-radius: 2px; margin: 10px auto 6px; flex: none; }
.sheet .scroll { padding: 4px 16px calc(20px + var(--safe-bottom)); }
.dock { position: absolute; z-index: 4; left: 12px; right: 12px; bottom: calc(14px + var(--safe-bottom)); background: var(--surface);
  border: 1px solid var(--line); border-radius: 22px; padding: 10px 16px 16px; box-shadow: var(--shadow); }
.dock .grab { width: 40px; height: 4px; background: var(--line); border-radius: 2px; margin: 0 auto 12px; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } }

/* Menu */
.drawer-wrap { position: absolute; inset: 0; z-index: 40; }
.drawer-wrap .scrim { position: absolute; inset: 0; background: var(--scrim); animation: fade .2s; }
.drawer { position: absolute; top: 0; left: 0; bottom: 0; width: min(312px, 86vw); background: var(--surface); border-right: 1px solid var(--line);
  padding: calc(14px + var(--safe-top)) 0 calc(16px + var(--safe-bottom)); display: flex; flex-direction: column; animation: slide .22s ease; overflow-y: auto; }
@keyframes slide { from { transform: translateX(-30px); opacity: 0; } }
.nav-item { display: flex; align-items: center; gap: 14px; padding: 12px; margin: 0 8px; border-radius: 12px; color: var(--text);
  text-decoration: none; font-weight: 500; font-size: 16px; border: 0; background: none; width: calc(100% - 16px); text-align: left; }
.nav-item[aria-current="page"] { background: var(--gold-soft); color: var(--gold); font-weight: 600; }
.nav-item .badge { margin-left: auto; background: var(--gold); color: var(--on-gold); font-size: 12px; font-weight: 600; border-radius: 999px; padding: 2px 8px; }
.nav-item .soon { margin-left: auto; font-size: 11px; color: var(--faint); letter-spacing: 1px; text-transform: uppercase; }
.nav-sub { color: var(--muted); font-size: 15px; padding: 10px 12px; }

/* Park page */
.hero { position: relative; height: 230px; flex: none; background: #1B2621; overflow: hidden; }
.hero img { width: 100%; height: 100%; object-fit: cover; }
.hero::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 130px; background: linear-gradient(to bottom, transparent, var(--bg)); }
.hero .bar { position: absolute; left: 0; right: 0; top: 0; z-index: 2; }
.hero-title { position: absolute; z-index: 2; left: 16px; right: 16px; bottom: 12px; display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.weather { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.weather div { background: var(--surface); border-radius: 10px; padding: 7px 0; text-align: center; }
.weather .d { font-size: 12px; color: var(--muted); }
.weather .t { font-family: var(--head); font-weight: 700; font-size: 17px; }
.search { display: flex; gap: 8px; }
.search label { flex: 1; display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; height: 44px; }
.search input { flex: 1; min-width: 0; background: transparent; border: 0; outline: none; font-size: 16px; }
.trail { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.trail .info { flex: 1; min-width: 0; border: 0; background: none; text-align: left; padding: 4px 0; color: var(--text); }
.trail .name { font-weight: 600; font-size: 15px; }
.trail .meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.tick { width: 44px; height: 44px; flex: none; border-radius: 50%; border: 2px solid var(--line); background: transparent; display: flex; align-items: center; justify-content: center; padding: 0; }
.tick.done { background: var(--gold); border-color: var(--gold); color: var(--on-gold); }
.tick.done svg.i { stroke-width: 2.8; }
.star { width: 44px; height: 44px; border: 0; background: none; color: var(--faint); display: flex; align-items: center; justify-content: center; padding: 0; }
.star[aria-pressed="true"] { color: var(--gold); }
.star[aria-pressed="true"] svg { fill: var(--gold); }

/* Celebration */
.celebrate { position: absolute; inset: 0; z-index: 60; background: #0A0E0D; color: #E8ECE9; display: flex; flex-direction: column; align-items: center; overflow: hidden; }
.celebrate canvas { position: absolute; inset: 0; pointer-events: none; }
.celebrate .medal { margin-top: calc(110px + var(--safe-top)); animation: pop .6s cubic-bezier(.2,1.4,.4,1); }
@keyframes pop { from { transform: scale(.4) rotate(-20deg); opacity: 0; } to { transform: none; opacity: 1; } }
.celebrate .big { font-family: var(--head); font-weight: 700; font-size: 64px; line-height: .95; margin-top: 6px; }
.badge-pop { animation: up .4s .5s both; display: flex; align-items: center; gap: 12px; background: #19160E; border: 1px solid #5C4520; border-radius: 16px; padding: 12px 14px; }

/* Lists */
.list-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line-2); }
.thumb { width: 52px; height: 52px; border-radius: 10px; background: var(--surface-2); flex: none; object-fit: cover; display: flex; align-items: center; justify-content: center; color: var(--faint); }
.avatar { border-radius: 50%; background: var(--line); border: 2px solid var(--gold); display: flex; align-items: center; justify-content: center;
  font-family: var(--head); font-weight: 700; color: var(--gold); overflow: hidden; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.medals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.medal-cell { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; font-size: 12px; color: var(--muted); }

/* Toast */
.toast { position: absolute; z-index: 90; left: 16px; right: 16px; bottom: calc(20px + var(--safe-bottom)); background: var(--text); color: var(--bg);
  border-radius: 14px; padding: 14px 16px; font-weight: 500; font-size: 15px; box-shadow: var(--shadow); animation: up .25s; }
.offline-pill { position: absolute; z-index: 50; top: calc(8px + var(--safe-top)); left: 50%; transform: translateX(-50%); background: var(--warn-bg);
  color: var(--warn-text); border: 1px solid var(--warn-line); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; white-space: nowrap; }

/* Auth / onboarding */
.auth { justify-content: center; }
.auth .inner { width: 100%; max-width: 420px; margin: 0 auto; padding: calc(30px + var(--safe-top)) 20px calc(30px + var(--safe-bottom)); }
.divider { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--gold); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.center { display: flex; align-items: center; justify-content: center; }

@media (min-width: 700px) {
  .screen > .scroll, .screen .narrow { max-width: 640px; margin: 0 auto; width: 100%; }
  .dock { left: 50%; right: auto; width: 440px; transform: translateX(-50%); }
  .sheet { max-width: 560px; width: 100%; margin: 0 auto; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Printable park passport (Stats & recap) */
@media print {
  html, body, #app, .screen, .scroll { height: auto !important; overflow: visible !important; position: static !important; background: #fff !important; }
  body * { visibility: hidden; }
  #passport, #passport * { visibility: visible; color: #111 !important; }
  #passport { position: absolute !important; left: 0; top: 0; width: 100%; border: 0 !important; background: #fff !important; }
  #passport > div > div[style*="solid"] { border-color: #b8860b !important; }
  #st-print { display: none !important; }
}
