/* ==========================================================================
   Swiss Random CFF Discovery — styles mobile-first, thème clair/sombre automatique.
   ========================================================================== */

:root {
  color-scheme: light dark;

  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
    Roboto, Helvetica, Arial, sans-serif;

  --bg: #f3f1ec;
  --bg-deep: #e6e2d8;
  --surface: #ffffff;
  --surface-2: #ebe8e1;
  --surface-3: #dedad0;
  --text: #111111;
  --muted: #4a4a4a;
  --muted-2: #6b6b6b;

  --brand: #111111;
  --brand-strong: #000000;
  --brand-soft: #e9e6df;
  --accent: #eb0000;
  --accent-strong: #b30000;
  --accent-soft: #fde4e4;

  --cta: #eb0000;
  --cta-hover: #b30000;
  --cta-text: #ffffff;
  --status-bg: #111111;

  --line: rgba(17, 17, 17, 0.18);
  --line-strong: #111111;
  --focus-ring: rgba(235, 0, 0, 0.35);
  --shadow: 6px 6px 0 #111111;
  --shadow-soft: 3px 3px 0 #111111;

  --glow-brand: rgba(17, 17, 17, 0.06);
  --glow-accent: rgba(235, 0, 0, 0.06);

  --kind-train: #0b5fb0;
  --kind-train-bg: #e4f0fb;
  --kind-bus: #b45a0e;
  --kind-bus-bg: #fdf0e3;
  --kind-tram: #b0154f;
  --kind-tram-bg: #fbe5ed;
  --kind-boat: #1668b3;
  --kind-boat-bg: #e5f2fd;
  --kind-cableway: #6f1a94;
  --kind-cableway-bg: #f4e8fb;
  --kind-walk: #5d6b63;
  --kind-walk-bg: #ece7dc;

  --radius-xl: 6px;
  --radius-lg: 4px;
  --radius-md: 4px;
  --radius-sm: 3px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e0e;
    --bg-deep: #050505;
    --surface: #181818;
    --surface-2: #202020;
    --surface-3: #2a2a2a;
    --text: #f5f5f5;
    --muted: #b8b8b8;
    --muted-2: #8f8f8f;

    --brand: #f5f5f5;
    --brand-strong: #ffffff;
    --brand-soft: rgba(245, 245, 245, 0.1);
    --accent: #ff6b5f;
    --accent-strong: #ff9b92;
    --accent-soft: rgba(255, 107, 95, 0.14);

    --cta: #eb0000;
    --cta-hover: #ff3b30;
    --cta-text: #ffffff;
    --status-bg: #050505;

    --line: rgba(245, 245, 245, 0.16);
    --line-strong: rgba(245, 245, 245, 0.9);
    --focus-ring: rgba(245, 245, 245, 0.35);
    --shadow: 6px 6px 0 #f5f5f5;
    --shadow-soft: 3px 3px 0 #f5f5f5;

    --glow-brand: rgba(245, 245, 245, 0.05);
    --glow-accent: rgba(255, 107, 95, 0.06);

    --kind-train: #7db9ff;
    --kind-train-bg: rgba(125, 185, 255, 0.12);
    --kind-bus: #ffb36b;
    --kind-bus-bg: rgba(255, 179, 107, 0.12);
    --kind-tram: #ff8fb4;
    --kind-tram-bg: rgba(255, 143, 180, 0.12);
    --kind-boat: #7db9ff;
    --kind-boat-bg: rgba(125, 185, 255, 0.12);
    --kind-cableway: #d9a0ff;
    --kind-cableway-bg: rgba(217, 160, 255, 0.12);
    --kind-walk: #a7b5ad;
    --kind-walk-bg: rgba(167, 181, 173, 0.12);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    radial-gradient(1100px 680px at 50% -12%, var(--glow-brand), transparent 62%),
    radial-gradient(900px 520px at 105% 100%, var(--glow-accent), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* Bandeau sombre derrière la barre d'état iOS (texte blanc translucide). */
body::before {
  content: "";
  position: fixed;
  z-index: 5;
  top: 0;
  right: 0;
  left: 0;
  height: env(safe-area-inset-top, 0px);
  background: var(--status-bg);
  pointer-events: none;
}

button,
input,
select,
output {
  font: inherit;
}

button {
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

a {
  color: inherit;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.svg-sprite symbol {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon {
  display: inline-block;
  flex: none;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: middle;
}

.app-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 760px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding:
    calc(14px + env(safe-area-inset-top, 0px))
    16px
    calc(28px + env(safe-area-inset-bottom, 0px));
}

main {
  flex: 1;
}

/* --------------------------------------------------------------------------
   En-tête et accueil
   -------------------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 2px 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  text-decoration: none;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  box-shadow: var(--shadow-soft);
}

.brand-name {
  /* Nom long : la taille s'adapte aux petits iPhone (SE, mini). */
  font-size: clamp(16px, 5.4vw, 22px);
  font-weight: 800;
  letter-spacing: -0.035em;
}

.brand-tag {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.hero {
  padding: 10px 2px 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hero h1,
.result-header h1 {
  margin: 0;
  font-size: clamp(34px, 9vw, 50px);
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 1.02;
}

.hero-text {
  max-width: 46ch;
  margin: 13px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.panel {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow);
}

/* --------------------------------------------------------------------------
   Formulaire
   -------------------------------------------------------------------------- */

.field {
  margin-bottom: 19px;
}

label,
.field-label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 700;
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
}

.autocomplete {
  position: relative;
  min-width: 0;
}

input[type="text"],
input[type="time"],
select {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
}

input[type="text"]::placeholder {
  color: var(--muted-2);
}

input[type="text"]:focus,
input[type="time"]:focus,
select:focus {
  border-color: var(--brand);
  outline: 3px solid var(--focus-ring);
  outline-offset: 1px;
}

select {
  appearance: none;
  padding-right: 40px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 23px,
    calc(100% - 13px) 23px;
  background-repeat: no-repeat;
  background-size: 5px 5px, 5px 5px;
}

.geo-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 50px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.geo-button .icon {
  color: var(--brand);
}

.geo-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.autocomplete-list {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  max-height: 280px;
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow);
  -webkit-overflow-scrolling: touch;
}

.autocomplete-option {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.autocomplete-option.is-active,
.autocomplete-option:hover {
  background: var(--brand-soft);
}

.autocomplete-option .icon {
  color: var(--brand);
}

.autocomplete-name {
  font-size: 15px;
  font-weight: 600;
}

.autocomplete-state {
  padding: 12px;
  color: var(--muted);
  font-size: 14px;
}

.hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.45;
}

.hint:empty {
  display: none;
}

.hint.is-error {
  color: var(--accent-strong);
}

.label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

output {
  color: var(--brand);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  height: 44px;
  margin: 0;
  background: transparent;
  accent-color: var(--accent);
  -webkit-appearance: none;
  appearance: none;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--brand));
}

input[type="range"]::-webkit-slider-thumb {
  width: 28px;
  height: 28px;
  margin-top: -10px;
  border: 4px solid var(--accent);
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  -webkit-appearance: none;
}

input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--brand));
}

input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border: 4px solid var(--accent);
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

input[type="range"]:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.range-labels {
  display: flex;
  justify-content: space-between;
  margin-top: -7px;
  color: var(--muted-2);
  font-size: 11px;
}

.switch-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin-top: 10px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.switch-line input[type="checkbox"] {
  flex: none;
  width: 22px;
  height: 22px;
  accent-color: var(--brand);
}

.switch-line small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.switch-line--boxed {
  align-items: flex-start;
  margin: 0 0 19px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}

.switch-line--boxed input[type="checkbox"] {
  margin-top: 2px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
}

.segmented-button {
  min-height: 44px;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.segmented-button.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-soft);
}

.time-field {
  margin-top: 12px;
}

.time-field label {
  margin-bottom: 6px;
}

.primary-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 58px;
  padding: 12px 18px;
  border: 0;
  border-radius: 18px;
  background: var(--cta);
  color: var(--cta-text);
  font-size: 17px;
  font-weight: 800;
  box-shadow: 0 14px 28px rgba(201, 48, 40, 0.25);
  transition: transform 0.15s ease, background 0.15s ease;
}

.primary-button:hover {
  background: var(--cta-hover);
}

.primary-button:active {
  transform: scale(0.99);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.primary-button .icon {
  width: 22px;
  height: 22px;
}

.secondary-button {
  width: 100%;
  min-height: 52px;
  padding: 10px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
}

.ghost-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.ghost-button:hover {
  background: var(--surface-2);
}

.error-message {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Résultat
   -------------------------------------------------------------------------- */

.result-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  margin-bottom: 6px;
}

.result-count {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.result-header {
  padding: 4px 2px 18px;
}

.result-header h1 {
  font-size: clamp(38px, 10vw, 56px);
}

.canton-badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  margin: 10px 0 0;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 13px;
  font-weight: 800;
}

.summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 28px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 74px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.stat-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--brand-soft);
  color: var(--brand);
}

.stat-content {
  min-width: 0;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stat-value {
  display: block;
  overflow-wrap: anywhere;
  font-size: 18px;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.summary-note {
  grid-column: 1 / -1;
  margin: 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 600;
}

.result-section {
  margin-bottom: 30px;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-heading h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.025em;
}

.section-heading .hint {
  margin: 0;
  text-align: right;
}

/* --------------------------------------------------------------------------
   Frise du trajet
   -------------------------------------------------------------------------- */

.timeline {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  padding-bottom: 14px;
}

.timeline-item::before {
  content: "";
  position: absolute;
  top: 38px;
  bottom: 0;
  left: 20px;
  width: 2px;
  background: var(--line-strong);
}

.timeline-item:last-child::before {
  display: none;
}

.timeline-item.timeline-walk::before {
  background: repeating-linear-gradient(
    to bottom,
    var(--line-strong) 0 4px,
    transparent 4px 8px
  );
}

.timeline-icon {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--brand);
  box-shadow: var(--shadow-soft);
}

.timeline-icon.kind-train {
  border-color: transparent;
  background: var(--kind-train-bg);
  color: var(--kind-train);
}

.timeline-icon.kind-bus {
  border-color: transparent;
  background: var(--kind-bus-bg);
  color: var(--kind-bus);
}

.timeline-icon.kind-tram {
  border-color: transparent;
  background: var(--kind-tram-bg);
  color: var(--kind-tram);
}

.timeline-icon.kind-boat {
  border-color: transparent;
  background: var(--kind-boat-bg);
  color: var(--kind-boat);
}

.timeline-icon.kind-cableway {
  border-color: transparent;
  background: var(--kind-cableway-bg);
  color: var(--kind-cableway);
}

.timeline-item.timeline-walk .timeline-icon {
  border-color: transparent;
  background: var(--kind-walk-bg);
  color: var(--kind-walk);
}

.timeline-item.timeline-walk .timeline-card {
  background: var(--surface-2);
}

.line-badge.kind-train {
  color: var(--kind-train);
}

.line-badge.kind-bus {
  color: var(--kind-bus);
}

.line-badge.kind-tram {
  color: var(--kind-tram);
}

.line-badge.kind-boat {
  color: var(--kind-boat);
}

.line-badge.kind-cableway {
  color: var(--kind-cableway);
}

.timeline-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.timeline-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.line-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 4px 9px;
  border-radius: 9px;
  background: var(--brand-soft);
  font-size: 13px;
  font-weight: 800;
}

.line-badge.kind-train {
  background: var(--kind-train-bg);
}

.line-badge.kind-bus {
  background: var(--kind-bus-bg);
}

.line-badge.kind-tram {
  background: var(--kind-tram-bg);
}

.line-badge.kind-boat {
  background: var(--kind-boat-bg);
}

.line-badge.kind-cableway {
  background: var(--kind-cableway-bg);
}

.line-badge .icon {
  width: 16px;
  height: 16px;
}

.timeline-direction {
  color: var(--muted);
  font-size: 12px;
}

.timeline-duration {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.timeline-title {
  font-size: 15px;
}

.timeline-route {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.timeline-time {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.stop-row {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 10px;
  padding: 7px 0;
}

.stop-row + .stop-row {
  border-top: 1px dashed var(--line);
}

.stop-time {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-variant-numeric: tabular-nums;
}

.stop-time strong {
  font-size: 16px;
}

.delay-badge {
  align-self: flex-start;
  padding: 1px 5px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 10px;
  font-weight: 800;
}

.stop-place {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.stop-name {
  font-weight: 700;
}

.stop-platform {
  color: var(--muted);
  font-size: 12px;
}

.stops-details {
  margin-top: 10px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
}

.stops-details summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  color: var(--brand);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

.stops-details summary::-webkit-details-marker {
  display: none;
}

.stops-details summary::after {
  content: "+";
  margin-left: auto;
  font-size: 16px;
}

.stops-details[open] summary::after {
  content: "−";
}

.stops-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0 0 4px;
  list-style: none;
}

.stops-list li {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 8px;
  padding: 4px 0;
  color: var(--muted);
  font-size: 12.5px;
}

.stop-list-time {
  font-variant-numeric: tabular-nums;
}

.stop-list-name {
  color: var(--text);
}

.stop-list-platform {
  text-align: right;
}

.timeline-empty {
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 14px;
}

/* --------------------------------------------------------------------------
   Prochains départs
   -------------------------------------------------------------------------- */

.departures {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 2px 10px;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.departures::-webkit-scrollbar {
  display: none;
}

.departure-card {
  position: relative;
  display: flex;
  flex: 0 0 148px;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-height: 104px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  scroll-snap-align: start;
  box-shadow: var(--shadow-soft);
}

.departure-card.is-selected {
  border-color: var(--brand);
  background: var(--brand-soft);
  box-shadow: 0 0 0 1px var(--brand), var(--shadow-soft);
}

.departure-time {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.departure-duration {
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
}

.departure-meta {
  color: var(--muted);
  font-size: 11px;
}

.departure-delay {
  color: var(--accent-strong);
  font-size: 10px;
  font-weight: 800;
}

.departure-selected {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--brand);
  color: var(--surface);
  font-size: 9px;
  font-weight: 800;
}

/* --------------------------------------------------------------------------
   Carte Leaflet
   -------------------------------------------------------------------------- */

.map {
  height: 300px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  box-shadow: var(--shadow-soft);
}

.leaflet-container {
  background: var(--surface-2);
  font: inherit;
}

.leaflet-control-attribution {
  background: rgba(255, 255, 255, 0.82) !important;
  color: #333 !important;
  font-size: 10px !important;
}

.leaflet-control-attribution a {
  color: #1a5e8a !important;
}

.leaflet-popup-content {
  color: #14211b;
}

.map-marker-wrap {
  border: 0;
  background: transparent;
}

.map-marker {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 3px solid #fff;
  border-radius: 50%;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}

.map-marker-start {
  background: #0e4d3a;
}

.map-marker-end {
  background: #d63027;
}

.map-popup {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
}

.map-popup span {
  color: #5d6b63;
  font-size: 12px;
}

/* --------------------------------------------------------------------------
   Actions, pied de page, overlays
   -------------------------------------------------------------------------- */

.result-actions {
  display: grid;
  gap: 10px;
  margin: 8px 0 26px;
}

.site-footer {
  padding: 26px 4px 6px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.55;
  text-align: center;
}

.site-footer p {
  margin: 0 0 6px;
}

.site-footer a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.loading-overlay {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  place-items: center;
  padding:
    calc(20px + env(safe-area-inset-top, 0px))
    20px
    calc(20px + env(safe-area-inset-bottom, 0px));
  background: rgba(7, 17, 13, 0.55);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.loading-card {
  width: min(100%, 340px);
  padding: 26px 22px;
  border-radius: 24px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  text-align: center;
}

.spinner {
  width: 44px;
  height: 44px;
  margin: 0 auto 16px;
  border: 4px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-text {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 800;
}

.loading-card .ghost-button {
  margin-top: 12px;
}

.toast {
  position: fixed;
  z-index: 1100;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  width: min(calc(100% - 32px), 440px);
  padding: 13px 16px;
  border-radius: 14px;
  background: #14211b;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.3);
  transform: translateX(-50%);
}

.toast.is-error {
  background: #b7221b;
}

.noscript {
  margin: 20px;
  padding: 16px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  text-align: center;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 420px) {
  .brand-tag {
    display: none;
  }
}

@media (max-width: 380px) {
  .geo-button {
    width: 50px;
    padding: 0;
  }

  .geo-button span {
    display: none;
  }
}

@media (min-width: 620px) {
  .app-shell {
    padding-right: 24px;
    padding-left: 24px;
  }

  .panel {
    padding: 26px;
  }

  .summary {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .map {
    height: 360px;
  }

  .result-actions {
    grid-template-columns: 1fr 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================================================
   Refonte visuelle : esprit affiche de musée (blocs nets, titres en gras)
   et signalétique suisse (rouge, filets noirs). Inspiration seulement :
   aucun logo, texte ou ressource de ces sites n'est repris.
   ========================================================================== */

body {
  background: var(--bg);
}

.brand-name {
  text-transform: uppercase;
  letter-spacing: 0.01em;
  font-weight: 900;
}

.eyebrow {
  color: var(--accent);
  letter-spacing: 0.14em;
}

/* Filet rouge sous l'en-tête, comme une signalétique de gare. */
.app-header,
header.topbar {
  border-bottom: 6px solid var(--accent);
}

.panel,
.stat-card,
.departure-card,
.timeline-item,
.field select,
.field input,
.segmented,
.switch-line--boxed {
  border: 2px solid var(--line-strong);
  box-shadow: var(--shadow-soft);
}

.primary-button {
  border: 2px solid var(--text);
  box-shadow: 4px 4px 0 var(--text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 800;
}

.primary-button:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--text);
}

.ghost-button {
  border: 2px solid var(--text);
}

/* Sélecteur de langue, dans l'en-tête à droite. */
.topbar {
  position: relative;
}

.lang-picker {
  margin-left: auto;
}

.lang-select {
  width: auto;
  min-width: 136px;
  min-height: 40px;
  padding: 0 28px 0 10px;
  border: 2px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
}

/* Trajet « départ → arrivée » sous le nom de la destination. */
.route-line {
  margin: 10px 0 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--muted);
}

/* Libellés des cartes de synthèse : retour à la ligne plutôt que débordement. */
.stat-label {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.2;
}

/* ==========================================================================
   Page « Que faire là-bas »
   ========================================================================== */

.places-open {
  width: 100%;
  margin-top: 14px;
}

.places-categories {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}

.places-categories legend {
  padding: 0;
  margin-bottom: 8px;
}

.places-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.place-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 6px 14px;
  border: 2px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.place-chip input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
}

.place-chip.is-checked {
  background: var(--cta);
  border-color: var(--cta);
  color: var(--cta-text);
}

.place-chip:focus-within {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.places-summary {
  margin: 0 0 6px;
}

.places-results {
  margin-top: 4px;
}

.place-list {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
  display: grid;
  gap: 10px;
}

.place-card {
  background: var(--surface);
  border: 2px solid var(--line-strong);
  box-shadow: var(--shadow-soft);
  padding: 12px 14px;
}

.place-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}

.place-name {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.place-distance {
  white-space: nowrap;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.9rem;
}

.place-type {
  margin: 2px 0 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.place-meta {
  margin: 0;
  display: grid;
  gap: 4px;
  font-size: 0.9rem;
}

.place-meta > div {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: 8px;
}

.place-meta dt {
  color: var(--muted-2);
}

.place-meta dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.place-meta .is-missing {
  color: var(--muted-2);
  font-style: italic;
}

.place-osm {
  display: inline-block;
  margin-top: 8px;
  min-height: 44px;
  line-height: 44px;
  font-weight: 700;
  color: var(--accent-strong);
}

.places-more {
  width: 100%;
  margin-top: 4px;
}

.places-note {
  margin-top: 20px;
}

.sbb-box {
  margin-top: 10px;
}

.link-button {
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  text-decoration: none;
  width: 100%;
}

/* Actions du résultat : carré 2 × 2, rouge en haut, blanc en bas. */
.result-actions {
  grid-template-columns: 1fr 1fr;
  align-items: stretch;
}

.result-actions > * {
  min-width: 0;
  min-height: 56px;
}

.ticket-route {
  margin: -14px 0 26px;
}
