/* ==========================================================================
   Live Bus Departures — airport-style board
   ========================================================================== */
.departures-stage {
  position: relative;
  z-index: 1; /* sit above the fixed .mesh-background (orbs + grid) */
  padding: 4.5rem 0 5rem;
  background: var(--white);
}

.departures-title {
  margin: 0;
  text-align: center;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.4rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--navy-text);
}

.departures-accent {
  color: var(--primary-deep);
}

.departures-sub {
  margin: 0.75rem auto 0;
  max-width: 560px;
  text-align: center;
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* ---------- Board shell ---------- */
.departures-board {
  --board-line: #E3ECF7;
  padding: 1.5rem 1.5rem 1rem;
  border-radius: var(--radius-xl);
  margin-top: 2.75rem;
  background: linear-gradient(180deg, #FFFFFF 0%, #F7FAFF 100%);
  border: 1px solid #DCE7F5;
  box-shadow:
    0 30px 60px -28px rgba(15, 76, 255, 0.28),
    0 2px 6px rgba(11, 31, 58, 0.04);
  color: var(--navy-text);
}

.board-head {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0 0.25rem 1.25rem;
}

.board-logo {
  display: block;
  height: 52px;
  width: auto;
}

.board-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
  padding-right: 1.5rem;
  border-right: 1px solid var(--board-line);
}

.board-label-ico {
  width: 34px;
  height: 34px;
  color: var(--primary-deep);
  flex-shrink: 0;
}

.board-label strong {
  display: block;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--navy-text);
}

.board-label span {
  font-size: 0.85rem;
  color: var(--text-tertiary);
}

.board-clock {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 150px;
}

.board-clock time {
  font-size: 2.6rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--primary-deep);
  font-variant-numeric: tabular-nums;
}

.board-clock span {
  margin-top: 0.3rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ---------- Table ---------- */
.board-scroll {
  border-radius: var(--radius-md);
  overflow: hidden;
}

.board-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.board-table thead th {
  padding: 0.85rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.92rem;
  color: #FFFFFF;
  white-space: nowrap;
}

/* One continuous gradient across the whole header row (not restarted per cell) */
.board-table thead {
  background: linear-gradient(90deg, var(--primary-deep) 0%, var(--electric-blue) 100%);
}

.board-table thead th > * {
  vertical-align: middle;
}

.board-ico {
  width: 17px;
  height: 17px;
  margin-right: 0.45rem;
  opacity: 0.95;
}

.board-table tbody td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--board-line);
  white-space: nowrap;
  color: var(--navy-text);
}

.board-table tbody tr:nth-child(even) td {
  background: #F5F9FF;
}

.board-table tbody tr:last-child td {
  border-bottom: 0;
}

.board-table tbody .col-time {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--navy-text);
  font-variant-numeric: tabular-nums;
}

.board-table tbody tr.is-next .col-time {
  color: var(--primary-deep);
}

.col-route,
.col-bus {
  font-variant-numeric: tabular-nums;
}

.col-route {
  text-align: center;
}

tr.is-departed td {
  opacity: 0.6;
}

/* Provider badge: 5 colour variants */
.provider-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.8rem 0.3rem 0.3rem;
  border-radius: 10px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--badge-ink);
  background: var(--badge-bg);
}

.provider-code {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--badge-ink);
  color: #FFFFFF;
  font-variant-numeric: tabular-nums;
}

.provider-badge--1 { --badge-bg: #E3EDFF; --badge-ink: #0F4CFF; }
.provider-badge--2 { --badge-bg: #FFEEE3; --badge-ink: #C2410C; }
.provider-badge--3 { --badge-bg: #E3F6EA; --badge-ink: #15803D; }
.provider-badge--4 { --badge-bg: #E0F2FE; --badge-ink: #0369A1; }
.provider-badge--5 { --badge-bg: #FFE4E8; --badge-ink: #BE123C; }

/* Status */
.status {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 600;
}

.status::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 18%, transparent);
  flex-shrink: 0;
}

.status small {
  font-size: 0.78rem;
  font-weight: 500;
  opacity: 0.85;
}

.status--ontime { color: #16A34A; }
.status--boarding { color: #0284C7; }
.status--delayed { color: #D97706; }
.status--departed { color: #64748B; }
.status--departed::before { box-shadow: none; }

.status--boarding::before {
  animation: boardPulse 1.4s ease-in-out infinite;
}

@keyframes boardPulse {
  50% { transform: scale(0.7); opacity: 0.6; }
}

.board-note {
  margin: 0.9rem 0 0;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-tertiary);
}

/* ---------- Desktop: terminal-photo scene (>= 1200px) ----------
   The board sits on the hanging display in the photo (2398x1120). Without JS it is a
   flat box over the display's bounding area; departures.js projects it onto the display's
   exact perspective corners (.is-projected). Smaller screens keep the plain white board. */
@media (min-width: 1200px) {
  .departures-scene {
    --u: min(1vw, 16px); /* departures.js overrides this from the projected board height */
    position: relative;
    width: min(100% - 3rem, 1600px);
    max-width: none;
    margin: 2.5rem auto 0;
    padding: 0;
    aspect-ratio: 2398 / 1120;
    background: #DCEBFA url("../../assets/departures-terminal.webp") center / 100% 100% no-repeat;
    border-radius: var(--radius-xl);
    overflow: hidden;
  }
  .departures-scene .departures-board {
    position: absolute;
    left: 14.2%;
    top: 8.5%;
    width: 82.2%;
    height: 75%;
    margin: 0;
    padding: calc(var(--u) * 1.1) calc(var(--u) * 1.4) calc(var(--u) * 0.5);
    border: 3px solid #2F6BEA; /* blue display line */
    border-radius: calc(var(--u) * 1.4);
    box-shadow:
      0 0 0 7px #EEF3F9, /* silver bezel */
      0 0 0 8px #B9C8DB,
      0 30px 60px -24px rgba(15, 40, 90, 0.45);
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .departures-scene .departures-board.is-projected {
    left: 0;
    top: 0;
    transform-origin: 0 0;
    backface-visibility: hidden;
  }
  /* 8 rows fit the display: 1 departed + next 7 */
  .departures-scene .board-table tbody tr:first-child,
  .departures-scene .board-table tbody tr:nth-child(n + 10) { display: none; }

  .departures-scene .board-head { gap: calc(var(--u) * 1.4); padding: 0 0.25rem calc(var(--u) * 0.8); }
  .departures-scene .board-logo { height: calc(var(--u) * 3); }
  .departures-scene .board-label-ico { width: calc(var(--u) * 2.2); height: calc(var(--u) * 2.2); }
  .departures-scene .board-label strong { font-size: calc(var(--u) * 1.1); }
  .departures-scene .board-label span { font-size: calc(var(--u) * 0.8); }
  .departures-scene .board-clock { min-width: 0; }
  .departures-scene .board-clock time { font-size: calc(var(--u) * 2.5); }
  .departures-scene .board-clock span { font-size: calc(var(--u) * 0.8); }
  .departures-scene .board-scroll { flex: 1; min-height: 0; }
  .departures-scene .board-table { font-size: calc(var(--u) * 0.95); }
  .departures-scene .board-table thead th { padding: calc(var(--u) * 0.7) calc(var(--u) * 1); font-size: calc(var(--u) * 0.9); }
  .departures-scene .board-ico { width: calc(var(--u) * 1.1); height: calc(var(--u) * 1.1); }
  .departures-scene .board-table tbody td { padding: calc(var(--u) * 0.45) calc(var(--u) * 1); }
  .departures-scene .board-table tbody .col-time { font-size: calc(var(--u) * 1.05); }
  .departures-scene .provider-badge { font-size: calc(var(--u) * 0.85); padding: calc(var(--u) * 0.25) calc(var(--u) * 0.7) calc(var(--u) * 0.25) calc(var(--u) * 0.25); }
  .departures-scene .provider-code { width: calc(var(--u) * 1.5); height: calc(var(--u) * 1.5); font-size: calc(var(--u) * 0.65); }
  .departures-scene .status::before { width: calc(var(--u) * 0.75); height: calc(var(--u) * 0.75); }
  .departures-scene .status small { font-size: calc(var(--u) * 0.72); }
  .departures-scene .board-note { margin-top: calc(var(--u) * 0.35); font-size: calc(var(--u) * 0.72); }
}

/* ---------- Phones & tablets (< 1200px): same white board, terminal photo behind it ---------- */
@media (max-width: 1199px) {
  .departures-scene {
    margin-top: 2.5rem;
    padding: 3rem 1.5rem 6rem;
    background: #DCEBFA url("../../assets/departures-terminal.webp") 45% 30% / cover no-repeat;
    border-radius: var(--radius-xl);
    max-width: calc(100% - 2rem);
  }
  .departures-scene .departures-board {
    margin-top: 0;
    box-shadow:
      0 24px 48px -20px rgba(11, 31, 58, 0.45),
      0 2px 6px rgba(11, 31, 58, 0.08);
  }
}

@media (max-width: 640px) {
  .departures-scene {
    margin-top: 2rem;
    padding: 2rem 0.6rem 4rem;
    max-width: calc(100% - 1rem);
    border-radius: var(--radius-lg);
  }
}

/* ---------- Responsive ---------- */
@media (prefers-reduced-motion: reduce) {
  .status--boarding::before { animation: none; }
}

/* Tablet: keep the table, scroll it sideways with an edge-fade hint */
@media (max-width: 1100px) {
  .board-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    -webkit-mask-image: linear-gradient(90deg, #000 92%, transparent);
    mask-image: linear-gradient(90deg, #000 92%, transparent);
  }
  .board-table { min-width: 860px; }
}

/* Phone: each departure becomes a compact white card */
@media (max-width: 640px) {
  .departures-stage { padding: 3.25rem 0 3.5rem; }
  .departures-board { margin-top: 2rem; padding: 1rem 0.75rem 0.75rem; border-radius: var(--radius-lg); }

  .board-head { flex-wrap: wrap; gap: 0.75rem 1rem; padding-bottom: 1rem; }
  .board-logo { height: 34px; }
  .board-clock { margin-left: auto; min-width: 0; }
  .board-clock time { font-size: 1.8rem; }
  .board-clock span { font-size: 0.75rem; }
  .board-label { order: 3; flex-basis: 100%; margin: 0; padding: 0.6rem 0 0; border-right: 0; border-top: 1px solid var(--board-line); }
  .board-label-ico { width: 24px; height: 24px; }
  .board-label strong { font-size: 0.95rem; }
  .board-label span { font-size: 0.75rem; }

  .board-scroll { overflow: visible; -webkit-mask-image: none; mask-image: none; }
  .board-table { min-width: 0; }
  .board-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }
  .board-table,
  .board-table tbody { display: block; }

  .board-table tbody tr {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "time route  status"
      "prov prov   prov";
    align-items: center;
    gap: 0.5rem 0.75rem;
    padding: 0.85rem 0.75rem;
    margin-bottom: 0.6rem;
    border: 1px solid var(--board-line);
    border-radius: 14px;
    background: #FFFFFF;
    box-shadow: 0 6px 16px -10px rgba(15, 76, 255, 0.25);
  }
  .board-table tbody tr:nth-child(even) td { background: none; }
  .board-table tbody tr:last-child { margin-bottom: 0; }
  /* keep the phone view short: next 6 upcoming departures only */
  .board-table tbody tr.is-departed { display: none; }
  .board-table tbody tr:not(.is-departed) ~ tr:not(.is-departed) ~ tr:not(.is-departed) ~ tr:not(.is-departed) ~ tr:not(.is-departed) ~ tr:not(.is-departed) ~ tr { display: none; }
  .board-table tbody td { padding: 0; border: 0; white-space: normal; }

  .board-table tbody .col-time { grid-area: time; font-size: 1.15rem; }
  .col-from { grid-area: route; font-weight: 600; font-size: 0.95rem; }
  .col-to { display: none; }
  .col-from::after { content: " \2192  " attr(data-to); font-weight: 600; }
  .col-status { grid-area: status; justify-self: end; font-size: 0.82rem; }
  .col-provider { grid-area: prov; }
  .provider-badge { font-size: 0.78rem; }

  /* Route / Bus on one line with mini labels */
  .col-route, .col-bus {
    grid-row: 3;
    font-size: 0.8rem;
    text-align: left;
  }
  .col-route { grid-column: 1; }
  .col-bus { grid-column: 2 / -1; }
  .col-route::before, .col-bus::before {
    content: attr(data-label) " ";
    color: var(--text-tertiary);
    font-weight: 400;
  }
  .status::before { width: 9px; height: 9px; }
  .status small { display: none; }
}
