/* list.css -- ranked bottom-sheet list.
 *
 * Consumes base.css design tokens via CSS variables. Every var() has a safe
 * fallback so this module still renders if a token name differs, but the host
 * theme (light/dark) is meant to drive the real values. Quality tiers
 * (great/ok/poor/unrated) are theme-mapped here once and reused by detail.css
 * via the same data-tier attribute contract.
 */

:root {
  /* Tier colors: prefer host tokens, else a safe accessible default.
     These are intentionally defined on :root (not scoped) so detail.css can
     share them without redefining. base.css may override them. */
  --ps-tier-great: var(--color-great, #197d46);
  --ps-tier-ok: var(--color-ok, #94640b);
  --ps-tier-poor: var(--color-poor, #c63127);
  --ps-tier-unrated: var(--color-muted, #636e7d);
  --ps-tier-great-bg: var(--color-great-bg, rgba(22, 163, 74, 0.12));
  --ps-tier-ok-bg: var(--color-ok-bg, rgba(217, 119, 6, 0.12));
  --ps-tier-poor-bg: var(--color-poor-bg, rgba(220, 38, 38, 0.12));
  --ps-tier-unrated-bg: var(--color-muted-bg, rgba(148, 163, 184, 0.14));
}

.ps-list {
  display: flex;
  flex-direction: column;
  background: var(--surface, var(--color-surface, #ffffff));
  color: var(--text, var(--color-text, #0f172a));
  border-top-left-radius: var(--radius-lg, 18px);
  border-top-right-radius: var(--radius-lg, 18px);
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.18);
  max-height: 62vh;
  overflow: hidden;
  font-family: var(--font, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
}

.ps-list-grip {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: var(--color-muted, #636e7d);
  opacity: 0.7;
  margin: 8px auto 4px;
  flex: none;
}

.ps-list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 16px 10px;
  flex: none;
}

.ps-list-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.ps-list-count {
  font-size: 0.8rem;
  color: var(--text-muted, var(--color-muted, #636e7d));
}

.ps-list-scroll {
  list-style: none;
  margin: 0;
  padding: 0 12px calc(16px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* --- row --- */
.ps-row {
  appearance: none;
  text-align: left;
  width: 100%;
  background: var(--surface-2, var(--color-surface-2, #f8fafc));
  border: 1.5px solid transparent;
  border-radius: var(--radius-md, 14px);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.12s ease, transform 0.06s ease, background 0.12s ease;
  min-height: 56px; /* generous one-handed touch target */
}
.ps-row:active { transform: scale(0.992); }
.ps-row.is-preview {
  border-color: var(--accent, var(--color-accent, #2563eb));
  background: var(--accent-bg, rgba(37, 99, 235, 0.06));
}
.ps-row.is-selected {
  border-color: var(--accent, var(--color-accent, #2563eb));
}
.ps-row:focus-visible {
  outline: 2px solid var(--accent, #2563eb);
  outline-offset: 2px;
}
.ps-row.is-unrated { background: var(--surface, var(--color-surface, #fff)); }

.ps-row-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.ps-row-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}
.ps-crown { font-size: 0.95rem; line-height: 1; }
.ps-row-name {
  font-weight: 650;
  font-size: 1rem;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60vw;
}
.ps-row-brand {
  font-size: 0.82rem;
  color: var(--text-muted, #64748b);
  font-weight: 500;
}
.ps-open {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 6px;
  border-radius: 6px;
}
.ps-open--yes { color: var(--ps-tier-great); background: var(--ps-tier-great-bg); }
.ps-open--no { color: var(--ps-tier-poor); background: var(--ps-tier-poor-bg); }

/* badge */
.ps-badge {
  flex: none;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  padding: 4px 8px;
  border-radius: var(--radius-sm, 10px);
  line-height: 1.1;
}
.ps-badge[data-tier="great"] { background: var(--ps-tier-great-bg); color: var(--ps-tier-great); }
.ps-badge[data-tier="ok"] { background: var(--ps-tier-ok-bg); color: var(--ps-tier-ok); }
.ps-badge[data-tier="poor"] { background: var(--ps-tier-poor-bg); color: var(--ps-tier-poor); }
.ps-badge[data-tier="unrated"] { background: var(--ps-tier-unrated-bg); color: var(--ps-tier-unrated); }
.ps-badge-score { font-size: 1.15rem; font-weight: 800; }
.ps-badge-tier { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; }

.ps-row-meta {
  margin-top: 4px;
  font-size: 0.85rem;
  color: var(--text-muted, #64748b);
}

/* six co-equal dimension meters -- each gets equal width, none enlarged.
 *
 * Three across, two rows: six across cannot hold the labels. Inside the 480px
 * app frame a row's meter area is ~320px at a 375px viewport and ~305px at
 * 360px, so a 6-up grid leaves ~45px per column -- while "CLEANLINESS" needs
 * ~77px and "BATHROOM" ~66px at 0.72rem uppercase. Three columns give ~97px at
 * 360px, which clears the longest label with room to spare, and the dimensions
 * stay co-equal because every cell is still 1fr. */
.ps-meters {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px 7px;
  margin-top: 10px;
}
.ps-meter { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ps-meter-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-muted, #64748b);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ps-meter-track {
  height: 6px;
  border-radius: 999px;
  background: var(--track, var(--color-track, rgba(148, 163, 184, 0.28)));
  overflow: hidden;
}
.ps-meter-fill { display: block; height: 100%; border-radius: 999px; }
.ps-meter-fill[data-tier="great"] { background: var(--ps-tier-great); }
.ps-meter-fill[data-tier="ok"] { background: var(--ps-tier-ok); }
.ps-meter-fill[data-tier="poor"] { background: var(--ps-tier-poor); }
.ps-meter-fill[data-tier="unrated"] { background: var(--ps-tier-unrated); opacity: 0.5; }

/* unrated invite -- honest, inviting, not blank */
.ps-unrated-invite {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm, 10px);
  border: 1px dashed var(--ps-tier-unrated);
  background: var(--ps-tier-unrated-bg);
  font-size: 0.8rem;
  color: var(--text-muted, #475569);
}
.ps-unrated-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--ps-tier-unrated);
  flex: none;
}

/* --- empty / loading states --- */
.ps-empty {
  list-style: none;
  text-align: center;
  padding: 32px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.ps-empty-title { margin: 0; font-weight: 700; font-size: 1rem; }
.ps-empty-sub { margin: 0; font-size: 0.85rem; color: var(--text-muted, #64748b); max-width: 30ch; }
.ps-empty-btn {
  margin-top: 12px;
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 10px 20px;
  font-weight: 700;
  font-size: 0.9rem;
  background: var(--accent, var(--color-accent, #2563eb));
  color: var(--accent-text, #fff);
  cursor: pointer;
  min-height: 44px;
}
.ps-empty-btn:active { transform: scale(0.97); }

/* shared spinner (also used by detail.css) */
.ps-spinner {
  width: 26px; height: 26px;
  border: 3px solid var(--track, rgba(148, 163, 184, 0.3));
  border-top-color: var(--accent, #2563eb);
  border-radius: 50%;
  animation: ps-spin 0.8s linear infinite;
}
.ps-spinner--sm { width: 16px; height: 16px; border-width: 2px; display: inline-block; vertical-align: middle; }
@keyframes ps-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .ps-spinner { animation-duration: 1.6s; }
  .ps-row { transition: none; }
}

/* ---------- trip mode: detour badge + next-stop card ---------- */

/* "+2 min off route" -- the freeway-accessibility truth. Colored by pain. */
.ps-detour {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  vertical-align: middle;
}
.ps-detour[data-tier="easy"] { color: var(--ps-tier-great); background: var(--ps-tier-great-bg); }
.ps-detour[data-tier="mid"] { color: var(--ps-tier-ok); background: var(--ps-tier-ok-bg); }
.ps-detour[data-tier="far"] { color: var(--ps-tier-poor); background: var(--ps-tier-poor-bg); }
.ps-detour[data-tier="unknown"] { color: var(--ps-tier-unrated); background: var(--ps-tier-unrated-bg); }

/* The trip headline card: the stop most worth pulling off for. */
.ps-next {
  flex: none;
  margin: 0 12px 10px;
  padding: 10px 14px 12px;
  border-radius: var(--radius, 14px);
  background: var(--surface-2, rgba(47, 109, 240, 0.06));
  border: 1px solid var(--brand, #2f6df0);
  cursor: pointer;
}
.ps-next:active { transform: translateY(1px); }
.ps-next-eyebrow {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--brand, #2f6df0);
  margin-bottom: 4px;
}
.ps-next-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.ps-next-name {
  font-weight: 700;
  font-size: 1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ps-next-meta {
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--text-dim, #5b6470);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Off-route banner (live trip): honest state + one action. */
.ps-offroute {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 12px 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm, 10px);
  background: var(--ps-tier-ok-bg, rgba(217, 119, 6, 0.12));
  color: var(--ps-tier-ok, #94640b);
  font-size: 0.82rem;
  font-weight: 600;
}
.ps-offroute-btn {
  flex: none;
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 800;
  background: var(--ps-tier-ok, #94640b);
  /* a tier fill takes the tier ink -- hardcoded white inverted in dark mode */
  color: var(--tier-ink, #fff);
}
