/* Crosswise — dark, calm, high contrast, one accent colour.
   Layout: full-screen map behind; search on top; sheet + camera bar at the bottom (thumb zone).
   All text is at least 18 px (1rem). Colours are tokens: change them here only. */

:root {
  color-scheme: dark;
  --bg: #0b0d10;
  --surface: #14181d;       /* sheet, search bar, cards */
  --surface-2: #1c2128;     /* buttons, inputs, route cards */
  --surface-3: #272d36;     /* pressed */
  --line: #2f3641;
  --line-strong: #4b5563;
  --text: #f4f6f8;
  --muted: #b4bcc7;         /* 9:1 on --surface */
  --accent: #4cc2ff;        /* the one accent: sky blue, 9.7:1 on --bg, far from the crossing colours */
  --accent-ink: #04131d;    /* text on accent */
  --accent-soft: rgba(76, 194, 255, 0.14);
  --danger: #ff6b6b;
  --danger-ink: #1f0707;
  /* crossing colours (map dots, legend, route level) */
  --c-sound: #3ddc84;
  --c-lights: #ffd23f;
  --c-zebra: #ff9f1c;
  --c-unmarked: #ff5a5a;
  --focus: #ffffff;
  --r-sheet: 24px;
  --r-card: 18px;
  --r-btn: 16px;
  --r-pill: 999px;
  --tap: 64px;              /* minimum height of main buttons */
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  font-size: 112.5%;        /* 18 px, and it grows with the browser's text size setting */
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.4;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.hint { margin: 0; color: var(--muted); font-weight: 400; }
.section-title { margin: 0; font-size: 1rem; font-weight: 700; color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: var(--tap); padding: 12px 18px;
  border: 1px solid var(--line-strong); border-radius: var(--r-btn);
  background: var(--surface-2); color: var(--text);
  font-weight: 700; line-height: 1.2; text-align: center;
  transition: transform 0.12s ease, background-color 0.15s ease, border-color 0.15s ease;
}
.btn:active, .tile:active, .quick button:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-quiet { background: transparent; border-color: var(--line-strong); }
.btn-xl { min-height: 76px; font-size: 1.3rem; border-radius: 20px; }
.icon-btn {
  display: inline-grid; place-items: center; flex: none;
  width: 52px; height: 52px; padding: 0;
  border: 0; border-radius: var(--r-pill); background: transparent; color: var(--text);
}
.icon-btn:active { background: var(--surface-3); }
.icon-btn.round { width: 60px; height: 60px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }

/* ---------- start screen ---------- */
.gate { position: fixed; inset: 0; overflow-y: auto; display: grid; place-items: center; padding: 24px 20px calc(24px + env(safe-area-inset-bottom)); }
.gate-inner { width: min(460px, 100%); display: grid; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 1.2rem; font-weight: 800; }
.brand .logo { width: 36px; height: 36px; color: var(--accent); }
.gate-title { margin: 8px 0 0; font-size: 2rem; line-height: 1.15; letter-spacing: -0.01em; }
.gate-lead { margin: 0 0 8px; color: var(--muted); font-size: 1.1rem; }

/* ---------- app frame ---------- */
.app { position: fixed; inset: 0; }
.map-layer { position: absolute; inset: 0; z-index: 0; isolation: isolate; background: #11151a; } /* keeps Leaflet's z-index 400+ inside */
.map-layer .map { position: absolute; inset: 0; }
.leaflet-container { background: #11151a; font: inherit; }
/* dark, calm map from the standard OSM tiles (their colours inverted and muted) */
.map-layer .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.95) contrast(0.85) saturate(0.35); }

/* ---------- top: search / walking banner ---------- */
.top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 30;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: start;
  padding: calc(env(safe-area-inset-top) + 12px) 12px 0;
  pointer-events: none;
}
.top > * { pointer-events: auto; }
.search-bar {
  display: flex; align-items: center; gap: 4px;
  height: 60px; padding: 0 4px 0 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-pill);
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.search-bar:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }
.search-icon { color: var(--muted); margin-right: 6px; }
.search-bar input, .from-row input {
  flex: 1; min-width: 0; height: 100%; padding: 0;
  border: 0; background: transparent; outline: none;
  font-size: 1.1rem; font-weight: 600;
}
.search-bar input::placeholder, .from-row input::placeholder { color: var(--muted); font-weight: 500; opacity: 1; }
input[type="search"]::-webkit-search-cancel-button { display: none; }
.search-back, .search-go { display: none; }
.search-panel { display: none; }
.map-credit {
  position: absolute; right: 12px; bottom: calc(var(--bottom-h, 300px) + 8px); z-index: 25;
  padding: 2px 8px; border-radius: var(--r-pill);
  background: rgba(11, 13, 16, 0.75); color: var(--muted); font-size: 0.8rem; text-decoration: none;
}

/* searching: the search becomes a full-screen panel (the keyboard covers the bottom anyway) */
.is-searching .top { position: fixed; inset: 0; grid-template-columns: 1fr; align-content: start; overflow-y: auto; background: var(--bg); padding-bottom: 24px; }
.is-searching #settings-open, .is-searching .bottom, .is-searching .map-credit { display: none; }
.sheet-expanded .map-credit { display: none; }
.is-searching .search-bar { box-shadow: none; padding-left: 4px; }
.is-searching .search-icon { display: none; }
.is-searching .search-back, .is-searching .search-go { display: inline-grid; }
.is-searching .search-panel { display: grid; gap: 12px; margin-top: 12px; }
.from-row {
  display: flex; align-items: center; gap: 12px; height: 60px; padding: 0 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-btn);
}
.from-row:focus-within { border-color: var(--accent); }
.from-row label { color: var(--muted); font-weight: 700; }
.search-status { margin: 4px 4px 0; color: var(--muted); }
.search-status:empty { display: none; }

.suggestions { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.suggestion {
  width: 100%; min-height: 72px; padding: 10px 14px;
  display: grid; grid-template-columns: 40px minmax(0, 1fr); column-gap: 12px; align-items: center;
  border: 1px solid var(--line); border-radius: var(--r-btn); background: var(--surface);
  text-align: left;
}
.suggestion .s-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; background: var(--surface-2); color: var(--accent); }
.suggestion .s-text { display: grid; gap: 2px; min-width: 0; }
.suggestion .s-name { font-weight: 700; }
.suggestion .s-detail { color: var(--muted); }
.suggestion .s-detail:empty { display: none; }
.suggestion:active { background: var(--surface-2); }

/* walking: the next instruction replaces the search bar */
.nav-banner {
  grid-column: 1 / -1; margin: 0;
  padding: 14px 18px 16px; border-radius: var(--r-card);
  background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow);
}
.nav-label { margin: 0; font-size: 1rem; font-weight: 700; opacity: 0.85; }
.nav-label:focus { outline: none; }
.nav-next { margin: 2px 0 6px; font-size: 1.55rem; font-weight: 800; line-height: 1.2; }
.nav-remaining { margin: 0; font-weight: 700; }
.is-walking .search, .is-walking #settings-open { display: none; }

/* ---------- bottom: sheet + camera bar ---------- */
.bottom {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; flex-direction: column; pointer-events: none;
}
.bottom > * { pointer-events: auto; }
/* The sheet keeps at least ~160 px of map visible; "expanded" (handle) gives it almost the whole screen. */
.sheet {
  display: grid; gap: 14px; align-content: start;
  max-height: 40vh;
  max-height: min(40dvh, calc(100dvh - var(--top-h, 84px) - var(--dock-h, 170px) - 160px));
  overflow-y: auto; overscroll-behavior: contain;
  padding: 0 16px 14px;
  background: var(--surface); border: 1px solid var(--line); border-bottom: 0;
  border-radius: var(--r-sheet) var(--r-sheet) 0 0; box-shadow: var(--shadow);
}
.sheet.expanded { max-height: calc(100dvh - var(--top-h, 84px) - var(--dock-h, 170px) - 24px); }
.sheet-handle {
  position: sticky; top: 0; z-index: 1;
  display: grid; place-items: center; width: calc(100% + 32px); height: 30px; margin: 0 -16px;
  padding: 0; border: 0; background: var(--surface); border-radius: var(--r-sheet) var(--r-sheet) 0 0;
}
.sheet-handle span { width: 44px; height: 5px; border-radius: var(--r-pill); background: var(--line-strong); }
.sheet-handle:focus-visible { outline-offset: -3px; }
.status-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: start; }
.status { margin: 0; font-size: 1.3rem; font-weight: 700; line-height: 1.3; }
.status:focus { outline: none; }
.status-row .icon-btn { margin: -8px -8px 0 0; color: var(--muted); }
.voice-heard { margin: -8px 0 0; color: var(--muted); }
.voice-heard:empty { display: none; }
/* a question from the app: big Yes / No (also answerable by voice) */
.confirm { display: grid; gap: 8px; padding: 14px; border: 2px solid var(--accent); border-radius: var(--r-card); background: var(--surface-2); }
.confirm-question { margin: 0; font-size: 1.25rem; line-height: 1.3; }
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.confirm-actions .btn { min-height: var(--tap); font-size: 1.15rem; }

.actions, .nav-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.status-row { padding-top: 2px; }
#voice.listening { background: var(--danger); border-color: var(--danger); color: var(--danger-ink); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(255, 107, 107, 0.25); } }

.plan { display: grid; gap: 16px; }

/* mode: segmented control */
.segmented {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 20px;
}
.segmented button {
  min-height: var(--tap); padding: 6px 8px;
  border: 0; border-radius: 16px; background: transparent; color: var(--muted);
  font-weight: 700; line-height: 1.2;
  transition: background-color 0.18s ease, color 0.18s ease;
}
.segmented button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

/* quick destinations */
.quick-block { display: grid; gap: 8px; }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quick button {
  min-height: var(--tap); padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--r-btn); background: var(--surface-2);
  font-weight: 700; line-height: 1.2;
}

/* routes */
.routes-block { display: grid; gap: 10px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0; color: var(--muted); }
.dot { display: inline-block; width: 14px; height: 14px; margin-right: 6px; border-radius: 50%; vertical-align: -1px; box-shadow: 0 0 0 2px #0b0b10; }
.dot.sound { background: var(--c-sound); }
.dot.lights { background: var(--c-lights); }
.dot.zebra { background: var(--c-zebra); }
.dot.unmarked { background: var(--c-unmarked); }
.routes { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.route {
  display: grid; gap: 6px; padding: 14px;
  border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface-2);
  cursor: pointer; transition: border-color 0.15s ease, background-color 0.15s ease;
}
.route.selected { border-color: var(--accent); background: linear-gradient(var(--accent-soft), var(--accent-soft)), var(--surface-2); }
.route h3 { margin: 0; font-size: 1.15rem; }
.route-pick { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; cursor: pointer; }
.route-pick:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; border-radius: 8px; }
.route-pick .title { flex: 1; }
.route-pick .time { font-size: 1.25rem; font-weight: 800; }
.swatch { width: 44px; height: 12px; flex: none; }
.route .meta, .route .worst { margin: 0; color: var(--muted); }
.route .worst .label { color: var(--muted); }
.route .worst .value { color: var(--text); }
.route .level { margin: 0; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.route .level::before { content: ""; width: 14px; height: 14px; flex: none; border-radius: 50%; background: currentColor; }
.route.level-good .level { color: var(--c-sound); }
.route.level-ok .level { color: var(--c-lights); }
.route.level-caution .level { color: var(--c-zebra); }
.route.level-risky .level { color: var(--c-unmarked); }
.route .go { width: 100%; margin-top: 6px; }
.route.selected .go { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* public transport options: walk = solid line, ride = dashed line (like the map) */
.line { display: inline-block; width: 28px; height: 0; margin-right: 6px; vertical-align: 4px; border-top: 5px solid var(--text); border-radius: 3px; }
.line.ride { border-top-style: dotted; }
.route .legs { list-style: none; margin: 2px 0 0; padding: 0; display: grid; gap: 4px; }
.route .legs li { display: flex; gap: 8px; align-items: baseline; }
.route .legs li::before { content: ""; flex: none; width: 18px; border-top: 4px solid var(--muted); transform: translateY(-5px); }
.route .legs li.ride { font-weight: 700; }
.route .legs li.ride::before { border-top-style: dotted; border-color: var(--text); }
.route .times { margin: 0; font-weight: 700; }
.route .access, .route .compare { margin: 0; color: var(--muted); }
#walk-compare { width: 100%; }
#options-note { color: var(--c-lights); }

/* camera assistant: full screen above the dock (the tiles stay usable), result in big text under the video */
.camera {
  position: fixed; top: 0; left: 0; right: 0; bottom: var(--dock-h, 180px); z-index: 35;
  display: flex; flex-direction: column; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 12px) 12px 12px;
  background: var(--bg);
}
.camera-title { margin: 0; font-size: 1.1rem; font-weight: 800; }
.camera-view { position: relative; flex: 1 1 auto; min-height: 120px; overflow: hidden; border-radius: var(--r-card); background: #000; }
.camera-view video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.camera-caption { margin: 0; font-size: 1.3rem; font-weight: 700; line-height: 1.3; }
.camera-caption:empty { display: none; }
.camera .btn { width: 100%; }
.look-live {
  position: absolute; left: 10px; bottom: 10px; margin: 0; padding: 6px 12px;
  border-radius: var(--r-pill); background: rgba(0, 0, 0, 0.7); color: #fff; font-weight: 700;
}
.look-live:empty { display: none; }
.bus-line-row { display: grid; gap: 6px; }
.bus-line-row label { font-weight: 700; }
#bus-line {
  width: 100%; min-height: 60px; padding: 10px 14px;
  border: 1px solid var(--line-strong); border-radius: var(--r-btn); background: var(--bg);
  font-size: 1.3rem; font-weight: 800; letter-spacing: 0.04em;
}
#bus-line:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
#bus-line::placeholder { color: var(--muted); font-weight: 500; letter-spacing: 0; }

/* dock: Speak / Where am I + the 4 camera features — always visible, in reach of the thumb */
.dock {
  display: grid; gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line);
}
.actions .btn { padding-inline: 10px; min-height: 60px; }
.camera-bar { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.tile {
  min-height: 76px; padding: 8px 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); border-radius: var(--r-btn); background: var(--surface-2);
  font-weight: 700; line-height: 1.15; text-align: center;
  transition: transform 0.12s ease, border-color 0.15s ease, background-color 0.15s ease;
}
.tile .icon { width: 28px; height: 28px; color: var(--accent); }
.tile.active { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- settings dialog ---------- */
.settings {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 48px); padding: 20px;
  border: 1px solid var(--line); border-radius: var(--r-sheet);
  background: var(--surface); color: var(--text);
}
.settings::backdrop { background: rgba(0, 0, 0, 0.6); }
.settings > * + * { margin-top: 14px; }
.settings-head { display: flex; align-items: center; justify-content: space-between; }
.settings h2 { margin: 0; font-size: 1.3rem; }
.settings h3 { margin-bottom: 0; font-size: 1.05rem; }
.settings p { margin-bottom: 0; }
.settings .app-voice-toggle { width: 100%; }
.settings a { color: var(--accent); }
.app-voice-toggle[aria-pressed="false"] { border-style: dashed; }
.legend-list { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 6px; }

/* ---------- wide screens (laptop demo): panels on the left, map on the right ---------- */
@media (min-width: 768px) {
  .top { right: auto; width: 460px; padding-left: 16px; }
  .bottom { right: auto; left: 16px; bottom: 16px; width: 444px; }
  .sheet, .sheet.expanded { max-height: calc(100dvh - var(--dock-h, 170px) - var(--top-h, 84px) - 48px); border: 1px solid var(--line); border-radius: var(--r-sheet); }
  .sheet-handle { display: none; }
  .sheet { padding-top: 16px; }
  .dock { margin-top: 8px; border: 1px solid var(--line); border-radius: var(--r-sheet); padding-bottom: 10px; }
  .camera { left: 16px; right: auto; width: 444px; top: 16px; bottom: calc(var(--dock-h, 180px) + 32px); border: 1px solid var(--line); border-radius: var(--r-sheet); }
  .is-searching .top { right: auto; width: 480px; border-right: 1px solid var(--line); }
  .map-credit { bottom: 12px; }
}

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