/* The ride sheet (P2.22 step 5): docs/design.md "Riding" and the canvas's
   Ride_choose / Ride_riding / Ride_arrived boards (their .rd-*, .mx-* and
   .pv-* rules). The markup is ride-sheet.js's; the sidebar it sits in is
   shell.css's. Same pattern as the bus sheet: a flex column in #sb-body with
   a scrolling middle and a pinned footer.

   --rs-color (the route colour) is set inline on .rs-scroll. The chips and
   the End ride button use the same tokens in both themes, as design.md's
   "Status chips" table says. */

/* ── The sheet's frame ───────────────────────────────────────────────── */
.sb-body.ride-mode { display: flex; flex-direction: column; padding: 0; }
#sidebar.ride-open .sb-header { display: none; }
/* From 600px the panel leaves the same 16px under the navigation card as the
   stop board and the bus sheet. */
@media (min-width: 600px) { .sb-body.ride-mode { margin-top: 16px; } }
/* "Where are you getting off?" has a list to show, and an alert banner takes
   room from the stops: a phone gives the sheet more than the 45vh default
   (the choose board is drawn at about 59%). A dragged height (inline) still
   wins; from 600px the panel fills its height anyway. */
@media (max-width: 599px) { #sidebar.ride-tall { height: 59vh; } }
/* On a short screen (a phone sideways, a small phone with the banner up) the
   whole sheet scrolls rather than squeezing the stops out: the list keeps
   room for two rows, and the fade at its foot shows there is more. */
.sb-body.ride-mode { overflow-y: auto; }

/* ── Header ──────────────────────────────────────────────────────────── */
.rs-head { display: flex; align-items: flex-start; gap: 8px; padding: 0 16px 12px; flex-shrink: 0; }
.rs-head-text { flex: 1; min-width: 0; }
.rs-title { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; color: var(--ink); }
.rs-hs { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rs-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 26px; height: 22px; padding: 0 8px; flex-shrink: 0;
  border-radius: var(--radius-pill); font-size: 12px; font-weight: 800;
}
.rs-meta { font-size: 12px; color: var(--ink-secondary); margin-top: 4px; }
.rs-icon-btn {
  width: 44px; height: 44px; flex-shrink: 0; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: var(--radius-pill); cursor: pointer;
  background: var(--surface-raised); color: var(--ink-secondary);
}

/* ── The alert banner (riding): the leave-now amber ──────────────────── */
.rs-banner {
  margin: 0 16px 12px; padding: 12px 16px; flex-shrink: 0;
  border-radius: var(--radius-button);
  background: var(--chip-warn-bg); color: var(--chip-warn-ink);
}
.rs-banner b { display: block; font-size: 13px; font-weight: 800; }
.rs-banner span { display: block; font-size: 12px; font-weight: 600; margin-top: 4px; }

/* ── The stops: a list to tap (choose) or the stops left (riding) ────── */
.rs-scroll {
  flex: 1 1 auto; min-height: 104px; overflow-y: auto; padding: 0 16px;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 24px), transparent 100%);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 24px), transparent 100%);
}
.rs-scroll::-webkit-scrollbar { display: none; }
.rs-ask { font-size: 15px; font-weight: 700; color: var(--ink); padding: 4px 0 8px; }
.rs-empty { padding: 16px 0; font-size: 13px; color: var(--ink-secondary); }
.rs-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--rs-color, var(--navy)); }
.rs-name { flex: 1; min-width: 0; font-size: 13px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rs-time { font-size: 13px; font-weight: 700; color: var(--ink); white-space: nowrap; }

.rs-pick {
  display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: 44px; padding: 8px 0; box-sizing: border-box;
  border: none; border-bottom: 1px solid var(--line); background: transparent;
  font-family: inherit; text-align: left; cursor: pointer;
}
.rs-pick:hover { background: var(--surface-raised); }
.rs-chev { display: inline-flex; color: var(--ink-muted); }

.rs-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; min-height: 44px; box-sizing: border-box; }
.rs-row .rs-time { font-size: 16px; font-weight: 800; }
/* The stop to get off at: the route colour at 8%, outlined, "Get off" chip. */
.rs-row.rs-sel {
  background: color-mix(in srgb, var(--rs-color, var(--navy)) 8%, transparent);
  border: 1.5px solid var(--rs-color, var(--navy)); border-radius: var(--radius-button);
  padding: 10px 8px; margin: 0 -8px;
}
.rs-chip {
  display: inline-flex; align-items: center; flex-shrink: 0;
  padding: 4px 12px; border-radius: var(--radius-pill);
  background: var(--chip-warn-bg); color: var(--chip-warn-ink);
  font-size: 11px; font-weight: 700; white-space: nowrap;
}

/* On a short screen (a phone sideways) there is no room for the stops before
   the one to get off at: the pinned row, its time in the header and End ride
   stay, the rest of the list is dropped. */
@media (max-height: 480px) { .rs-scroll.rs-list { display: none; } }

/* ── Footer: the GPS line and the buttons ────────────────────────────── */
/* Sticky: when the sheet scrolls (a short screen), End ride stays in reach. */
.rs-foot {
  padding: 12px 16px 16px; flex-shrink: 0; display: flex; flex-direction: column; gap: 8px;
  position: sticky; bottom: 0; background: var(--surface);
}
/* Riding: the stop to get off at and the footer are one pinned group. */
.rs-bottom { flex-shrink: 0; position: sticky; bottom: 0; background: var(--surface); }
.rs-bottom .rs-foot { position: static; margin-top: auto; }
/* Pinned: the group fills what the list leaves, the stop to get off at right
   under the list and the footer at the bottom. */
.rs-bottom.rs-grow { flex: 1 0 auto; display: flex; flex-direction: column; }
.rs-pin { padding: 0 16px; }
.rs-pin .rs-row { margin: 0 -8px; }
/* The list above it takes only what it needs and shrinks first. */
.rs-scroll.rs-list { flex: 0 1 auto; min-height: 56px; }
.rs-share { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-muted); }
.rs-share svg { flex-shrink: 0; }
.rs-danger, .rs-outline {
  width: 100%; min-height: 44px; border-radius: var(--radius-button);
  font-family: inherit; font-size: 13px; cursor: pointer;
}
.rs-danger { border: none; font-weight: 800; background: var(--chip-late-bg); color: var(--chip-late-ink); }
.rs-danger:hover { filter: brightness(.97); }
.rs-outline { font-weight: 700; color: var(--navy); background: var(--surface); border: 1.5px solid #d6dbe2; }
.rs-outline:hover { background: var(--surface-raised); }
body.dark .rs-outline { color: #93c5fd; border-color: var(--line); }

/* ── Arrived ─────────────────────────────────────────────────────────── */
.rs-done {
  margin: 0 16px 12px; padding: 16px; flex-shrink: 0;
  display: flex; gap: 12px; align-items: flex-start;
  border-radius: var(--radius-button);
  background: var(--chip-ok-bg); color: var(--chip-ok-ink);
}
.rs-done svg { flex-shrink: 0; }
.rs-done b { display: block; font-size: 15px; font-weight: 800; }
.rs-done span { display: block; font-size: 13px; font-weight: 600; margin-top: 4px; }
.rs-note { margin: 0; padding: 0 16px; font-size: 12px; color: var(--ink-secondary); }
.rs-spacer { flex: 1; }

/* Keyboard focus, on the route colour's neighbour: the navy ring the rest
   of the app's buttons get. */
.rs-pick:focus-visible, .rs-icon-btn:focus-visible, .rs-danger:focus-visible, .rs-outline:focus-visible {
  outline: 2px solid var(--navy); outline-offset: 2px;
}
body.dark .rs-pick:focus-visible, body.dark .rs-icon-btn:focus-visible,
body.dark .rs-danger:focus-visible, body.dark .rs-outline:focus-visible { outline-color: #93c5fd; }

/* ── The pill: how back to a ride whose sheet is hidden ──────────────────
   Shown only while a ride is on and its sheet is not (ride.js). A 44px
   chip floating on the map, not squeezed into the navigation: on a phone
   centred under it, between zoom and locate; from 600px at the top right of
   the map (locate is at the bottom right there). The tracking green, white
   text 5.0:1; the badge darkens it rather than lightening, to stay above
   4.5:1. */
#ride-pill {
  display: none; align-items: center; gap: 8px;
  position: fixed; z-index: 1001; top: 72px; left: 50%; transform: translateX(-50%);
  max-width: calc(100vw - 160px); min-height: 44px; box-sizing: border-box;
  padding: 0 16px 0 8px; border: none; border-radius: var(--radius-pill);
  background: #15803d; color: #fff; cursor: pointer;
  box-shadow: var(--shadow-map-control);
  font-family: inherit; font-size: 13px; font-weight: 800; white-space: nowrap;
}
#ride-pill.visible { display: inline-flex; }
#ride-pill:hover { background: #166534; }
#ride-pill:focus-visible { outline: 2px solid #fff; outline-offset: 2px; box-shadow: 0 0 0 4px var(--navy); }
#ride-pill .ride-pill-badge {
  background: rgba(0, 0, 0, .28); color: #fff;
  padding: 3px 10px; border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 800; flex-shrink: 0;
}
#ride-pill .ride-pill-text { overflow: hidden; text-overflow: ellipsis; }
@media (min-width: 600px) {
  #ride-pill { top: 24px; left: auto; right: 24px; transform: none; max-width: 320px; }
}
