/* Train Nomade : outil « suivre un train » / « carte des trains » (composants/outil-suivi.html, suivi.js).
   Direction « Relief » : feuille blanche cerclée d'encre, sienne pour l'action, chiffres en Spline Sans Mono.
   Contrastes AA : texte doux #4f5953 sur blanc 6,6:1 ; blanc sur forêt #42684a 6,3:1, sur sienne #a8481d 5,8:1,
   sur #8f1d0e 9:1 ; encre sur moutarde #c99a2e 7,4:1 ; blanc sur ardoise #4d6878 5,9:1. */
.tns { margin: 4px 0 8px; }
.tns-cherche label { display: block; margin-bottom: 6px; font: 600 12px/1.4 var(--mono); text-transform: uppercase; letter-spacing: .08em; }
.tns-champ { display: flex; max-width: 560px; border: 2px solid var(--encre); background: var(--blanc); }
.tns-champ input { flex: 1; min-width: 0; border: 0; padding: 13px 12px; font: 600 22px var(--mono); letter-spacing: .06em; background: transparent; color: var(--encre); }
.tns-champ input::placeholder { color: #6b746e; }
.tns-champ input:focus-visible { outline-offset: -4px; }
.tns-champ button { flex: none; border: 0; border-left: 2px solid var(--encre); background: var(--sienne-texte); color: #fff; font: 800 18px var(--titre); font-stretch: 120%; padding: 0 20px; cursor: pointer; }
.tns-champ button:hover { background: var(--encre); }
.tns-aide { margin: 6px 0 0; font-size: 14px; color: var(--doux); }
.tns-exemples { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 10px 0 0; font: 13px/1.4 var(--mono); color: var(--doux); }
.tns-exemples a { display: inline-block; padding: 7px 10px; border: 1.5px solid var(--encre); background: var(--blanc); color: var(--encre); text-decoration: none; font-weight: 600; }
.tns-exemples a:hover { background: var(--vert-pale); }
.tns-etat { min-height: 0; margin: 10px 0 0; font-weight: 700; }
.tns-etat:empty { margin: 0; } /* reste dans l arbre d accessibilité (région aria-live) */
.tns-bandeau { margin: 12px 0 0; padding: 10px 14px; background: var(--blanc); border: 1.5px solid var(--encre); border-left: 5px solid var(--sienne); font-size: 15px; }
.tns-bandeau[hidden] { display: none; }

/* Carte + fiche */
.tns-cadre { display: grid; gap: 14px; margin-top: 14px; }
.tns-carte { position: relative; height: min(68vh, 540px); min-height: 380px; border: 1.5px solid var(--encre); background: #f4f5f0; overflow: hidden; }
.tns-fond { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; transition: opacity .4s; }
.tns-gl { position: absolute; inset: 0; opacity: 0; transition: opacity .5s; }
.tns-poster { position: absolute; inset: 0; cursor: pointer; }
.tns-carte-ok .tns-poster, .tns-carte-ok .tns-explorer { display: none; }
.tns-explorer { position: absolute; z-index: 2; right: 10px; bottom: 52px; min-height: 40px; padding: 8px 12px; border: 1.5px solid var(--encre); background: var(--blanc); color: var(--encre); font: 600 13px/1.2 var(--mono); cursor: pointer; }
.tns-explorer:hover:not(:disabled) { background: var(--vert-pale); }
.tns-explorer:disabled { cursor: progress; color: var(--doux); }
.tns-carte-ok .tns-gl { opacity: 1; }
.tns-carte-ok .tns-fond { opacity: 0; }
.tns-haut { position: absolute; z-index: 2; top: 10px; left: 10px; max-width: calc(100% - 66px); display: flex; flex-direction: column; align-items: flex-start; gap: 6px; pointer-events: none; }
.tns-chiffres, .tns-mention, .tns-legende, .tns-carte-note { margin: 0; background: rgba(253, 253, 251, .95); border: 1.5px solid var(--encre); }
.tns-legende, .tns-carte-note { position: absolute; z-index: 2; }
.tns-chiffres { display: flex; flex-wrap: wrap; gap: 0 10px; padding: 6px 10px; font: 13px/1.5 var(--mono); }
.tns-chiffres b { font-size: 15px; }
.tns-heure { font-weight: 600; color: var(--sienne-texte); }
.tns-mention { display: flex; align-items: center; gap: 6px; padding: 3px 8px; font: 600 12px/1.4 var(--mono); color: var(--sienne-texte); }
.tns-legende { bottom: 10px; left: 10px; padding: 0; font: 12px/1.4 var(--mono); max-width: calc(100% - 60px); }
.tns-legende summary { cursor: pointer; padding: 6px 10px; font-weight: 600; }
.tns-legende ul { list-style: none; margin: 0; padding: 0 10px 8px; }
.tns-legende li { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.tns-legende i { flex: none; width: 11px; height: 11px; border-radius: 50%; border: 1px solid #fdfdfb; box-shadow: 0 0 0 1px rgba(28, 35, 32, .25); }
.tns-c0 { background: #4d6878; } .tns-c1 { background: #42684a; } .tns-c2 { background: #c99a2e; }
.tns-c3 { background: #c25a2b; } .tns-c4 { background: #8f1d0e; }
.tns-legende .tns-c5 { background: #fdfdfb; border: 2px solid #8f1d0e; box-shadow: none; }
.tns-legende .tns-gros { width: 15px; height: 15px; background: #4d6878; }
.tns-carte-note { top: 50%; left: 10px; right: 10px; padding: 10px 12px; font-size: 14px; }
.tns-carte-note[hidden] { display: none; }
.tns-doux { color: var(--doux); }
.tns-erreur { color: var(--retard); font-weight: 700; }
.tns-mono { font-family: var(--mono); }
/* chargement : fine barre sienne sous le bord haut */
.tns-charge .tns-carte::after { content: ""; position: absolute; z-index: 3; top: 0; left: 0; height: 3px; width: 30%; background: var(--sienne); animation: tns-barre 1.2s ease-in-out infinite; }
@keyframes tns-barre { 0% { left: -30%; } 100% { left: 100%; } }

/* Fiche du train */
.tns-fiche { background: var(--blanc); border: 1.5px solid var(--encre); padding: 16px 16px 14px; position: relative; min-width: 0; }
.tns-fiche::before { content: ""; position: absolute; top: -6px; left: 16px; width: 10px; height: 10px; background: var(--sienne); transform: rotate(45deg); }
.tns-fiche-type { margin: 0 0 4px; font: 600 12px/1.4 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--sienne-texte); }
.tns-fiche-titre { margin: 0; font: 800 24px/1.1 var(--titre); font-stretch: 85%; text-transform: uppercase; }
.tns-fiche-titre b { font-family: var(--mono); font-stretch: normal; letter-spacing: .02em; }
.tns-trajet { margin: 6px 0 0; font-weight: 700; }
.tns-libelle { margin: 8px 0 0; font-size: 16px; }
.tns-fiche-vide { margin: 0; font-weight: 700; }
.tns-mesures { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 12px 0 0; background: var(--courbe); border: 1px solid var(--courbe); }
.tns-mesures div { background: var(--blanc); padding: 8px 10px; min-width: 0; }
.tns-mesures dt { font: 600 11px/1.3 var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--doux); }
.tns-mesures dd { margin: 3px 0 0; font-weight: 700; overflow-wrap: anywhere; }
.tns-r { display: inline-block; padding: 1px 7px; font: 600 15px/1.5 var(--mono); color: #fff; background: #4d6878; }
.tns-r1 { background: #42684a; } .tns-r2 { background: #c99a2e; color: var(--encre); } .tns-r3 { background: #a8481d; } .tns-r4, .tns-r5 { background: #8f1d0e; }
.tns-note { margin: 10px 0 0; font-size: 14px; color: var(--doux); }
.tns-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; }
.tns-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 7px 12px; border: 1.5px solid var(--encre); background: var(--blanc); color: var(--encre); font: 600 13px/1.2 var(--mono); cursor: pointer; }
.tns-btn:hover:not(:disabled) { background: var(--vert-pale); }
.tns-btn[aria-pressed="true"] { background: var(--encre); color: #fff; }
.tns-btn:disabled { border-style: dashed; color: var(--doux); cursor: not-allowed; }
.tns-btn small { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.tns-liste-arrets { margin: 12px 0 0; }
.tns-liste-arrets summary { cursor: pointer; font: 600 13px/1.6 var(--mono); color: var(--eau); }
.tns-liste-arrets ol { list-style: none; margin: 8px 0 0; padding: 0; max-height: 330px; overflow-y: auto; }
.tns-liste-arrets li { display: grid; grid-template-columns: 96px 1fr; gap: 10px; position: relative; padding: 4px 0 4px 0; font-size: 15px; }
.tns-liste-arrets li::before { content: ""; position: absolute; left: 101px; top: 0; bottom: 0; width: 2px; background: var(--courbe); }
.tns-liste-arrets li::after { content: ""; position: absolute; left: 97px; top: 11px; width: 10px; height: 10px; border-radius: 50%; background: var(--blanc); border: 2px solid var(--encre); }
.tns-liste-arrets .tns-g { padding-left: 14px; min-width: 0; overflow-wrap: anywhere; }
.tns-h { display: flex; flex-direction: column; font: 13px/1.5 var(--mono); text-align: right; }
.tns-he { color: var(--retard); font-weight: 600; }
.tns-he:empty { display: none; }
.tns-barre { text-decoration: line-through; color: var(--doux); }
.tns-passe { color: var(--doux); }
.tns-passe::after { background: var(--courbe) !important; border-color: var(--courbe) !important; }
.tns-ici .tns-g, .tns-suivant .tns-g { font-weight: 700; }
.tns-ici::after { background: var(--sienne) !important; border-color: var(--sienne) !important; }
.tns-suivant::after { border-color: var(--sienne) !important; }
.tns-officiel { margin: 12px 0 0; font-size: 13px; color: var(--doux); }
.tns-credits { margin: 10px 0 0; font: 12px/1.6 var(--mono); color: var(--doux); }
.tns-noscript { margin: 10px 0 0; padding: 10px 12px; border: 1.5px dashed var(--encre); }

/* Pion du train suivi (marqueur MapLibre) */
.tns-pion { position: relative; width: 22px; height: 22px; --teinte: #c25a2b; --cap: 0deg; pointer-events: none; }
.tns-pion-point { position: absolute; inset: 0; border-radius: 50%; background: var(--teinte); border: 3px solid #fdfdfb; box-shadow: 0 0 0 1.5px #1c2320, 0 2px 6px rgba(0, 0, 0, .35); }
.tns-pion-fleche { position: absolute; left: 50%; top: 50%; width: 0; height: 0; transform: translate(-50%, -50%) rotate(var(--cap)) translateY(-17px); border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 9px solid #1c2320; }
.tns-pion-arrete .tns-pion-fleche { display: none; }
.tns-pion-onde { position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--teinte); animation: tns-onde 2s ease-out infinite; }
@keyframes tns-onde { from { transform: scale(.8); opacity: .9; } to { transform: scale(2.6); opacity: 0; } }
.tns-pion-num { position: absolute; left: 30px; top: 50%; transform: translateY(-50%); white-space: nowrap; padding: 2px 7px; background: #1c2320; color: #fff; font: 600 12px/1.5 var(--mono); }

/* Contrôles MapLibre à la mode « Relief » */
.tns .maplibregl-ctrl-group { border-radius: 0; box-shadow: none; border: 1.5px solid var(--encre); }
.tns .maplibregl-ctrl-group button { width: 36px; height: 36px; }
.tns .maplibregl-ctrl-attrib { font: 11px/1.4 var(--mono); }
.tns .maplibregl-ctrl-attrib a { color: var(--encre); }

/* Page « carte des trains » : la carte d'abord, plus haute ; recherche ensuite */
.tns-vue-carte { display: flex; flex-direction: column; }
.tns-vue-carte .tns-cadre { order: -1; margin-top: 0; }
.tns-vue-carte .tns-bandeau { order: -2; margin: 0 0 12px; }
.tns-vue-carte .tns-cherche { margin-top: 16px; }

@media (min-width: 960px) {
  .tns-cadre { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
  .tns-carte { height: 620px; }
  .tns-fiche { max-height: 620px; overflow-y: auto; }
  .tns-vue-carte .tns-carte { height: 680px; }
}
@media (max-width: 420px) {
  .tns-mention { font-size: 11px; white-space: nowrap; }
  .tns-champ input { font-size: 20px; padding: 12px 10px; }
  .tns-champ button { padding: 0 14px; }
  .tns-liste-arrets li { grid-template-columns: 78px 1fr; }
  .tns-liste-arrets li::before { left: 83px; }
  .tns-liste-arrets li::after { left: 79px; }
}
@media (prefers-reduced-motion: reduce) {
  .tns-pion-onde { display: none; }
  .tns-fond, .tns-gl { transition: none; }
}
/* Icônes des contrôles : fichiers hébergés (la CSS de MapLibre utilise des images data:, refusées par la CSP img-src 'self') */
.tns .maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon { background-image: url("icones/plus.svg"); }
.tns .maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon { background-image: url("icones/moins.svg"); }
.tns .maplibregl-ctrl-attrib-button { background-image: url("icones/info.svg"); }
