:root {
  --bg: #f4f6f4;
  --surface: #ffffff;
  --surface-2: #eef1ee;
  --border: #dde1dc;
  --ink: #101a16;
  --muted: #56655d;
  --accent: #0a6555;
  --accent-ink: #ffffff;
  --accent-soft: #dff0eb;
  --warn-bg: #fff4e5;
  --warn-ink: #7a4200;
  --warn-border: #f0c68a;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgb(16 26 22 / 0.06), 0 6px 20px rgb(16 26 22 / 0.05);
  --tap: 44px;
  /* Fond clair impose: le theme sombre du systeme ne doit pas repeindre la page. */
  color-scheme: light;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  padding: 0 1rem calc(3rem + env(safe-area-inset-bottom));
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}

main { max-width: 44rem; margin: 0 auto; }

a { color: var(--accent); }

button { font: inherit; cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.icon { width: 1em; height: 1em; flex: none; }
.icon.flip { transform: scaleX(-1); }

/* ---------- en-tete ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1.1rem 0 0.9rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  font-size: 1.05rem;
  font-weight: 640;
  letter-spacing: -0.01em;
}

.brand .mark { width: 1.6rem; height: 1.6rem; color: var(--accent); }
.brand span { color: var(--accent); }

.freshness {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.75rem;
  text-align: right;
}

.freshness::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
}

.freshness.stale {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn-ink);
}

.freshness.stale::before { background: currentColor; }

/* ---------- recherche ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.search { padding: 0.85rem; }

.route {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.4rem;
  align-items: end;
}

.field label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin: 0 0 0.25rem 0.15rem;
}

select {
  width: 100%;
  min-height: var(--tap);
  padding: 0.6rem 2rem 0.6rem 0.65rem;
  font: inherit;
  font-weight: 560;
  color: var(--ink);
  background-color: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  appearance: none;
  /* appearance:none enleve la fleche native: sans elle, rien ne dit que
     le champ s'ouvre. On la redessine plutot que de la laisser manquer. */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2356655d' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.55rem center;
  background-size: 1.05rem;
}

.field { min-width: 0; }

#swap {
  width: var(--tap);
  height: var(--tap);
  display: grid;
  place-items: center;
  color: var(--accent);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 50%;
  transition: transform 200ms ease-out, background 160ms ease-out;
}

#swap .icon { width: 1.15rem; height: 1.15rem; }
#swap:hover { background: var(--accent-soft); }
#swap.turn { transform: rotate(180deg); }

.chips {
  display: flex;
  gap: 0.4rem;
  margin: 0.7rem 0 0;
  overflow-x: auto;
  scrollbar-width: none;
}

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

.chip {
  flex: none;
  min-height: 36px;
  padding: 0.35rem 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
  font-size: 0.85rem;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: background 160ms ease-out, color 160ms ease-out;
}

.chip:hover { color: var(--ink); }
.chip[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); border-color: var(--accent); }

/* ---------- bandeau de dates ---------- */

.days {
  display: flex;
  gap: 0.4rem;
  margin: 0.6rem -1rem 0;
  padding: 0.15rem 1rem 0.35rem;
  overflow-x: auto;
  scrollbar-width: none;
  scroll-snap-type: x mandatory;
}

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

.day {
  flex: none;
  width: 4.1rem;
  min-height: 62px;
  padding: 0.4rem 0.2rem 0.35rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  scroll-snap-align: center;
  transition: background 160ms ease-out, border-color 160ms ease-out;
}

.day .dow { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; }
.day .num { font-size: 1.15rem; font-weight: 640; color: var(--ink); font-variant-numeric: tabular-nums; }

.day .load {
  display: flex;
  gap: 2px;
  height: 6px;
  align-items: center;
}

.day .load i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.85;
}

.day .load i.faint { background: var(--muted); opacity: 0.45; }
.day.none { opacity: 0.5; }
.day.none .num { color: var(--muted); }

.day[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.day[aria-pressed="true"] .num { color: var(--accent); }
.day[aria-pressed="true"] .load i { background: var(--accent); }

.day.pick { position: relative; width: auto; padding-inline: 0.7rem; justify-content: center; gap: 0.3rem; cursor: pointer; }
.day.pick .icon { width: 1.15rem; height: 1.15rem; }
.day.pick .num { font-size: 0.8rem; font-weight: 560; color: inherit; }

.day.pick input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
  background: none;
}

.day.back { width: auto; padding-inline: 0.7rem; justify-content: center; gap: 0.3rem; }
.day.back .icon { width: 1.15rem; height: 1.15rem; }
.day.back .num { font-size: 0.8rem; font-weight: 560; color: inherit; }

/* ---------- filtres de mode ---------- */

.modes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.6rem 0 0;
  padding: 0;
  border: 0;
}

.modes legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.modes input { position: absolute; opacity: 0; pointer-events: none; }

.modes label {
  min-height: 36px;
  padding: 0.35rem 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: background 160ms ease-out, color 160ms ease-out;
}

.modes input:checked + label {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent);
}

.modes input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Sept compagnies tiennent mal sur trois lignes d'un ecran de telephone: la
   rangee defile plutot que d'empiler. */
.companies {
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  /* Un fieldset vaut min-inline-size: min-content par defaut: sans cela il
     s'elargit jusqu'a la derniere pastille et deborde de la carte au lieu de
     defiler. */
  min-inline-size: 0;
}

.companies::-webkit-scrollbar { display: none; }
.companies label { flex: none; }

/* Seules les pastilles a logo se resserrent a gauche: "Tous" garde la meme
   silhouette que le "Tous" des modes, juste au-dessus. */
.companies label:has(.mono) { padding-left: 0.3rem; }

.mono {
  display: grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  flex: none;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 0.62rem;
  font-weight: 700;
  font-style: normal;
  letter-spacing: 0.02em;
}

.modes input:checked + label .mono { background: var(--surface); color: var(--accent); }

/* Les logos n'ont ni le meme cadrage ni le meme format: le fond blanc et le
   contain leur donnent la meme pastille sans les deformer. */
img.mono { background: #fff; object-fit: contain; padding: 2px; }

/* ---------- reponse ---------- */

.answer {
  margin-top: 0.9rem;
  padding: 1.1rem 1.1rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.answer .kicker {
  margin: 0;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
}

.answer .headline {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.3rem 0.7rem;
  margin: 0.35rem 0 0;
}

.answer .big {
  font-size: clamp(2.4rem, 11vw, 3.4rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
}

.answer .countdown {
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.85rem;
  font-weight: 600;
}

.answer .detail {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.6rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.answer .detail strong { color: var(--ink); font-weight: 600; }
.answer .detail .icon { color: var(--accent); width: 1.05rem; height: 1.05rem; }

.answer .then {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.85rem 0 0;
  padding: 0.7rem 0 0;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--muted);
  align-items: center;
}

.answer .then b {
  color: var(--ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.answer.empty-state .big { font-size: 1.15rem; font-weight: 620; line-height: 1.4; letter-spacing: 0; }

.jump {
  margin-top: 0.7rem;
  min-height: 40px;
  padding: 0.45rem 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--accent-ink);
  background: var(--accent);
  border: 0;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 560;
}

.book {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.82rem;
  font-weight: 560;
}

/* ---------- listes ---------- */

h2 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  margin: 1.8rem 0 0.6rem;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.section-head h2 { margin: 1.8rem 0 0.6rem; }
.section-head select { align-self: center; margin-top: 1.2rem; }

.section-head select {
  width: auto;
  min-height: 38px;
  padding: 0.3rem 1.9rem 0.3rem 0.75rem;
  font-size: 0.85rem;
  color: var(--accent);
  background-color: var(--accent-soft);
  border-color: var(--accent);
  border-radius: 999px;
}

ol { list-style: none; margin: 0; padding: 0; }

li.trip {
  display: grid;
  grid-template-columns: auto 0.7rem 1fr;
  gap: 0 0.7rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
}

li.trip:last-child { border-bottom: 0; }

.when {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-variant-numeric: tabular-nums;
}

.when .dep { font-size: 1.2rem; font-weight: 650; letter-spacing: -0.01em; }
.when .arr { font-size: 0.85rem; color: var(--muted); }

.rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.4rem 0 0.3rem;
}

.rail i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  flex: none;
}

.rail i:last-child { background: var(--accent); }
.rail span { flex: 1; width: 2px; background: var(--border); min-height: 12px; }

.trip-body { display: block; min-width: 0; }

.trip-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.trip-title .icon { color: var(--accent); width: 1rem; height: 1rem; }

.trip-sub { display: block; margin: 0.15rem 0 0; font-size: 0.84rem; color: var(--muted); }
.trip-sub em { font-style: normal; color: var(--accent); }

.tags { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.35rem; }

.tag {
  font-size: 0.7rem;
  letter-spacing: 0.03em;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}

.tag.direct { background: var(--accent-soft); border-color: transparent; color: var(--accent); }

#past { margin-top: 0.7rem; }

#past summary {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.85rem;
  font-size: 0.82rem;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  list-style: none;
  cursor: pointer;
}

#past summary::-webkit-details-marker { display: none; }
#past ol { margin-top: 0.5rem; opacity: 0.55; }

/* ---------- tarifs ---------- */

table { width: 100%; min-width: 26rem; border-collapse: collapse; font-size: 0.9rem; }

caption {
  text-align: left;
  padding: 0.9rem 1rem 0.4rem;
  font-weight: 600;
  font-size: 0.9rem;
}

th, td { padding: 0.5rem 1rem; text-align: right; }
th:first-child, td:first-child { text-align: left; }

thead th {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
}

tbody td {
  font-variant-numeric: tabular-nums;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td:first-child { white-space: normal; }
tbody tr:last-child td { border-bottom: 0; }

.fares-scroll { overflow-x: auto; }

footer {
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--muted);
}

@media (min-width: 40rem) {
  .route { grid-template-columns: 1fr auto 1fr auto; }
  .answer { padding: 1.3rem 1.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition-duration: 1ms !important; animation-duration: 1ms !important; }
}

/* Les definitions d'icones ne doivent occuper aucune place dans le flux. */
.defs { position: absolute; }

/* ---------- pages de trajet ---------- */

/* Hors accueil, la marque n'est plus le titre de la page mais le retour vers elle. */
.brand a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: inherit;
  text-decoration: none;
}

.route-head {
  padding: 0.2rem 0 0.9rem;
}

.route-head h1 {
  margin: 0;
  font-size: 1.5rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.route-head p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.liaison-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.liaison-list a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 36px;
  padding: 0.35rem 0.8rem;
  font-size: 0.85rem;
  color: var(--muted);
  text-decoration: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.liaison-list a:hover { color: var(--ink); }

.liaison-list a[aria-current='page'] {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent);
}
