/* WHEREAMI — LA Neighborhood Navigator
   Design system: "Citizen Cartographer" (see design/stitch/prd.html) */

:root {
  --bg: #0A0E17;
  --surface: #121826;
  --grid: #1D263B;
  --text: #E6EDF3;
  --muted: #8494A8;
  --vibe-main: #13ec99;
  --vibe-accent: #FF00E5;
  --hazard: #FFD700;
  --font-mono: "Space Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; border-radius: 0; }

html, body {
  height: 100%;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 640px;
  margin: 0 auto;
  border-left: 1px solid var(--grid);
  border-right: 1px solid var(--grid);
  position: relative;
  overflow: hidden;
}

/* Topographical noise overlay */
.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.05;
  z-index: 90;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

button {
  font-family: var(--font-mono);
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
}

.view { display: none; flex: 1; min-height: 0; flex-direction: column; }
.view.active { display: flex; }

/* ============ RADAR ============ */
#radar { position: relative; }

#map-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #05080c;
  overflow: hidden;
  touch-action: none;
}

#map { position: absolute; inset: 0; width: 100%; height: 100%; }

.map-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.map-controls button {
  width: 44px;
  height: 44px;
  background: var(--surface);
  border: 1px solid var(--grid);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
}

.map-controls button:active { border-color: var(--vibe-main); color: var(--vibe-main); }
.map-controls button.on { color: var(--vibe-main); border-color: var(--vibe-main); }

.map-tag {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 20;
  font-size: 10px;
  letter-spacing: 0.15em;
  color: var(--muted);
  background: rgba(10,14,23,0.85);
  border: 1px solid var(--grid);
  padding: 6px 8px;
  text-transform: uppercase;
}

/* Center reticle */
.reticle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 15;
  pointer-events: none;
}

.reticle .dot {
  width: 14px;
  height: 14px;
  background: var(--vibe-main);
  border-radius: 50%;
  box-shadow: 0 0 15px var(--vibe-main);
  position: relative;
}

.reticle .dot::before {
  content: "";
  position: absolute;
  inset: -10px;
  border: 2px solid var(--vibe-main);
  border-radius: 50%;
  animation: pulse-ring 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

.reticle .hline, .reticle .vline {
  position: absolute;
  background: color-mix(in srgb, var(--vibe-main) 30%, transparent);
  top: 50%;
  left: 50%;
}
.reticle .hline { width: 200px; height: 1px; transform: translate(-50%, -50%); }
.reticle .vline { width: 1px; height: 200px; transform: translate(-50%, -50%); }

@keyframes pulse-ring {
  0% { transform: scale(0.8); opacity: 0.8; }
  100% { transform: scale(2.5); opacity: 0; }
}

/* Scan laser sweep */
#laser {
  position: absolute;
  left: 0;
  right: 0;
  top: -4px;
  height: 3px;
  background: var(--vibe-main);
  box-shadow: 0 0 18px 2px var(--vibe-main);
  z-index: 30;
  display: none;
}
#laser.on { display: block; animation: sweep 0.9s linear 1; }
@keyframes sweep { from { top: -4px; } to { top: 100%; } }

/* Telemetry panel */
#telemetry {
  background: var(--surface);
  border-top: 2px solid var(--vibe-main);
  position: relative;
  z-index: 25;
  flex-shrink: 0;
}

#telemetry .corner {
  position: absolute;
  width: 14px;
  height: 14px;
  top: -2px;
}
#telemetry .corner.l { left: 0; border-top: 2px solid var(--vibe-main); border-left: 2px solid var(--vibe-main); }
#telemetry .corner.r { right: 0; border-top: 2px solid var(--vibe-main); border-right: 2px solid var(--vibe-main); }

.tele-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--grid);
}

.tele-status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--vibe-main);
  text-transform: uppercase;
}

.tele-status .blip {
  width: 8px;
  height: 8px;
  background: var(--vibe-main);
}

.tele-status.seeking .blip,
.tele-status.seeking .label { animation: blink 1.5s step-end infinite; }

@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

.tele-sys { font-size: 10px; color: var(--muted); letter-spacing: 0.1em; }

.tele-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
  padding: 12px 16px;
}

.tele-cell { border-left: 1px solid var(--grid); padding: 2px 0 2px 10px; min-width: 0; }
.tele-cell .k { display: block; font-size: 10px; color: var(--muted); letter-spacing: 0.12em; margin-bottom: 3px; }
.tele-cell .v {
  display: block;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tele-cell .v.hot { color: var(--vibe-main); }

.tele-actions { display: flex; justify-content: center; padding: 6px 16px 14px; }

#scan-btn {
  min-width: 150px;
  height: 48px;
  background: var(--vibe-main);
  color: var(--bg);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}
#scan-btn:active { filter: brightness(1.25); }
#scan-btn:disabled { opacity: 0.4; }

/* ============ DOSSIER ============ */
#dossier { overflow-y: auto; }

.dos-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--grid);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.dos-head {
  padding: 22px 16px;
  border-bottom: 1px solid var(--grid);
  background: color-mix(in srgb, var(--surface) 50%, transparent);
}

.dos-head .eyebrow {
  font-size: 10px;
  color: var(--vibe-main);
  letter-spacing: 0.25em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.dos-head h1 {
  font-size: clamp(28px, 9vw, 44px);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.dos-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.dos-chip {
  border: 1px solid var(--grid);
  background: var(--bg);
  padding: 4px 8px;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.05em;
}
.dos-chip.hot { color: var(--vibe-main); border-color: color-mix(in srgb, var(--vibe-main) 50%, transparent); }

.dos-section { border-bottom: 1px solid var(--grid); padding: 18px 16px; }

.dos-section > h2 {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.25em;
  text-transform: uppercase;
  margin-bottom: 14px;
  font-weight: 400;
}

.dos-blurb { font-size: 14px; line-height: 1.65; color: var(--text); }

/* Also-matches chips */
.dos-alsos { display: flex; flex-direction: column; gap: 8px; }
.also-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  border: 1px solid var(--grid);
  background: color-mix(in srgb, var(--surface) 40%, transparent);
  padding: 10px 12px;
  width: 100%;
  text-align: left;
  cursor: pointer;
}
.also-row .nm { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.also-row .src { font-size: 9px; color: var(--muted); letter-spacing: 0.15em; white-space: nowrap; }
.also-row:active { border-color: var(--vibe-main); }
.also-row.primary { border-color: color-mix(in srgb, var(--vibe-main) 60%, transparent); }
.also-row.primary .nm { color: var(--vibe-main); }

/* Vibe meters */
.vibe-row { margin-bottom: 14px; }
.vibe-row:last-child { margin-bottom: 0; }
.vibe-row .lbl {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 5px;
}
.vibe-row .pct { color: var(--vibe-main); font-weight: 700; }
.vibe-row.alt .pct { color: var(--vibe-accent); }
.vibe-row .bar {
  height: 8px;
  background: var(--bg);
  border: 1px solid var(--grid);
  overflow: hidden;
}
.vibe-row .fill { height: 100%; background: var(--vibe-main); width: 0; transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1); }
.vibe-row.alt .fill { background: var(--vibe-accent); }

/* External links */
.ext-links { display: flex; flex-wrap: wrap; gap: 8px; }
.ext-links a {
  border: 1px solid var(--vibe-main);
  color: var(--vibe-main);
  text-decoration: none;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.ext-links a:active { background: var(--vibe-main); color: var(--bg); }

/* Field notes */
.facts { list-style: none; }
.facts li {
  padding: 10px 0 10px 16px;
  border-bottom: 1px solid var(--grid);
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
  position: relative;
}
.facts li:last-child { border-bottom: none; }
.facts li::before {
  content: "▪";
  color: var(--vibe-accent);
  font-size: 10px;
  position: absolute;
  left: 0;
  top: 12px;
}

/* Landmarks */
.marks { list-style: none; }
.marks li {
  padding: 10px 0 10px 14px;
  border-bottom: 1px solid var(--grid);
  font-size: 13px;
  position: relative;
}
.marks li:last-child { border-bottom: none; }
.marks li::before {
  content: "◆";
  color: var(--vibe-main);
  font-size: 9px;
  position: absolute;
  left: 0;
  top: 13px;
}

/* Claim check (debunk) module */
.claims-box {
  margin: 18px 16px;
  border: 1px solid var(--grid);
  background: var(--bg);
}
.hazard-tape {
  height: 8px;
  background: repeating-linear-gradient(45deg, var(--hazard), var(--hazard) 10px, #000 10px, #000 20px);
}
.claims-inner { padding: 16px; }
.claims-inner > .claims-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 14px;
}
.claims-inner > .claims-title h2 {
  font-size: 12px;
  color: var(--hazard);
  letter-spacing: 0.25em;
  text-transform: uppercase;
}
.claims-inner > .claims-title span { font-size: 9px; color: var(--muted); letter-spacing: 0.15em; }

.claim { border: 1px solid var(--grid); margin-bottom: 10px; }
.claim:last-child { margin-bottom: 0; }
.claim .c-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--surface) 60%, transparent);
}
.claim .c-text { font-size: 12px; font-weight: 700; }
.claim .c-verdict {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  padding: 3px 6px;
  border: 1px solid currentColor;
  white-space: nowrap;
}
.claim .c-verdict.DEBUNKED { color: var(--vibe-accent); }
.claim .c-verdict.CONTESTED { color: var(--hazard); }
.claim .c-verdict.ADVISORY { color: var(--muted); }
.claim .c-reality {
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
  border-top: 1px solid var(--grid);
}

.dos-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  color: var(--muted);
  text-align: center;
  padding: 40px 20px;
}
.dos-empty pre { font-size: 10px; line-height: 1.3; color: var(--grid); }
.dos-empty p { font-size: 12px; letter-spacing: 0.2em; text-transform: uppercase; }

.ghost-btn {
  border: 1px solid var(--vibe-main);
  color: var(--vibe-main);
  padding: 12px 22px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}
.ghost-btn:active { background: var(--vibe-main); color: var(--bg); }

/* ============ LOGBOOK ============ */
#logbook { overflow: hidden; }

.log-head {
  background: var(--surface);
  border-bottom: 1px solid var(--grid);
  flex-shrink: 0;
}
.log-head .ttl { padding: 14px 16px; border-bottom: 1px solid var(--grid); }
.log-head h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--vibe-main);
  text-transform: uppercase;
}
.log-head .sub { font-size: 10px; color: var(--muted); letter-spacing: 0.15em; text-transform: uppercase; margin-top: 3px; }

.log-sorts { display: flex; background: var(--bg); }
.log-sorts button {
  flex: 1;
  padding: 11px 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--muted);
  border-right: 1px solid var(--grid);
  text-transform: uppercase;
}
.log-sorts button:last-child { border-right: none; }
.log-sorts button.on { color: var(--vibe-main); background: var(--surface); }

#log-list { flex: 1; overflow-y: auto; }

.log-row {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 16px;
  min-height: 48px;
  border-bottom: 1px solid var(--grid);
  cursor: pointer;
}
.log-row:active { background: color-mix(in srgb, var(--vibe-main) 6%, transparent); }
.log-row .ts { font-size: 10px; color: var(--muted); letter-spacing: 0.08em; }
.log-row .coords { font-size: 13px; font-weight: 700; letter-spacing: 0.02em; margin: 2px 0; }
.log-row .zone { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.log-row .zone b { color: var(--vibe-main); font-weight: 700; }

.log-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--muted);
  opacity: 0.6;
  text-align: center;
}
.log-empty pre { font-size: 11px; line-height: 1.35; margin-bottom: 18px; }
.log-empty p { font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; }

.log-clear {
  flex-shrink: 0;
  border-top: 1px solid var(--grid);
  padding: 10px 16px;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-align: center;
  background: var(--surface);
}
.log-clear:active { color: var(--vibe-accent); }

/* ============ NAV ============ */
nav {
  display: flex;
  gap: 2px;
  border-top: 1px solid var(--grid);
  background: var(--surface);
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
  flex-shrink: 0;
  z-index: 40;
}

nav button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  padding: 4px 0;
}
nav button.on { color: var(--vibe-main); }
nav button svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; }
nav button span { font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }

/* Toast */
#toast {
  position: absolute;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--vibe-accent);
  color: var(--vibe-accent);
  font-size: 11px;
  letter-spacing: 0.1em;
  padding: 10px 14px;
  z-index: 80;
  display: none;
  max-width: 85%;
  text-align: center;
  text-transform: uppercase;
}
#toast.show { display: block; }
