/* Résultats : onglets de tri, cartes de trajet, carte schématique. Voir docs/DESIGN.md. */

/* Couleur d'une catégorie, quand les données ne fournissent pas celle de la ligne */
.cat-grande_vitesse { --cat: var(--mode-grande-vitesse); }
.cat-intercites, .cat-ter { --cat: var(--mode-ter); }
.cat-rer, .cat-metro { --cat: var(--mode-metro); }
.cat-tram { --cat: var(--mode-tram); }
.cat-bus { --cat: var(--mode-bus); }
.cat-car { --cat: var(--mode-car); }
.cat-bateau { --cat: var(--mode-bateau); }
.cat-extremite { --cat: var(--encre); }
.cat-marche { --cat: var(--marche); }
.cat-attente { --cat: var(--filet-fort); }

/* Bandeau : compact sur téléphone, pour que le premier trajet se voie tout de suite ------ */
.bandeau-resultats, .bandeau-trajet { padding-block: 14px 18px; }
.bandeau-resultats h1, .bandeau-trajet h1 { max-width: none; }
.bandeau-resultats h1 { font-size: clamp(24px, 6.4vw, 60px); line-height: 1.04; text-wrap: balance; }
.bandeau-resultats .capitales { display: none; }
.resultats-tete {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 6px 32px;
}
.resultats-resume { font-size: 14px; color: var(--lavande-clair); }
.bandeau-trajet .resultats-resume { margin-top: 8px; font-size: 15px; }

.modifier { margin-top: 12px; }
.modifier summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 1.5px solid rgb(255 255 255 / .5);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  transition: background .2s, border-color .2s, transform .3s var(--ease-pop);
}
.modifier summary::-webkit-details-marker { display: none; }
.modifier summary:hover, .modifier[open] summary { background: rgb(255 255 255 / .14); border-color: var(--blanc); }
.modifier summary:active { transform: scale(.96); }
.modifier .panneau-recherche { margin-top: 14px; color: var(--encre); animation: og-apparait .45s var(--ease-out) both; }

/* Onglets de tri : une rangée qui reste collée en haut de l'écran pendant le défilement --- */
.resultats { gap: 14px; padding-top: 14px; }
.onglets {
  --k: 0;
  position: sticky;
  top: 8px;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 5px;
  background: rgb(255 255 255 / .9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--filet);
  border-radius: 18px;
  box-shadow: 0 10px 30px -18px rgb(14 18 51 / .45);
}
.onglets[data-tri="duree"] { --k: 1; }
.onglets[data-tri="marche"] { --k: 2; }
.onglets[data-tri="co2"] { --k: 3; }
.onglets-pastille {
  position: absolute;
  top: 5px; bottom: 5px; left: 5px;
  width: calc((100% - 10px) / 4);
  border-radius: 13px;
  background: var(--outremer);
  transform: translateX(calc(var(--k) * 100%));
  transition: transform .55s var(--ease-swap);
}
.onglet {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-height: 52px;
  padding: 6px 4px;
  border-radius: 13px;
  color: var(--encre);
  text-align: center;
  text-decoration: none;
  transition: color .35s ease, transform .3s var(--ease-pop);
  -webkit-tap-highlight-color: transparent;
}
.onglet:active { transform: scale(.94); }
.onglet-libelle {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--gris);
  transition: color .35s ease;
}
.onglet-valeur {
  max-width: 100%;
  font-family: var(--titre);
  font-weight: 750;
  font-stretch: 84%;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.onglet[aria-current="true"], .onglet[aria-current="true"]:hover { color: var(--blanc); }
.onglet[aria-current="true"] .onglet-libelle { color: var(--lavande); }
.onglet:not([aria-current="true"]):hover .onglet-libelle { color: var(--outremer); }
.tri-resume { margin: 0 4px; font-size: 13px; color: var(--gris); }
@media (max-width: 719px) {
  /* Sur téléphone, la phrase d'explication laisse la place aux trajets ; elle reste lue par les lecteurs d'écran. */
  .tri-resume { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .plus { min-height: 40px; padding-inline: 18px; font-size: 14px; }
}

@media (min-width: 720px) {
  .bandeau-resultats, .bandeau-trajet { padding-block: clamp(22px, 3vw, 34px) clamp(26px, 3.4vw, 38px); }
  .bandeau-resultats .capitales { display: block; }
  .resultats-resume { font-size: 15px; }
  .bandeau-trajet .resultats-resume { margin-top: 12px; font-size: 17px; }
  .modifier { margin-top: 20px; }
  .resultats { gap: 18px; padding-top: 28px; }
  .onglets { top: 12px; padding: 6px; border-radius: 20px; }
  .onglets-pastille { top: 6px; bottom: 6px; left: 6px; width: calc((100% - 12px) / 4); border-radius: 14px; }
  .onglet { align-items: flex-start; min-height: 64px; padding: 12px 16px; border-radius: 14px; text-align: left; }
  .onglet-libelle { font-size: 12px; letter-spacing: .09em; }
  .onglet-valeur { font-size: 20px; font-stretch: 88%; }
  .tri-resume { margin: 2px 4px 6px; font-size: 15px; }
}

/* Mise en page --------------------------------------------------------------------- */
.resultats-grille, .trajet-grille {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 32px;
  align-items: start;
}
.resultats-liste { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.resultats-cote { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
@media (max-width: 1080px) {
  .resultats-grille, .trajet-grille { grid-template-columns: minmax(0, 1fr); }
  .resultats-grille > .resultats-cote { display: none; }
}
.plus { align-self: center; }
.plus[aria-busy="true"] { opacity: .6; pointer-events: none; }
.plus-etat { align-self: center; font-size: 14px; font-weight: 600; color: var(--gris); }
.plus-etat:empty { display: none; }
.bouton-auto { width: auto; padding-inline: 28px; }

/* Carte de trajet : toute la carte est cliquable -------------------------------------- */
.cartes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.carte { animation: og-apparait .5s var(--ease-out) both; }
.carte:nth-child(2) { animation-delay: .05s; }
.carte:nth-child(3) { animation-delay: .1s; }
.carte:nth-child(4) { animation-delay: .15s; }
.carte:nth-child(n+5) { animation-delay: .2s; }
.carte-in {
  position: relative;
  display: grid;
  gap: 10px;
  padding: 16px 16px 12px;
  background: var(--blanc);
  border: 1.5px solid var(--blanc);
  border-radius: 24px;
  transition: border-color .4s ease, box-shadow .4s ease, transform .3s var(--ease-out);
}
.carte.est-premiere .carte-in { border-color: var(--outremer); box-shadow: 0 22px 50px -28px rgb(42 51 216 / .55); }
.carte-in:hover { transform: translateY(-3px); box-shadow: 0 18px 40px -24px rgb(14 18 51 / .4); }
/* Le doigt posé : la carte s'enfonce un peu, pour confirmer qu'elle répond. */
.carte-in:has(.lien-detail:active) { transform: scale(.985); transition-duration: .1s; }
.carte-in:has(.lien-detail:focus-visible) { outline: 3px solid var(--outremer); outline-offset: 3px; }
.carte.est-supprimee .carte-in { opacity: .72; }

.carte-tete { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 24px; }
.rang {
  margin-right: 2px;
  font-family: var(--titre);
  font-weight: 800;
  font-stretch: 62%;
  font-size: 22px;
  line-height: 1;
  color: #C9CCE6;
  transition: color .5s ease;
}
.carte.est-premiere .rang { color: var(--outremer); }

.carte-corps { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.carte-horaire { min-width: 0; }
.carte-heures { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; margin: 0; }
.heure {
  font-family: var(--titre);
  font-size: clamp(27px, 7.6vw, 32px);
  font-weight: 800;
  font-stretch: 80%;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.tiret { display: inline-block; width: 18px; height: 3px; border-radius: 2px; background: var(--signal); align-self: center; }
.jour-plus { font-size: 13px; font-weight: 700; color: var(--gris); }
.carte-sous { display: flex; flex-wrap: wrap; gap: 2px 8px; margin: 6px 0 0; font-size: 14px; color: var(--gris); }
.carte-duree { font-weight: 700; color: var(--encre); font-variant-numeric: tabular-nums; }
.carte-corr::before { content: "·"; margin-right: 8px; }

.badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.badge-prix { background: var(--badge-prix-bg); color: var(--badge-prix-fg); }
.badge-duree { background: var(--badge-duree-bg); color: var(--badge-duree-fg); }
.badge-sobre { background: var(--badge-sobre-bg); color: var(--badge-sobre-fg); }
.badge-alerte { background: #FBDDE4; color: #7A0F2B; }
.badge-bientot { background: var(--encre); color: var(--blanc); font-variant-numeric: tabular-nums; }
.badge-bientot::before { content: ""; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--signal); animation: og-pulse 1s ease-in-out infinite alternate; }

.carte-prix { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; text-align: right; }
.prix {
  font-family: var(--titre);
  font-size: clamp(24px, 6.8vw, 28px);
  font-weight: 800;
  font-stretch: 84%;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
/* Nature du prix : toujours écrite, avec un signe qui se reconnaît d'un coup d'œil. */
.prix-nature { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; color: var(--gris); white-space: nowrap; }
.prix-picto { width: 9px; height: 9px; border-radius: 50%; background: var(--filet-fort); }
.prix-nature-exact .prix-picto { background: var(--sobre); }
.prix-nature-fourchette .prix-picto { border-radius: 3px; width: 14px; background: var(--outremer); }
.prix-nature-estimation .prix-picto { background: transparent; border: 2px dashed var(--gris); }

.carte-pied { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px; }
.lien-detail {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  min-height: 32px;
  margin-top: -2px;
  font-size: 14px;
  font-weight: 700;
  color: var(--outremer);
  text-decoration: none;
}
.lien-detail::after { content: ""; position: absolute; inset: 0; border-radius: 24px; }
.lien-detail:focus-visible { outline: none; }
.lien-detail svg { transition: transform .35s var(--ease-out); }
.carte-in:hover .lien-detail svg { transform: translateX(4px); }

/* Le critère trié ressort sur chaque carte ; les autres restent discrets. */
.resultats:has(.onglets[data-tri="prix"]) .prix,
.resultats:has(.onglets[data-tri="duree"]) .carte-duree,
.resultats:has(.onglets[data-tri="marche"]) .mesure-marche,
.resultats:has(.onglets[data-tri="co2"]) .mesure-co2 { color: var(--outremer); font-weight: 800; }
.resultats:has(.onglets[data-tri="marche"]) .mesure-marche svg,
.resultats:has(.onglets[data-tri="co2"]) .mesure-co2 svg { color: var(--outremer); }

@media (min-width: 900px) {
  .cartes { gap: 16px; }
  .carte-in {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "tete tete" "corps corps" "trait trait" "pied lien";
    column-gap: 20px;
    padding: 20px 24px 14px;
  }
  .carte-tete { grid-area: tete; }
  .carte-corps { grid-area: corps; }
  .trait { grid-area: trait; }
  .carte-pied { grid-area: pied; }
  .lien-detail { grid-area: lien; align-self: center; }
  .heure { font-size: 34px; }
  .prix { font-size: 30px; }
  .rang { font-size: 28px; }
}

/* Le trait du trajet : positions en % du temps total (attributs SVG) */
.trait { display: block; overflow: visible; }
.trait-rail { fill: var(--rail); }
.trait-marche { stroke: var(--marche); stroke-width: 3; stroke-dasharray: 3 3; }
.trait-seg[class*="cat-"] { fill: var(--cat, var(--mode-autre)); }
.trait-point { fill: var(--blanc); stroke-width: 3; }
.trait-point[class*="cat-"] { stroke: var(--cat, var(--mode-autre)); }
.trait-bout { fill: var(--blanc); stroke: var(--encre); stroke-width: 3; }
.trait-bout-fin { fill: var(--encre); }
.trait-nom { font-size: 12px; font-weight: 600; fill: var(--gris); }

.pastilles { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.pastille { display: inline-flex; align-items: center; gap: 4px; }
.pastille-pied { font-size: 14px; font-weight: 700; color: var(--gris); }
.jeton {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 26px;
  padding: 0 6px;
  border: 2px solid var(--encre);
  border-radius: 7px;
  background: var(--blanc);
  color: var(--encre);
  font-family: var(--titre);
  font-weight: 800;
  font-stretch: 85%;
  font-size: 11px;
  letter-spacing: .03em;
}
.jeton-rond { width: 26px; min-width: 26px; padding: 0; border-radius: 50%; font-size: 13px; }
.ligne {
  display: inline-flex;
  align-items: center;
  height: 26px;
  max-width: 100%;
  padding: 0 9px;
  border-radius: 7px;
  background: var(--cat, var(--mode-autre));
  color: var(--blanc);
  font-family: var(--titre);
  font-weight: 750;
  font-stretch: 90%;
  font-size: 13px;
  white-space: nowrap;
}

.mesures { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; min-width: 0; font-size: 13px; color: var(--gris); }
.mesures li { display: flex; align-items: center; gap: 5px; transition: color .4s ease; }
.mesures svg { flex: none; color: var(--encre); }
.mesures .icone-sobre { color: var(--sobre); }
.gain { color: var(--sobre); white-space: nowrap; }
@media (max-width: 560px) {
  .trait-nom-middle { display: none; }
  .mesure-co2 .gain { display: none; }
}

/* Encarts de la colonne latérale ---------------------------------------------------- */
.encart {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px;
  background: var(--blanc);
  border-radius: 22px;
  min-width: 0;
}
.encart h2 { font-size: 20px; font-weight: 750; font-stretch: 105%; }
.encart-tete { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.encart-legende { color: var(--outremer); }
.encart-note { font-size: 13px; line-height: 1.5; color: var(--gris); }
.plan { display: block; height: auto; }
.plan-trace { fill: none; stroke: var(--outremer); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.plan-depart { fill: var(--blanc); stroke: var(--encre); stroke-width: 4; }
.plan-arrivee { fill: var(--encre); }

/* États : aucun trajet, panne, adresse introuvable ------------------------------------ */
.etat { display: flex; flex-direction: column; gap: 10px; max-width: 720px; }
.etat h2 { font-size: 24px; }
.etat ul { padding-left: 1.2em; }
.etat-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }

.bandeau .squelette-titre {
  font-family: var(--titre);
  font-size: clamp(34px, 4.4vw, 60px);
  font-weight: 800;
  font-stretch: 110%;
  line-height: 1;
  letter-spacing: -.02em;
}

/* Squelettes : pendant le calcul, la forme d'une carte et un trait qui se dessine ----- */
.squelette-carte {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px 12px;
  padding: 20px 16px;
  border-radius: 24px;
  background: var(--blanc);
  overflow: hidden;
  animation: og-apparait .4s var(--ease-out) both;
}
.squelette-carte:nth-child(2) { animation-delay: .08s; }
.squelette-carte:nth-child(3) { animation-delay: .16s; }
.sq { display: block; height: 14px; border-radius: 8px; background: var(--rail); }
.sq-heures { width: min(190px, 70%); height: 28px; }
.sq-prix { width: 72px; height: 28px; }
.sq-trait { grid-column: 1 / -1; display: block; overflow: visible; }
.sq-rail { stroke: var(--rail); stroke-width: 3; stroke-linecap: round; }
.sq-ligne { stroke: var(--signal); stroke-width: 5; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; animation: og-trace 1.4s var(--ease-trace) infinite; }
.squelette-carte:nth-child(2) .sq-ligne { animation-delay: .2s; }
.squelette-carte:nth-child(3) .sq-ligne { animation-delay: .4s; }
.sq-trait circle { fill: var(--blanc); stroke: var(--encre); stroke-width: 3; }
.sq-pastilles { width: 120px; height: 22px; }
.squelette-carte::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgb(255 255 255 / .6) 50%, transparent 70%);
  transform: translateX(-100%);
  animation: og-squelette 1.3s linear infinite;
}
