/* SNU Caddy: student map in a strict Uber style.
   One system (see the design rules in docs/ARCHITECTURE.md, "Design"):
   black and white, one grey scale, Inter set tight, 8 px corners, flat lists
   with hairlines, no cards, no pills, one crisp shadow for things that float
   over the map. Colour only where it means something. */

@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src:
    url('../assets/fonts/inter-latin-wght-normal.woff2') format('woff2-variations'),
    url('../assets/fonts/inter-latin-wght-normal.woff2') format('woff2');
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------------------------------------------------------------- Tokens -- */

:root {
  --font: 'Inter Variable', 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  --bg: #ffffff;
  --fg: #000000;
  --text-2: #545454; /* secondary text, 7.4:1 on white */
  --text-3: #757575; /* tertiary text, 4.6:1 on white */
  --line: #e2e2e2; /* hairlines */
  --line-strong: #cbcbcb; /* input borders */
  --fill: #eeeeee; /* secondary buttons, tiles */
  --fill-2: #f6f6f6; /* hover, selected row */
  --map-bg: #f6f6f4;
  --focus: #276ef1;
  --float: 0 1px 3px rgba(0, 0, 0, 0.2); /* the one shadow: things over the map */

  /* Caddy states. Colour is never the only signal: each state has a word. */
  --state-moving: #048a4a;
  --state-parked: #276ef1;
  --state-charging: #7356bf; /* 5.5:1 on white */
  --state-lost: #c26a00;
  --state-offline: #808080;
  --error-text: #c41700; /* 6.0:1 on white */

  --caddy-body: #000000;
  --caddy-outline: #ffffff;
  --caddy-roof: #4b4b4b;
  --caddy-glass: #bdbdbd;
  --caddy-wheel: #000000;

  --mask-fill: #000000;
  --mask-opacity: 0.07;
  --outline: #000000;
  --outline-opacity: 0.3;

  --bar-h: 56px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --sheet-visible: 0px; /* set by sheet.js */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  color-scheme: light;
}

/* Dark: pure black surfaces (OLED pixels off). */
:root[data-theme='dark'] {
  --bg: #000000;
  --fg: #ffffff;
  --text-2: #afafaf;
  --text-3: #8f8f8f;
  --line: #2a2a2a;
  --line-strong: #444444;
  --fill: #1f1f1f;
  --fill-2: #141414;
  --map-bg: #0e0e0e;
  --float: 0 1px 3px rgba(0, 0, 0, 0.8);

  --error-text: #ff5a4f; /* 6.8:1 on black */

  --state-moving: #06c167;
  --state-charging: #a58df0; /* 7.7:1 on black */
  --state-lost: #ffc043; /* the same amber as the driver screen's warnings */
  --state-offline: #9e9e9e;

  --caddy-body: #ffffff;
  --caddy-outline: #000000;
  --caddy-roof: #c9c9c9;
  --caddy-glass: #5a5a5a;
  --caddy-wheel: #ffffff;

  --mask-opacity: 0.45;
  --outline: #ffffff;
  --outline-opacity: 0.35;

  color-scheme: dark;
}

/* ------------------------------------------------------------------ Base -- */

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

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

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

body {
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 16px;
  line-height: 22px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
}

: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;
}

/* Wordmark: the brand is the name, set bold and tight. */
.wordmark {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  line-height: 24px;
  letter-spacing: -0.03em;
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
  /* Fast repeated taps (hidden driver setup) must not zoom the page. */
  touch-action: manipulation;
}

/* Icons: solid geometry, 2 px strokes, square ends. */
.icon {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: square;
  stroke-linejoin: miter;
}

.icon .fill {
  fill: currentColor;
  stroke: none;
}

/* --------------------------------------------------------------- Buttons -- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 48px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  line-height: 20px;
  cursor: pointer;
}

.btn--primary {
  background: var(--fg);
  color: var(--bg);
}

.btn--secondary {
  background: var(--fill);
  color: var(--fg);
}

.btn:active {
  opacity: 0.85;
}

/* Busy: aria-disabled keeps keyboard focus (a disabled button would drop it). */
.btn[aria-disabled='true'] {
  opacity: 0.5;
  cursor: progress;
}

.link-btn {
  padding: 8px 0;
  border: 0;
  background: none;
  color: var(--fg);
  font-size: 14px;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* ------------------------------------------------------------------- Map -- */

#map {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: var(--map-bg);
}

/* The map fills the screen and its tiles cover an inside outline, so the ring
   is drawn above the map panes, and only after Tab (main.js sets .kbd). */
#map:focus-visible {
  outline: none;
}

/* The ring goes round the part of the map that is in view (between the top
   bar and the sheet; right of the panel on wide screens). */
.kbd #map:focus-visible::after {
  content: '';
  position: absolute;
  inset: calc(var(--safe-top) + var(--bar-h)) 0 var(--sheet-visible) 0;
  z-index: 1000;
  border: 3px solid var(--focus);
  pointer-events: none;
}

.leaflet-container {
  font-family: var(--font);
  background: var(--map-bg);
}

/* No-key fallback: grey OSM tiles (light) and inverted grey tiles (dark). */
.tiles-fallback .leaflet-tile-pane {
  filter: grayscale(1) contrast(0.9) brightness(1.05);
}

:root[data-theme='dark'] .tiles-fallback .leaflet-tile-pane {
  filter: grayscale(1) invert(1) brightness(0.8) contrast(1.15);
}

.campus-mask {
  fill: var(--mask-fill);
  fill-opacity: var(--mask-opacity);
}

.campus-outline {
  stroke: var(--outline);
  stroke-opacity: var(--outline-opacity);
}

/* Attribution stays readable just above the bottom sheet. */
.leaflet-bottom {
  bottom: calc(var(--sheet-visible) + var(--safe-bottom));
}

/* Slide with the sheet when it snaps; follow it at once when it is dragged
   or its content changes (sheet.js sets the class). */
.sheet-animating .leaflet-bottom,
.sheet-animating .map-btn {
  transition: bottom 0.32s var(--ease);
}

.leaflet-control-attribution.leaflet-control {
  margin: 0;
  padding: 0 6px;
  border-radius: 0;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  color: var(--text-2);
  font-size: 10px;
  line-height: 16px;
}

.leaflet-control-attribution a {
  color: inherit;
}

/* Map button: frames the whole campus. White square, the one shadow. */
.map-btn {
  position: fixed;
  right: calc(16px + var(--safe-right));
  bottom: calc(var(--sheet-visible) + var(--safe-bottom) + 28px);
  z-index: 800;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
  box-shadow: var(--float);
  cursor: pointer;
}

/* Sheet at full: the button would sit under the top bar. */
.sheet-full .map-btn {
  visibility: hidden;
}

.map-btn:active {
  background: var(--fill);
}

/* On the dark map a shadow cannot be seen: a hairline separates the button. */
:root[data-theme='dark'] .map-btn {
  box-shadow: 0 0 0 1px var(--line-strong);
}

/* --------------------------------------------------------------- Top bar -- */

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: calc(var(--bar-h) + var(--safe-top));
  padding: var(--safe-top) calc(var(--safe-right) + 8px) 0 calc(var(--safe-left) + 16px);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 40px;
  height: 40px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--fg);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.icon-btn:active {
  background: var(--fill);
}

@media (hover: hover) {
  .icon-btn:hover {
    background: var(--fill);
  }
}

/* Theme button: shows the icon of the current mode. */
#theme-btn .icon {
  display: none;
}

:root[data-theme-mode='auto'] #theme-btn .icon--auto,
:root[data-theme-mode='light'] #theme-btn .icon--light,
:root[data-theme-mode='dark'] #theme-btn .icon--dark {
  display: block;
}

/* --------------------------------------------------------------- Snackbar -- */

/* Idle pause. Any touch resumes (main.js); the button itself works too. */
.snackbar {
  position: fixed;
  top: calc(var(--safe-top) + var(--bar-h) + 8px);
  left: calc(var(--safe-left) + 16px);
  right: calc(var(--safe-right) + 16px);
  z-index: 1000;
  max-width: 480px;
  margin: 0 auto;
  padding: 14px 16px;
  border: 0;
  border-radius: 8px;
  background: var(--fg);
  color: var(--bg);
  box-shadow: var(--float);
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  text-align: left;
  cursor: pointer;
}

/* ---------------------------------------------------------- Bottom sheet -- */

/* Phones: edge to edge, 12 px top corners, a hairline and the one shadow. */
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 900;
  display: flex;
  flex-direction: column;
  max-width: 600px;
  margin: 0 auto;
  overflow: hidden;
  border-top: 1px solid var(--line);
  border-radius: 12px 12px 0 0;
  background: var(--bg);
  box-shadow: var(--float);
  will-change: transform;
}

.sheet.is-animating {
  transition: transform 0.32s var(--ease);
}

.sheet__grab {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 24px;
  padding: 0;
  border: 0;
  background: none;
  cursor: grab;
  touch-action: none;
}

.sheet__handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--line-strong);
}

.sheet__header {
  display: flex;
  flex: none;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 0 16px 12px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.sheet__title {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  line-height: 30px;
  letter-spacing: -0.02em;
}

/* Titles that take focus for screen readers (student-gate.js); not controls. */
.sheet__title:focus,
.gate__title:focus {
  outline: none;
}

.sheet__summary {
  margin: 2px 0 0;
  color: var(--text-2);
  font-size: 14px;
  line-height: 20px;
}

.sheet__body {
  flex: 1 1 auto;
  padding: 0 0 calc(16px + var(--safe-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Below full, a swipe on the list moves the sheet (like Uber / Google Maps);
   at full, the list scrolls. */
.sheet:not(.is-full) .sheet__body {
  overflow-y: hidden;
  touch-action: none;
}

/* Demo switch: a plain label and a standard switch. */
.switch {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 8px;
  height: 40px;
  margin-top: -4px;
  padding: 0;
  border: 0;
  background: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.switch__track {
  position: relative;
  width: 40px;
  height: 24px;
  border-radius: 12px;
  background: var(--line-strong);
  transition: background 0.2s;
}

.switch__thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 0.2s var(--ease);
}

.switch[aria-checked='true'] .switch__track {
  background: var(--fg);
}

.switch[aria-checked='true'] .switch__thumb {
  transform: translateX(16px);
  background: var(--bg);
}

/* Caddy list: flat rows, hairlines inset to the text column. */
.list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.list li + li .row::before {
  content: '';
  position: absolute;
  top: 0;
  left: 72px;
  right: 0;
  border-top: 1px solid var(--line);
}

.row {
  position: relative;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  width: 100%;
  min-height: 72px;
  padding: 12px 16px;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

/* Hover only where a pointer really hovers (a phone would keep it after a tap). */
@media (hover: hover) {
  .row:hover {
    background: var(--fill-2);
  }
}

.row.is-selected {
  background: var(--fill);
}

/* Full-width controls in a clipped list: draw the focus ring inside. */
.row:focus-visible,
.sheet__grab:focus-visible {
  outline-offset: -3px;
}

/* The caddy drawing on a square grey tile. */
.row__icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--fill);
}

.row.is-selected .row__icon {
  background: var(--bg);
}

.row__icon svg {
  width: 14px;
  height: 21px;
}

.row__main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.row__title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  font-size: 16px;
  font-weight: 500;
  line-height: 22px;
}

.row__title > :first-child {
  flex: none;
}

.row__line,
.row__meta {
  overflow: hidden;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Place and age: up to two lines on narrow screens, so the age is not cut. */
.row__meta {
  display: -webkit-box;
  margin-top: 2px;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.row[data-state='offline'] .row__title {
  color: var(--text-2);
}

/* State: a word with a small dot. Only "Moving" is bold. */
.row__state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  white-space: nowrap;
}

.row__state::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dot);
}

.row[data-state='moving'] .row__state {
  color: var(--fg);
  font-weight: 700;
}

[data-state='moving'] {
  --dot: var(--state-moving);
}

[data-state='parked'] {
  --dot: var(--state-parked);
}

[data-state='charging'] {
  --dot: var(--state-charging);
}

[data-state='lost'] {
  --dot: var(--state-lost);
}

[data-state='offline'] {
  --dot: var(--state-offline);
}

/* Empty list */
.empty {
  padding: 4px 16px 8px;
}

.empty__text {
  margin: 0;
  color: var(--text-2);
  font-size: 14px;
  line-height: 20px;
}

/* --------------------------------------------- Location card + sign-in -- */

/* While the location card shows, it replaces the list. */
.sheet.is-gated .list,
.sheet.is-gated .empty {
  display: none !important;
}

/* Live data is not loaded yet, paused or refused: no "A caddy shows here…". */
.sheet.is-loading .empty {
  display: none;
}

.gate {
  padding: 4px 16px 8px;
}

.gate__title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  line-height: 24px;
  letter-spacing: -0.01em;
}

.gate__text {
  margin: 4px 0 16px;
  color: var(--text-2);
  font-size: 14px;
  line-height: 20px;
}

.gate[data-kind='checking'] .gate__text {
  margin-bottom: 4px;
}

.account {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 16px;
  margin: 16px 16px 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--text-2);
  font-size: 14px;
  line-height: 20px;
}

.account span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Sign-in: the campus map stays in view; the sign-in is a panel over it
   (bottom on phones, within thumb reach; left on wide screens), like the
   caddy sheet. The map behind it is inert (main.js). */
.login {
  position: fixed;
  inset: calc(var(--safe-top) + var(--bar-h)) 0 0;
  z-index: 1500;
  display: flex;
  flex-direction: column;
  overflow-y: auto; /* phone landscape: scroll instead of cutting off */
  color: var(--fg);
}

/* A top auto margin keeps the panel at the bottom, and (unlike flex-end) it
   can still scroll to its top when the screen is short. */
.login__inner {
  width: 100%;
  max-width: 600px;
  margin: auto auto 0;
  padding: 24px calc(var(--safe-right) + 16px) calc(var(--safe-bottom) + 16px)
    calc(var(--safe-left) + 16px);
  border-top: 1px solid var(--line);
  border-radius: 12px 12px 0 0;
  background: var(--bg);
  box-shadow: var(--float);
}

.login__ready {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Until Firebase knows the session: only the map, no flash of the sign-in. */
.login[data-state='loading'] .login__inner {
  display: none;
}

.login__title {
  margin: 0;
  font-size: 32px;
  font-weight: 700;
  line-height: 36px;
  letter-spacing: -0.02em;
}

/* It takes focus when the panel opens (for screen readers); it is not a control. */
.login__title:focus {
  outline: none;
}

.login__text {
  margin: 12px 0 0;
  color: var(--text-2);
  font-size: 16px;
  line-height: 22px;
}

.login__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.login__error {
  margin: 0 0 4px;
  color: var(--error-text);
  font-size: 14px;
  line-height: 20px;
}

.login__error:empty {
  display: none;
}

/* Wide screens: a flush panel on the left, like the caddy panel. */
@media (min-width: 768px) {
  /* Same column as the caddy panel: text at 16 px, from the top. */
  .login__inner {
    width: 400px;
    min-height: 100%;
    margin: 0;
    padding: 20px 16px calc(var(--safe-bottom) + 16px) calc(var(--safe-left) + 16px);
    border-top: 0;
    border-right: 1px solid var(--line);
    border-radius: 0;
    box-shadow: none;
  }
}

/* ------------------------------------------------ Driver-phone setup -- */

.enroll {
  width: min(100% - 24px, 420px);
  max-height: calc(100% - 24px);
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: var(--bg);
  color: var(--fg);
}

/* A black dialog on a black page needs an edge. */
:root[data-theme='dark'] .enroll {
  box-shadow: 0 0 0 1px var(--line-strong);
}

.enroll::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

.enroll__inner {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px 16px 16px;
}

.enroll__title {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  line-height: 30px;
  letter-spacing: -0.02em;
}

.enroll__text {
  margin: -8px 0 0;
  color: var(--text-2);
  font-size: 14px;
  line-height: 20px;
}

.enroll__scan {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1;
  border-radius: 8px;
  background: #000000;
}

.enroll__scan video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.enroll__frame {
  position: absolute;
  inset: 18%;
  border: 2px solid #ffffff;
  border-radius: 8px;
}

.enroll__field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
}

.enroll__field input {
  height: 48px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 16px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* Inputs on every page: a black border and ring, not the blue button ring. */
.enroll__field input:focus-visible,
.field input:focus-visible,
.field select:focus-visible {
  border-color: var(--fg);
  outline: 2px solid var(--fg);
  outline-offset: 0;
}

.enroll__status {
  margin: 0;
  color: var(--text-2);
  font-size: 14px;
  line-height: 20px;
}

/* Empty: no extra gap between the code field and the buttons. It stays
   rendered (a status region must exist to be read). */
.enroll__status:empty {
  margin-top: -16px;
}

.enroll__status[data-state='error'] {
  color: var(--error-text);
}

.enroll__status[data-state='ok'] {
  color: var(--fg);
  font-weight: 500;
}

.enroll__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* ----------------------------------------------------------- Caddy icons -- */

.caddy-marker {
  border-radius: 50%;
}

.caddy__body {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  /* The white outline of the drawing separates it from any tile; this crisp
     drop keeps it readable on the dark map too. */
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35));
  transition: transform 0.45s cubic-bezier(0.3, 0.7, 0.3, 1);
}

.caddy__body svg {
  width: 22px;
  height: 33px;
  overflow: visible;
}

.cart-body {
  fill: var(--caddy-body);
  stroke: var(--caddy-outline);
  stroke-width: 1.5;
}

.cart-roof {
  fill: var(--caddy-roof);
}

.cart-glass {
  fill: var(--caddy-glass);
}

.cart-wheel {
  fill: var(--caddy-wheel);
}

.caddy__badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--dot);
  box-shadow: 0 0 0 2px var(--bg);
}

/* Signal lost: the last known place, dimmed. */
.caddy-marker[data-state='lost'] .caddy__body {
  opacity: 0.45;
}

.caddy-marker[data-state='offline'] {
  --caddy-body: var(--state-offline);
  --caddy-wheel: var(--state-offline);
  --caddy-roof: var(--line-strong);
}

/* Selected: a larger cart, drawn above the others (caddy-layer.js). The
   separate scale property keeps the inline rotate() transform. */
.caddy-marker.is-selected .caddy__body {
  scale: 1.25;
}

/* Same cart drawing in the list rows (no outline needed there). */
.row__icon .cart-body {
  stroke: none;
}

.row[data-state='offline'] {
  --caddy-body: var(--state-offline);
  --caddy-wheel: var(--state-offline);
}

/* ------------------------------------------- Narrow phones (iPhone SE) -- */

@media (max-width: 380px) {
  /* Icon only on small phones; the word stays for screen readers. */
  .icon-btn__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .row {
    gap: 12px;
  }

  .list li + li .row::before {
    left: 68px; /* 16 + 40 + 12: the text column */
  }
}

@media (max-width: 359px) {
  .row__line {
    display: none;
  }
}

/* -------------------------------------------------- Wide screens (pitch) -- */

/* A flush panel on the left, below the top bar, like Uber on the web. */
@media (min-width: 768px) {
  .sheet {
    top: calc(var(--safe-top) + var(--bar-h));
    right: auto;
    bottom: 0;
    left: 0;
    width: 400px;
    max-width: none;
    margin: 0;
    padding-left: var(--safe-left);
    border-top: 0;
    border-right: 1px solid var(--line);
    border-radius: 0;
    box-shadow: none;
    transform: none !important;
    height: auto !important;
  }

  .sheet__grab {
    display: none;
  }

  .sheet__header {
    padding-top: 20px;
    touch-action: auto;
  }

  .sheet__body,
  .sheet:not(.is-full) .sheet__body {
    max-height: none !important;
    overflow-y: auto;
    touch-action: auto;
  }

  .leaflet-bottom {
    bottom: var(--safe-bottom);
  }

  .leaflet-right {
    right: var(--safe-right);
  }

  .map-btn {
    bottom: calc(var(--safe-bottom) + 28px);
  }

  .kbd #map:focus-visible::after {
    left: 400px;
  }
}

/* ------------------------------------------------------------ Misc / a11y -- */

.noscript {
  position: fixed;
  inset: auto 16px 16px;
  z-index: 2000;
  padding: 16px;
  border-radius: 8px;
  background: var(--fg);
  color: var(--bg);
}

@media (prefers-reduced-motion: reduce) {
  .sheet.is-animating,
  .caddy__body,
  .sheet-animating .leaflet-bottom,
  .sheet-animating .map-btn,
  .switch__thumb,
  .switch__track {
    transition: none !important;
  }
}
