/* ═══ SEARCH PAGE ═══ */

[hidden] { display: none !important; }

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; position: relative; }

:root {
  --green: #34C759;
  --green-soft: rgba(52, 199, 89, 0.10);
  --orange: #FF9500;
  --orange-soft: rgba(255, 149, 0, 0.10);
  --red: #FF3B30;
  --red-soft: rgba(255, 59, 48, 0.10);
  --blue: #007AFF;
  --blue-soft: rgba(0, 122, 255, 0.10);
}

[data-theme="dark"] {
  --glow: rgba(88,86,214,0.18);
  --timeline-line: rgba(255,255,255,0.06);
  --timeline-dot-muted: rgba(255,255,255,0.12);
  --tag-bg: rgba(255,255,255,0.05);
  --search-bg: rgba(255,255,255,0.04);
  --search-border: rgba(255,255,255,0.08);
  --search-glow: var(--accent-ring);
  --livery-bg: #0a0a0c;
  --stop-hover: rgba(255,255,255,0.02);
}

[data-theme="light"] {
  --glow: rgba(88,86,214,0.10);
  --timeline-line: rgba(0,0,0,0.06);
  --timeline-dot-muted: rgba(0,0,0,0.08);
  --tag-bg: rgba(0,0,0,0.03);
  --search-bg: rgba(255,255,255,0.8);
  --search-border: rgba(0,0,0,0.06);
  --search-glow: var(--accent-soft);
  --livery-bg: #f0f0f5;
  --stop-hover: rgba(0,0,0,0.015);
}

/* ═══ NAV ═══
   Nav styles live in common.css. Search-only utilities below. */

/* Floating theme toggle - mirrors the home page masthead treatment */
.thm-float {
  position: fixed;
  bottom: 20px; right: 20px;
  z-index: 90;
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border-2);
  color: var(--fg-2);
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 15px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.08);
  transition: color .2s, background .2s, transform .25s var(--ease-out);
}
[data-theme="dark"] .thm-float { box-shadow: 0 6px 20px rgba(0,0,0,0.4); }
.thm-float:hover { color: var(--fg); background: var(--surface-2); transform: rotate(12deg); }
.thm-float:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Responsive nav rules are in common.css */

/* ═══ AMBIENT GLOW ═══ */
main::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 100vh; pointer-events: none;
  background: radial-gradient(900px 700px at 50% 200px, var(--glow), transparent 70%);
}

/* ═══ SEARCH HERO ═══ */
.search-hero {
  padding: 120px max(5vw, 20px) 56px;
  text-align: center;
  position: relative;
}
.search-wrap {
  max-width: 600px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}
.search-title {
  font-family: var(--font-display);
  font-size: clamp(30px, 4.5vw, 46px);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.05;
  margin-bottom: 14px;
  opacity: 0;
  animation: heroIn .7s cubic-bezier(0.16, 1, 0.3, 1) .05s forwards;
}
.search-title em {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  background: linear-gradient(135deg, var(--accent-light), var(--accent-gradient-end));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.search-sub {
  font-size: clamp(14px, 1.5vw, 16px);
  color: var(--fg-2);
  line-height: 1.55;
  margin-bottom: 32px;
  opacity: 0;
  animation: heroIn .7s cubic-bezier(0.16, 1, 0.3, 1) .12s forwards;
}
@keyframes heroIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ═══ SEARCH FORM ═══ */
.search-form {
  display: flex;
  align-items: stretch;
  background: var(--search-bg);
  border: 1px solid var(--search-border);
  border-radius: 18px;
  padding: 6px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 4px 32px rgba(0,0,0,0.08), inset 0 1px 0 rgba(255,255,255,0.04);
  transition: border-color .3s, box-shadow .3s;
  opacity: 0;
  animation: heroIn .7s cubic-bezier(0.16, 1, 0.3, 1) .2s forwards;
}
.search-form:focus-within {
  border-color: var(--accent-ring-strong);
  box-shadow: 0 4px 32px rgba(0,0,0,0.08), 0 0 0 3px var(--search-glow), inset 0 1px 0 rgba(255,255,255,0.04);
}
.search-input-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute; left: 14px;
  color: var(--fg-3); pointer-events: none;
  transition: color .2s;
}
.search-input-wrap:focus-within .search-icon { color: var(--accent-light); }
.search-input {
  width: 100%;
  padding: 12px 14px 12px 42px;
  border-radius: 12px;
  border: none; background: transparent;
  color: var(--fg);
  font-size: 16px; font-family: var(--font-body); font-weight: 600;
  letter-spacing: -0.01em; outline: none;
  transition: background .2s;
}
.search-input::placeholder { color: var(--fg-3); font-weight: 400; }
.search-input:focus { background: var(--accent-tint); }
.search-input:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.search-date-wrap {
  flex-shrink: 0; display: flex; align-items: center;
  border-left: 1px solid var(--search-border);
  margin: 4px 0; padding-left: 2px;
}
.search-date {
  padding: 10px;
  border-radius: 10px; border: none; background: transparent;
  color: var(--fg-2); font-size: 16px; font-family: var(--font-body); font-weight: 500;
  outline: none; cursor: pointer; transition: color .2s;
}
.search-date:focus { color: var(--fg); }
.search-date:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.search-btn {
  padding: 12px 22px; border-radius: 12px;
  background: var(--accent); color: #fff;
  font-size: 14px; font-weight: 700; font-family: var(--font-body);
  border: none; cursor: pointer; white-space: nowrap;
  letter-spacing: -0.01em;
  transition: all .25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 2px 12px var(--accent-ring-strong), inset 0 1px 0 rgba(255,255,255,.15);
  flex-shrink: 0;
}
.search-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--accent-shadow), inset 0 1px 0 rgba(255,255,255,.15);
}
.search-btn:active { transform: translateY(0) scale(0.98); }
.search-btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.search-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; box-shadow: 0 0 0 4px var(--accent); }

/* ═══ LOADING SKELETON (mimics the real result layout) ═══ */
.loading-skeleton { animation: sk-fade .3s var(--ease-out); }
@keyframes sk-fade { from { opacity: 0; } to { opacity: 1; } }

.sk {
  background: linear-gradient(
    90deg,
    var(--surface) 0%,
    var(--surface-2) 50%,
    var(--surface) 100%
  );
  background-size: 200% 100%;
  border-radius: 8px;
  animation: sk-shimmer 1.4s ease-in-out infinite;
}
@keyframes sk-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.sk-livery {
  width: 100%; height: 220px;
  background: var(--livery-bg);
  border-bottom: 1px solid var(--border);
}
.sk-grid {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px max(5vw, 24px) 100px;
  display: grid;
  grid-template-columns: minmax(340px, 400px) 1fr;
  gap: 56px;
  align-items: start;
}
.sk-info { display: flex; flex-direction: column; gap: 28px; }
.sk-card {
  padding: 22px; border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.sk-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 24px;
}
.sk-badge { width: 72px; height: 22px; border-radius: 980px; }
.sk-line { height: 12px; border-radius: 6px; }
.sk-line.sk-w-60  { width: 60px; }
.sk-line.sk-w-80  { width: 80px; }
.sk-line.sk-w-100 { width: 100px; }
.sk-line.sk-w-120 { width: 120px; }
.sk-line.sk-w-140 { width: 140px; }
.sk-line.sk-w-160 { width: 160px; }
.sk-line.sk-w-180 { width: 180px; }
.sk-line.sk-w-200 { width: 200px; }

.sk-route { display: flex; flex-direction: column; gap: 2px; }
.sk-route-row {
  display: grid;
  grid-template-columns: 18px auto 1fr;
  column-gap: 14px;
  align-items: start;
  padding: 4px 0;
}
.sk-dot {
  width: 14px; height: 14px; border-radius: 50%;
  margin-top: 6px; margin-left: 2px;
}
.sk-dot.ring {
  background: transparent; border: 2.5px solid var(--border-2);
  animation: none;
}
.sk-dot.small { width: 10px; height: 10px; margin-top: 4px; }
.sk-time { width: 60px; height: 22px; border-radius: 6px; }
.sk-time.small { width: 40px; height: 14px; }
.sk-route-col { display: flex; flex-direction: column; gap: 6px; padding-top: 6px; }
.sk-route-middle {
  padding: 10px 0 10px 38px;
  position: relative;
}
.sk-route-middle::before {
  content: "";
  position: absolute;
  left: 11px; top: -2px; bottom: -2px;
  width: 2px;
  background: repeating-linear-gradient(to bottom, var(--timeline-line) 0 4px, transparent 4px 7px);
}

.sk-stops { padding-top: 4px; }
.sk-stop {
  display: grid;
  grid-template-columns: 18px 60px 1fr;
  column-gap: 14px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.sk-stop:last-child { border-bottom: 0; }

@media (max-width: 960px) {
  .sk-grid { grid-template-columns: 1fr; max-width: 680px; gap: 32px; }
}
@media (max-width: 600px) {
  .sk-livery { height: 160px; }
  .sk-grid { padding: 24px 16px 60px; }
}

/* ═══ LEGACY loading block (kept for old markup paths) ═══ */
.spinner {
  width: 24px; height: 24px;
  border: 2px solid var(--border-2); border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .65s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══ ERROR ═══ */
.error-wrap {
  max-width: 1040px; margin: 0 auto;
  padding: 0 max(5vw, 20px);
}
.error-box {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; border-radius: 14px;
  background: var(--red-soft); border: 1px solid var(--red-soft);
  color: var(--red); font-size: 13.5px; font-weight: 600;
  animation: shakeIn .5s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes shakeIn {
  0%   { opacity: 0; transform: translateX(-8px); }
  40%  { transform: translateX(4px); }
  70%  { transform: translateX(-2px); }
  100% { opacity: 1; transform: translateX(0); }
}

/* ═══ EMPTY STATE ═══ */
.empty-state {
  max-width: 1040px;
  margin: 0 auto;
  padding: 16px max(5vw, 20px) 120px;
  animation: heroIn .6s cubic-bezier(0.16, 1, 0.3, 1) .3s both;
}
.empty-inner {
  text-align: center;
  display: flex; flex-direction: column; align-items: center;
  gap: 20px;
}
.empty-text {
  font-size: 14px; color: var(--fg-3); line-height: 1.5;
}
.empty-chips {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px;
}
.empty-chip {
  display: inline-flex; align-items: center; gap: 0;
  padding: 10px 18px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--fg-2); font-size: 13.5px; font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all .25s cubic-bezier(0.16, 1, 0.3, 1);
}
.empty-chip strong {
  font-weight: 700; color: var(--fg); margin-right: 6px;
  font-family: var(--font-display); letter-spacing: -0.02em;
}
.empty-chip:hover {
  border-color: var(--accent); background: var(--accent-soft); color: var(--fg);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px var(--accent-soft);
}
.empty-chip:active { transform: translateY(0) scale(0.97); }
.empty-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ═══ TRAIN DETAIL ═══ */
.train-detail {
  animation: resultIn .5s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes resultIn {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ══ LIVERY BANNER ══ */
.td-livery:empty { display: none; }
.td-livery {
  position: relative; width: 100%; overflow: hidden;
  background: var(--livery-bg);
  border-bottom: 1px solid var(--border);
}
.livery-banner {
  max-width: 100%; margin: 0 auto;
  padding: 20px max(5vw, 24px) 24px;
  display: flex; flex-direction: column; align-items: center;
  gap: 20px;
}
.livery-meta {
  display: flex; flex-direction: column; align-items: center;
  gap: 6px; text-align: center;
}
.livery-marque {
  font-family: var(--font-display);
  font-size: 24px; font-weight: 800;
  letter-spacing: -0.03em; color: var(--fg); line-height: 1.1;
}
.livery-nom {
  font-size: 13px; color: var(--fg-3); font-weight: 500;
  letter-spacing: -0.01em;
}
.livery-rakes {
  display: flex; flex-direction: row; flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  width: 100%;
  margin-top: 4px;
}
.livery-rake {
  display: flex; flex-direction: column; align-items: center;
  gap: 6px;
  padding: 10px 14px; border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border-2);
}
.livery-rake-title {
  display: flex; align-items: baseline; gap: 8px;
  flex-wrap: wrap; justify-content: center;
}
.livery-rake-index {
  font-family: var(--font-display);
  font-size: 11px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase;
  padding: 2px 8px; border-radius: 980px;
  background: var(--accent-soft); color: var(--accent-light);
}
.livery-rake-name {
  font-size: 13px; font-weight: 600; color: var(--fg);
  letter-spacing: -0.01em;
}
.livery-stats--couples { margin-top: 4px; }
.livery-img-wrap {
  width: 100%;
  display: flex; align-items: center; justify-content: center;
  gap: 0;
  filter: drop-shadow(0 12px 48px rgba(0,0,0,0.35));
  transition: transform .4s cubic-bezier(0.16, 1, 0.3, 1);
}
.livery-img-wrap:hover { transform: scale(1.01); }
.livery-img {
  height: auto; display: block;
  flex-shrink: 1; min-width: 0;
  max-width: 100%;
}
/* Multi-element rakes (loco + rame, coupled trains): pin every image to the
   same height so they share a consistent pixel/metre scale. The combined
   width can exceed the viewport - horizontal scroll lets the user pan. */
.livery-img-wrap--multi {
  align-items: end;
  overflow-x: auto;
  /* Centre when the rake fits, fall back to start (no clipping) when it overflows. */
  justify-content: safe center;
  scrollbar-width: thin;
  scrollbar-color: var(--border-3) transparent;
  cursor: grab;
  -webkit-user-select: none; user-select: none;
}
.livery-img-wrap--multi.is-dragging { cursor: grabbing; }
.livery-img-wrap--multi.is-dragging:hover { transform: none; }
.livery-img-wrap--multi .livery-img {
  -webkit-user-drag: none;
  pointer-events: none; /* let mousedown bubble to the wrap */
}
.livery-img-wrap--multi::-webkit-scrollbar { height: 4px; }
.livery-img-wrap--multi::-webkit-scrollbar-track { background: transparent; }
.livery-img-wrap--multi::-webkit-scrollbar-thumb {
  background: var(--border-3); border-radius: 980px;
}
.livery-img-wrap--multi::-webkit-scrollbar-thumb:hover { background: var(--fg-3); }
.livery-img-wrap--multi .livery-img {
  height: 50px;
  width: auto;
  max-width: none;
  flex-shrink: 0;
}
[data-theme="light"] .livery-img-wrap {
  filter: drop-shadow(0 6px 24px rgba(0,0,0,0.12));
}
.livery-stats {
  display: flex; flex-wrap: wrap; gap: 6px;
  justify-content: center; margin-top: 4px;
}
.livery-stat {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 11px; border-radius: 8px;
  background: var(--tag-bg);
  font-size: 12px; font-weight: 600; color: var(--fg-2);
}
.livery-stat .svc-icon { width: 13px; height: 13px; flex-shrink: 0; }

/* Clickable variant: coupled train numbers pivot the search on click. */
button.livery-stat-coupled {
  font-family: var(--font-body);
  border: 1px solid var(--accent-ring-soft);
  background: var(--accent-soft);
  color: var(--accent-light);
  cursor: pointer;
  transition: all .2s var(--ease-out);
}
button.livery-stat-coupled strong {
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
  color: var(--fg); font-weight: 700;
  margin-left: 2px;
}
button.livery-stat-coupled:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  box-shadow: 0 3px 10px var(--accent-soft);
}
button.livery-stat-coupled:active { transform: translateY(0) scale(0.98); }
button.livery-stat-coupled:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* ══ TWO-COLUMN GRID ══ */
.td-grid {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px max(5vw, 24px) 100px;
  display: grid;
  grid-template-columns: minmax(340px, 400px) 1fr;
  gap: 56px;
  align-items: start;
}

/* ── Left: info panel ── */
.td-info {
  position: sticky; top: 72px;
  display: flex; flex-direction: column; gap: 28px;
}

/* Header card */
.td-header-card {
  padding: 22px 22px 20px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: background .3s, border-color .3s;
  position: relative;
}
.td-header-card::before {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(120% 80% at 0% 0%, var(--accent-tint), transparent 60%);
  pointer-events: none;
  z-index: 0;
}
.td-header-card > * { position: relative; z-index: 1; }

/* Top row: category badge + train number */
.td-top-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}
.td-category {
  display: inline-flex; padding: 5px 12px; border-radius: 980px;
  font-size: 10.5px; font-weight: 700;
  letter-spacing: .05em; text-transform: uppercase;
  flex-shrink: 0;
}
.td-cat-tgv { background: var(--accent-soft); color: var(--accent-light); }
.td-cat-ouigo { background: rgba(0,166,214,.10); color: var(--color-ouigo); }
.td-cat-ter { background: rgba(0,150,199,.10); color: var(--color-ter); }
.td-cat-intercites { background: rgba(163,31,52,.10); color: var(--color-intercites); }
.td-cat-default { background: var(--tag-bg); color: var(--fg-2); }
.td-trip-id {
  font-family: var(--font-display);
  font-size: 13px; font-weight: 700; color: var(--fg);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  text-align: right;
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.td-trip-date {
  color: var(--fg-3); font-weight: 500;
}

/* Freshness indicator (kept for legacy / future use) */
.td-freshness {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; color: var(--fg-3);
}
.td-freshness-dot { width: 6px; height: 6px; border-radius: 50%; }
.td-freshness-dot.realtime {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse-dot 2s ease-in-out infinite;
}
.td-freshness-dot.adapted { background: var(--orange); }
.td-freshness-dot.scheduled { background: var(--fg-3); }
@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 8px var(--green); }
  50%      { opacity: .5; box-shadow: 0 0 4px var(--green); }
}

/* Vertical mini-timeline route */
.td-route {
  position: relative;
  padding: 4px 0 4px 2px;
}
.td-route-row {
  display: grid;
  grid-template-columns: 18px auto 1fr;
  column-gap: 14px;
  align-items: start;
  padding: 2px 0;
}
.td-route-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring-soft);
  margin-top: 6px; margin-left: 2px;
  position: relative; z-index: 2;
}
.td-route-dot.dest {
  background: var(--bg);
  border: 2.5px solid var(--accent);
  box-shadow: none;
}
.td-route-time {
  font-family: var(--font-display);
  font-size: 26px; font-weight: 800;
  letter-spacing: -0.03em; line-height: 1.05;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
}
.td-route-time.delayed { color: var(--orange); }
.td-route-station-wrap {
  min-width: 0;
  padding-top: 3px;
}
.td-route-station {
  font-size: 14px; font-weight: 600;
  color: var(--fg); line-height: 1.3;
  letter-spacing: -0.01em;
  word-wrap: break-word; overflow-wrap: anywhere;
}
.td-route-tz {
  font-family: var(--font-display);
  font-size: 10.5px; font-weight: 600;
  color: var(--fg-3); margin-top: 3px;
  letter-spacing: 0;
}
.td-route-delay {
  margin-top: 6px;
  font-size: 11.5px; font-weight: 700; color: var(--orange);
  line-height: 1.4;
}

/* Middle connector: dashed line + duration + direct badge */
.td-route-middle {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 0 6px 38px;
  position: relative;
  min-height: 24px;
}
.td-route-middle::before {
  content: "";
  position: absolute;
  left: 11px; top: -2px; bottom: -2px;
  width: 2px;
  background: repeating-linear-gradient(to bottom, var(--timeline-line) 0 4px, transparent 4px 7px);
}
.td-route-duration {
  font-family: var(--font-display);
  font-size: 12px; font-weight: 700;
  color: var(--fg-2); letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.td-route-badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 980px;
  font-size: 10.5px; font-weight: 700;
  letter-spacing: .02em;
  background: var(--tag-bg); color: var(--fg-3);
}
.td-route-badge.direct {
  background: var(--accent-soft); color: var(--accent-light);
}
.td-cancelled-badge {
  margin-top: 16px; padding: 10px 16px; border-radius: 10px;
  background: var(--red-soft); border: 1px solid var(--red-soft);
  color: var(--red); font-size: 13px; font-weight: 700; text-align: center;
}
.td-route-terminus-tag {
  display: inline-block; vertical-align: middle;
  margin-left: 6px;
  padding: 2px 8px; border-radius: 980px;
  font-family: var(--font-display);
  font-size: 10.5px; font-weight: 700; letter-spacing: .02em;
  background: var(--orange-soft); color: var(--orange);
  white-space: nowrap;
}
.td-route-origin-tag {
  display: inline-block; vertical-align: middle;
  margin-left: 6px;
  padding: 2px 8px; border-radius: 980px;
  font-family: var(--font-display);
  font-size: 10.5px; font-weight: 700; letter-spacing: .02em;
  background: var(--accent-soft); color: var(--accent-light);
  border: 1px solid var(--accent-ring-soft);
  white-space: nowrap;
}
.td-rerouted-badge {
  margin-top: 14px; padding: 12px 14px; border-radius: 12px;
  background: var(--orange-soft); border: 1px solid var(--orange-soft);
  color: var(--orange);
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 13px; line-height: 1.45;
}
.td-rerouted-badge--origin {
  background: var(--accent-soft); border-color: var(--accent-ring-soft);
  color: var(--accent-light);
}
.td-rerouted-badge svg { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 1px; }
.td-rerouted-badge strong { font-weight: 700; }

/* ═══ DISRUPTIONS ═══ */
.td-disruptions:empty { display: none; }
.disruption {
  padding: 14px 16px; border-radius: 14px;
  border: 1px solid; position: relative; overflow: hidden;
}
.disruption + .disruption { margin-top: 8px; }
.disruption::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
}
.disruption.info { background: var(--blue-soft); border-color: var(--blue-soft); }
.disruption.info::before { background: var(--blue); }
.disruption.warning { background: var(--orange-soft); border-color: var(--orange-soft); }
.disruption.warning::before { background: var(--orange); }
.disruption.critical { background: var(--red-soft); border-color: var(--red-soft); }
.disruption.critical::before { background: var(--red); }
.disruption-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.disruption-icon { width: 16px; height: 16px; flex-shrink: 0; }
.disruption.info .disruption-icon { color: var(--blue); }
.disruption.warning .disruption-icon { color: var(--orange); }
.disruption.critical .disruption-icon { color: var(--red); }
.disruption-title { font-size: 13px; font-weight: 700; }
.disruption.info .disruption-title { color: var(--blue); }
.disruption.warning .disruption-title { color: var(--orange); }
.disruption.critical .disruption-title { color: var(--red); }
.disruption-message {
  font-size: 12px; color: var(--fg-2); line-height: 1.5; padding-left: 24px;
}
.disruption-toggle {
  display: block; width: 100%; margin-top: 8px;
  padding: 8px; border-radius: 10px;
  background: transparent; border: 1px solid var(--border);
  color: var(--fg-2); font-size: 12.5px; font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer; transition: all .2s;
}
.disruption-toggle:hover {
  background: var(--surface); color: var(--fg);
}

/* ═══ COMPOSITION SERVICES ═══ */
.td-composition:empty { display: none; }
.comp-services-card {
  padding: 20px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  transition: background .3s, border-color .3s;
}
.comp-services-title {
  font-size: 11px; font-weight: 700; color: var(--fg-3);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 10px;
}
.comp-services { display: flex; flex-wrap: wrap; gap: 6px; }
.comp-service {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px; border-radius: 980px;
  background: var(--accent-soft);
  font-size: 11px; font-weight: 600; color: var(--accent-light);
}
.comp-service .svc-icon { width: 13px; height: 13px; flex-shrink: 0; }

/* ═══ STOPS TIMELINE ═══ */
.td-stops-title {
  font-family: var(--font-display);
  font-size: 15px; font-weight: 700; letter-spacing: -0.01em;
  margin-bottom: 28px; color: var(--fg);
  display: flex; align-items: center; gap: 12px;
}
.td-stops-title::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}

.stop-list {
  position: relative; padding-left: 36px;
}
/* Background track (full, muted) */
.stop-list::before {
  content: ""; position: absolute;
  left: 9px; top: 10px; bottom: 10px;
  width: 2px; z-index: 0;
  background: var(--timeline-line);
  border-radius: 1px;
}
/* Progress track (colored, set via JS --progress) */
.stop-list::after {
  content: ""; position: absolute;
  left: 9px; top: 10px;
  width: 2px; z-index: 1;
  height: var(--progress, 0%);
  background: var(--accent);
  border-radius: 1px;
  transition: height .6s cubic-bezier(0.16, 1, 0.3, 1);
}

.stop {
  position: relative; z-index: 2;
  padding: 8px 12px 8px 20px;
  margin-bottom: 4px;
  border-radius: 12px;
  opacity: 0;
  animation: stopIn .45s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: background .2s;
}
.stop:hover { background: var(--stop-hover); }
.stop:last-child { margin-bottom: 0; }

@keyframes stopIn {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Dot - centered on the line (line center = 10px from stop-list edge) */
.stop-dot {
  position: absolute; left: -33px; top: 13px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--timeline-line);
  z-index: 2; transition: all .3s;
}

/* Origin & terminus */
.stop.origin .stop-dot,
.stop.terminus .stop-dot {
  width: 18px; height: 18px; left: -35px; top: 11px;
  background: var(--accent); border: 2.5px solid var(--accent);
  box-shadow: 0 0 12px var(--accent-ring-strong);
}
.stop.origin .stop-dot::after,
.stop.terminus .stop-dot::after {
  content: ""; position: absolute; inset: 3px;
  border-radius: 50%; background: var(--bg);
  transition: background .3s;
}

/* Default intermediate */
.stop:not(.origin):not(.terminus):not(.skipped):not(.cancelled) .stop-dot {
  border-color: var(--accent);
}

/* Passed stops: muted text */
.stop.passed .stop-name { color: var(--fg-2); }
.stop.passed .stop-time-scheduled { color: var(--fg-3); }

/* At station: highlighted row */
.stop.at-station { background: var(--accent-soft); }
.stop.at-station .stop-dot {
  background: var(--accent); border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-ring-soft);
  animation: currentPulse 2s ease-in-out infinite;
}

/* Current (next stop): subtle highlight */
.stop.current { background: var(--stop-hover); }

/* Passed stops - filled dot */
.stop.passed .stop-dot {
  background: var(--accent); border-color: var(--accent);
}
.stop.passed.origin .stop-dot,
.stop.passed.terminus .stop-dot {
  background: var(--accent);
}
.stop.passed.origin .stop-dot::after,
.stop.passed.terminus .stop-dot::after {
  background: var(--accent);
}

/* Current stop - pulsing */
.stop.current .stop-dot {
  background: var(--accent); border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-ring);
  animation: currentPulse 2s ease-in-out infinite;
}
@keyframes currentPulse {
  0%, 100% { box-shadow: 0 0 0 4px var(--accent-ring); }
  50%      { box-shadow: 0 0 0 8px rgba(88,86,214,0.08); }
}

/* Upcoming - default (hollow) */

/* Skipped */
.stop.skipped .stop-dot {
  border-color: var(--timeline-dot-muted); border-style: dashed; opacity: .6;
  background: var(--bg);
}
/* Delayed */
.stop.delayed:not(.passed) .stop-dot {
  border-color: var(--orange); box-shadow: 0 0 8px var(--orange-soft);
}
.stop.delayed.passed .stop-dot {
  background: var(--orange); border-color: var(--orange);
}
/* Cancelled */
.stop.cancelled .stop-dot {
  border-color: var(--red); background: var(--red); opacity: .35;
}

/* Stop content - timetable layout: time left, station right */
.stop-content {
  display: flex; align-items: flex-start; gap: 14px;
}

/* Time column (fixed width for scanability) */
.stop-time {
  width: 56px; flex-shrink: 0; text-align: right; padding-top: 1px;
}
.stop-time-scheduled {
  font-family: var(--font-display);
  font-size: 15px; font-weight: 700; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; color: var(--fg); line-height: 1;
}
.stop.delayed .stop-time-scheduled {
  font-size: 11.5px; color: var(--fg-3); text-decoration: line-through; opacity: .6;
}
.stop-time-actual {
  font-family: var(--font-display);
  font-size: 15px; font-weight: 700; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; color: var(--orange); line-height: 1; margin-top: 3px;
}
.stop-time-tz {
  font-family: var(--font-display); font-size: 10px; font-weight: 600;
  color: var(--fg-3); letter-spacing: 0; margin-top: 3px;
  white-space: nowrap;
}
.stop.skipped .stop-time-scheduled {
  color: var(--fg-3); text-decoration: line-through; opacity: .5;
}

/* Station info */
.stop-info { flex: 1; min-width: 0; }
.stop-name {
  font-size: 14.5px; font-weight: 600;
  letter-spacing: -0.015em; color: var(--fg); line-height: 1.35;
}
.stop.skipped .stop-name {
  text-decoration: line-through; color: var(--fg-3); opacity: .6;
}
.stop-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.stop-tag {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 3px 8px; border-radius: 6px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .01em;
}
.stop-tag.platform { background: var(--accent-soft); color: var(--accent-light); }
.stop-tag.hall { background: var(--tag-bg); color: var(--fg-2); }
.stop-tag.delay-tag { background: var(--orange-soft); color: var(--orange); }
.stop-tag.cancelled-tag { background: var(--red-soft); color: var(--red); }
.stop-tag.added-tag { background: var(--green-soft); color: var(--green); }
.stop-tag.exceptional-terminus-tag { background: var(--orange-soft); color: var(--orange); }
.stop-tag.exceptional-origin-tag {
  background: var(--accent-soft); color: var(--accent-light);
  border: 1px solid var(--accent-ring-soft);
  font-weight: 700;
  letter-spacing: .02em;
}
.stop-tag.boarding-tag,
.stop-tag.exit-tag { background: var(--tag-bg); color: var(--fg-3); }
.stop-tag.stop-duration { background: transparent; color: var(--fg-3); padding-left: 0; }
.stop-tag.at-station-tag {
  background: var(--accent); color: #fff; font-weight: 700;
  animation: currentPulse 2s ease-in-out infinite;
}
.stop-tag.next-stop-tag {
  background: var(--accent-soft); color: var(--accent-light); font-weight: 700;
}

/* Train position marker */
.train-marker {
  position: absolute;
  left: 3px; width: 14px; height: 14px;
  z-index: 3;
  transform: translateY(-50%);
  pointer-events: none;
}
.train-marker::before {
  content: "";
  position: absolute; inset: 0;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent-shadow), 0 0 20px var(--accent-ring-soft);
  animation: trainPulse 1.5s ease-in-out infinite;
}
@keyframes trainPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.3); opacity: .7; }
}

/* ═══ FAQ ═══ */
.search-faq {
  max-width: 760px;
  margin: 0 auto;
  padding: 80px max(5vw, 20px) 60px;
}
.faq-title {
  font-family: var(--font-display);
  font-size: clamp(20px, 2.5vw, 28px);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 32px;
  text-align: center;
}
.faq-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.faq-item {
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: background .3s, border-color .3s;
}
.faq-item[open] {
  border-color: var(--accent-ring-soft);
}
.faq-q {
  padding: 16px 20px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--fg);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: color .2s;
}
.faq-q::-webkit-details-marker { display: none; }
.faq-q::marker { display: none; content: ""; }
.faq-q::after {
  content: "+";
  font-size: 18px;
  font-weight: 400;
  color: var(--fg-3);
  flex-shrink: 0;
  transition: transform .2s;
}
.faq-item[open] .faq-q::after {
  content: "\2212";
}
.faq-q:hover { color: var(--accent-light); }
.faq-q:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 14px; }
.faq-a {
  padding: 0 20px 16px;
  font-size: 13.5px;
  color: var(--fg-2);
  line-height: 1.65;
}
.faq-a a {
  color: var(--accent-light);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.faq-a a:hover {
  color: var(--accent);
}

/* ═══ RESPONSIVE ═══ */

@media (max-width: 960px) {
  /* Mobile reorder: the livery (rames + train SVG) is a "nice to know" not
     the primary content. The user searched by number, they want to see the
     header + journey first. We push the livery to the bottom of the page
     and let header → disruptions → stops → composition flow naturally above.
     `display: contents` on .td-info flattens its children into .td-grid so
     we can order all 4 of them (header, disruptions, composition, stops). */
  .train-detail {
    display: flex; flex-direction: column;
  }
  .td-grid { order: 1; }
  .td-livery { order: 2; }

  .td-grid {
    grid-template-columns: 1fr;
    gap: 24px;
    max-width: 680px;
  }
  .td-info {
    display: contents;
  }
  .td-header        { order: 1; }
  .td-disruptions   { order: 2; }
  .td-stops         { order: 3; }
  .td-composition   { order: 4; }

  .livery-banner { padding: 14px 20px 20px; gap: 14px; }
  .livery-marque { font-size: 20px; }
  .livery-nom    { font-size: 12px; }
}

@media (max-width: 600px) {
  .search-hero { padding: 100px 16px 40px; }
  .search-form {
    flex-direction: column; padding: 8px;
  }
  .search-date-wrap {
    border-left: none;
    border-top: 1px solid var(--search-border);
    margin: 0; padding: 0;
  }
  .search-date { width: 100%; padding: 10px 14px; }
  .search-btn {
    width: 100%; padding: 14px;
    border-radius: 10px; margin-top: 2px;
  }
  .td-grid { padding: 24px 16px 60px; }
  .td-route-time { font-size: 24px; }
  .td-route-station { font-size: 13.5px; }
  .stop-time { width: 48px; }
  .stop-list { padding-left: 30px; }
  .stop-dot { left: -27px; }
  .stop.origin .stop-dot,
  .stop.terminus .stop-dot { left: -29px; }
  /* Single-rake images get the full card width on mobile - they fit. */
  .livery-img-wrap:not(.livery-img-wrap--multi) {
    flex-direction: column;
    gap: 14px;
    min-height: 0;
  }
  .livery-img-wrap:not(.livery-img-wrap--multi) .livery-img {
    width: 100%;
    max-width: 100%;
    height: auto;
  }
  /* Multi-rake (coupled trains, loco + rame) stays horizontally scrollable so
     users can swipe through the long train and see each voiture. Bumped
     height so details are readable on small screens. A subtle right-edge
     fade hints there's more to scroll. */
  .livery-img-wrap--multi {
    padding: 4px 0;
    -webkit-overflow-scrolling: touch;
    mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 24px), transparent 100%);
    -webkit-mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 24px), transparent 100%);
  }
  .livery-img-wrap--multi .livery-img {
    height: 68px;
  }
  .livery-banner { padding: 14px 16px 18px; }
  .empty-state { padding-bottom: 80px; }
  .search-faq { padding: 60px 16px 40px; }
}
