/* =============================================================================
   UMNDENI MAP — STYLES
   Palette: Waterberg bushveld. Red-soil ochre, olive khaki, bone, ink.
   The map is the hero; chrome floats quietly and stays legible in sunlight.
   ============================================================================= */

:root {
  --bone:      #F2EBDD;
  --bone-2:    #E7DEC9;
  --ink:       #241C14;
  --ink-soft:  #4A3D2E;
  --ochre:     #C0692B;
  --ochre-dk:  #A5551F;
  --rust:      #B4472E;
  --khaki:     #6B7150;
  --water:     #3A6C7A;
  --line:      rgba(36,28,20,0.12);
  --shadow:    0 6px 24px rgba(36,28,20,0.28);
  --shadow-sm: 0 2px 8px rgba(36,28,20,0.22);
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* Components below set their own `display` (flex/block) unconditionally, which
   otherwise beats the UA [hidden] rule on specificity ties by source order —
   without this, toggling .hidden = true/false in app.js has no visual effect. */
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: var(--ink);
  overscroll-behavior: none;
}

#map {
  position: fixed; inset: 0;
  background: #2b2b28;
}

/* ---- Leaflet tweaks ---- */
.leaflet-container { background: #2b2b28; font-family: var(--font); }
.leaflet-control-attribution {
  background: rgba(242,235,221,0.75) !important;
  font-size: 10px !important;
  padding: 1px 6px !important;
}
.leaflet-bar a { color: var(--ink) !important; }

/* =============================================================================
   TOP BAR
   ============================================================================= */
.topbar {
  position: fixed; z-index: 500;
  top: calc(var(--safe-top) + 10px); left: 12px; right: 12px;
  display: flex; align-items: center; justify-content: space-between;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }

.brand {
  display: flex; align-items: center; gap: 7px;
  background: var(--ink);
  color: var(--bone);
  padding: 7px 13px 7px 11px;
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}
.brand__mark { color: var(--ochre); font-size: 15px; line-height: 1; }
.brand__name {
  font-weight: 600; letter-spacing: 0.06em;
  font-size: 14px; text-transform: uppercase;
}

.chip {
  border: none; cursor: pointer;
  display: flex; align-items: center; gap: 7px;
  background: var(--bone);
  color: var(--ink);
  padding: 7px 13px;
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  font-size: 12.5px; font-weight: 600;
  font-family: var(--font);
}
.status-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #b9b0a0; flex: none;
}
.status-dot.is-ready   { background: var(--khaki); }
.status-dot.is-partial { background: var(--ochre); }
.status-dot.is-none    { background: var(--rust); }

/* =============================================================================
   RIGHT RAIL
   ============================================================================= */
.rail {
  position: fixed; z-index: 500;
  right: 12px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 9px;
}
.rail__btn {
  width: 46px; height: 46px; border: none; cursor: pointer;
  background: var(--bone); color: var(--ink);
  border-radius: 14px; box-shadow: var(--shadow-sm);
  font-size: 19px; display: grid; place-items: center;
}
.rail__btn:active { transform: scale(0.94); }
.rail__btn.is-on { background: var(--ochre); color: var(--bone); }
.rail__glyph { line-height: 1; }

/* =============================================================================
   BOTTOM DOCK
   ============================================================================= */
.dock {
  position: fixed; z-index: 500;
  left: 12px; right: 12px;
  bottom: calc(var(--safe-bottom) + 12px);
  display: flex; gap: 8px; align-items: stretch;
}
.dock__btn {
  border: none; cursor: pointer;
  background: var(--bone); color: var(--ink);
  border-radius: 14px; box-shadow: var(--shadow-sm);
  font-family: var(--font); font-weight: 600; font-size: 13px;
  padding: 0 14px; height: 48px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  white-space: nowrap;
}
.dock__btn:active { transform: scale(0.97); }
.dock__btn--wide { flex: 1 1 auto; }
.dock__btn--accent { background: var(--ochre); color: var(--bone); }
.dock__btn--locate { background: var(--ink); color: var(--bone); width: 48px; padding: 0; font-size: 20px; }
.dock__btn.is-recording { background: var(--rust); color: var(--bone); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.7} }

/* readout strip */
.readout {
  position: fixed; z-index: 500;
  left: 12px; right: 12px;
  bottom: calc(var(--safe-bottom) + 70px);
  background: var(--ink); color: var(--bone);
  border-radius: 12px; box-shadow: var(--shadow-sm);
  padding: 9px 14px; font-size: 12.5px; font-weight: 600;
  display: flex; gap: 16px; justify-content: center; flex-wrap: wrap;
}
.readout b { color: var(--ochre); font-variant-numeric: tabular-nums; }

/* =============================================================================
   BOTTOM SHEET + SCRIM
   ============================================================================= */
.scrim {
  position: fixed; inset: 0; z-index: 600;
  background: rgba(36,28,20,0.45);
  backdrop-filter: blur(1px);
}
.sheet {
  position: fixed; z-index: 700;
  left: 0; right: 0; bottom: 0;
  max-height: 82vh;
  background: var(--bone);
  border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow);
  padding: 8px 0 calc(var(--safe-bottom) + 16px);
  display: flex; flex-direction: column;
  animation: sheetUp 0.24s cubic-bezier(0.2,0.8,0.2,1);
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet__grab {
  width: 40px; height: 4px; border-radius: 999px;
  background: var(--bone-2); margin: 4px auto 8px;
}
.sheet__body { overflow-y: auto; padding: 0 18px; -webkit-overflow-scrolling: touch; }

/* sheet content helpers */
.sheet h2 { margin: 4px 0 2px; font-size: 19px; }
.sheet h3 { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); }
.sheet p  { margin: 6px 0; font-size: 14px; line-height: 1.45; color: var(--ink-soft); }
.sheet .muted { color: var(--ink-soft); font-size: 12.5px; }

.row { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: none; }
.row__icon { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-size: 17px; flex: none; background: var(--bone-2); }
.row__main { flex: 1 1 auto; min-width: 0; }
.row__title { font-weight: 600; font-size: 14.5px; }
.row__sub { font-size: 12px; color: var(--ink-soft); }
.row__meta { font-size: 12px; color: var(--ink-soft); font-variant-numeric: tabular-nums; white-space: nowrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: none; cursor: pointer; font-family: var(--font);
  font-weight: 600; font-size: 14px;
  padding: 12px 16px; border-radius: 12px; width: 100%;
  background: var(--ochre); color: var(--bone); margin-top: 12px;
}
.btn:active { transform: scale(0.98); }
.btn--ghost { background: var(--bone-2); color: var(--ink); }
.btn--rust { background: var(--rust); color: var(--bone); }
.btn:disabled { opacity: 0.5; }

.field { margin-top: 12px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-soft); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.04em; }
.field input, .field textarea, .field select {
  width: 100%; font-family: var(--font); font-size: 15px;
  padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink);
}
.field textarea { min-height: 64px; resize: vertical; }

/* toggle list (layers / filters) */
.toggle { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); }
.toggle:last-child { border-bottom: none; }
.toggle__label { display: flex; align-items: center; gap: 10px; font-size: 14.5px; font-weight: 500; }
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: var(--bone-2); border-radius: 999px; transition: 0.15s; }
.switch .track::before { content: ""; position: absolute; height: 20px; width: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: 0.15s; box-shadow: var(--shadow-sm); }
.switch input:checked + .track { background: var(--khaki); }
.switch input:checked + .track::before { transform: translateX(18px); }

/* opacity slider */
.slider { width: 100%; margin-top: 10px; accent-color: var(--ochre); }

/* progress */
.progress { height: 10px; background: var(--bone-2); border-radius: 999px; overflow: hidden; margin: 10px 0 4px; }
.progress__fill { height: 100%; width: 0%; background: var(--ochre); transition: width 0.2s; }

/* photo thumbs */
.thumb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px,1fr)); gap: 8px; margin-top: 10px; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--bone-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb__tag { position: absolute; left: 0; right: 0; bottom: 0; font-size: 10px; padding: 3px 5px; background: rgba(36,28,20,0.7); color: var(--bone); }

/* =============================================================================
   MAP MARKERS  (custom divIcons)
   ============================================================================= */
.poi-pin {
  width: 30px; height: 30px; border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: var(--shadow-sm);
  display: grid; place-items: center;
  border: 2px solid rgba(255,255,255,0.85);
}
.poi-pin span { transform: rotate(45deg); font-size: 14px; line-height: 1; }

.me-dot {
  width: 18px; height: 18px; border-radius: 50%;
  background: #2E7BD6; border: 3px solid #fff;
  box-shadow: 0 0 0 2px rgba(46,123,214,0.4), var(--shadow-sm);
}
.me-heading {
  width: 0; height: 0;
  border-left: 7px solid transparent; border-right: 7px solid transparent;
  border-bottom: 12px solid #2E7BD6;
}

/* =============================================================================
   TOAST
   ============================================================================= */
.toast {
  position: fixed; z-index: 800;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--safe-bottom) + 76px);
  background: var(--ink); color: var(--bone);
  padding: 11px 18px; border-radius: 999px;
  font-size: 13px; font-weight: 600; box-shadow: var(--shadow);
  max-width: 88vw; text-align: center;
}

/* iOS install hint card */
.install-card b { color: var(--ochre); }
.install-step { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; font-size: 13.5px; }
.install-step .n { flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--ochre); color: var(--bone); font-size: 12px; font-weight: 700; display: grid; place-items: center; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
