/* Kickstand. Type: Big Shoulders Display (drawn for the City of Chicago) for the name and
   numbers, Overpass (from US highway signage) for everything you read. Colour is reserved
   for meaning: lanes run green (separated) through gold and orange to red (paint only),
   crimson is crashes, violet is theft, grey is traffic. */

:root {
  --ink: #0e1a2b;
  --ink-soft: #4d596a;
  --ink-faint: #7b8594;
  --paper: #ffffff;
  --mist: #eef0ee;
  --rule: #d9dedb;
  --focus: #1b3fd8;
  --theft: #6a2fb8;
  --crash: #9f1239;
  --flag-red: #e4002b;
  --hover: #f7f8f7;
  --handle: #c3cac6;
  --note: #8a4f0b;
  --primary-hover: #24344d;
  --banner: #0e1a2b; /* the ride banner stays dark by day and night */
  --tag-calm: #1d6b3f; --tag-calm-bg: #e2f1e7;
  --tag-fast: #24519e; --tag-fast-bg: #e3ebf8;

  --display: 'Big Shoulders Display', 'Arial Narrow', sans-serif;
  --text: 'Overpass', system-ui, sans-serif;

  --panel-width: 392px;
  --gutter: 22px;
}

/* Night: dark surfaces, light text, and the accent colours lifted so they read on dark. */
:root[data-theme='dark'] {
  color-scheme: dark;
  --ink: #e6ebf1;
  --ink-soft: #aab4c1;
  --ink-faint: #7d8898;
  --paper: #161e28;
  --mist: #1f2833;
  --rule: #2d3744;
  --focus: #6ea0ff;
  --theft: #b08cf0;
  --crash: #e8618a;
  --hover: #1c2530;
  --handle: #3a4553;
  --note: #d49a4e;
  --primary-hover: #ffffff;
  --banner: #0b1118;
  --tag-calm: #7fd6a3; --tag-calm-bg: #183326;
  --tag-fast: #9dbcff; --tag-fast-bg: #1b2a44;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  font-family: var(--text);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--mist);
  -webkit-font-smoothing: antialiased;
}

h1, h2, p, ul, ol { margin: 0; padding: 0; }
ul, ol { list-style: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* ------------------------------------------------------------ layout */

.app {
  display: grid;
  grid-template-columns: var(--panel-width) 1fr;
  height: 100dvh;
}

.panel {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--paper);
  border-right: 1px solid var(--rule);
}

.panel__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.panel__body > * { padding: 0 var(--gutter); }

.map { min-width: 0; min-height: 0; }

.sheet-top, .sheet-handle, .sheet-peek { display: none; }

/* ------------------------------------------------------------ masthead */

.masthead { padding-top: 22px; padding-bottom: 18px; }

.wordmark {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--display);
  font-weight: 800;
  font-size: 46px;
  line-height: 0.95;
  letter-spacing: 0.005em;
  text-transform: uppercase;
}

.wordmark__city { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: none; }
.wordmark__stars { width: 92px; height: 20px; fill: var(--flag-red); flex: none; }
.wordmark__city-name { font-size: 15px; font-weight: 700; letter-spacing: 0.28em; margin-right: -0.28em; color: var(--ink-soft); }

.masthead__lede { margin-top: 8px; color: var(--ink-soft); max-width: 34ch; }

/* ------------------------------------------------------------ trip form */

.trip { position: relative; padding-bottom: 18px; }

.field { position: relative; }
.field + .field { margin-top: 8px; }

.field label {
  display: block;
  margin-bottom: 3px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}

.field__row {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 6px 0 12px;
  background: var(--mist);
  border: 1.5px solid transparent;
  border-radius: 4px;
}

.field__row:focus-within { background: var(--paper); border-color: var(--ink); }

.field__dot { flex: none; width: 12px; height: 12px; border-radius: 50%; border: 3px solid var(--ink); }
.field__dot--to { background: var(--ink); }

.field input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: none;
  outline: none;
  text-overflow: ellipsis;
}

.field input::placeholder { color: var(--ink-faint); }

.icon-button {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--ink-soft);
}

.icon-button:hover { background: var(--rule); color: var(--ink); }
.icon-button:disabled { opacity: 0.4; cursor: progress; }
.icon-button svg { width: 18px; height: 18px; }

.suggestions {
  position: absolute;
  z-index: 5;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: 4px;
  box-shadow: 0 10px 24px rgb(14 26 43 / 0.16);
  overflow: hidden;
}

.suggestions li { padding: 9px 12px; }
.suggestions li[role='option'] { cursor: pointer; }
.suggestions li[role='option']:hover,
.suggestions li[aria-selected='true'] { background: var(--mist); }
.suggestions li + li { border-top: 1px solid var(--rule); }
.suggestions__main { display: block; font-weight: 600; }
.suggestions__sub, .suggestions__note { display: block; font-size: 13px; color: var(--ink-soft); }

/* ------------------------------------------------------------ route options */

.routes { padding-top: 18px; padding-bottom: 6px; border-top: 1px solid var(--rule); }

.routes__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }

h2 { font-size: 15px; font-weight: 700; line-height: 1.3; }

.text-button {
  flex: none;
  padding: 0;
  border: 0;
  background: none;
  font-size: 13px;
  color: var(--ink-soft);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.text-button:hover { color: var(--ink); }

.status { margin-top: 8px; font-size: 14px; color: var(--ink-soft); }

.options { margin: 12px calc(var(--gutter) * -1) 0; }

.option {
  position: relative;
  display: block;
  padding: 12px var(--gutter) 13px;
  border-top: 1px solid var(--rule);
  cursor: pointer;
}

.option:last-child { border-bottom: 1px solid var(--rule); }
.option:hover { background: var(--hover); }

.option input { position: absolute; opacity: 0; pointer-events: none; }

/* The chosen option gets a solid bar on its left edge, like a lane line. */
.option::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--ink);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 120ms ease-out;
}

.option:has(input:checked) { background: var(--mist); }
.option:has(input:checked)::before { transform: scaleX(1); }
.option:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: -2px; }

.option__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }

.option__name { font-weight: 700; font-size: 16px; }

/* The list runs edge to edge for the cards; the empty note keeps the panel's margins. */
.options__empty { margin: 0; padding: 0 var(--gutter); font-size: 14px; color: var(--ink-soft); }
.option__tags { display: flex; gap: 6px; margin-top: 4px; }
.tag {
  font-size: 11px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  padding: 2px 6px; border-radius: 4px;
}
.tag--calmest { color: var(--tag-calm); background: var(--tag-calm-bg); }
.tag--fastest { color: var(--tag-fast); background: var(--tag-fast-bg); }
.tag--least-traffic { color: var(--tag-calm); background: var(--tag-calm-bg); }
.tag--yours { color: var(--paper); background: var(--focus); }

.option__numbers { display: flex; align-items: baseline; gap: 10px; font-family: var(--display); }

.option__time { font-size: 30px; font-weight: 800; line-height: 1; letter-spacing: 0.01em; }
.option__unit { font-size: 17px; font-weight: 600; }
.option__distance { font-size: 17px; font-weight: 600; color: var(--ink-soft); }

/* The ride drawn as a strip, start to finish, coloured by what you are riding on. */
.ribbon {
  display: flex;
  height: 12px;
  margin-top: 9px;
  border-radius: 2px;
  overflow: hidden;
  background: var(--rule);
}

.ribbon span { flex-basis: 0; min-width: 1px; }

.option__facts { display: block; margin-top: 8px; font-size: 13px; color: var(--ink-soft); }
.option__facts span { display: block; }

/* A brown dot, like the dotted line marking local notes on the map. */
.option__facts .fact--note { color: var(--note); }
.option__facts .fact--note::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--note);
  vertical-align: 1px;
}

/* The same warning triangle that marks these crossings on the map. */
.option__facts .fact--hazard::before {
  content: '';
  display: inline-block;
  width: 12px;
  height: 11px;
  margin-right: 6px;
  vertical-align: -1px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 22'%3E%3Cpath d='M12 2 22 20H2z' fill='%23ffd23f' stroke='%230e1a2b' stroke-width='2.5' stroke-linejoin='round'/%3E%3Cpath d='M12 8v6' stroke='%230e1a2b' stroke-width='2.5'/%3E%3Ccircle cx='12' cy='17' r='1.4' fill='%230e1a2b'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* ------------------------------------------------------------ trip detail */

.detail { padding-top: 16px; padding-bottom: 4px; }

.lockup { padding: 14px 16px 15px; background: var(--mist); border-radius: 4px; }
.lockup p { margin-top: 6px; font-size: 14px; color: var(--ink-soft); }
.lockup strong { color: var(--ink); }
.lockup__theft--high strong { color: var(--theft); }

.steps { margin-top: 12px; }

.steps summary {
  padding: 8px 0;
  font-weight: 700;
  cursor: pointer;
}

.step {
  display: grid;
  grid-template-columns: 6px 1fr auto;
  gap: 12px;
  padding: 9px 6px 9px 0;
  border-top: 1px solid var(--rule);
  font-size: 14px;
  cursor: pointer;
}

.step:hover { background: var(--hover); }
.step__mark { border-radius: 3px; }
/* Walking the bike: dots, like the dotted line on the map. */
.step__mark--walk { background: radial-gradient(circle, var(--ink) 2px, transparent 2.5px) center top / 6px 7px repeat-y; }
.step__kind { display: block; font-size: 13px; color: var(--ink-faint); }
.step__distance { color: var(--ink-soft); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ------------------------------------------------------------ map key */

.key { margin-top: 18px; padding-top: 18px; padding-bottom: 8px; border-top: 1px solid var(--rule); }

.key__rule { margin-top: 5px; font-size: 14px; color: var(--ink-soft); }

.key__list { margin-top: 10px; }
.key__list--places { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--rule); }

.key__row label {
  display: grid;
  grid-template-columns: 18px 44px 1fr;
  align-items: start;
  gap: 10px;
  padding: 6px 0;
  cursor: pointer;
}

.key__row input {
  appearance: none;
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  border: 1.5px solid var(--ink);
  border-radius: 3px;
  background: var(--paper);
  cursor: pointer;
}

.key__row input:checked {
  background: var(--ink) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.4l3 3 6-6.6' fill='none' stroke='white' stroke-width='2'/%3E%3C/svg%3E") center / 14px no-repeat;
}

.key__row label:has(input:not(:checked)) .swatch,
.key__row label:has(input:not(:checked)) .key__text { opacity: 0.45; }

.swatch { display: block; width: 44px; height: 12px; margin-top: 4px; }

.swatch--racks {
  width: 12px; height: 12px; justify-self: center;
  border: 2px solid var(--ink); border-radius: 50%; background: var(--paper);
}

.swatch--thefts {
  height: 14px; margin-top: 3px; border-radius: 7px;
  background: radial-gradient(closest-side, rgb(72 28 140 / 0.85), rgb(160 122 224 / 0.35) 70%, rgb(160 122 224 / 0));
}

/* A wedge from light grey to ink: more traffic, darker and thicker. */
.swatch--traffic {
  height: 10px; margin-top: 5px;
  background: linear-gradient(90deg, #c4cad2, #6b7584 45%, #0e1a2b);
  clip-path: polygon(0 40%, 100% 0, 100% 100%, 0 60%);
}

.swatch--arrows {
  height: 12px; margin-top: 4px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 44 12'%3E%3Cg fill='none' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 2l6 4-6 4' stroke='%235d6878'/%3E%3Cpath d='M22 6h16 M25 3l-3 3 3 3 M35 3l3 3-3 3' stroke='%232a9a55'/%3E%3C/g%3E%3C/svg%3E") left center / 44px 12px no-repeat;
}

.swatch--notes {
  height: 6px; margin-top: 7px;
  background: radial-gradient(circle, var(--note) 2.2px, transparent 2.6px) left center / 9px 6px repeat-x;
}

.swatch--hotspots {
  width: 16px; height: 16px; margin-top: 2px; justify-self: center;
  border: 1.5px solid var(--paper); border-radius: 50%; background: #b3274f;
  box-shadow: 0 0 0 1px rgb(14 26 43 / 0.15);
}

.swatch--crashes {
  width: 6px; height: 6px; margin-top: 7px; justify-self: center;
  border-radius: 50%; background: var(--crash); opacity: 0.8;
}

.key__label { display: block; font-weight: 600; line-height: 1.35; }
.key__hint { display: block; font-size: 13px; color: var(--ink-soft); }

.sources { padding-top: 14px; padding-bottom: 26px; font-size: 12.5px; color: var(--ink-faint); border-top: 1px solid var(--rule); margin-top: 10px; }
.sources p + p { margin-top: 6px; }

/* ------------------------------------------------------------ on the map */

.pin { cursor: grab; }

.pin--from {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--paper); border: 6px solid var(--ink);
  box-shadow: 0 0 0 2px var(--paper);
}

/* A teardrop: a circle with one square corner, turned to point down. */
.pin--to { width: 26px; height: 26px; }
.pin--to::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--ink);
  border: 2px solid var(--paper);
  border-radius: 50% 50% 0 50%;
  transform: translateY(-4px) rotate(45deg);
  box-shadow: inset 0 0 0 6px var(--ink), inset 0 0 0 20px var(--paper);
}

/* A smaller, quieter teardrop than the trip's end pin: a spot you're looking at, not a choice yet. */
.pin--probe { width: 18px; height: 18px; pointer-events: none; }
.pin--probe::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--ink-soft);
  border: 2px solid var(--paper);
  border-radius: 50% 50% 0 50%;
  transform: translateY(-3px) rotate(45deg);
  box-shadow: 0 1px 4px rgb(14 26 43 / 0.35);
}

.map-area { position: relative; min-width: 0; min-height: 0; }
.map-area .map { position: absolute; inset: 0; }

/* Floats over the map's top-left corner while a route is showing. */
.map-clear {
  position: absolute;
  z-index: 3;
  top: 12px;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 14px 0 10px;
  border: 1.5px solid var(--ink);
  border-radius: 20px;
  background: var(--paper);
  font-weight: 700;
  box-shadow: 0 2px 8px rgb(14 26 43 / 0.2);
}

.map-clear svg { width: 16px; height: 16px; }
.map-clear:hover { background: var(--mist); }
.map-clear[hidden], .app--riding .map-clear { display: none; }

/* Drawing your own route: instructions and controls along the top of the map; the usual route
   controls step aside meanwhile. */
.draw-bar {
  position: absolute;
  z-index: 4;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: min(460px, calc(100% - 24px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 8px 8px 14px;
  background: var(--paper);
  color: var(--ink);
  border-radius: 10px;
  box-shadow: 0 2px 10px rgb(0 0 0 / 18%);
}
.draw-bar[hidden] { display: none; }
.draw-bar__text { margin: 0; font-size: 14px; font-weight: 600; }
.draw-bar__buttons { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.draw-bar .button { height: 36px; padding: 0 12px; font-size: 14px; }
.draw-bar .text-button { padding: 8px 6px; font-size: 14px; }
.draw-bar button:disabled { opacity: .4; cursor: default; }
.app--drawing .map-clear, .app--drawing .route-key { display: none; }
.app--drawing .map { cursor: crosshair; }
.app--drawing .maplibregl-canvas { cursor: crosshair; }
@media (max-width: 760px) {
  .draw-bar { flex-direction: column; align-items: stretch; gap: 6px; }
  .draw-bar__buttons { justify-content: flex-end; }
}

.draw-start { display: block; margin: 10px auto 0; font-size: 13px; }
.app--riding .draw-start { display: none; }
.option__verdict { display: block; margin-top: 6px; font-size: 13px; font-weight: 600; color: var(--tag-calm); }
.option__verdict--worse { color: var(--note); }
.sheet-peek .icon-button[hidden] { display: none; }

/* Top left of the map with a route showing: which colours mean what, and a switch between them. */
.route-key {
  position: absolute;
  z-index: 3;
  top: 62px;
  left: 12px;
  width: 196px;
  padding: 8px 10px 9px;
  background: var(--paper);
  border-radius: 8px;
  box-shadow: 0 2px 10px rgb(14 26 43 / 0.2);
  font-size: 13px;
}

.route-key[hidden], .app--riding .route-key { display: none; }

.route-key__switch { display: flex; padding: 2px; background: var(--mist); border-radius: 6px; }
.route-key__switch button {
  flex: 1;
  height: 30px;
  border: 0;
  border-radius: 5px;
  background: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}
.route-key__switch button[aria-pressed='true'] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 3px rgb(14 26 43 / 0.2); }

.route-key__list { margin-top: 8px; display: grid; gap: 3px; }
.route-key__list li { display: flex; align-items: center; gap: 8px; line-height: 1.3; }
.route-key__swatch { flex: none; width: 18px; height: 6px; border-radius: 3px; box-shadow: inset 0 0 0 1px rgb(14 26 43 / 0.15); }
.route-key__tip { margin-top: 7px; font-size: 12px; color: var(--ink-faint); }

/* A tapped stretch of route, made to be read at a glance: a traffic badge, the street, a picture
   of the lane, a speed limit sign and a traffic gauge. */
.seg__top { display: flex; align-items: center; gap: 10px; }
.seg__band {
  padding: 3px 10px 2px;
  border-radius: 12px;
  color: #ffffff;
  font-weight: 700;
  font-size: 14px;
}
.seg__band--light { color: #0e1a2b; } /* dark text on the yellow "some traffic" band */
.seg__size { font-size: 14px; color: var(--ink-soft); }
.seg__street { margin-top: 6px; font-size: 18px; font-weight: 700; line-height: 1.25; }

.seg__facts { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-top: 10px; }
.seg__lanes { display: grid; gap: 6px; }
.seg__lanes li { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; }
.seg__share { font-weight: 400; color: var(--ink-soft); }

.glyph { display: block; flex: none; width: 58px; height: 34px; }
.glyph svg { display: block; width: 100%; height: 100%; }

.seg__signs { display: flex; align-items: flex-end; gap: 14px; flex: none; }

.speed { display: grid; justify-items: center; gap: 2px; font-family: var(--text); }
.speed svg { display: block; width: 34px; height: 42px; font-family: var(--text); }
.speed--assumed svg { opacity: 0.55; }
.speed__caption { font-size: 11px; color: var(--ink-faint); }

.gauge { display: grid; justify-items: center; gap: 4px; }
.gauge__car { width: 22px; height: 15px; }
.gauge__bars { display: flex; align-items: flex-end; gap: 2px; height: 16px; }
.gauge__bars i { display: block; width: 6px; border-radius: 1px; background: var(--rule); }
.gauge__bars i:nth-child(1) { height: 5px; }
.gauge__bars i:nth-child(2) { height: 8px; }
.gauge__bars i:nth-child(3) { height: 12px; }
.gauge__bars i:nth-child(4) { height: 16px; }
.gauge__bars[data-level='1'] i:nth-child(-n+1),
.gauge__bars[data-level='2'] i:nth-child(-n+2),
.gauge__bars[data-level='3'] i:nth-child(-n+3),
.gauge__bars[data-level='4'] i:nth-child(-n+4) { background: var(--ink); }
.gauge__label { font-size: 11px; color: var(--ink-soft); white-space: nowrap; }

.seg__note { margin-top: 8px; font-size: 13px; color: var(--note); }
.seg__caveat { margin-top: 8px; font-size: 13px; color: var(--ink-soft); }

/* Describing a stretch of route: nothing to set as a start or end. */
.place-card--info .place-card__actions { display: none; }

/* Docked to the bottom of the map, clear of wherever you clicked. */
.place-card {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: 36px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  grid-template-areas: 'body actions close';
  align-items: center;
  gap: 8px 16px;
  width: min(560px, calc(100% - 32px));
  padding: 14px 10px 14px 18px;
  transform: translateX(-50%);
  background: var(--paper);
  border-radius: 6px;
  box-shadow: 0 10px 30px rgb(14 26 43 / 0.24);
}

.place-card[hidden] { display: none; }

.place-card__body { grid-area: body; min-width: 0; }
.place-card__title { font-weight: 700; font-size: 16px; line-height: 1.3; }
.place-card__place { font-size: 14px; color: var(--ink-soft); }
.place-card__place:empty { display: none; }
.place-card__note { margin-top: 4px; font-size: 13px; color: var(--ink-soft); }
.place-card__note--theft { color: var(--theft); }

.place-card__actions { grid-area: actions; display: flex; gap: 8px; }
.place-card__close { grid-area: close; align-self: start; margin-left: -8px; }

.button {
  height: 38px;
  padding: 0 14px;
  border: 1.5px solid var(--ink);
  border-radius: 4px;
  background: var(--paper);
  font-weight: 600;
  white-space: nowrap;
}

.button:hover { background: var(--mist); }
.button--primary { background: var(--ink); color: var(--paper); }
.button--primary:hover { background: var(--primary-hover); }

@media (max-width: 560px) {
  .place-card { grid-template-columns: 1fr auto; grid-template-areas: 'body close' 'actions actions'; bottom: 12px; }
  .place-card .button { height: 44px; }
  .place-card__actions .button { flex: 1; }
}

.maplibregl-ctrl-group { border-radius: 4px; box-shadow: 0 1px 4px rgb(14 26 43 / 0.25) !important; }
.maplibregl-ctrl-attrib { font-family: var(--text); font-size: 11px; }

/* ------------------------------------------------------------ ride mode */

/* Stays in view at the bottom of the panel while the route options are on screen. */
.ride-start {
  position: sticky;
  bottom: 0;
  z-index: 1;
  margin: 0 calc(var(--gutter) * -1);
  padding: 12px var(--gutter) 14px;
  background: linear-gradient(transparent, var(--paper) 30%);
}

.ride-start[hidden] { display: none; }
.ride-start .button { width: 100%; height: 50px; font-size: 17px; }

.google-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 8px;
  padding: 6px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  text-decoration: none;
}
.google-link:hover { color: var(--ink); text-decoration: underline; }
.google-link svg { width: 16px; height: 16px; }

.app--riding { grid-template-columns: 1fr; }
.app--riding .panel { display: none; }
.app--riding .maplibregl-ctrl-top-right { display: none; }
/* The "show my location" button, styled like the zoom buttons, pulsing while it looks. */
/* (Scoped to the control group so it wins over MapLibre's own button rule.) */
.maplibregl-ctrl-group .find-me { display: flex; align-items: center; justify-content: center; color: var(--ink); }
.find-me svg { display: block; width: 18px; height: 18px; }
.find-me--looking svg { color: var(--focus); animation: find-me-pulse 1s ease-in-out infinite; }
@keyframes find-me-pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .find-me--looking svg { animation: none; } }

/* A short note over the top of the map. */
.map-message {
  position: absolute;
  z-index: 4;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: min(420px, calc(100% - 120px));
  margin: 0;
  padding: 10px 14px;
  font-size: 14px;
  background: var(--paper);
  color: var(--ink);
  border-radius: 10px;
  box-shadow: 0 2px 10px rgb(0 0 0 / 18%);
}
.map-message[hidden] { display: none; }
.app--riding .maplibregl-ctrl-bottom-right { bottom: calc(92px + env(safe-area-inset-bottom)); }

.ride {
  position: absolute;
  z-index: 4;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}

.ride[hidden] { display: none; }
.ride > * { pointer-events: auto; }

/* Readable at arm's length on a handlebar: big arrow, big distance, the street name in bold. */
.ride__banner {
  display: grid;
  grid-template-columns: 60px 1fr auto;
  align-items: center;
  gap: 14px;
  margin: calc(env(safe-area-inset-top) + 10px) 10px 0;
  padding: 14px 16px;
  background: var(--banner);
  color: #ffffff;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgb(14 26 43 / 0.3);
}

.ride__arrow { width: 60px; height: 60px; color: #ffffff; }
.ride__instruction { min-width: 0; }
.ride__distance { font-family: var(--display); font-weight: 800; font-size: 40px; line-height: 1; }
.ride__text { margin-top: 4px; font-size: 21px; font-weight: 700; line-height: 1.2; }
.ride__then { margin-top: 6px; font-size: 15px; color: rgb(255 255 255 / 0.72); }

.ride__browse { display: flex; gap: 8px; }
.ride__browse[hidden] { display: none; }

.ride__step-button {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1.5px solid rgb(255 255 255 / 0.5);
  border-radius: 50%;
  background: none;
  color: #ffffff;
}

.ride__step-button svg { width: 22px; height: 22px; }

.ride__bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 10px calc(env(safe-area-inset-bottom) + 10px);
  padding: 10px 10px 10px 16px;
  background: var(--paper);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgb(14 26 43 / 0.24);
}

.ride__left { flex: 1; min-width: 0; font-size: 16px; color: var(--ink-soft); }
.ride__notice { display: block; font-size: 14px; line-height: 1.3; }
.ride__left strong { font-family: var(--display); font-size: 28px; font-weight: 800; color: var(--ink); }
.ride__bar .button { height: 48px; font-size: 16px; }
.ride__bar .button[hidden] { display: none; }

/* You, while riding: a flag-red dot with a slow pulse. */
.pin--me {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--flag-red);
  border: 3px solid var(--paper);
  box-shadow: 0 0 0 0 rgb(228 0 43 / 0.5), 0 1px 4px rgb(14 26 43 / 0.4);
  animation: pulse 2s ease-out infinite;
}

@keyframes pulse {
  to { box-shadow: 0 0 0 16px rgb(228 0 43 / 0), 0 1px 4px rgb(14 26 43 / 0.4); }
}

/* ------------------------------------------------------------ small screens: the panel becomes a bottom sheet */

@media (max-width: 760px) {
  :root { --gutter: 16px; }

  /* The sheet's height is set by script as --sheet: collapsed, half, full, or wherever a drag is. */
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr var(--sheet, 50dvh);
    transition: grid-template-rows 220ms ease-out;
  }
  .app--dragging { transition: none; user-select: none; }
  .app--riding { grid-template-rows: 1fr; }

  /* 16px keeps iOS from zooming the page when a field is tapped. */
  .field input { font-size: 16px; }
  /* On a phone a floating button is too easy to hit while panning; the sheet has its own. */
  .map-clear { display: none; }
  .route-key { top: 12px; width: 172px; padding: 6px 8px 7px; font-size: 12px; }
  .route-key__tip { display: none; }
  .field__row { height: 48px; }
  .icon-button { width: 44px; height: 44px; }
  .panel__body { padding-bottom: env(safe-area-inset-bottom); }
  .ride-start { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .ride__distance { font-size: 36px; }
  .ride__text { font-size: 19px; }

  .map-area { grid-row: 1; }

  .panel {
    grid-row: 2;
    border-right: 0;
    border-top: 1px solid var(--rule);
    box-shadow: 0 -6px 20px rgb(14 26 43 / 0.12);
  }

  .sheet-top {
    display: block;
    flex: none;
    touch-action: none; /* the page doesn't scroll while you drag the sheet */
    cursor: grab;
  }
  .app--dragging .sheet-top { cursor: grabbing; }

  .sheet-handle {
    display: grid;
    place-items: center;
    width: 100%;
    height: 28px;
    border: 0;
    background: none;
    cursor: inherit;
  }

  .sheet-handle__bar { width: 44px; height: 5px; border-radius: 3px; background: var(--handle); }

  /* Collapsed: a slim bar with the chosen route and a way to start riding. */
  .app--collapsed .sheet-peek {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 var(--gutter) calc(10px + env(safe-area-inset-bottom));
  }
  .sheet-peek__text { flex: 1; min-width: 0; font-size: 15px; color: var(--ink-soft); }
  .sheet-peek__text strong { font-family: var(--display); font-size: 24px; font-weight: 800; color: var(--ink); }
  .sheet-peek .button { height: 44px; }
  .sheet-peek .button[hidden] { display: none; }
  .app--collapsed .panel__body { display: none; }

  .masthead { padding-top: 2px; padding-bottom: 12px; }
  .wordmark { font-size: 34px; }
  .wordmark__stars { width: 74px; height: 16px; }
  .wordmark__city { gap: 2px; }
  .wordmark__city-name { font-size: 12px; }
  .masthead__lede { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .option::before { transition: none; }
  .pin--me { animation: none; }
}

/* ------------------------------------------------------------ night mode */

.masthead__top { display: flex; align-items: center; gap: 10px; }
.masthead__top .wordmark { flex: 1; }
.theme-toggle svg { width: 20px; height: 20px; }
.about-link { display: grid; place-items: center; color: inherit; }
.about-link svg { width: 20px; height: 20px; }
.theme-toggle__sun, [data-theme='dark'] .theme-toggle__moon { display: none; }
[data-theme='dark'] .theme-toggle__sun { display: block; }

.gauge__car { color: var(--ink); }

/* The tick is dark on the light box at night. */
[data-theme='dark'] .key__row input:checked {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.4l3 3 6-6.6' fill='none' stroke='%23161e28' stroke-width='2'/%3E%3C/svg%3E");
}

/* At night busy streets are drawn light, so the key's wedge runs dark to light. */
[data-theme='dark'] .swatch--traffic { background: linear-gradient(90deg, #3a4452, #8b96a6 45%, #f2f5f8); }

/* The map's own buttons and credits. */
[data-theme='dark'] .maplibregl-ctrl-group { background: var(--paper); }
[data-theme='dark'] .maplibregl-ctrl-group button + button { border-top-color: var(--rule); }
[data-theme='dark'] .maplibregl-ctrl button .maplibregl-ctrl-icon { filter: invert(1); }
[data-theme='dark'] .maplibregl-ctrl-attrib { background: rgb(22 30 40 / 0.85); color: var(--ink-soft); }
[data-theme='dark'] .maplibregl-ctrl-attrib a { color: var(--ink-soft); }
[data-theme='dark'] .maplibregl-ctrl-attrib-button { filter: invert(1); }
