/* ─────────────────────────────────────────────────────────────
   Trip schedule — weekly List + Week-calendar views (adapted from
   the SOLOS Admin prototype, ADMIN-001). Calendar cells stack their
   trip blocks in flow (not absolute) so multiple same-hour
   departures grow the row instead of overlapping.
   ───────────────────────────────────────────────────────────── */

/* Layout: fill the (fixed-height, overflow-hidden) .content area and put the
   scroll on the list/grid. The date-bar stays pinned above it. */
/* The notify wrapper sits between .content and the frame, so it has to relay the
   flex chain or .schedule-scroll loses its scroll box and .content clips the grid. */
.schedule-stack { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.schedule-stack > .filter-bar, .schedule-stack > .notify-pill { flex-shrink: 0; }
#trips-schedule { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#trips-schedule > .date-bar { flex-shrink: 0; }
/* No top padding so the sticky day/hour headers pin flush under the date-bar. */
.schedule-scroll { flex: 1; min-height: 0; overflow: auto; padding: 0 var(--space-6) var(--space-4); }

/* Date / view bar */
.date-bar { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; padding: var(--space-3) var(--space-6); background: var(--bg-sunken); border-bottom: 1px solid var(--border-subtle); }
.date-nav { display: flex; align-items: center; gap: var(--space-1); }
.date-nav__btn { width: 30px; height: 30px; border: 1px solid var(--border-default); background: var(--bg-elevated); color: var(--text-secondary); border-radius: var(--radius-md); display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.date-nav__btn:hover { color: var(--text-primary); border-color: var(--border-strong); }
.date-nav__btn svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.date-nav__current { font-family: var(--font-display); font-size: 14px; font-weight: 600; letter-spacing: -0.01em; padding: 0 var(--space-3); min-width: 200px; text-align: center; }
.date-nav__current small { display: block; font-family: var(--font-mono); font-size: 10px; color: var(--text-tertiary); letter-spacing: 0.05em; font-weight: 400; margin-top: 2px; }
.date-nav__today { height: 30px; padding: 0 var(--space-3); border: 1px solid var(--border-default); background: var(--bg-elevated); color: var(--text-secondary); border-radius: var(--radius-md); font-family: var(--font-display); font-size: 11px; font-weight: 600; letter-spacing: 0.04em; display: inline-flex; align-items: center; text-decoration: none; }
.date-nav__today:hover { color: var(--text-primary); border-color: var(--border-strong); }
.date-bar__filters { display: flex; align-items: center; gap: var(--space-2); margin-left: auto; }

.view-toggle { display: inline-flex; background: var(--bg-elevated); border: 1px solid var(--border-default); border-radius: var(--radius-md); padding: 2px; }
.view-toggle__btn { height: 26px; padding: 0 var(--space-3); border: 0; background: transparent; color: var(--text-tertiary); border-radius: 6px; font-family: var(--font-display); font-size: 11px; font-weight: 600; letter-spacing: 0.05em; display: inline-flex; align-items: center; gap: 5px; text-decoration: none; cursor: pointer; }
.view-toggle__btn svg { width: 13px; height: 13px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.view-toggle__btn:hover { color: var(--text-secondary); }
.view-toggle__btn[aria-pressed="true"] { background: var(--bg-canvas); color: var(--text-primary); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); }

/* ── List view ───────────────────────────────────────────────── */
/* No overflow:hidden here — it would trap the sticky day-group headers inside
   this box instead of pinning them to the .schedule-scroll viewport. */
.schedule-body { display: flex; flex-direction: column; border: 1px solid var(--border-subtle); border-top: 0; }
.day-group { border-bottom: 1px solid var(--border-subtle); }
.day-group:last-child { border-bottom: 0; }
.day-group__head { padding: var(--space-3) var(--space-4); display: flex; align-items: baseline; gap: var(--space-3); background: var(--bg-sunken); border-bottom: 1px solid var(--border-subtle); position: sticky; top: 0; z-index: 2; }
.day-group__date { font-family: var(--font-display); font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.day-group__date-day { font-family: var(--font-mono); font-size: 11px; color: var(--text-tertiary); letter-spacing: 0.08em; text-transform: uppercase; margin-left: var(--space-1); font-weight: 500; }
.day-group__date-today { margin-left: var(--space-2); padding: 3px 8px; font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.1em; font-weight: 600; background: var(--accent-emphasis); color: white; border-radius: var(--radius-sm); text-transform: uppercase; }
.day-group__stats { margin-left: auto; display: flex; gap: var(--space-4); font-family: var(--font-mono); font-size: 11px; color: var(--text-tertiary); letter-spacing: 0.04em; }
.day-group__stats strong { color: var(--text-primary); font-weight: 600; }

.trip-list { display: flex; flex-direction: column; }
.trip-list__empty { padding: var(--space-4); font-size: 12px; color: var(--text-tertiary); font-style: italic; }

.trip-row { display: grid; grid-template-columns: 110px minmax(0, 1.8fr) 90px minmax(0, 1.4fr) 110px 32px; gap: var(--space-3); align-items: center; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border-subtle); text-decoration: none; color: var(--text-primary); transition: background var(--duration-fast) var(--ease-out); }
.trip-row:last-child { border-bottom: 0; }
.trip-row:hover { background: var(--bg-elevated); }
.trip-row--selected { background: var(--bg-elevated); box-shadow: inset 3px 0 0 var(--accent-emphasis); }
.trip-row__time { font-family: var(--font-mono); font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.trip-row__time small { display: block; font-size: 10px; font-weight: 400; color: var(--text-tertiary); letter-spacing: 0.04em; margin-top: 2px; }
.trip-row__route { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.trip-row__route-main { font-family: var(--font-display); font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trip-row__route-meta { font-family: var(--font-mono); font-size: 10px; color: var(--text-tertiary); letter-spacing: 0.04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trip-row__bus { font-family: var(--font-mono); font-size: 12px; font-weight: 600; }
.trip-row__crew { display: flex; flex-direction: column; gap: 1px; min-width: 0; font-size: 11px; line-height: 1.3; }
.trip-row__crew-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trip-row__crew-name--att { color: var(--text-tertiary); font-size: 10px; font-weight: 400; }
.trip-row__crew-name--att::before { content: '↳ '; opacity: 0.6; }
.trip-row__muted { color: var(--text-tertiary); font-size: 11px; }
.trip-row__chevron { display: flex; align-items: center; justify-content: center; color: var(--text-tertiary); }
.trip-row__chevron svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.trip-row:hover .trip-row__chevron { color: var(--text-primary); }

/* ── Week calendar view ──────────────────────────────────────── */
/* grid fills wide screens (1fr) but keeps a min width so the .schedule-scroll
   wrapper scrolls horizontally when the area is narrower. */
.calendar-grid { display: grid; grid-template-columns: 60px repeat(7, minmax(120px, 1fr)); width: 100%; min-width: calc(60px + 7 * 120px); background: var(--bg-surface); border: 1px solid var(--border-subtle); }
.calendar-grid__corner { background: var(--bg-sunken); border-bottom: 1px solid var(--border-subtle); border-right: 1px solid var(--border-subtle); position: sticky; top: 0; left: 0; z-index: 4; }
.calendar-grid__day-head { padding: var(--space-3) var(--space-2); background: var(--bg-sunken); border-bottom: 1px solid var(--border-subtle); border-right: 1px solid var(--border-subtle); text-align: center; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; z-index: 3; }
.calendar-grid__day-head:last-child { border-right: 0; }
.calendar-grid__day-name { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-tertiary); font-weight: 500; }
.calendar-grid__day-num { font-family: var(--font-display); font-size: 18px; font-weight: 600; letter-spacing: -0.01em; color: var(--text-primary); line-height: 1.1; }
.calendar-grid__day-head--today .calendar-grid__day-num { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-emphasis); color: white; display: flex; align-items: center; justify-content: center; margin: 0 auto; font-size: 14px; }
.calendar-grid__hour-label { padding: var(--space-2); font-family: var(--font-mono); font-size: 10px; color: var(--text-tertiary); letter-spacing: 0.04em; text-align: right; border-bottom: 1px dashed var(--border-subtle); border-right: 1px solid var(--border-subtle); background: var(--bg-surface); position: sticky; left: 0; z-index: 1; }
.calendar-grid__cell { position: relative; display: flex; flex-direction: column; gap: 3px; border-bottom: 1px dashed var(--border-subtle); border-right: 1px solid var(--border-subtle); min-height: 56px; padding: 3px; }
/* Current-time line. `top` is a percentage set inline by the server and nudged
   each minute by now_line_controller, so it tracks the cell's real height. z-index
   2 clears the trip blocks (unpositioned) but stays under the sticky day heads (3). */
.calendar-grid__now { position: absolute; left: 0; right: 0; height: 2px; background: var(--accent-emphasis); z-index: 2; pointer-events: none; }
/* The dot is the only part that takes pointer events — the line spans the full
   cell and would otherwise swallow clicks meant for the trip blocks beneath it.
   At rest it's a plain circle; on hover it widens into a pill (5ch is exactly
   "HH:MM" in the mono face, so the width isn't a magic number). */
.calendar-grid__now-dot {
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  pointer-events: auto; cursor: default; box-sizing: border-box;
  display: flex; align-items: center; overflow: hidden; white-space: nowrap;
  width: 10px; height: 10px; padding: 0; border-radius: 999px;
  background: var(--accent-emphasis); color: #fff;
  font-family: var(--font-mono); font-size: 10px; font-weight: 600; line-height: 1;
  transition: width var(--duration-fast) var(--ease-out),
              height var(--duration-fast) var(--ease-out),
              padding var(--duration-fast) var(--ease-out);
}
/* Hidden by opacity, not just clipped: at 10px the circle would otherwise show a
   sliver of the first digits. It trails the pill opening slightly on the way in
   and leaves immediately on the way out, so the text never spills past the shape. */
.calendar-grid__now-time {
  opacity: 0; transform: translateX(-4px);
  transition: opacity var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
}
.calendar-grid__now-dot:hover { width: calc(5ch + 12px); height: 16px; padding: 0 6px; }
.calendar-grid__now-dot:hover .calendar-grid__now-time {
  opacity: 1; transform: none; transition-delay: 60ms;
}
@media (prefers-reduced-motion: reduce) {
  .calendar-grid__now-dot, .calendar-grid__now-time { transition: none; }
}
.calendar-grid__cell:nth-child(8n) { border-right: 0; }
.calendar-grid__cell--today { background: rgba(233, 114, 76, 0.03); }
.calendar-empty { padding: var(--space-6); text-align: center; font-size: 13px; color: var(--text-tertiary); }

/* Trip blocks — flow-stacked in a cell (no absolute positioning) */
.trip-block { display: block; background: var(--info-bg); border: 1px solid var(--info-border); border-left: 3px solid var(--info-color); border-radius: var(--radius-sm); padding: 4px 6px; text-decoration: none; overflow: hidden; transition: transform var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out); }
.trip-block:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); }
.trip-block--assigned { background: rgba(233, 114, 76, 0.10); border-color: rgba(233, 114, 76, 0.35); border-left-color: var(--accent-emphasis); }
.trip-block--unassigned { background: var(--bg-elevated); border-color: var(--border-subtle); border-left-color: var(--text-disabled); }
.trip-block--selected { box-shadow: 0 0 0 2px var(--accent-emphasis); }
.trip-block__time { font-family: var(--font-mono); font-size: 10px; font-weight: 700; letter-spacing: 0.04em; color: var(--accent-emphasis); }
.trip-block--unassigned .trip-block__time { color: var(--text-secondary); }
.trip-block__route { font-family: var(--font-display); font-size: 10px; font-weight: 500; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.trip-block__meta { font-family: var(--font-mono); font-size: 9px; color: var(--text-secondary); letter-spacing: 0.04em; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
