/* HailAFare v1 — components. Needs /css/tokens.css first. Mobile first; the Live Board layout lives under body.board. */

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; height: 100%; }
body { margin: 0; font-family: var(--font); font-size: var(--fs-15); line-height: var(--lh-body); color: var(--ink); background: var(--bg); min-height: 100%; }
h1, h2, h3 { margin: 0; line-height: var(--lh-heading); font-weight: 800; letter-spacing: -.01em; }
h1 { font-size: var(--fs-24); } h2 { font-size: var(--fs-20); } h3 { font-size: var(--fs-17); }
p { margin: 0 0 var(--s-3); }
a { color: var(--primary); }
button { font: inherit; color: inherit; }
img, svg { display: inline-block; vertical-align: middle; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.icon { width: 20px; height: 20px; flex: none; }
.skip { position: absolute; left: var(--s-2); top: -64px; z-index: 100; background: var(--surface); color: var(--primary); padding: 10px 14px; border-radius: var(--r-field); box-shadow: var(--shadow-float); font-weight: 700; }
.skip:focus { top: var(--s-2); }
[hidden] { display: none !important; }

/* ---------- top bar (navy in both themes) ---------- */
.topbar { position: relative; z-index: 40; min-height: var(--topbar-h); display: flex; align-items: center; gap: var(--s-2); padding: env(safe-area-inset-top) var(--s-4) 0; background: var(--navy); color: var(--on-navy); }
.topbar :focus-visible { outline-color: var(--focus-on-navy); }
.brand { font-size: var(--fs-24); font-weight: 800; letter-spacing: -.01em; color: #FFFFFF; text-decoration: none; display: inline-flex; align-items: center; min-height: var(--tap); }
.brand span { color: #F2A900; }
.topnav { display: flex; gap: var(--s-1); margin-left: auto; }
.topnav a { color: var(--on-navy-muted); text-decoration: none; font-weight: 600; font-size: var(--fs-13); padding: 0 var(--s-2); min-height: var(--tap); display: inline-flex; align-items: center; border-radius: var(--r-field); }
.topnav a:hover { color: #FFFFFF; }
.iconbtn { width: var(--tap); height: var(--tap); flex: none; border-radius: var(--r-chip); border: 0; background: transparent; color: inherit; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.topbar .iconbtn { color: #FFFFFF; }
.topbar .iconbtn:hover { background: rgba(255, 255, 255, .12); }
.topbar .theme-icon.sun, .topbar .theme-icon.moon { display: none; }
.topbar [data-mode="light"] .theme-icon.moon, .topbar [data-mode="dark"] .theme-icon.sun { display: block; }

/* ---------- buttons, fields, chips, segmented ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); min-height: var(--tap); padding: 10px var(--s-4); border-radius: var(--r-field); border: 1px solid var(--primary); background: var(--surface); color: var(--primary); font-weight: 700; font-size: var(--fs-15); line-height: 1.2; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background var(--t-chip) var(--ease), color var(--t-chip) var(--ease); }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #FFFFFF; }
.btn.amber { background: var(--amber); border-color: var(--amber); color: var(--amber-ink); }
.btn.block { width: 100%; }
.btn.small { min-height: var(--tap); padding: 8px var(--s-3); font-size: var(--fs-13); }
.btn:disabled { opacity: .55; cursor: default; }
.linkbtn { background: none; border: 0; padding: 0 var(--s-1); min-height: var(--tap); color: var(--primary); font-weight: 600; font-size: var(--fs-13); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.field { position: relative; }
.field > label { display: block; font-size: var(--fs-13); font-weight: 600; color: var(--muted); margin: 0 0 var(--s-1); }
.input { width: 100%; font: inherit; font-size: 16px; min-height: var(--tap); padding: 10px var(--s-3); border: 1px solid var(--field-line); border-radius: var(--r-field); background: var(--surface); color: var(--ink); }
.input::placeholder { color: var(--muted); opacity: 1; }
.field.lead .input { padding-left: 40px; }
.field.lead > .icon { position: absolute; left: 11px; top: 12px; color: var(--muted); pointer-events: none; }
.field.trail .input { padding-right: 48px; }
.field .inbtn { position: absolute; right: 0; top: 0; width: var(--tap); height: var(--tap); border: 0; background: transparent; color: var(--primary); border-radius: var(--r-field); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.field .inbtn:hover { background: var(--estimate-tint); }
.suggest { position: absolute; left: 0; right: 0; top: 100%; z-index: 30; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-field); margin-top: var(--s-1); max-height: 240px; overflow: auto; box-shadow: var(--shadow-float); }
.suggest [role="option"] { padding: 10px var(--s-3); min-height: var(--tap); border-bottom: 1px solid var(--line); cursor: pointer; font-size: var(--fs-15); }
.suggest [role="option"]:last-child { border-bottom: 0; }
.suggest [role="option"][aria-selected="true"], .suggest [role="option"]:hover { background: var(--amber-tint); }
.suggest small { display: block; color: var(--muted); font-size: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border-radius: var(--r-chip); padding: 3px 10px; font-size: 12px; font-weight: 700; letter-spacing: .02em; line-height: 1.3; white-space: nowrap; }
.chip.live { background: var(--live-tint); color: var(--live); }
.chip.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--live); flex: none; }
.chip.est { background: var(--estimate-tint); color: var(--estimate); }
.chip.app { background: var(--estimate-tint); color: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: 6px; border-radius: var(--r-chip); padding: 4px 10px 4px 8px; font-size: 12px; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; background: var(--amber); color: var(--amber-ink); }
.badge .icon { width: 14px; height: 14px; }
.badge.fastest { background: var(--teal); color: var(--teal-ink); }
.badge.value { background: var(--navy); color: #FFFFFF; box-shadow: 0 0 0 1px var(--primary) inset; }
.segmented { display: flex; gap: 2px; padding: 2px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-field); }
.segmented > label, .segmented > .seg { flex: 1; min-width: 0; }
.segmented input { position: absolute; opacity: 0; width: 0; height: 0; }
.seg { min-height: var(--tap); width: 100%; border: 0; border-radius: 8px; background: transparent; color: var(--primary); font-weight: 700; font-size: var(--fs-13); display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; padding: 0 var(--s-2); white-space: nowrap; transition: background var(--t-chip) var(--ease), color var(--t-chip) var(--ease); }
.seg .icon { width: 16px; height: 16px; }
.seg[aria-checked="true"], .segmented input:checked + .seg { background: var(--navy); color: #FFFFFF; }
.segmented input:focus-visible + .seg { outline: 3px solid var(--focus); outline-offset: 2px; }
.status { font-size: var(--fs-13); color: var(--muted); min-height: 1.3em; }
.status.error { color: var(--danger); font-weight: 600; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: var(--s-4); }

/* ---------- notices ---------- */
.notice { border-radius: var(--r-card); padding: 10px var(--s-3); font-size: var(--fs-13); margin: 0 0 var(--s-3); display: flex; gap: var(--s-2); align-items: flex-start; background: var(--estimate-tint); color: var(--ink); }
.notice .icon { margin-top: 1px; color: var(--muted); }
.notice.warn { background: var(--amber-tint); }
.notice.error { background: var(--danger-tint); color: var(--danger); font-weight: 600; }
.notice.error .icon { color: var(--danger); }
.notice .btn { margin-left: auto; }
.notice p { margin: 0; }

/* ---------- Live Board layout (JS on) ---------- */
.js body.board { height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
.board-main { position: relative; flex: 1; min-height: 0; }
.map { display: none; }
.js .map { display: block; position: absolute; inset: 0; background: var(--map-bg); overflow: hidden; }
.map canvas { outline: none; }
.map-fallback { position: absolute; left: var(--map-inset-l, 0); right: 0; top: var(--map-inset-t, 0); bottom: var(--map-inset-b, 0); display: flex; align-items: center; justify-content: center; text-align: center; color: var(--muted); padding: var(--s-6); font-size: var(--fs-13); }
.map[data-map="failed"] { background-image: repeating-linear-gradient(0deg, transparent 0 39px, var(--line) 39px 40px), repeating-linear-gradient(90deg, transparent 0 39px, var(--line) 39px 40px); }
.map-fallback p { max-width: 260px; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: var(--s-3) var(--s-4); }
.map.dark-filter .maplibregl-canvas-container { filter: invert(.92) hue-rotate(180deg) saturate(.6); }
.live-chip { position: absolute; top: calc(var(--map-inset-t, 0px) + var(--s-3)); right: var(--s-3); z-index: 5; }
.map .maplibregl-ctrl-bottom-left, .map .maplibregl-ctrl-bottom-right { bottom: var(--map-inset-b, 0); }
.map .maplibregl-ctrl-bottom-left { left: var(--map-inset-l, 0); }
.map .maplibregl-ctrl.maplibregl-ctrl-attrib, .map .maplibregl-ctrl-attrib { background: var(--surface); color: var(--muted); font-size: 11px; border-radius: 6px 0 0 0; opacity: .94; }
.map .maplibregl-ctrl-attrib a, .map .maplibregl-ctrl.maplibregl-ctrl-attrib a { color: var(--primary); }
.map .maplibregl-ctrl-attrib-button { filter: none; }
:root[data-theme="dark"] .map .maplibregl-ctrl-attrib-button, .map .maplibregl-ctrl-attrib-button { background-color: var(--surface); }
/* map overlays: rider pin + pulse, ring labels, vehicles */
.rider-pulse { width: 56px; height: 56px; border-radius: 50%; background: var(--amber); opacity: .35; animation: pulse var(--pulse) ease-out infinite; animation-play-state: var(--pulse-play); pointer-events: none; }
@keyframes pulse { 0% { transform: scale(.35); opacity: .45; } 70% { opacity: .08; } 100% { transform: scale(1.1); opacity: 0; } }
.rider-pin { width: 32px; height: 40px; color: var(--navy); filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .35)); pointer-events: none; }
.dest-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 3px solid var(--primary); box-shadow: 0 1px 3px rgba(0, 0, 0, .3); pointer-events: none; }
.ring-label { background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-left: 4px solid var(--ring-color, var(--primary)); border-radius: var(--r-chip); padding: 3px 10px; font-size: 12px; font-weight: 700; white-space: nowrap; box-shadow: var(--shadow-float); pointer-events: none; }
.vehicle { width: 28px; height: 28px; color: var(--navy); position: relative; pointer-events: none; }
.vehicle .icon { width: 28px; height: 28px; background: var(--surface); border-radius: 50%; padding: 3px; box-shadow: 0 1px 3px rgba(0, 0, 0, .35); }
.vehicle::after { content: ""; position: absolute; right: -1px; top: -1px; width: 9px; height: 9px; border-radius: 50%; background: var(--live); border: 2px solid var(--surface); }

/* panel = search card + results sheet (mobile: two floating pieces; desktop: one side panel) */
.panel { display: contents; }
.search { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: var(--s-3); margin: var(--s-3); }
.js .search { position: absolute; top: 0; left: var(--s-3); right: var(--s-3); margin: var(--s-3) 0 0; z-index: 20; box-shadow: var(--shadow-float); }
.search form { display: grid; gap: var(--s-2); }
.cta-row { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: var(--s-2); align-items: stretch; }
.search .status:empty { display: none; }
.search.collapsed form { display: none; }
.tripbar { display: none; align-items: center; gap: var(--s-2); min-height: var(--tap); }
.search.collapsed .tripbar { display: flex; }
.tripbar .trip { flex: 1; min-width: 0; font-weight: 700; font-size: var(--fs-15); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tripbar .trip small { display: block; font-weight: 500; color: var(--muted); font-size: var(--fs-13); }

/* results sheet */
.sheet { position: relative; background: var(--surface); border-top: 1px solid var(--line); display: flex; flex-direction: column; }
.js .sheet { position: absolute; left: 0; right: 0; top: 0; height: 100%; z-index: 30; border: 0; border-radius: 16px 16px 0 0; box-shadow: var(--shadow-sheet); transform: translateY(var(--sheet-y, calc(100% - 168px))); transition: transform var(--t-sheet) var(--ease); will-change: transform; }
.js .sheet.dragging { transition: none; }
.handle { display: none; }
.js .handle { display: flex; align-items: center; justify-content: center; width: 100%; height: var(--tap); margin-bottom: -18px; border: 0; background: transparent; cursor: grab; touch-action: none; position: relative; z-index: 1; border-radius: 16px 16px 0 0; }
.handle .grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line); }
.handle:focus-visible { outline-offset: -4px; }
.sheet-head { padding: var(--s-2) var(--s-4) var(--s-3); touch-action: none; }
.sheet-head h2 { font-size: var(--fs-17); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-head h2:focus { outline: none; }
.sheet-head .meta { font-size: var(--fs-13); color: var(--muted); margin: 2px 0 var(--s-3); }
.sheet-head .segmented { touch-action: auto; }
.sheet-body { flex: 1; min-height: 0; overflow: auto; padding: 0 var(--s-4) var(--s-6); overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; margin: var(--s-2) 0 var(--s-3); }
.sheet-actions .status { flex: 1 1 100%; }

/* service card */
.opt { border: 1px solid var(--line); border-radius: var(--r-card); padding: var(--s-3) var(--s-4); margin-bottom: var(--s-3); background: var(--surface); display: grid; grid-template-columns: minmax(0, 1fr) max-content; grid-template-areas: "badge badge" "who price" "range range" "eta eta" "actions actions"; gap: 2px var(--s-3); align-items: center; }
.opt.first { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber) inset; background: var(--amber-tint); }
.opt.first.fastest { border-color: var(--teal); box-shadow: 0 0 0 1px var(--teal) inset; background: var(--surface); }
.opt.first.value { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; background: var(--surface); }
.opt .badge-row { grid-area: badge; margin-bottom: 2px; }
.opt .who { grid-area: who; display: flex; align-items: center; gap: var(--s-2); min-width: 0; }
.opt .glyph { color: var(--primary); width: 24px; height: 24px; }
.opt .name { font-size: var(--fs-17); font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.opt .price { grid-area: price; justify-self: end; font-size: var(--fs-24); font-weight: 800; font-variant-numeric: tabular-nums; color: var(--primary); line-height: 1.15; background: none; border: 0; padding: 0 2px; min-height: 32px; cursor: pointer; text-decoration: underline dotted var(--line); text-decoration-thickness: 2px; text-underline-offset: 5px; }
.opt .price.na { font-size: var(--fs-15); color: var(--muted); font-weight: 700; }
.opt .range { grid-area: range; justify-self: end; font-size: var(--fs-13); color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; margin-top: -2px; }
.opt .range:empty { display: none; }
.opt .range .crowd { display: block; color: var(--ink); font-weight: 600; }   /* v2.4: riders paid ~$X (N receipts) */
.opt .eta { grid-area: eta; display: flex; align-items: center; gap: var(--s-2); min-width: 0; margin-top: 2px; }
.opt .eta > .icon { color: var(--muted); }
.opt .etabtn { background: none; border: 0; padding: 0 2px; min-height: 32px; font-weight: 700; font-size: var(--fs-15); font-variant-numeric: tabular-nums; color: var(--ink); cursor: pointer; text-align: left; text-decoration: underline dotted var(--line); text-decoration-thickness: 2px; text-underline-offset: 4px; min-width: 0; }
.opt .etabtn.quiet { font-weight: 600; color: var(--muted); }
.opt .spark { flex: none; color: var(--muted); }
.opt .spark .now { fill: var(--primary); }
.opt .actions { grid-area: actions; display: flex; flex-wrap: wrap; gap: 0 var(--s-3); align-items: center; margin-top: 4px; }
.opt .actions .btn { margin-right: var(--s-1); }
.inline-form { grid-column: 1 / -1; display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap; padding-top: var(--s-2); border-top: 1px dashed var(--line); }
.inline-form .input { width: 120px; }
.inline-form .status { flex: 1 1 100%; }

/* skeletons (never spinners over the map) */
.skel { border: 1px solid var(--line); border-radius: var(--r-card); padding: var(--s-3) var(--s-4); margin-bottom: var(--s-3); display: grid; grid-template-columns: 1fr auto; gap: var(--s-2) var(--s-4); }
.skel .bar { height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--line) 0%, var(--bg) 50%, var(--line) 100%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; animation-play-state: var(--pulse-play); }
.skel .bar.w1 { width: 40%; } .skel .bar.w2 { width: 70%; } .skel .bar.w3 { width: 56px; height: 24px; justify-self: end; } .skel .bar.w4 { width: 80px; justify-self: end; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* availability (pickup known, no destination) */
.avail { list-style: none; margin: 0 0 var(--s-3); padding: 0; }
.avail li { display: flex; align-items: center; gap: var(--s-2); min-height: var(--tap); border-bottom: 1px solid var(--line); font-size: var(--fs-15); }
.avail li:last-child { border-bottom: 0; }
.avail .name { font-weight: 700; flex: 1; }
.avail .glyph { color: var(--primary); }
.avail .etabtn { background: none; border: 0; padding: 6px 2px; font: inherit; font-weight: 600; color: var(--ink); cursor: pointer; text-decoration: underline dotted var(--line); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.intro { font-size: var(--fs-15); color: var(--ink); }
.intro .services { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 var(--s-3); }
.intro .services span { border: 1px solid var(--line); border-radius: var(--r-chip); padding: 4px 10px; font-size: var(--fs-13); font-weight: 600; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.intro .services .icon { width: 16px; height: 16px; }

/* about + footer (inside the sheet / panel) */
.about { margin-top: var(--s-6); padding-top: var(--s-4); border-top: 1px solid var(--line); font-size: 14px; }
.about h2 { font-size: var(--fs-17); margin-bottom: var(--s-2); color: var(--primary); }
.about details { margin: 0 0 var(--s-3); }
.about summary { cursor: pointer; color: var(--primary); font-weight: 700; min-height: var(--tap); display: flex; align-items: center; }
.about .links { display: flex; flex-wrap: wrap; gap: var(--s-3); }
.about .links a { min-height: var(--tap); display: inline-flex; align-items: center; font-weight: 600; }
.foot { margin-top: var(--s-4); padding-top: var(--s-3); border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.foot p { margin: var(--s-2) 0; }

/* provenance sheet (dialog) */
.prov { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; background: var(--scrim); }
.prov-card { width: 100%; max-height: 88dvh; overflow: auto; background: var(--surface); color: var(--ink); border-radius: 16px 16px 0 0; padding: var(--s-3) var(--s-4) calc(var(--s-6) + env(safe-area-inset-bottom)); box-shadow: var(--shadow-sheet); }
.prov-head { display: flex; align-items: flex-start; gap: var(--s-2); margin-bottom: var(--s-2); }
.prov-head h2 { font-size: var(--fs-17); flex: 1; padding-top: 10px; }
.prov-head .iconbtn { color: var(--primary); margin-right: -8px; }
.prov .kv { margin: 0; display: grid; grid-template-columns: 1fr; gap: var(--s-3); }
.prov .kv > div { border: 1px solid var(--line); border-radius: var(--r-card); padding: 10px var(--s-3); }
.prov dt { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
.prov dd { margin: 0; font-size: 14px; overflow-wrap: anywhere; }
.prov dd .big { font-size: var(--fs-20); font-weight: 800; font-variant-numeric: tabular-nums; color: var(--primary); }
.prov dd a { overflow-wrap: anywhere; }
.prov .actions { margin-top: var(--s-4); }

/* install banner */
.install { position: fixed; left: var(--s-3); right: var(--s-3); bottom: calc(var(--s-3) + env(safe-area-inset-bottom)); z-index: 55; background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-card); padding: var(--s-3); box-shadow: var(--shadow-float); display: flex; gap: var(--s-3); align-items: center; font-size: var(--fs-13); }
.install img { width: 40px; height: 40px; border-radius: 10px; flex: none; }
.install .txt { flex: 1; min-width: 0; }
.install .txt b { display: block; font-size: var(--fs-15); }
.install .btns { display: flex; gap: var(--s-1); flex: none; }

/* ---------- desktop: side panel ---------- */
@media (min-width: 600px) { .topnav { margin-right: var(--s-2); overflow-x: auto; scrollbar-width: none; } .topnav a { white-space: nowrap; } }
@media (min-width: 600px) and (max-width: 759px) { .topnav a { font-size: 12px; padding: 0 6px; } } /* v2: five links fit beside the wordmark and the toggle */
@media (max-width: 599px) { .topnav { display: none; } }
@media (min-width: 900px) {
  .js .panel { display: flex; flex-direction: column; position: absolute; top: 0; left: 0; bottom: 0; width: var(--panel-w); z-index: 20; background: var(--surface); border-right: 1px solid var(--line); box-shadow: var(--shadow-float); }
  .js .search { position: static; margin: 0; border: 0; border-radius: 0; box-shadow: none; border-bottom: 1px solid var(--line); padding: var(--s-4); }
  .js .search.collapsed form { display: grid; }
  .js .search .tripbar { display: none; }
  .js .sheet { position: static; height: auto; flex: 1; min-height: 0; transform: none; border-radius: 0; box-shadow: none; }
  .js .handle { display: none; }
  .js .map { left: var(--panel-w); }
  .sheet-head { padding-top: var(--s-4); }
  .prov { align-items: center; }
  .prov-card { max-width: 520px; border-radius: 16px; max-height: 84vh; }
  .install { left: auto; width: 380px; right: var(--s-4); }
}
