/* Vancity Connect shared component styles, used by Carpool and Split. Loaded right after tokens.css and before
   each app's app.css. THIS FILE IS IDENTICAL IN vancity-carpool AND vancity-split (test/shared-files.test.ts).
   Every colour, font, size, radius, shadow and space comes from tokens.css. */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--surface-page); color: var(--ink); min-height: 100vh; display: flex; flex-direction: column; }
img { max-width: 100%; height: auto; }
a { color: var(--surface-brand); text-underline-offset: 3px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Header: the full lockup (star + wordmark). The star's ink is exactly surface-brand, so on a surface-brand band it
   vanishes and only the wordmark shows; surface-inverse keeps the star, the butter VAN CITY and the white CONNECT visible.
   On dark screens the darker lilac does the same job (surface-inverse turns light there and would hide CONNECT). */
.site-header { background: var(--surface-inverse); padding: var(--space-4); }
.site-header a { display: inline-block; border-radius: var(--radius-sm); }
.site-header img { display: block; width: 180px; }
@media (prefers-color-scheme: dark) { .site-header { background: var(--surface-lilac); } }

main { width: 100%; max-width: 68ch; margin: 0 auto; padding: var(--space-5) var(--space-4) var(--space-7); flex: 1; }
.site-footer { padding: var(--space-5) var(--space-4); color: var(--ink-subtle); font-size: var(--caption-size); line-height: var(--caption-line); text-align: center; }

/* Type */
h1, h2, h3 { margin: 0; color: var(--ink); }
h1 { font-size: var(--display-lg-size); line-height: var(--display-lg-line); letter-spacing: var(--display-lg-tracking); }
h2 { font-size: var(--display-md-size); line-height: var(--display-md-line); letter-spacing: var(--display-md-tracking); }
h3 { font-size: var(--display-sm-size); line-height: var(--display-sm-line); letter-spacing: var(--display-sm-tracking); }
@media (min-width: 640px) {
  h1 { font-size: var(--display-xl-size); line-height: var(--display-xl-line); letter-spacing: var(--display-xl-tracking); }
}
p { margin: 0; }
.eyebrow { color: var(--ink-muted); margin: 0 0 var(--space-2); }
.lead { font-size: var(--lead-size); line-height: var(--lead-line); font-weight: var(--lead-weight); color: var(--ink-muted); }
.small { font-size: var(--body-sm-size); line-height: var(--body-sm-line); }
.muted { color: var(--ink-muted); }
.stack > * + * { margin-top: var(--space-4); }
.stack-sm > * + * { margin-top: var(--space-2); }
.section { margin-top: var(--space-7); }
.section > h2 { margin-bottom: var(--space-4); }

/* Meta rows: one icon per row */
.meta { list-style: none; margin: var(--space-4) 0 0; padding: 0; }
.meta li { display: flex; gap: var(--space-2); align-items: flex-start; }
.meta li + li { margin-top: var(--space-2); }
.meta .icon { color: var(--ink-muted); flex: none; margin-top: var(--space-1); }
.icon { flex: none; vertical-align: middle; }

/* Cards */
.card { background: var(--surface-card); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-4); box-shadow: var(--shadow-sm); }
.cards > * + * { margin-top: var(--space-5); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); }
.card-head h3 { overflow-wrap: anywhere; }

/* Butter: one highlight block per screen. Text on it is always on-butter. */
.butter { background: var(--surface-butter); color: var(--on-butter); border-radius: var(--radius-lg); padding: var(--space-4); }
.butter :focus-visible { outline-color: var(--focus-inverse); }
/* On the dark blocks the purple ring all but vanishes; use the light ink instead. */
.hero :focus-visible, .site-header :focus-visible, .notice-brand :focus-visible { outline-color: var(--ink-inverse); }
.butter .muted, .butter .eyebrow { color: var(--on-butter); }

/* Buttons: pill by default */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--space-7); padding: var(--space-2) var(--space-5); border-radius: var(--radius-pill);
  font: inherit; font-size: var(--label-size); line-height: var(--label-line); font-weight: var(--label-weight);
  border: 1px solid transparent; cursor: pointer; text-decoration: none; transition: background-color 150ms, border-color 150ms;
  background: var(--surface-brand); color: var(--on-brand);
}
.btn:hover { background: var(--surface-brand-strong); }
.btn-sunset { background: var(--surface-sunset); color: var(--on-sunset); }
.btn-sunset:hover { background: var(--surface-sunset); filter: brightness(0.9); }
.btn-quiet { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn-quiet:hover { background: var(--surface-muted); }
.btn-block { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { background: var(--surface-muted); color: var(--ink-subtle); border-color: transparent; cursor: not-allowed; filter: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--space-3); }

/* Forms */
.field { display: block; }
.field + .field, .field + fieldset, fieldset + .field { margin-top: var(--space-4); }
/* Labels only: a hint span inside the label keeps the hint style (it used to come out bold and label-sized). */
.field > span:not(.hint), legend { display: block; padding: 0; font-size: var(--label-size); line-height: var(--label-line); font-weight: var(--label-weight); margin-bottom: var(--space-2); }
.hint { display: block; font-size: var(--caption-size); line-height: var(--caption-line); color: var(--ink-subtle); margin-top: var(--space-1); }
input, select, textarea {
  width: 100%; font: inherit; font-size: var(--body-size); color: var(--ink); background: var(--surface-card);
  border: 1px solid var(--line-strong); border-radius: var(--radius-md); padding: var(--space-3); min-height: var(--space-7);
}
textarea { resize: vertical; min-height: calc(var(--space-7) * 2); }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--status-closed); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.row-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.row-2 > * { min-width: 0; }
/* Date and time inputs keep a wide intrinsic size (iOS Safari especially), which pushed "Arrive by" past the card edge. */
input[type="date"], input[type="time"] { min-width: 0; max-width: 100%; display: block; -webkit-appearance: none; appearance: none; }
input::-webkit-date-and-time-value { text-align: left; }
.row-2 .field + .field { margin-top: 0; }

/* Choice cards (role picker) */
.choices { display: grid; gap: var(--space-2); }
.choice { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3) var(--space-4); border: 1px solid var(--line-strong); border-radius: var(--radius-md); background: var(--surface-card); cursor: pointer; }
.choice input { width: auto; min-height: 0; margin: var(--space-1) 0 0; accent-color: var(--surface-brand); }
.choice:has(input:checked) { border-color: var(--surface-brand); background: var(--surface-lilac-soft); box-shadow: inset 0 0 0 1px var(--surface-brand); }
.choice strong { display: block; font-weight: var(--label-weight); }
.choice small { display: block; color: var(--ink-muted); font-size: var(--body-sm-size); line-height: var(--body-sm-line); }

/* Status: always icon + word */
.status { display: inline-flex; align-items: center; gap: var(--space-1); font-size: var(--body-sm-size); line-height: var(--body-sm-line); font-weight: var(--label-weight); white-space: nowrap; }
.status-confirmed { color: var(--status-confirmed); }
.status-pending { color: var(--status-pending); }
.status-closed { color: var(--status-closed); }

/* Notices */
.notice { display: flex; gap: var(--space-3); align-items: flex-start; border: 1px solid var(--line-strong); border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); background: var(--surface-card); }
.notice .icon { margin-top: var(--space-1); }
.stale { margin-bottom: var(--space-4); }
.notice-error { border-color: var(--status-closed); }
.notice-error .icon { color: var(--status-closed); }
.notice-warn .icon { color: var(--status-pending); }
.notice-brand { background: var(--surface-inverse); color: var(--ink-inverse); border-color: transparent; }

/* Copy-able link */
.copy-row { display: flex; gap: var(--space-2); align-items: stretch; }
.copy-row input { flex: 1; min-width: 0; font-size: var(--body-sm-size); }

/* People lists */
.people { list-style: none; margin: 0; padding: 0; }
.people li { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); padding: var(--space-2) 0; border-top: 1px solid var(--line); }
.people li:first-child { border-top: 0; }
.people .who { font-weight: var(--label-weight); overflow-wrap: anywhere; }
.people li > :first-child { min-width: 0; }
.people .where { flex: none; max-width: 50%; color: var(--ink-muted); font-size: var(--body-sm-size); line-height: var(--body-sm-line); text-align: right; overflow-wrap: anywhere; }
.people .note { display: block; color: var(--ink-subtle); font-size: var(--caption-size); line-height: var(--caption-line); overflow-wrap: anywhere; }

/* Stat strip: Anton numbers, eyebrow words */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-3); background: var(--surface-inverse); color: var(--ink-inverse); border-radius: var(--radius-lg); padding: var(--space-4); text-align: center; }
.stats b { display: block; font-family: var(--font-display); font-weight: var(--stat-number-weight); font-size: var(--stat-number-size); line-height: var(--stat-number-line); letter-spacing: var(--stat-number-tracking); }
.stats .eyebrow { color: var(--ink-inverse); margin: var(--space-1) 0 0; }

@media (prefers-reduced-motion: no-preference) {
  .enter { animation: enter 240ms ease-out; }
  @keyframes enter { from { opacity: 0; } to { opacity: 1; } }
}
.plain { list-style: none; margin: 0; padding: 0; }
.meta.flush { margin: 0; }
.section-sm { margin-top: var(--space-4); }
.card-mine { border-color: var(--surface-brand); box-shadow: var(--shadow-md); }
.card-actions { margin-top: var(--space-4); }
.stat { font-family: var(--font-display); font-weight: var(--stat-number-weight); font-size: var(--stat-number-size); line-height: var(--stat-number-line); letter-spacing: var(--stat-number-tracking); }

/* ---------- Organizer dashboard (/e/:code/admin) ---------- */
main.wide { max-width: 1200px; }
.stats-4 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 560px) { .stats-4 { grid-template-columns: repeat(4, 1fr); } }
.lock-panel { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; justify-content: space-between; }
.lock-panel .notice { flex-basis: 100%; }

/* Cars as columns: one per row on a phone, side by side as the screen widens. */
.columns { display: grid; gap: var(--space-5); grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); align-items: start; }
.car-col { display: flex; flex-direction: column; gap: var(--space-3); transition: border-color 150ms, background-color 150ms; }
.car-col.drop-ok { border-color: var(--surface-brand); background: var(--surface-lilac-soft); }
.car-col.drop-no { border-color: var(--status-closed); }
.car-facts { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); margin: 0; padding: 0; list-style: none; color: var(--ink-muted); font-size: var(--body-sm-size); line-height: var(--body-sm-line); }
.car-facts li { display: inline-flex; align-items: center; gap: var(--space-1); }
.rider-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.rider { border: 1px solid var(--line-strong); border-radius: var(--radius-md); background: var(--surface-card); padding: var(--space-3); display: grid; gap: var(--space-2); }
.rider[draggable="true"] { cursor: grab; }
.rider.dragging { opacity: 0.5; }
.rider-top { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: flex-start; }
.rider-top .grip { color: var(--ink-subtle); margin-top: var(--space-1); }
/* The name keeps at least ~9rem; on a narrow card the status chip drops below instead of squeezing it. */
.rider-top .who { flex: 1 1 9rem; min-width: 0; font-weight: var(--label-weight); overflow-wrap: anywhere; }
.rider-top .who small { display: block; font-weight: var(--body-weight); color: var(--ink-muted); font-size: var(--body-sm-size); line-height: var(--body-sm-line); }
.rider-actions { display: flex; gap: var(--space-2); align-items: center; }
.rider-actions select { flex: 1; min-width: 0; min-height: var(--space-7); padding: var(--space-2) var(--space-3); font-size: var(--body-sm-size); }
.btn-sm { min-height: var(--space-7); padding: var(--space-2) var(--space-4); }
.btn-icon { min-width: var(--space-7); padding: var(--space-2); }
.empty-drop { border: 1px dashed var(--line-strong); border-radius: var(--radius-md); padding: var(--space-4); text-align: center; color: var(--ink-muted); font-size: var(--body-sm-size); line-height: var(--body-sm-line); }
.wa-text { font-family: var(--font-sans); min-height: calc(var(--space-9) * 2.5); font-size: var(--body-sm-size); line-height: var(--body-sm-line); white-space: pre-wrap; }
.people .phone { white-space: nowrap; }

/* Edit dialog */
dialog { border: 0; border-radius: var(--radius-lg); padding: 0; width: min(100% - var(--space-5), 34rem); max-height: calc(100% - var(--space-5)); background: var(--surface-card); color: var(--ink); box-shadow: var(--shadow-lg); }
dialog::backdrop { background: var(--surface-inverse); opacity: 0.55; }
dialog form { padding: var(--space-5) var(--space-4); }
.dialog-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); justify-content: space-between; margin-top: var(--space-5); }

/* ---------- Rider pages: /e/:code and /e/:code/car/:driverId (SPEC V2.1, restyled to V3.1–V3.3) ---------- */
.site-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }

/* ---------- Components both apps use the same way ---------- */

/* Tabs: pills, the selected one filled. A count sits beside the label and drops under it when space runs out. */
.tabs { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: var(--space-1); padding: var(--space-2) 0; border-bottom: 1px solid var(--line); }
.tabs [role="tab"] {
  display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 2px var(--space-1); min-width: 0;
  min-height: var(--space-7); padding: var(--space-1) var(--space-2); border: 0; border-radius: var(--radius-pill); background: none;
  color: var(--ink-muted); font: inherit; font-size: var(--label-size); line-height: var(--label-line); font-weight: var(--label-weight); cursor: pointer; text-align: center;
}
.tabs [role="tab"]:hover:not([aria-selected="true"]) { color: var(--ink); background: var(--surface-muted); }
.tabs [role="tab"][aria-selected="true"] { background: var(--surface-brand); color: var(--on-brand); }
.tabs [role="tab"]:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.tabs .count { display: inline-flex; align-items: center; justify-content: center; min-width: var(--space-5); padding: 0 var(--space-1); border-radius: var(--radius-pill);
  background: var(--surface-muted); color: var(--ink); font-size: var(--caption-size); line-height: var(--caption-line); font-weight: var(--label-weight); }
.tabs [aria-selected="true"] .count { background: var(--surface-card); color: var(--surface-brand-strong); }
.tabs .count-alert, .tabs [aria-selected="true"] .count-alert { background: var(--surface-butter); color: var(--on-butter); }

/* Avatars (avatar.js): initials on a colour picked from the name, the same in both apps. Text always says who. */
.avatar { display: inline-grid; place-items: center; flex: none; border-radius: var(--radius-pill); font-weight: var(--label-weight); letter-spacing: 0; line-height: 1; user-select: none; }
.avatar-md { width: calc(var(--space-6) + var(--space-2)); height: calc(var(--space-6) + var(--space-2)); font-size: var(--body-sm-size); }
.avatar-sm { width: var(--space-6); height: var(--space-6); font-size: var(--caption-size); }
.tone-0 { background: var(--surface-brand); color: var(--on-brand); }
.tone-1 { background: var(--surface-sunset); color: var(--on-sunset); }
.tone-2 { background: var(--surface-pacific); color: var(--on-pacific); }
.tone-3 { background: var(--surface-butter); color: var(--on-butter); }
.tone-4 { background: var(--surface-lilac-soft); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong); }
/* Overlapping faces, each ringed in the card colour. */
.avatar-stack { display: inline-flex; flex: none; }
.avatar-stack .avatar { box-shadow: 0 0 0 2px var(--surface-card); }
.avatar-stack .avatar + .avatar { margin-left: calc(var(--space-1) * -1); }
.avatar-stack .tone-4 { box-shadow: inset 0 0 0 1px var(--line-strong), 0 0 0 2px var(--surface-card); }

/* How it works: numbered-free steps, an icon in a lilac circle, a bold title and a softer line. */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); }
.steps li { display: flex; gap: var(--space-3); align-items: flex-start; background: var(--surface-card); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-4); }
.steps strong { display: block; font-weight: var(--label-weight); }
.steps p { margin: var(--space-1) 0 0; color: var(--ink-muted); font-size: var(--body-sm-size); line-height: var(--body-sm-line); }
.step-icon { display: inline-grid; place-items: center; flex: none; width: calc(var(--space-6) + var(--space-2)); height: calc(var(--space-6) + var(--space-2)); border-radius: var(--radius-pill); background: var(--surface-lilac-soft); color: var(--surface-brand); }

/* "From Luma" pickers (Carpool's New carpool, Split's Start a trip): two-way switch, event rows with a date tile,
   and the picked event as a card. */
.seg-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-1); padding: var(--space-1); background: var(--surface-muted); border-radius: var(--radius-pill); }
.seg-tabs [role="tab"] { min-height: calc(var(--space-6) + var(--space-2)); padding: 0 var(--space-3); border: 0; border-radius: var(--radius-pill); background: transparent; color: var(--ink-muted); cursor: pointer;
  font: inherit; font-size: var(--label-size); line-height: var(--label-line); font-weight: var(--label-weight); transition: background-color 150ms, color 150ms; }
.seg-tabs [role="tab"][aria-selected="true"] { background: var(--surface-brand); color: var(--on-brand); }
.seg-tabs [role="tab"]:hover:not([aria-selected="true"]) { color: var(--ink); }
.seg-tabs [role="tab"]:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.luma-list { list-style: none; margin: var(--space-3) 0 0; padding: 0; display: grid; gap: var(--space-3); }
.luma-pick { display: flex; gap: var(--space-3); align-items: center; width: 100%; padding: var(--space-3) var(--space-4); text-align: left; cursor: pointer; font: inherit; color: var(--ink);
  background: var(--surface-card); border: 1px solid var(--line-strong); border-radius: var(--radius-lg); transition: border-color 150ms, background-color 150ms; }
.luma-pick:hover { border-color: var(--surface-brand); background: var(--surface-lilac-soft); }
.luma-pick .icon { color: var(--ink-muted); margin-left: auto; }
.picked-card { display: flex; gap: var(--space-3); align-items: center; padding: var(--space-3) var(--space-4); background: var(--surface-card); border: 2px solid var(--surface-brand); border-radius: var(--radius-lg); }
.picked-card .btn { flex: none; border-color: transparent; color: var(--surface-brand); }
.filled { margin: var(--space-1) 0 0; }
.date-tile { flex: none; display: grid; place-content: center; width: calc(var(--space-6) + var(--space-2)); min-height: calc(var(--space-6) + var(--space-3)); padding: var(--space-1) 0;
  border-radius: var(--radius-sm); background: var(--surface-inverse); color: var(--ink-inverse); text-align: center; }
.date-tile small { display: block; font-size: var(--caption-size); line-height: var(--caption-line); font-weight: var(--eyebrow-weight); letter-spacing: var(--eyebrow-tracking); text-transform: uppercase; color: var(--surface-lilac); }
.date-tile b { display: block; font-family: var(--font-display); font-weight: var(--display-sm-weight); font-size: var(--display-sm-size); line-height: var(--display-sm-line); }
@media (prefers-color-scheme: dark) { .date-tile small { color: var(--ink-inverse); } }
.what { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.what strong { display: block; font-size: var(--body-sm-size); line-height: var(--body-sm-line); font-weight: var(--label-weight); }
.what small { display: block; color: var(--ink-muted); font-size: var(--caption-size); line-height: var(--caption-line); }
