/* The Commuter Engine — DFW rider demo
   Design system: dark map; palette + semantic color tokens centralized in
   the :root block below (THEME-1). */

:root {
  /* THEME-2: light palette. Base + semantic tokens flipped from dark; mirrored
     in CommuterShared.theme (shared.js) for the map (which can't read CSS vars). */
  --ink: #ffffff;                /* page background */
  --panel: #f6f8f7;              /* cards / sheets */
  --text: #1a1f1c;               /* body text */
  --muted: #5a6660;              /* muted text (AA on white) */
  --accent: #00a664;             /* CTAs / badges / fills (green) */
  --route: #4285f4;              /* corridor line (unchanged) */
  --hub: #34a853;                /* hub marker (unchanged) */
  --dest: #c13838;               /* negatives / NOT YET / dest marker (AA text on white) */
  --hairline: #e3e8e5;           /* borders / dividers */

  /* Semantic tokens — centralized in THEME-1; values flipped for light here. */
  --on-accent: #08110c;          /* dark text/icons on the green accent (CTA) */
  --positive-text: #007a4a;      /* green $ values / positive numbers (AA on white) */
  --warn: #c13838;               /* invalid / partial / gap — AA as text on white */
  --warn-text: #991b1b;          /* error/badge text on light tint (dark red, not pink) */
  --dest-soft: var(--warn);      /* partial-match badge dot */
  --neutral-marker: #9aa0a6;     /* home/work map markers (gray, unchanged) */
  --focus-ring: #1a1f1c;         /* keyboard focus outline (dark on light) */
  --marker-stroke: #ffffff;      /* map marker border ring */
  --hover-overlay: rgba(0, 0, 0, 0.05);          /* list/row hover wash */
  --skeleton-base: #e3e8e5;      /* skeleton shimmer base */
  --skeleton-shine: #f2f5f3;     /* skeleton shimmer highlight */
  --shadow-elev: 0 6px 24px rgba(0, 0, 0, 0.10);    /* card / input / dropdown */
  --shadow-sheet: 0 -10px 40px rgba(0, 0, 0, 0.12); /* bottom sheet */
  --shadow-marker: 0 0 0 2px rgba(0, 0, 0, 0.20);   /* marker contrast ring */

  --radius: 16px;
  --sheet-max: 460px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  /* Mobile bottom-sheet snap points = VISIBLE height at each state (original
     spec). dvh (not vh) so the sheet tracks the CURRENT viewport like .stage —
     full 88dvh always leaves ≥12dvh of map. These drive both CSS and JS. */
  --snap-peek: 22dvh;
  --snap-half: 58dvh;
  --snap-full: 88dvh;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

.mono { font-family: "IBM Plex Mono", ui-monospace, monospace; font-weight: 600; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* ---------- Stage (map + overlays = first screen) ---------- */
.stage {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;       /* clip the off-screen (hidden) sheet states */
  isolation: isolate;     /* contain the overlay z-indexes; FAQ scrolls below */
}

/* ---------- Map ---------- */
#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
/* Zoom +/- buttons live top-right (clear of the left-stacked cards on desktop).
   On mobile the search card fills the top, and pinch/double-tap cover zoom — so
   hide the buttons there to avoid overlapping the address inputs. */
@media (max-width: 768px) {
  .mapboxgl-ctrl-top-right { display: none; }
}

/* ---------- Loader ---------- */
.loader {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: var(--ink);
  transition: opacity 0.4s ease;
}
.loader.hidden { opacity: 0; pointer-events: none; }
.loader-mark {
  font-weight: 600;
  letter-spacing: 0.02em;
  font-size: 18px;
  color: var(--text);
}
.loader-bar {
  width: 160px; height: 3px;
  border-radius: 3px;
  background: var(--hairline);
  overflow: hidden;
}
.loader-bar span {
  display: block;
  width: 40%; height: 100%;
  background: var(--accent);
  border-radius: 3px;
  animation: slide 1.1s ease-in-out infinite;
}
@keyframes slide {
  0%   { transform: translateX(-110%); }
  100% { transform: translateX(360%); }
}

/* ---------- Search overlay ---------- */
.search {
  position: absolute;
  z-index: 30;
  top: max(14px, env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 24px);
  max-width: 460px;
}
/* Home input, work input, and the Find button form one unified stacked card:
   identical width, height, radius, horizontal padding, and elevation. */
.search-field {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 0 16px;
  box-shadow: var(--shadow-elev);
}
.search-field + .search-field { margin-top: 10px; }
/* Submit-time geocode failure: flag the offending field with a coral border. */
.search-field.invalid { border-color: var(--warn); }

/* ---------- Day picker (rider page) ---------- */
/* Sits between the address inputs and the time rows. Five M–F toggle pills,
   all selected by default; the count of selected days drives the price. */
.day-picker { margin-top: 10px; }
.day-picker-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin-bottom: 8px;
}
.day-pills { display: flex; gap: 8px; }
.day-pill {
  flex: 1 1 0;
  min-height: 44px;            /* comfortable tap target on mobile */
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: var(--panel);    /* unselected: surface fill */
  color: var(--muted);         /* unselected: muted text */
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.day-pill[aria-pressed="true"] {
  background: var(--accent);   /* selected: accent-green fill */
  color: var(--on-accent);     /* selected: dark text */
  border-color: var(--accent);
}
.day-pill:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }

/* ---------- Matched-state summary chip (desktop; R-1) ---------- */
/* Hidden by default; shown only when .search.collapsed on desktop (toggle rules
   live in the ≥769px block). Compact card summarizing the matched search. */
.search-summary {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: 12px;
}
.summary-route { font-size: 15px; font-weight: 600; color: var(--text); }
.summary-meta { margin-top: 4px; font-size: 13px; color: var(--muted); }
.summary-edit {
  flex: none;
  min-height: 40px;
  padding: 8px 14px;
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  color: var(--accent);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.summary-edit:hover { background: var(--hover-overlay); }
.summary-edit:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }

.find-btn {
  display: block;
  width: 100%;
  min-height: 48px;
  margin-top: 10px;
  padding: 13px 16px;
  background: var(--accent);
  color: var(--on-accent);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  /* Same elevation as the input fields so the three controls read as a set. */
  box-shadow: var(--shadow-elev);
  transition: filter 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.find-btn:hover:not(:disabled) { filter: brightness(1.06); }
/* Disabled: a SOLID muted fill, never opacity — a translucent CTA lets the
   Mapbox basemap labels bleed through and breaks the visual hierarchy. */
.find-btn:disabled {
  background: var(--hairline);
  color: var(--muted);
  box-shadow: none;
  cursor: not-allowed;
}
.find-btn:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.search-icon { color: var(--muted); flex: none; }
#home, #work {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 16px; /* 16px avoids iOS zoom-on-focus */
  padding: 13px 0;
  min-height: 48px;
  text-overflow: ellipsis; /* graceful overflow for very long addresses */
}
#home::placeholder, #work::placeholder { color: var(--muted); }

/* Arrival-time row — same unified card treatment as the address fields.
   The whole row is a <label>, so the entire surface opens the picker. */
.time-field { cursor: pointer; }
.time-field .time-label {
  flex: 1 1 0; /* basis 0 → yields width to the icon and time value first */
  min-width: 0;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#arrival, #departure {
  flex: none;
  width: auto;
  min-width: 112px; /* room for "09:00 AM" + clock indicator, no meridiem clip */
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-weight: 600;
  font-size: 16px;
  padding: 13px 0;
  min-height: 48px;
  text-align: right;
  color-scheme: light; /* light native time picker */
  -webkit-appearance: none;
  appearance: none; /* strip the default chip/pill so the value sits on the row */
}
/* Neutralize WebKit's internal white pill — the time reads as part of the row. */
#arrival::-webkit-datetime-edit,
#departure::-webkit-datetime-edit { color: var(--text); padding: 0; }
#arrival::-webkit-datetime-edit-fields-wrapper,
#departure::-webkit-datetime-edit-fields-wrapper { background: transparent; }
#arrival::-webkit-datetime-edit-text,
#departure::-webkit-datetime-edit-text { color: var(--muted); padding: 0 1px; }
#arrival::-webkit-datetime-edit-hour-field,
#arrival::-webkit-datetime-edit-minute-field,
#arrival::-webkit-datetime-edit-meridiem-field,
#departure::-webkit-datetime-edit-hour-field,
#departure::-webkit-datetime-edit-minute-field,
#departure::-webkit-datetime-edit-meridiem-field {
  background: transparent;
  color: var(--text);
  padding: 0 1px;
}
/* Selected sub-field: mint highlight instead of the system white/blue pill. */
#arrival::-webkit-datetime-edit-hour-field:focus,
#arrival::-webkit-datetime-edit-minute-field:focus,
#arrival::-webkit-datetime-edit-meridiem-field:focus,
#departure::-webkit-datetime-edit-hour-field:focus,
#departure::-webkit-datetime-edit-minute-field:focus,
#departure::-webkit-datetime-edit-meridiem-field:focus {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: var(--text);
  outline: none;
  border-radius: 4px;
}
/* Keep the native clock indicator on the right edge, tinted for the dark row. */
#arrival::-webkit-calendar-picker-indicator,
#departure::-webkit-calendar-picker-indicator {
  filter: invert(0.7);
  cursor: pointer;
  margin-left: 4px;
  opacity: 0.85;
}
.clear-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  margin-right: -10px; /* keep the 40px tap target flush to the 16px inset edge */
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  border-radius: 50%;
}
.clear-btn:hover { color: var(--text); }
/* The class's display would otherwise override the [hidden] attribute. */
.clear-btn[hidden] { display: none; }

.field-error {
  margin: 8px 4px 0;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--warn-text);
  background: color-mix(in srgb, var(--dest) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--dest) 40%, transparent);
  border-radius: 10px;
}

/* ---------- Suggestions dropdown ---------- */
.suggestions {
  list-style: none;
  margin: 8px 0 0;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow-elev);
  max-height: 48vh;
  overflow-y: auto;
}
.suggestions li {
  padding: 12px 12px;
  min-height: 44px;
  display: flex;
  align-items: center;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.3;
}
.suggestions li:hover,
.suggestions li[aria-selected="true"] {
  background: var(--hover-overlay);
}
.suggestions li .sug-sub { color: var(--muted); font-size: 12px; }
.suggestions li .sug-main { color: var(--text); }

/* ---------- Bottom sheet (shared) ---------- */
.sheet {
  position: absolute;
  z-index: 40;
  left: 50%;
  bottom: 0;
  width: 100%;
  max-width: var(--sheet-max);
  transform: translateX(-50%) translateY(110%);
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-bottom: none;
  border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow-sheet);
  transition: transform 0.42s cubic-bezier(0.22, 1, 0.36, 1);
  padding-bottom: var(--safe-bottom);
  will-change: transform;
}
.sheet.open { transform: translateX(-50%) translateY(0); }

/* Drag handle — thin rounded pill, captures drags (no native scroll/zoom). */
.sheet-handle {
  display: block;
  flex: none;
  width: 100%;
  padding: 12px 0 6px;
  background: transparent;
  border: none;
  cursor: grab;
  touch-action: none;
}
.sheet-handle:active { cursor: grabbing; }
.sheet-handle::before {
  content: "";
  display: block;
  width: 40px; height: 4px;
  margin: 0 auto;
  border-radius: 999px;
  background: var(--muted);
}
.sheet-handle:focus-visible { outline: none; }
.sheet-handle:focus-visible::before { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Peek header — always-visible summary; also a drag surface on mobile. */
.sheet-peek {
  flex: none;
  padding: 0 20px 14px;
}
.peek-summary {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-top: 12px;
}
.peek-summary .metric { margin-top: 0; }
.peek-summary .metric-time .metric-value { font-size: 30px; } /* match the price size */
.peek-summary .metric-time .metric-label { font-size: 14px; }
.peek-summary .metric-cost { text-align: right; }
.peek-summary .metric-cost .metric-value { font-size: 30px; }
/* Selected commute days, tied to the price (right-aligned under "per month"). */
.cost-days { margin-top: 4px; font-size: 12px; color: var(--muted); }

.sheet-body { padding: 0 20px 24px; }

/* ---------- Result card ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 5px 10px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
}
.badge-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
}
/* State colors: strong = mint, partial = coral. */
.badge.strong { color: var(--text); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.badge.strong .badge-dot { background: var(--accent); }
.badge.partial { color: var(--warn-text); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.badge.partial .badge-dot { background: var(--dest-soft); }

/* Partial-match gap message */
.gap-msg {
  margin: 14px 0 0;
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
}
.gap-msg strong { color: var(--warn); font-weight: 600; }

/* Strong-match distance detail */
.dist-detail {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}
.dist-item svg { color: var(--muted); flex: none; }
.dist-item strong { color: var(--text); }

/* Schedule timeline */
.timeline {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--hairline);
}
/* Schedule toggle (R-2): hidden by default — shown only on desktop (≥769px),
   where it collapses/expands the adjacent .timeline. Mobile never shows it, so
   the timeline stays visible there as before. */
.schedule-toggle {
  display: none;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  padding: 8px 0;
  background: none;
  border: none;
  color: var(--accent);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.schedule-toggle:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.tl-section + .tl-section { margin-top: 18px; }
.timeline-head { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.timeline-head .tl-period {
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.06em;
}
.timeline-rows {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.timeline-rows li {
  display: flex;
  align-items: baseline;
  gap: 12px;
  position: relative;
  padding-left: 18px;
  font-size: 15px;
}
/* Connector dots down the left edge. */
.timeline-rows li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 6px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.timeline-rows li:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 5.5px;
  top: 13px;
  bottom: -10px;
  width: 1px;
  background: var(--hairline);
}
.timeline-rows li:last-child::before { background: var(--dest); } /* arrival */
.timeline-rows .t-time {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-weight: 600;
  color: var(--text);
  min-width: 74px;
}
.timeline-rows .t-label { color: var(--muted); }
.timeline-note {
  margin: 12px 0 0;
  font-size: 11px;
  line-height: 1.4;
  color: var(--muted);
}
/* Operator context — trust-building prose between the schedule disclaimer and
   the price block. Sized to match the price-lock note (13px), not the fine print. */
.operator-note {
  margin: 16px 0 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
}

.metric { margin-top: 14px; }
.metric-value { color: var(--text); line-height: 1; }
.metric-label { color: var(--muted); font-size: 14px; margin-top: 6px; }

.metric-time .metric-value { font-size: 52px; }
.metric-time .metric-label { font-size: 16px; color: var(--text); }

.row {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--hairline);
}
.metric-cost { margin-top: 0; }
.metric-cost .metric-value { font-size: 30px; }

.price-lock {
  margin: 12px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}
.price-lock-note { color: var(--muted); }

.comparator { margin-top: 14px; }
.comparator-line { color: var(--muted); font-size: 15px; }
.comparator-line + .comparator-line { margin-top: 4px; }
.comparator-value { color: var(--muted); }

.social {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--hairline);
  color: var(--muted);
  font-size: 14px;
}
.social svg { color: var(--accent); flex: none; }
.social strong { color: var(--text); }

.cta {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 52px;
  margin-top: 20px;
  padding: 14px 20px;
  background: var(--accent);
  color: var(--on-accent);
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  white-space: nowrap; /* a primary CTA must never wrap — keep it one line */
  transition: filter 0.15s ease;
}
.cta:hover { filter: brightness(1.06); }
.cta:active { filter: brightness(0.94); }
.cta:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }

.route-note {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

/* ---------- Waitlist card ---------- */
.sheet-title { margin: 8px 0 6px; font-size: 22px; font-weight: 600; }
.sheet-sub { margin: 0 0 18px; color: var(--muted); font-size: 15px; line-height: 1.4; }
#waitlist-form { display: flex; flex-direction: column; gap: 12px; }
#wl-email {
  width: 100%;
  background: var(--ink);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  padding: 14px 14px;
  min-height: 44px;
  outline: none;
}
#wl-email:focus { border-color: var(--accent); }
.waitlist-done { color: var(--positive-text); font-size: 14px; text-align: center; margin: 4px 0 0; }

/* ---------- Skeleton ---------- */
.skeleton {
  display: inline-block;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--skeleton-base) 25%, var(--skeleton-shine) 37%, var(--skeleton-base) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease infinite;
  vertical-align: middle;
}
.skeleton-lg { width: 150px; height: 48px; }
.skeleton-md { width: 100px; height: 28px; }
@keyframes shimmer {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* ---------- Marker tooltips ---------- */
.map-marker {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 3px solid var(--marker-stroke);
  box-shadow: var(--shadow-marker);
  cursor: pointer;
}
.map-marker.hub { background: var(--hub); }
.map-marker.dest { background: var(--dest); }
/* User's own endpoints — muted gray, smaller (the spoke ends). */
.map-marker.home,
.map-marker.work {
  background: var(--neutral-marker);
  width: 14px; height: 14px;
  border-width: 2px;
}
.mapboxgl-popup-content {
  background: var(--panel);
  color: var(--text);
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--hairline);
}
.mapboxgl-popup-tip { display: none; }

/* ---------- FAQ (scrolls in below the stage) ---------- */
.faq {
  background: var(--ink);
  color: var(--text);
  padding: 48px 16px 64px;
  border-top: 1px solid var(--hairline); /* divide the map stage from the FAQ */
}
#faq-heading {
  max-width: 760px;
  margin: 0 auto 20px;
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 22px;
  font-weight: 600;
  text-align: left;
  color: var(--text);
}
.faq-list {
  max-width: 760px;
  margin: 0 auto;
  border-top: 1px solid var(--hairline);
}
.faq-item { border-bottom: 1px solid var(--hairline); }
.faq-q {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}
.faq-q:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.faq-chevron {
  flex: none;
  color: var(--muted);
  transition: transform 200ms ease;
}
.faq-item.open .faq-chevron { transform: rotate(180deg); }
/* Animate to the answer's natural height via a 0fr→1fr grid track. */
.faq-a {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 200ms ease;
}
.faq-item.open .faq-a { grid-template-rows: 1fr; }
.faq-a-inner { overflow: hidden; min-height: 0; }
.faq-a p {
  margin: 0;
  padding: 0 20px 20px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
}

/* ---------- Mobile: 3-snap persistent bottom sheet (≤768px) ---------- */
@media (max-width: 768px) {
  /* The result sheet is a fixed-height container (full snap) translated down
     to reveal peek / half / full. The body scrolls internally; the map stays
     visible and interactive above it at every snap point. */
  #result-sheet {
    height: var(--snap-full);
    display: flex;
    flex-direction: column;
  }
  #result-sheet[hidden] { display: none; }

  #result-sheet.open[data-snap="full"] { transform: translateX(-50%) translateY(0); }
  #result-sheet.open[data-snap="half"] {
    transform: translateX(-50%) translateY(calc(var(--snap-full) - var(--snap-half)));
  }
  #result-sheet.open[data-snap="peek"] {
    transform: translateX(-50%) translateY(calc(var(--snap-full) - var(--snap-peek)));
  }

  /* Peek header is a drag surface too (Google Maps lets you grab the header). */
  #result-sheet .sheet-peek { touch-action: none; }

  #result-sheet .sheet-body {
    flex: 1 1 auto;
    min-height: 0;            /* allow the flex child to shrink so it can scroll */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* M-2: schedule toggle on mobile (mirror of desktop R-2). The #schedule-toggle
     button + its [aria-expanded="false"] + .timeline collapse are already live on
     desktop and the JS (reset per match + label flip) is breakpoint-agnostic — we
     only mirror the three CSS rules here so the schedule starts collapsed on mobile
     too, freeing sheet height for the comparators + CTA. Headline content (badge,
     time, $, day echo, detail lines, comparators, CTA) is untouched and stays
     visible. Scoped to .rider so /drive (no schedule) is frozen; desktop rules in
     the ≥769px block are left intact. */
  .rider .schedule-toggle {
    display: inline-flex;
    min-height: 44px;          /* ≥44px tap target on mobile */
  }
  .rider .schedule-toggle[hidden] { display: none; } /* hide when a result lacks a schedule */
  .rider .schedule-toggle[aria-expanded="false"] + .timeline { display: none; }
}

/* ---------- Desktop (≥769px): left panel, no snap points ---------- */
@media (min-width: 769px) {
  /* Shared overlay search card — used by the /drive page (and the rider page
     before B-2): a 380px card at top-left over the full-bleed map. The rider
     page overrides this into a two-column layout below; /drive keeps it. */
  .search {
    left: 20px;
    top: 16px;
    width: 380px;
    max-width: 380px;
    transform: none;
  }

  /* B-2 rider-only desktop restructure: two columns — search stack on white
     (left ~38%), map edge-to-edge (right ~62%). The map stops being a full-bleed
     background and becomes the right grid track; the search overlay becomes the
     left track in normal flow. Scoped to body.rider so /drive keeps the overlay
     above. Mobile (<769px) is untouched (outside this query). Result/waitlist
     sheets stay absolute this step — B-3 repositions them. */
  .rider .stage {
    display: grid;
    grid-template-columns: minmax(320px, 38%) 1fr;
    /* Two rows: row 1 = search/chip (auto), row 2 = result (remaining). The two
       always sum to the stage height, so the map (spanning both) never resizes
       when the search collapses on match — only the split between rows changes. */
    grid-template-rows: auto 1fr;
  }
  .rider #map {
    position: relative;      /* map column fills the right track, full height */
    inset: auto;
    grid-column: 2;
    grid-row: 1 / -1;        /* span both rows → constant full height in every state */
    width: auto;
    height: 100%;            /* 100% of the (definite) full-height grid area */
  }
  .rider .search {
    position: static;        /* flow inside the left column, not an overlay */
    grid-column: 1;
    grid-row: 1;             /* top of the left column */
    align-self: start;       /* size to content (inputs or chip); content from the TOP */
    min-height: 0;
    max-height: 100dvh;      /* cap on short viewports so it scrolls, never clips */
    transform: none;
    width: auto;
    max-width: none;
    overflow-y: auto;        /* left column scrolls independently if it overflows */
    padding: 48px 40px;
    background: var(--ink);  /* white left column */
    z-index: auto;
  }
  /* R-1: on a successful match the input stack collapses to the summary chip.
     One rule hides the whole stack (hero, fields, picker, time rows, Find,
     teaser); the chip is the only visible child. Reversible via .collapsed. */
  .rider .search.collapsed > :not(.search-summary) { display: none; }
  .rider .search.collapsed .search-summary { display: flex; }

  /* R-2: schedule collapsible in the result card. Toggle shown on desktop; the
     timeline is collapsed while the toggle is not expanded. Card growth on
     expand is absorbed by .rider .sheet's max-height + overflow-y (no clip). */
  .rider .schedule-toggle { display: inline-flex; }
  .rider .schedule-toggle[hidden] { display: none; } /* hide if a result lacks schedule */
  .rider .schedule-toggle[aria-expanded="false"] + .timeline { display: none; }
  .sheet {
    left: 20px;
    bottom: 16px;
    transform: translateY(160%);
    border-radius: 20px;
    border-bottom: 1px solid var(--hairline);
    max-height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
  }
  .sheet.open { transform: translateY(0); }
  .sheet .sheet-body { overflow-y: auto; min-height: 0; }
  .sheet-handle { cursor: default; }

  /* R-3 rider-only: the result + waitlist render in the LEFT column, row 2,
     below the summary chip — the map column shows only the route (no overlay).
     Replaces the B-3 over-map placement. Height caps to row 2 and scrolls, so an
     expanded schedule grows/scrolls within the column instead of clipping.
     Aligns with the chip's 40px inset. Overrides the shared .sheet desktop rule
     (/drive still uses it) but inherits its display:flex / flex-column chrome. */
  .rider .sheet {
    grid-column: 1;
    grid-row: 2;
    position: relative;
    left: auto;
    right: auto;
    top: auto;
    bottom: auto;
    align-self: start;       /* content height when short; sits below the chip */
    min-height: 0;
    margin: 0 40px 24px;     /* match the chip's 40px horizontal inset */
    width: auto;
    max-width: none;
    max-height: calc(100% - 24px); /* cap to row 2 → scroll, never clip */
    overflow-y: auto;
    transform: none;         /* cancel the base/desktop off-screen translate */
    z-index: auto;
  }
  .rider .sheet[hidden] { display: none; }  /* actually hide when JS closes it */

  /* Dark themed scrollbar for the result card's internal scroll. The actual
     scroller is .sheet-body (flex child), so style both to be safe. */
  #result-sheet,
  #result-sheet .sheet-body {
    scrollbar-width: thin;
    scrollbar-color: var(--hairline) transparent;
  }
  #result-sheet::-webkit-scrollbar,
  #result-sheet .sheet-body::-webkit-scrollbar { width: 6px; }
  #result-sheet::-webkit-scrollbar-thumb,
  #result-sheet .sheet-body::-webkit-scrollbar-thumb { background: var(--hairline); border-radius: 3px; }
  #result-sheet::-webkit-scrollbar-track,
  #result-sheet .sheet-body::-webkit-scrollbar-track { background: transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .sheet { transition: none; }
  .faq-a, .faq-chevron { transition: none; }
  .loader-bar span, .skeleton { animation: none; }
}

/* ── /drive driver result (spec v3 — appended; rider styles above untouched) ──
   The card now reuses the rider .sheet chrome (#drive-result has class .sheet),
   so background/border/handle/peek/body styling is inherited. Only positioning
   (left panel desktop / 3-snap sheet mobile, mirroring #result-sheet) and the
   driver-specific content blocks live here. */

/* Explicit hide: .sheet sets display:flex on desktop, which (author origin)
   beats the UA [hidden] rule. The card is empty until a search runs, so without
   this an empty handle bar would peek through on first load. id+attr specificity
   beats .sheet, so this holds at both breakpoints. */
#drive-result[hidden] { display: none; }

/* Mobile: 3-snap persistent bottom sheet — identical mechanics to #result-sheet. */
@media (max-width: 768px) {
  #drive-result {
    height: var(--snap-full);
    display: flex;
    flex-direction: column;
  }

  #drive-result.open[data-snap="full"] { transform: translateX(-50%) translateY(0); }
  #drive-result.open[data-snap="half"] {
    transform: translateX(-50%) translateY(calc(var(--snap-full) - var(--snap-half)));
  }
  #drive-result.open[data-snap="peek"] {
    transform: translateX(-50%) translateY(calc(var(--snap-full) - var(--snap-peek)));
  }

  #drive-result .sheet-peek { touch-action: none; }
  #drive-result .sheet-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Desktop: static left panel below the search card. The driver form is shorter
   than the rider's (2 fields + button, no time pickers), so the panel starts
   higher than the rider's 320px — ~210px clears the input card with a ~20px gap. */
@media (min-width: 769px) {
  #drive-result {
    left: 20px;
    top: 210px;
    bottom: auto;
    width: 380px;
    max-width: 380px;
    max-height: calc(100vh - 230px);
    overflow-y: auto;
    z-index: 20; /* at/below the input card (30) so inputs stay reachable */
  }
  #drive-result,
  #drive-result .sheet-body {
    scrollbar-width: thin;
    scrollbar-color: var(--hairline) transparent;
  }
  #drive-result::-webkit-scrollbar,
  #drive-result .sheet-body::-webkit-scrollbar { width: 6px; }
  #drive-result::-webkit-scrollbar-thumb,
  #drive-result .sheet-body::-webkit-scrollbar-thumb { background: var(--hairline); border-radius: 3px; }
  #drive-result::-webkit-scrollbar-track,
  #drive-result .sheet-body::-webkit-scrollbar-track { background: transparent; }
}

/* Peek summary amounts: equal size for both; the secondary (net · full car) is
   de-emphasized via opacity, not a smaller size. Scoped to #drive-result so the
   rider page's 44px/30px peek metrics are untouched (id beats the .metric-*
   class rules above). Labels keep their inherited styling. */
#drive-result .peek-summary .metric-value { font-size: 36px; }
#drive-result .peek-summary .metric-cost .metric-value { opacity: 0.65; }

.dc-hero { margin: 14px 0 6px; }
.dc-hero h1 { font-size: 20px; line-height: 1.25; font-weight: 600; margin: 0 0 6px; color: var(--text); }
.dc-hero p { font-size: 14px; line-height: 1.5; color: var(--muted); margin: 0; }
.dc-fellow { margin: 12px 0; }
.dc-density { font-size: 14px; line-height: 1.5; color: var(--text); margin: 12px 0; }
.dc-density strong { color: var(--positive-text); }
.dc-notyet-lead { font-size: 14px; line-height: 1.5; color: var(--text); margin: 12px 0; }

/* Earnings table — tiers as COLUMNS, metrics as ROWS. Four columns (label + 3
   tiers) fit the 380px panel with no horizontal scroll; the prior six-across
   layout clipped the "After financed" column. */
.dc-tiers-wrap { margin: 14px 0 8px; }
table.dc-tiers { width: 100%; border-collapse: collapse; font-size: 13px; }
table.dc-tiers th, table.dc-tiers td { padding: 8px 4px; text-align: right; border-bottom: 1px solid var(--hairline); }
table.dc-tiers thead th { color: var(--muted); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; }
table.dc-tiers tbody th[scope="row"] { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; white-space: nowrap; }
table.dc-tiers .dc-net { color: var(--positive-text); }
table.dc-tiers .dc-fee { color: var(--muted); }
.dc-pos { color: var(--positive-text); }
.dc-neg { color: var(--dest); }

.dc-qualifier { font-size: 12px; font-style: italic; color: var(--muted); margin: 2px 0 12px; }
.dc-how { margin: 16px 0 12px; }
.dc-how h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); font-weight: 600; margin: 0 0 6px; }
.dc-how p { font-size: 14px; line-height: 1.5; color: var(--muted); margin: 0; }
.dc-cta { margin-top: 8px; }

/* ── Reciprocal nav footer (shared by rider + driver pages) ── */
.page-foot {
  background: var(--ink);
  padding: 0 16px 56px;
  text-align: center;
}
.cross-link {
  display: inline-block;
  min-height: 44px;
  padding: 11px 4px;
  color: var(--positive-text);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
}
.cross-link:hover { text-decoration: underline; }
.cross-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

/* ── Rider search-card hero + driver teaser (rider page) ── */
.search-hero { margin: 2px 2px 12px; }
.search-hero h1 {
  margin: 0 0 6px;
  font-size: 20px;
  line-height: 1.25;
  font-weight: 600;
  color: var(--text);
}
.search-hero p {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
}
/* Driver teaser: its own white pill in the search-card stack, directly beneath
   the CTA. Without a surface the bare <p> floated over the basemap labels — it
   matches the field pills (panel/hairline/radius/elevation) so it reads as part
   of the card, never over the map. Same 10px stack rhythm as the controls. */
.drive-teaser {
  margin: 10px 0 0;
  padding: 11px 16px;
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  box-shadow: var(--shadow-elev);
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}
.drive-teaser .cross-link { font-size: 14px; }
@media (max-width: 768px) {
  .search-hero h1 { font-size: 18px; }     /* ≥18px on mobile */

  /* MOBILE-HERO-CARD: wrap the whole search stack in ONE white card (Uber/Lyft
     pattern) so the hero never renders bare over the map. Mobile-only — desktop
     (.rider ≥769px) and /drive get no .search background. Position/width come
     from the base .search rule (unchanged), so the overlay stays put and doesn't
     grow into the peek sheet. box-sizing:border-box keeps padding inside width. */
  .search {
    background: var(--panel);
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    box-shadow: var(--shadow-elev);
    padding: 14px;
  }
  /* Flatten the inner controls so the stack reads as one card, not pills floating
     on a card — drop their elevation; hairline borders still define the inputs,
     the green CTA stays distinct by color. */
  .search-field,
  .find-btn { box-shadow: none; }
  /* Teaser merges into the card: it only had its own pill (B-1) to avoid floating
     bare on the map — now the card is that surface, so it's plain text here. */
  .drive-teaser {
    background: none;
    border: none;
    box-shadow: none;
    padding: 0;
  }

  /* M-1: matched-state input collapse (mobile mirror of desktop R-1). On a
     successful match collapseInputs() adds .collapsed (breakpoint-agnostic — only
     desktop styled it before). Replace the full input card with the summary chip
     at the SAME top position/inset: strip the outer hero-card chrome so the chip's
     own card is the single surface (no card-in-card), and give the chip the card's
     elevation so it still floats over the map. Scoped to .rider so /drive (which
     never collapses) is frozen. "Edit" (#summary-edit → expandInputs) removes
     .collapsed and restores the full stack. */
  .rider .search.collapsed > :not(.search-summary) { display: none; }
  .rider .search.collapsed {
    background: none;
    border: none;
    box-shadow: none;
    padding: 0;
  }
  .rider .search.collapsed .search-summary {
    display: flex;
    box-shadow: var(--shadow-elev);
  }
  /* Narrow-width tuning: route/meta ellipsis rather than wrap or shove Edit off-row. */
  .rider .search.collapsed .summary-main { flex: 1; min-width: 0; }
  .rider .search.collapsed .summary-route,
  .rider .search.collapsed .summary-meta {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
