/* ================================================================
   results.css — Cartes trains, badges, liste des arrêts
   ================================================================ */

/* ── En-tête des résultats ────────────────────────────────── */
.results-header {
  font-size: .85rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
  padding: 0 2px;
}

.results-empty {
  text-align: center;
  color: var(--text-secondary);
  padding: 48px 0;
  font-size: .95rem;
}

/* ── Carte train ──────────────────────────────────────────── */
.train-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
  transition: box-shadow var(--transition);
}
.train-card:hover { box-shadow: var(--shadow); }

/* ── Header : badge type + numéro + durée ─────────────────── */
.train-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px 12px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.train-type-badge {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 20px;
  color: #fff;
  white-space: nowrap;
  flex-shrink: 0;
}

.train-num-main {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
}

.train-duration {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px;
  white-space: nowrap;
}

/* ── Corps : grid 3col × 2rows ────────────────────────────── */
/*
   col 1 : heure dep  →  auto
   col 2 : décoration →  1fr
   col 3 : heure arr  →  auto
   row 1 : heures + décoration
   row 2 : noms des gares
*/
.train-body {
  display: grid;
  grid-template-columns: max-content 1fr max-content;
  grid-template-rows: auto auto;
  column-gap: 0;
  row-gap: 6px;
  padding: 16px 20px;
  align-items: center;
  position: relative;
}

.trip-time {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.02em;
  color: var(--text-primary);
  white-space: nowrap;
}

.trip-time.dep { grid-column: 1; grid-row: 1; z-index: 2; }
.trip-time.arr { grid-column: 3; grid-row: 1; z-index: 2; text-align: right; }

.trip-station {
  font-size: .82rem;
  color: var(--text-secondary);
  line-height: 1.3;
  word-break: break-word;
}

.trip-station.dep { grid-column: 1; grid-row: 2; }
.trip-station.arr { grid-column: 3; grid-row: 2; text-align: right; }

/* ── Décoration ●──────────● ──────────────────────────────── */
.trip-decoration {
  grid-column: 1 / -1;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 85px;
  z-index: 1;
}

.deco-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--train-color, var(--primary));
  flex-shrink: 0;
}

.deco-bar {
  flex-grow: 1;
  height: 2px;
  background: var(--train-color, var(--primary));
}

/* ── Bouton dérouler ──────────────────────────────────────── */
.stops-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  background: var(--bg);
  cursor: pointer;
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition);
  text-align: left;
}

.stops-toggle:hover { background: var(--primary-light); color: var(--primary); }
.stops-toggle.open  { border-radius: 0; }

.stops-toggle .toggle-icon {
  flex-shrink: 0;
  transition: transform .2s ease;
}
.stops-toggle.open .toggle-icon { transform: rotate(180deg); }

/* ── Liste des arrêts ─────────────────────────────────────── */
.stops-list {
  padding: 16px 20px 20px;
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ── Un arrêt ─────────────────────────────────────────────── */
.stop-item {
  display: flex;
  flex-direction: column;
  position: relative;
  padding-bottom: 16px;
}

.stop-item:last-child { padding-bottom: 0; }

/* Segment au-dessus du dot — tous les arrêts sauf le premier */
.stop-item:not(:first-child)::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 0;
  width: 2px;
  height: 12px;
  background: var(--stop-line-color, var(--border));
  z-index: 0;
}

/* Ligne AU-DESSUS de la gare de départ de la recherche : toujours grise */
.stop-item.route-start::before {
  background: #9ca3af;
}

/* Segment en dessous du dot — tous les arrêts sauf le dernier */
.stop-item:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 12px;            /* juste sous le dot */
  width: 2px;
  bottom: 0;
  background: var(--stop-line-color, var(--border));
  z-index: 0;
}

/* Ligne EN-DESSOUS de la gare d'arrivée de la recherche : grise si pas terminus */
.stop-item.route-end::after {
  background: #9ca3af;
}

/* Point de l'arrêt — taille uniforme, sans margin-top */
.stop-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  /* background posé inline via JS */
}

/* Ligne principale : dot + heure + nom alignés */
.stop-main {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
}

.stop-arr-time {
  font-size: .88rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
  flex-shrink: 0;
  min-width: 38px;      /* largeur fixe → permet d'aligner .stop-dwell sous le nom */
}

.stop-name {
  font-size: .875rem;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

/* Temps d'arrêt — dot(12) + gap(10) + time(38) + gap(10) = 70px */
.stop-dwell {
  font-size: .75rem;
  color: var(--text-disabled);
  margin-top: 1px;
  padding-left: 70px;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 520px) {
  .train-body  { column-gap: 10px; padding: 14px 16px; }
  .trip-time   { font-size: 1.3rem; }
}

/* ── Bandeau temps réel (résultats de recherche) ─────────── */
.rt-trip-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}
.rt-trip-badge--cancelled { background: #fee2e2; color: #7f1d1d; }
.rt-trip-badge--delay     { background: #fff4e0; color: #8a5a00; }
.rt-trip-badge--ontime    { background: #e6f7e9; color: #1b5e20; }

.train-card--cancelled .train-body .trip-time,
.train-card--cancelled .train-body .trip-station {
  text-decoration: line-through;
  color: #b91c1c;
  opacity: .85;
}

.stop-delay {
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 700;
}
.stop-delay--late    { background: #fff4e0; color: #8a5a00; }
.stop-delay--early   { background: #e6f7e9; color: #1b5e20; }
.stop-delay--skipped { background: #fee2e2; color: #7f1d1d; }
.stop-skipped .stop-name,
.stop-skipped .stop-arr-time { text-decoration: line-through; opacity: .7; }

/* ── Bloc alertes (cause du retard) sur une carte train ──── */
.rt-trip-alerts {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 16px 0;
}
.rt-trip-alert {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: .813rem;
  background: #fff8e1;
  border-left: 3px solid #f0a500;
  color: #6d4a00;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
}
.rt-trip-alert--warning { background: #fff4e0; border-left-color: #f0a500; }
.rt-trip-alert--severe  { background: #fee2e2; border-left-color: #dc2626; color: #7f1d1d; }
.rt-trip-alert--info    { background: #e7f1fb; border-left-color: #2563eb; color: #0b3a78; }

.rt-trip-alert-cause {
  flex: 0 0 auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0,0,0,.08);
  font-size: .688rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.rt-trip-alert-header { flex: 1 1 auto; font-weight: 600; }
.rt-trip-alert-details { flex: 1 0 100%; font-size: .813rem; margin-top: 2px; }
.rt-trip-alert-details summary {
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  opacity: .85;
}
.rt-trip-alert-body { margin-top: 6px; line-height: 1.45; }
.rt-trip-alert-body p { margin: 6px 0; }
.rt-trip-alert-body a { color: inherit; text-decoration: underline; }
