/*
 * « La traversée » : séquence de la page d'accueil (voir inc/traversee.php).
 *
 * Base : téléphone et mouvement réduit. Chaque étape montre son texte et sa
 * photo, l'une sous l'autre ; la scène fixe n'existe pas.
 * Version immersive : à partir de 981 px, si le visiteur n'a pas demandé de
 * réduire les animations. Le récit défile, la scène reste en place à droite.
 */

/* Divi pose « overflow-y: hidden » en ligne sur #page-container : le conteneur
   devient une boîte de défilement et la scène ne peut plus rester en place.
   « clip » coupe toujours le débordement horizontal sans cet effet. */
body:has(.lam-trav) #page-container {
  overflow-x: clip !important;
  overflow-y: visible !important;
}

/* Le module Divi qui porte le shortcode : pleine largeur, sans marge. */
.lam-trav-section,
.lam-trav-section .et_pb_row,
.lam-trav-section .et_pb_column,
.lam-trav-section .et_pb_code_inner {
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

.lam-trav-section { background: var(--lam-primary) !important; }

.lam-trav {
  position: relative;
  padding: 5rem 0;
  background: var(--lam-primary);
  color: #fff;
}

/* Lien d'évitement : invisible tant qu'il n'a pas le focus clavier. */
.lam-trav__passer {
  position: absolute;
  top: 1rem;
  left: 5%;
  z-index: 2;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.lam-trav__passer:focus {
  width: auto;
  height: auto;
  padding: 0.5rem 1rem;
  clip-path: none;
  border-radius: var(--lam-radius);
  background: #fff;
  color: var(--lam-primary) !important;
  font-weight: 600;
}

.lam-trav__grille {
  width: 90%;
  max-width: 1200px;
  margin: 0 auto;
}

/* — Récit — */
.lam-trav__etape { padding: 0 0 3.5rem; }

.lam-trav h2 {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0 0 1.5rem;
  padding: 0;
  color: #fff;
  font-family: var(--lam-font-display);
  font-size: var(--lam-headline-lg-size);
  line-height: var(--lam-headline-lg-line);
  font-weight: var(--lam-headline-weight);
}

.lam-trav h2::before {
  content: "";
  flex: none;
  width: 0.5rem;
  height: 2.5rem;
  border-radius: var(--lam-radius-full);
  background: var(--lam-secondary-container);
}

.lam-trav h3 {
  margin: 0 0 0.75rem;
  padding: 0;
  color: #fff;
  font-family: var(--lam-font-display);
  font-size: var(--lam-headline-md-size);
  line-height: var(--lam-headline-md-line);
  font-weight: var(--lam-headline-weight);
}

.lam-trav p {
  max-width: 34rem;
  margin: 0;
  padding: 0;
  color: var(--lam-primary-fixed-dim);
  font-size: var(--lam-body-lg-size);
  line-height: 1.7;
}

.lam-trav .lam-plus-loin { margin: 0; padding: 0; }

.lam-trav .lam-plus-loin a,
.lam-trav .lam-plus-loin a:visited { color: #fff !important; text-decoration-color: var(--lam-secondary-container); }

.lam-trav__photo { margin: 1.5rem 0 0; }

.lam-trav__photo img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  border-radius: var(--lam-radius-lg);
}

/* La photo de la plaine, dans la silhouette de la commune. */
.lam-trav__photo--silhouette { position: relative; aspect-ratio: 4 / 5; }

.lam-trav__masque {
  position: absolute;
  inset: 0;
  overflow: hidden;
  -webkit-mask-image: url("../img/lamentin-contour.svg");
  mask-image: url("../img/lamentin-contour.svg");
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-position: center;
  mask-position: center;
}

.lam-trav__masque img,
.lam-trav__photo--silhouette .lam-trav__masque img {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  object-fit: cover;
  border-radius: 0;
  transform: scale(var(--lam-trav-img, 1));
  transform-origin: var(--lam-trav-origine, 50% 50%);
}

.lam-trav__masque.est-ouverte {
  -webkit-mask-image: none;
  mask-image: none;
}

.lam-trav__scene { display: none; }

/* Grand écran, mouvement réduit : les photos gardent une taille de lecture. */
@media (min-width: 981px) {
  .lam-trav__photo { max-width: 44rem; }

  .lam-trav__photo--silhouette { max-width: 26rem; }
}

/* — Version immersive — */
@media (min-width: 981px) and (prefers-reduced-motion: no-preference) {
  .lam-trav { padding: 0; }

  .lam-trav__grille {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    gap: 4rem;
  }

  .lam-trav__photo { display: none; }

  .lam-trav__etape {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 78vh;
    padding: 0;
  }

  /* L'ouverture tient la plus longue course : la silhouette s'ouvre pendant
     que le texte s'éloigne. */
  .lam-trav__etape--ouverture {
    justify-content: flex-start;
    min-height: 175vh;
    padding-top: 22vh;
  }

  .lam-trav__etape--fin { min-height: 70vh; }

  .lam-trav__scene {
    position: sticky;
    top: calc(var(--lam-trav-haut, 0px) + 2rem);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    height: calc(100vh - var(--lam-trav-haut, 0px) - 4rem);
    margin: 2rem 0;
  }

  .lam-trav__cadre {
    position: relative;
    flex: 1;
    min-height: 0;
    border-radius: var(--lam-radius-lg);
    overflow: hidden;
  }

  .lam-trav__vue {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.8s ease;
  }

  .lam-trav__vue.est-active { opacity: 1; }

  .lam-trav__vue > img,
  .lam-trav__vue > video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scale(1.06);
    transition: transform 1.6s cubic-bezier(0.2, 0.7, 0.2, 1);
  }

  .lam-trav__vue.est-active > img { transform: scale(1); }

  /* La vidéo porte déjà son mouvement : pas de zoom d'entrée. */
  .lam-trav__vue > video { transform: none; }

  /* L'arrivée au-dessus de l'hôtel de ville : la course de la vidéo. */
  .lam-trav__etape--video { min-height: 130vh; }

  /* — La carte — */
  .lam-trav__repere {
    display: flex;
    flex: none;
    align-items: center;
    gap: 1.5rem;
    height: 11rem;
  }

  .lam-trav__carte {
    flex: none;
    height: 100%;
    width: auto;
    aspect-ratio: 1000 / 1329;
    overflow: hidden;
    border-radius: var(--lam-radius);
  }

  .lam-trav__plan { transition: transform 1.1s cubic-bezier(0.3, 0.6, 0.2, 1); }

  .lam-trav__contour {
    fill: rgba(255, 255, 255, 0.04);
    stroke: rgba(255, 255, 255, 0.6);
    stroke-width: 1.5;
    vector-effect: non-scaling-stroke;
  }

  .lam-trav__trajet {
    fill: none;
    stroke: var(--lam-secondary-container);
    stroke-width: 2;
    stroke-dasharray: 1;
    stroke-dashoffset: var(--lam-trav-trajet, 1);
    vector-effect: non-scaling-stroke;
    transition: stroke-dashoffset 1s ease;
  }

  .lam-trav__point {
    fill: #fff;
    opacity: 0.35;
    transition: r 1.1s cubic-bezier(0.3, 0.6, 0.2, 1), opacity 0.4s ease;
  }

  .lam-trav__point.est-visite { opacity: 0.8; }

  .lam-trav__point.est-actif { fill: var(--lam-heraldic-red); opacity: 1; }

  .lam-trav__lieu {
    margin: 0;
    color: #fff;
    font-family: var(--lam-font-display);
    font-size: var(--lam-headline-md-size);
    line-height: var(--lam-headline-md-line);
    font-weight: var(--lam-headline-weight);
  }

  .lam-trav__lieu span { display: none; }

  .lam-trav__lieu span.est-actif { display: inline; }
}
