/* =================================================================
   Martin BTC · Le Lab nº 4 · La carte du terrain  (page /lab-terrain)
   Chargée après css/style.css et css/lab.css (bandeau .lab-top, .lab-btn,
   .lab-kicker). Toute la page est une carte plein écran : la carte (canvas
   + calque de points en DOM), le titre qui se replie, le zoom, le rail des
   douze endroits et la visionneuse (à droite sur ordinateur, en bas sur
   téléphone).
   ================================================================= */

html:has(body.terrain) { height: 100%; overflow: hidden; }
body.terrain { height: 100%; overflow: hidden; overscroll-behavior: none; background: var(--bg); }
body.terrain .lab-main.tr-main { position: fixed; inset: 0; z-index: 1; }

/* ---------- La carte ---------- */
.tr-carte { position: absolute; inset: 0; touch-action: none; cursor: grab; outline: none;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
.tr-carte.tr-glisse { cursor: grabbing; }
.tr-carte:focus-visible { box-shadow: inset 0 0 0 2px var(--orange-line); }
#tr-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.tr-calque { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }

/* Un endroit : un point orange, son nom au survol (et de près) */
.tr-point, .tr-groupe { position: absolute; left: 0; top: 0; pointer-events: auto; padding: 0; border: 0; background: none;
  color: var(--text); cursor: pointer; transform: translate3d(-200px, -200px, 0); will-change: transform; }
.tr-point { width: 40px; height: 40px; margin: -20px 0 0 -20px; display: grid; place-items: center; }
.tr-point[hidden], .tr-groupe[hidden], .tr-pays[hidden] { display: none; }
.tr-rond { position: relative; width: 14px; height: 14px; border-radius: 50%; background: var(--orange);
  box-shadow: 0 0 0 4px rgba(247, 147, 26, 0.2), 0 0 18px rgba(247, 147, 26, 0.65); transition: transform 0.25s var(--ease), background 0.25s; }
.tr-rond::after { content: ""; position: absolute; inset: -9px; border-radius: 50%; border: 1px solid rgba(247, 147, 26, 0.55);
  animation: tr-onde 2.8s var(--ease) infinite; }
.tr-point:hover .tr-rond, .tr-point:focus-visible .tr-rond { transform: scale(1.35); }
.tr-point:focus-visible { outline: none; }
.tr-point:focus-visible .tr-rond { box-shadow: 0 0 0 3px #0B0B0D, 0 0 0 5px var(--orange-2), 0 0 18px rgba(247, 147, 26, 0.65); }
.tr-point.vu .tr-rond { background: #FFC46B; }
.tr-point.actif .tr-rond { background: #FFF4E0; transform: scale(1.45);
  box-shadow: 0 0 0 5px rgba(247, 147, 26, 0.45), 0 0 26px rgba(247, 147, 26, 0.9); }
.tr-point.actif .tr-rond::after { border-color: rgba(255, 196, 107, 0.8); animation-duration: 1.8s; }
.tr-nom { position: absolute; left: 34px; top: 50%; transform: translateY(-50%); white-space: nowrap; pointer-events: none;
  font-family: var(--font-mono); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text);
  text-shadow: 0 0 3px #0B0B0D, 0 0 8px #0B0B0D, 0 0 14px #0B0B0D, 0 1px 2px #000; opacity: 0; transition: opacity 0.2s; }
.tr-point.gauche .tr-nom, .tr-groupe.gauche .tr-nom { left: auto; right: 34px; }
.tr-point:hover .tr-nom, .tr-point:focus-visible .tr-nom, .tr-point.actif .tr-nom, .tr-calque.tr-noms .tr-point .tr-nom { opacity: 1; }
.tr-point.actif .tr-nom { color: #FFC46B; }

/* Plusieurs endroits trop proches : un rond avec leur nombre */
.tr-groupe { width: 40px; height: 40px; margin: -20px 0 0 -20px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(247, 147, 26, 0.18); border: 1.5px solid var(--orange); box-shadow: 0 0 22px rgba(247, 147, 26, 0.45);
  transition: transform 0.2s var(--ease), background 0.2s; }
.tr-groupe:hover, .tr-groupe:focus-visible { background: rgba(247, 147, 26, 0.32); outline: none; }
.tr-compte { font-family: var(--font-display); font-weight: 700; font-size: 1rem; color: #FFC46B; line-height: 1; }

/* Les pays, de loin */
.tr-pays { position: absolute; left: 0; top: 0; pointer-events: none; white-space: nowrap; will-change: transform, opacity; line-height: 1.2;
  font-family: var(--font-mono); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.22em; text-transform: uppercase;
  color: rgba(244, 241, 234, 0.6); text-shadow: 0 0 6px #0B0B0D, 0 0 12px #0B0B0D; }

/* ---------- Le titre ---------- */
.tr-intro { position: absolute; z-index: 20; left: clamp(1rem, 3vw, 1.6rem); top: 86px; width: min(420px, calc(100vw - 2rem));
  padding: 1.05rem 1.25rem 1.15rem; border-radius: var(--radius); background: rgba(11, 11, 13, 0.86);
  border: 1px solid var(--line-2); box-shadow: var(--shadow); transition: padding 0.3s var(--ease); }
.tr-intro-bascule { display: flex; align-items: center; justify-content: space-between; gap: 1rem; width: 100%; padding: 0;
  border: 0; background: none; color: var(--muted); cursor: pointer; text-align: left; }
.tr-intro-bascule svg { width: 18px; height: 18px; flex: none; transition: transform 0.3s var(--ease); }
.tr-intro-bascule:hover, .tr-intro-bascule:focus-visible { color: var(--orange-2); }
.tr-intro.replie .tr-intro-bascule svg { transform: rotate(-90deg); }
.tr-titre { margin: 0.55rem 0 0; font-family: var(--font-display); font-weight: 700; letter-spacing: -0.035em;
  font-size: clamp(2rem, 3vw, 2.75rem); line-height: 0.95; color: var(--text); }
.tr-intro.replie .tr-titre { font-size: 1.35rem; margin-top: 0.4rem; }
.tr-intro.replie .tr-intro-corps { display: none; }
.tr-lead { margin: 0.85rem 0 0; color: var(--muted); font-size: 1rem; line-height: 1.5; }
.tr-aide { margin: 0.85rem 0 0; font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--orange-2); line-height: 1.6; }
.tr-aide-doigt { display: none; }
@media (pointer: coarse) { .tr-aide-souris { display: none; } .tr-aide-doigt { display: inline; } }
.tr-pied { display: flex; flex-wrap: wrap; gap: 0.35rem 1rem; margin-top: 1rem; padding-top: 0.8rem; border-top: 1px solid var(--line);
  font-family: var(--font-mono); font-size: 0.64rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted-2); }
.tr-pied nav { display: flex; flex-wrap: wrap; gap: 0.35rem 1rem; }
.tr-pied a { color: var(--muted); } .tr-pied a:hover, .tr-pied a:focus-visible { color: var(--orange-2); }

/* ---------- Zoom ---------- */
.tr-outils { position: absolute; z-index: 20; right: clamp(1rem, 3vw, 1.6rem); top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 0.45rem; transition: right 0.45s var(--ease), opacity 0.3s; }
.tr-outils button { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; cursor: pointer;
  background: rgba(11, 11, 13, 0.86); border: 1px solid var(--line-2); color: var(--text); transition: color 0.2s, border-color 0.2s; }
.tr-outils button:hover, .tr-outils button:focus-visible { color: var(--orange-2); border-color: var(--orange-line); }
.tr-outils svg { width: 20px; height: 20px; }

/* ---------- Le rail des douze endroits ---------- */
.tr-rail { position: absolute; z-index: 20; left: clamp(1rem, 3vw, 1.6rem); right: clamp(1rem, 3vw, 1.6rem);
  bottom: max(1rem, env(safe-area-inset-bottom)); pointer-events: none; transition: right 0.45s var(--ease), opacity 0.3s; }
.tr-liste { display: flex; gap: 0.4rem; width: max-content; max-width: 100%; margin: 0; padding: 0.15rem; list-style: none;
  overflow-x: auto; scrollbar-width: none; pointer-events: auto; touch-action: pan-x; }
.tr-liste::-webkit-scrollbar { display: none; }
.tr-liste li { flex: none; }
.tr-liste button { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.55rem 0.85rem; border-radius: 999px; cursor: pointer;
  background: rgba(11, 11, 13, 0.86); border: 1px solid var(--line-2); color: var(--text); white-space: nowrap;
  font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; transition: background 0.2s, border-color 0.2s, color 0.2s; }
.tr-liste button b { color: var(--orange); font-weight: 700; }
.tr-liste button:hover, .tr-liste button:focus-visible { border-color: var(--orange-line); color: var(--orange-2); }
.tr-liste button.vu b { color: #FFC46B; }
.tr-liste button.actif { background: var(--orange); border-color: var(--orange); color: #1A0F00; }
.tr-liste button.actif b { color: #1A0F00; }

/* ---------- La visionneuse ---------- */
.tr-visio { --larg: min(620px, 42vw); position: absolute; z-index: 30; top: 80px; right: clamp(1rem, 3vw, 1.6rem); max-height: calc(100% - 96px);
  width: var(--larg); display: flex; flex-direction: column; overflow: hidden; border-radius: var(--radius-lg);
  background: rgba(14, 14, 17, 0.96); border: 1px solid var(--line-2); box-shadow: var(--shadow);
  transform: translateX(calc(100% + 2.5rem)); transition: transform 0.45s var(--ease); }
.tr-visio[hidden] { display: none; }
.tr-visio.ouvert { transform: none; }
body.tr-visio-ouverte .tr-outils { right: calc(var(--tr-l, min(620px, 42vw)) + clamp(1rem, 3vw, 1.6rem) + 1rem); }
body.tr-visio-ouverte .tr-rail { right: calc(min(620px, 42vw) + clamp(1rem, 3vw, 1.6rem) + 1rem); }
.tr-v-tete { display: flex; align-items: center; gap: 0.8rem; padding: 0.85rem 0.85rem 0.75rem 1.2rem; }
.tr-v-tete .lab-kicker { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr-v-num { flex: none; font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.12em; color: var(--muted-2); }
.tr-v-fermer { flex: none; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; cursor: pointer;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line-2); color: var(--text); }
.tr-v-fermer:hover, .tr-v-fermer:focus-visible { color: var(--orange-2); border-color: var(--orange-line); }
.tr-v-fermer svg { width: 18px; height: 18px; }
.tr-v-video { position: relative; flex: none; aspect-ratio: 16 / 9; background: #000; }
.tr-v-video video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.tr-v-corps { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 1rem 1.2rem 1.25rem; overscroll-behavior: contain; }
.tr-v-lieu { margin: 0; font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--orange-2); }
.tr-v-titre { margin: 0.45rem 0 0; font-family: var(--font-display); font-weight: 700; letter-spacing: -0.03em;
  font-size: clamp(1.45rem, 2vw, 2rem); line-height: 1.06; color: var(--text); outline: none; }
.tr-v-texte { margin: 0.7rem 0 0; color: rgba(244, 241, 234, 0.86); line-height: 1.55; }
.tr-v-note { margin: 0.75rem 0 0; padding-left: 0.75rem; border-left: 2px solid var(--orange-line); color: var(--muted); font-size: 0.86rem; line-height: 1.5; }
.tr-v-note[hidden] { display: none; }
.tr-v-source { margin: 0.75rem 0 0; color: var(--muted-2); font-size: 0.8rem; line-height: 1.45; }
.tr-v-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 1.05rem; }
.tr-v-nav { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.6rem 0.85rem; border-radius: 999px; cursor: pointer;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line-2); color: var(--text);
  font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; transition: color 0.2s, border-color 0.2s, background 0.2s; }
.tr-v-nav svg { width: 16px; height: 16px; }
.tr-v-nav:hover, .tr-v-nav:focus-visible { color: var(--orange-2); border-color: var(--orange-line); }
.tr-v-nav.tr-appel { background: var(--orange); border-color: var(--orange); color: #1A0F00; }
.tr-v-yt { font-size: 0.86rem; }

/* Plusieurs extraits pour un même endroit : des onglets sous la vidéo */
.tr-v-onglets { display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 0.7rem 1.2rem 0; }
.tr-v-onglets[hidden] { display: none; }
.tr-v-onglet { display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.5rem 0.8rem; border-radius: 999px; cursor: pointer;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line-2); color: var(--text);
  font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; transition: background 0.2s, border-color 0.2s, color 0.2s; }
.tr-v-onglet b { color: var(--orange); }
.tr-v-onglet:hover, .tr-v-onglet:focus-visible { color: var(--orange-2); border-color: var(--orange-line); }
.tr-v-onglet.actif { background: var(--orange); border-color: var(--orange); color: #1A0F00; }
.tr-v-onglet.actif b { color: #1A0F00; }
.tr-v-onglet.tr-appel { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(247, 147, 26, 0.25); }
.tr-v-yt[hidden] { display: none; }

/* ---------- Le « ? » : la conclusion ---------- */
.tr-outils .tr-q { margin-top: 0.35rem; color: var(--orange-2); font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; line-height: 1; }
.tr-outils .tr-q:hover, .tr-outils .tr-q:focus-visible { background: var(--orange); color: #1A0F00; border-color: var(--orange); }
.tr-conclu { position: fixed; inset: 0; z-index: 90; display: flex; flex-direction: column; justify-content: center; cursor: pointer;
  padding: clamp(4.5rem, 9vh, 7rem) clamp(1.25rem, 8vw, 9rem) clamp(4rem, 8vh, 6rem); outline: none;
  background: radial-gradient(70% 60% at 78% 22%, rgba(247, 147, 26, 0.13), transparent 62%), radial-gradient(50% 50% at 10% 95%, rgba(247, 147, 26, 0.06), transparent 70%), #0B0B0D;
  opacity: 0; transition: opacity 0.35s var(--ease); -webkit-user-select: none; user-select: none; }
.tr-conclu[hidden] { display: none; }
.tr-conclu.ouvert { opacity: 1; }
.tr-conclu > .lab-kicker { position: absolute; top: clamp(1.4rem, 4vh, 2.4rem); left: clamp(1.25rem, 8vw, 9rem); }
.tr-c-fermer { position: absolute; top: clamp(1rem, 3vh, 1.8rem); right: clamp(1rem, 3vw, 1.8rem); width: 44px; height: 44px; display: grid; place-items: center;
  border-radius: 50%; cursor: pointer; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line-2); color: var(--text); }
.tr-c-fermer:hover, .tr-c-fermer:focus-visible { color: var(--orange-2); border-color: var(--orange-line); }
.tr-c-fermer svg { width: 20px; height: 20px; }
.tr-c-etapes { position: relative; list-style: none; margin: 0; padding: 0; width: 100%; max-width: 1180px; min-height: 52vh; }
.tr-c-etapes > li { position: absolute; left: 0; right: 0; top: 50%; transform: translateY(calc(-50% + 28px)); opacity: 0; visibility: hidden;
  transition: opacity 0.45s var(--ease), transform 0.6s var(--ease), visibility 0s 0.6s; }
.tr-c-etapes > li.passe { transform: translateY(calc(-50% - 28px)); }
.tr-c-etapes > li.on { opacity: 1; visibility: visible; transform: translateY(-50%); transition: opacity 0.45s var(--ease) 0.08s, transform 0.6s var(--ease), visibility 0s; }
.tr-c-etapes h2 { margin: 0; font-family: var(--font-display); font-weight: 700; letter-spacing: -0.035em; line-height: 1.02;
  font-size: clamp(2rem, 5vw, 4.6rem); color: var(--text); text-wrap: balance; }
.tr-c-etapes p { margin: 1.1rem 0 0; max-width: 60ch; font-size: clamp(1.1rem, 1.9vw, 1.65rem); line-height: 1.45; color: rgba(244, 241, 234, 0.72); }
.tr-c-etapes .tr-c-avant { margin: 0 0 1.1rem; max-width: none; font-family: var(--font-mono); font-size: clamp(0.85rem, 1.25vw, 1.1rem);
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--orange-2); }
.tr-c-etapes .tr-c-cite { color: var(--orange); }
.tr-c-etapes .tr-c-petit { font-family: var(--font-mono); font-size: clamp(0.8rem, 1.1vw, 0.95rem); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted-2); }
.tr-c-etapes .tr-c-fort { color: var(--text); font-weight: 600; }
.tr-c-etapes .tr-c-fin { color: var(--orange); font-size: clamp(2.3rem, 6vw, 5.6rem); }
.tr-c-pied { position: absolute; left: clamp(1.25rem, 8vw, 9rem); right: clamp(1.25rem, 3vw, 1.8rem); bottom: max(1.2rem, env(safe-area-inset-bottom));
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted-2); }
.tr-c-num { color: var(--orange-2); }
.tr-conclu.derniere .tr-c-aide { visibility: hidden; }
/* Pendant la conclusion, l'écran est à elle : le bandeau du site s'efface (sa croix cachait celle de la conclusion) */
body.lab .lab-top { transition: opacity 0.3s var(--ease), visibility 0s; }
body.tr-conclu-ouverte .lab-top { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 0.3s var(--ease), visibility 0s 0.3s; }

.tr-noscript { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(520px, calc(100vw - 2rem));
  text-align: center; color: var(--muted); }

/* ---------- Écrans moyens : moins de boutons dans le bandeau ---------- */
@media (max-width: 1180px) { .tr-autre-lab { display: none; } }

/* ---------- Téléphone et tablette : visionneuse en bas ---------- */
@media (max-width: 899px) {
  .tr-intro { top: 70px; left: 0.75rem; right: 0.75rem; width: auto; padding: 0.85rem 1rem 0.95rem; }
  .tr-titre { font-size: 1.85rem; }
  .tr-intro.replie .tr-titre { font-size: 1.15rem; }
  .tr-lead { font-size: 0.94rem; }
  .tr-outils { top: auto; transform: none; right: 0.75rem; bottom: calc(max(1rem, env(safe-area-inset-bottom)) + 3.4rem); flex-direction: column; }
  .tr-rail { left: 0.75rem; right: 0.75rem; }
  .tr-visio { --larg: auto; left: 0; right: 0; top: auto; bottom: 0; width: auto; height: min(70svh, 640px); max-height: none;
    border-radius: 22px 22px 0 0; border-bottom: 0; transform: translateY(105%); padding-bottom: env(safe-area-inset-bottom); }
  .tr-v-tete { padding: 0.7rem 0.7rem 0.6rem 1rem; }
  .tr-v-corps { padding: 0.85rem 1rem 1.1rem; }
  .tr-v-titre { font-size: 1.35rem; }
  .tr-v-texte { font-size: 0.95rem; }
  body.tr-visio-ouverte .tr-rail, body.tr-visio-ouverte .tr-outils, body.tr-visio-ouverte .tr-intro { opacity: 0; pointer-events: none; }
  body.tr-visio-ouverte .tr-outils { right: 0.75rem; }
  body.tr-visio-ouverte .tr-rail { right: 0.75rem; }
}
@media (max-width: 899px) and (max-height: 520px) {           /* téléphone à l'horizontale */
  .tr-visio { height: 100svh; top: 0; border-radius: 0; }
}

@media (prefers-reduced-motion: reduce) { .tr-conclu, .tr-c-etapes > li { transition: none; } }
@keyframes tr-onde { 0% { transform: scale(0.55); opacity: 0.95; } 100% { transform: scale(1.7); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .tr-rond::after { animation: none; opacity: 0.6; }
  .tr-visio, .tr-outils, .tr-rail, .tr-intro { transition: none; }
}
