/* Périhélie v2 : « le voyage ». Complète style.css (tokens, nav, boutons, panneaux, sections). */

:root {
  --terre: oklch(0.74 0.11 240);
  --toulouse: oklch(0.73 0.13 30); /* la ville rose */
}

html[data-world="terre"] { --accent: var(--terre); }
html[data-world="toulouse"] { --accent: var(--toulouse); }

/* =====================================================================
   La scène épinglée
   Portrait par défaut, paysage dans la media query plus bas.
   ===================================================================== */

.voyage { position: relative; }

.voyage__pin {
  position: relative;
  height: 600vh;
  height: 600svh; /* une scène + 5 écrans : 3 trajets, la plongée, 1 écran de marge après l'arrivée */
}

.scene {
  /* Planète « garée » : diamètre, décalage latéral du centre, hauteur du centre (lus par le JS) */
  --dref: min(98vw, 62svh);
  --xref: 30vw;
  --cy: 33%;

  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  overflow: clip;
  isolation: isolate;
  touch-action: pan-y pinch-zoom;
  background: var(--space-0);
}

.scene__bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform-origin: 50% 50%;
}

.stars {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ---------- Planètes ---------- */

.bodies { position: absolute; inset: 0; z-index: 2; pointer-events: none; }

.body {
  position: absolute;
  left: 50%;
  top: var(--cy);
  width: var(--dref);
  height: var(--dref);
  margin: calc(var(--dref) / -2) 0 0 calc(var(--dref) / -2);
  visibility: hidden;
  will-change: transform, opacity;
}

.body img {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  user-select: none;
  -webkit-user-drag: none;
}

.body__glow {
  position: absolute;
  inset: -9%;
  z-index: 0;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in oklch, var(--world) 36%, transparent) 76%, transparent);
}

/* Ombre du côté opposé à la lumière (qui vient du centre de l'écran) : du volume, sans masque */
.body__shade { position: absolute; inset: 4%; z-index: 2; border-radius: 50%; }
.body--right .body__shade { background: radial-gradient(circle at 28% 42%, transparent 44%, color-mix(in oklch, var(--space-0) 80%, transparent) 94%); }
.body--left .body__shade { background: radial-gradient(circle at 72% 42%, transparent 44%, color-mix(in oklch, var(--space-0) 80%, transparent) 94%); }

.body[data-world="braise"] { --world: var(--braise); }
.body[data-world="givre"] { --world: var(--givre); }
.body[data-world="orage"] { --world: var(--orage); }
.body[data-world="terre"] { --world: var(--terre); }

/* Sans script seulement : Braise garée à droite. Avec script, l'entrée est animée une fois l'image prête. */
@media (scripting: none) {
  .body:first-child { visibility: visible; transform: translate3d(var(--xref), 0, 0); }
}

/* ---------- Plongée ---------- */

.dive {
  --cover: max(100vw, 100vh); /* un niveau à l'échelle 1 couvre tout l'écran */
  position: absolute;
  inset: 0;
  z-index: 4;
  overflow: hidden;
  visibility: hidden;
  pointer-events: none;
}

.dive__level,
.dive__clouds {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--cover);
  height: var(--cover);
  max-width: none;
  margin: calc(var(--cover) / -2) 0 0 calc(var(--cover) / -2);
  opacity: 0;
  visibility: hidden;
  will-change: transform, opacity;
}

/* Bords fondus : un niveau apparaît comme une tache nette qui grandit au centre (effet « carte »),
   puis couvre tout l'écran à son arrêt (le disque opaque dépasse alors les coins). */
.dive__level {
  -webkit-mask-image: radial-gradient(closest-side, var(--ink) 86%, transparent 100%);
  mask-image: radial-gradient(closest-side, var(--ink) 86%, transparent 100%);
}

.dive__clouds,
.dive__cloud { mix-blend-mode: screen; }

.dive__ghost {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--cover);
  height: var(--cover);
  max-width: none;
  margin: calc(var(--cover) / -2) 0 0 calc(var(--cover) / -2);
  visibility: hidden;
  -webkit-mask-image: radial-gradient(closest-side, var(--ink) 86%, transparent 100%);
  mask-image: radial-gradient(closest-side, var(--ink) 86%, transparent 100%);
}

.dive__cloud {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 70vmax;
  height: 70vmax;
  max-width: none;
  margin: -35vmax 0 0 -35vmax;
  visibility: hidden;
}

.speed { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* L'éclair à l'impact sur Toulouse */
.flash {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: radial-gradient(circle at 50% 50%, var(--ink) 0%, color-mix(in oklch, var(--toulouse) 55%, transparent) 45%, transparent 80%);
  opacity: 0;
  pointer-events: none;
}

/* Altimètre : la valeur défile pendant la descente */
.altimeter {
  position: absolute;
  z-index: 6;
  right: var(--gutter);
  top: calc(var(--nav-h) + 12px);
  margin: 0;
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 700;
  font-stretch: 112%;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 12px color-mix(in oklch, var(--space-0) 80%, transparent);
  opacity: 0;
  transition: opacity 0.3s var(--ease-out);
  pointer-events: none;
}

.altimeter.is-on { opacity: 1; }

/* Voiles haut et bas pendant la plongée : nav, rail et légendes restent lisibles sur les images claires */
.scene::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  background:
    linear-gradient(to bottom, color-mix(in oklch, var(--space-0) 65%, transparent), transparent 150px),
    linear-gradient(to top, color-mix(in oklch, var(--space-0) 78%, transparent), transparent 30%);
  opacity: 0;
  transition: opacity 0.4s var(--ease-out);
  pointer-events: none;
}

.scene[data-phase="plongee"]::after { opacity: 1; }

.porthole {
  position: absolute;
  z-index: 5;
  left: 0;
  top: 0;
  border-radius: 50%;
  box-shadow:
    0 0 0 1px var(--line-strong),
    0 0 0 12px color-mix(in oklch, var(--ink) 5%, transparent),
    0 0 0 13px var(--line);
  opacity: 0;
  pointer-events: none;
}

.captions {
  position: absolute;
  z-index: 5;
  left: var(--gutter);
  bottom: calc(clamp(14px, 3.2svh, 36px) + 72px + env(safe-area-inset-bottom, 0px));
  display: grid;
  margin: 0;
  pointer-events: none;
}

.caption {
  grid-area: 1 / 1;
  color: var(--ink);
  font-size: clamp(2.25rem, 1rem + 4vw, 5rem);
  font-stretch: 125%;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  text-shadow: 0 2px 30px color-mix(in oklch, var(--space-0) 75%, transparent);
  opacity: 0;
  transform: translate3d(0, 12px, 0);
  transition: opacity 0.5s var(--ease-out), transform 0.7s var(--ease-out);
}

.caption small {
  display: block;
  margin-top: 0.6rem;
  color: var(--ink);
  font-size: 0.875rem;
  font-stretch: 100%;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: none;
}

.caption.is-on { opacity: 1; transform: none; }
.caption:not(.is-on) { transition-duration: 0.2s; }

/* ---------- Arrivée : l'accueil dévoilé autour du hublot ---------- */

.reveal {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  align-items: end;
  padding: var(--nav-h) var(--gutter) calc(clamp(14px, 3.2svh, 36px) + 88px);
  background:
    radial-gradient(ellipse 60% 50% at 50% 30%, color-mix(in oklch, var(--toulouse) 10%, transparent), transparent 70%),
    var(--space-0);
  opacity: 0;
  visibility: hidden;
}

.reveal__title {
  font-size: clamp(3rem, 1.4rem + 5.4vw, 7rem);
  font-stretch: 125%;
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: -0.02em;
}

.reveal__title em {
  display: block;
  text-wrap: balance;
  margin-top: 0.35em;
  color: var(--ink-2);
  font-size: 0.4em;
  font-stretch: 100%;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0;
}

.reveal__lead { max-width: 40ch; margin: 1.2rem 0 1.8rem; color: var(--ink-2); }
.reveal__actions { display: flex; flex-wrap: wrap; gap: 1rem; }

/* ---------- Arrêts (panneaux de texte) : reprennent .panel de style.css ---------- */

.stops {
  position: absolute;
  z-index: 6;
  left: var(--gutter);
  right: var(--gutter);
  bottom: calc(clamp(14px, 3.2svh, 36px) + 64px + env(safe-area-inset-bottom, 0px));
  display: grid;
  pointer-events: none;
}

.stop { pointer-events: auto; }
.stop__next { color: var(--ink); font-weight: 600; }

/* ---------- Barre du bas : rail des étapes, indice, évitement ---------- */

.rail {
  position: absolute;
  z-index: 7;
  left: 50%;
  bottom: calc(clamp(10px, 2.6svh, 30px) + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
}

.rail ol {
  position: relative;
  display: flex;
  gap: clamp(14px, 3vw, 44px);
  margin: 0;
  padding: 0;
  list-style: none;
}

.rail button {
  display: grid;
  justify-items: center;
  gap: 7px;
  width: 64px;
  padding: 6px 0;
  border: 0;
  background: none;
  color: var(--ink-3);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.3s var(--ease-out);
}

.rail button::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentColor;
  transition: transform 0.3s var(--ease-out), background-color 0.3s var(--ease-out);
}

.rail button:hover { color: var(--ink-2); }
.rail button[aria-current="step"] { color: var(--ink); }
.rail button[aria-current="step"]::before { background: var(--accent); transform: scale(1.45); }

.rail__track {
  position: absolute;
  z-index: -1;
  left: 32px;
  right: 32px;
  top: 16px;
  height: 1px;
  overflow: hidden;
  background: var(--line);
  pointer-events: none;
}

.rail__fill {
  position: absolute;
  inset: 0;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: 0 50%;
}

.scene__hint,
.scene__skip {
  position: absolute;
  z-index: 7;
  bottom: calc(clamp(14px, 3.2svh, 36px) + 6px + env(safe-area-inset-bottom, 0px));
  color: var(--ink-2);
  font-size: 0.8125rem;
}

.scene__hint { left: var(--gutter); display: none; transition: opacity 0.5s var(--ease-out), visibility 0.5s; }
.has-interacted .scene__hint { opacity: 0; visibility: hidden; }
.scene__skip { right: var(--gutter); color: var(--ink); font-weight: 600; text-decoration: none; }

.scene[data-phase="arrivee"] :is(.rail, .scene__skip, .scene__hint) {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s var(--ease-out), visibility 0s linear 0.4s;
}
.scene__skip:hover { color: var(--accent); }

@media (max-width: 559px) {
  .rail button span { font-size: 0.6875rem; }
  .rail button:not([aria-current="step"]) span { opacity: 0; }
  .scene__skip { display: none; }
}

/* ---------- Paysage : planète sur une moitié, texte sur l'autre ---------- */

@media (min-width: 640px) and (min-aspect-ratio: 11/10) {
  .scene {
    --dref: min(108svh, 66vw);
    --xref: 27vw;
    --cy: 52%;
  }

  .stops { top: var(--nav-h); bottom: calc(clamp(14px, 3.2svh, 36px) + 64px); align-content: center; }
  .stop.panel { align-self: start; width: min(38vw, 480px); }
  .stop--right { justify-self: end; }
  .scene__hint { display: block; }

  .reveal {
    align-items: center;
    padding-bottom: var(--nav-h);
  }

  .reveal__text { max-width: min(560px, 44vw); }
}

/* ---------- Écrans bas (téléphone en paysage, zoom fort) : le texte tient au-dessus du rail ---------- */

@media (max-height: 540px) {
  .stop.panel { align-self: end; }
  .stop .panel__facts { display: none; }
  .stop .panel__name { font-size: clamp(2rem, 4.5vw, 3rem); }
  .stop .panel__text { max-width: 44ch; margin-bottom: 0.8em; font-size: 0.9375rem; line-height: 1.5; }
  .scene__hint { display: none; }
  .caption { font-size: clamp(1.75rem, 1rem + 3vw, 3rem); }
  .reveal { padding-bottom: 24px; }
  .reveal__lead { display: none; }
  .reveal__title { font-size: clamp(2.25rem, 1rem + 4vw, 3.5rem); }
}

/* ---------- Bas de page à trois mondes ---------- */

@media (min-width: 900px) {
  .grounds--trois .ground--orage { grid-column: 4 / span 6; }
}

/* ---------- Apparition, sans script, mouvement réduit ---------- */

.scene.is-offscreen .stars { visibility: hidden; }

@media (scripting: none) {
  .voyage__pin { height: auto; }
  .scene { position: relative; }
  .rail, .scene__hint { display: none; }
}
