/* FLASH ESPORT — accueil.
   Par défaut : page statique (image fixe de l'éclair, simples fondus) — utilisée sans JavaScript,
   sans WebGL2 ou avec « mouvement réduit ». La classe html.mode-3d (posée par demarrage.js)
   transforme les mêmes sections en chapitres plein écran pilotés par le scroll, par-dessus la scène 3D. */

/* =========================================================================
   Éléments communs aux deux modes
   ========================================================================= */
.slide-title, .final-titre { font-size: clamp(2.75rem, 6.2vw, 6.25rem); line-height: 1; margin: 1.15rem 0 1.4rem; }
#accueil .slide-title { font-size: clamp(3.25rem, 8.4vw, 8.25rem); }
.slide-title .line, .final-titre .line { display: block; }
.slide-title .line.rouge, .final-titre .line.rouge { color: var(--rouge); }
.slide .badges { margin-top: 1.6rem; }

/* Les six jeux, en Anton */
.jeux { list-style: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.35rem 2rem; margin-bottom: 1.5rem; max-width: 36rem; }
.jeux li {
  display: flex; align-items: baseline; gap: 0.75rem; padding: 0.55rem 0;
  border-bottom: 1px solid var(--trait);
  font-family: var(--police-titre); font-size: clamp(1.125rem, 2vw, 1.75rem); line-height: 1.15; letter-spacing: 0.02em;
  text-transform: uppercase; color: var(--blanc);
}
.jeux li span { font-family: var(--police-texte); font-size: var(--t-mini); font-weight: 600; letter-spacing: 0.14em; color: var(--texte-doux); }



.tuto { list-style: none; }
.tuto-num { display: inline-flex; align-items: center; gap: 0.8em; font-size: var(--t-mini); font-weight: 600; letter-spacing: 0.3em; color: var(--texte-doux); }
.tuto-num::before { content: ""; width: 1.25rem; height: 2px; border-radius: 2px; background: var(--rouge); }
.tuto-texte h3 { margin: 0.5rem 0 0.6rem; font-size: clamp(1.625rem, 3vw, 2.75rem); }
.tuto-texte p { max-width: 32ch; color: var(--texte-doux); font-size: clamp(1rem, 1.25vw, 1.1875rem); line-height: 1.55; }
.tuto-points { display: none; }

/* Panneau en verre incliné (clin d'œil à l'ancien site) */
.panneau { perspective: 1200px; }
.panneau-verre {
  position: relative; padding: 10px; border-radius: 18px;
  border: 1px solid var(--trait-fort);
  background: var(--verre);
  -webkit-backdrop-filter: blur(18px) saturate(140%); backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 40px 90px var(--voile-fort), 0 0 80px var(--rouge-halo-doux);
  transform-style: preserve-3d; will-change: transform;
}
.panneau-verre img { width: 100%; height: auto; border-radius: 10px; }
.panneau-verre::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(120deg, var(--reflet) 0%, transparent 30%, transparent 70%, var(--neutre-contour) 100%);
}
/* Lame de lumière rouge sous le panneau */
.panneau::after {
  content: ""; display: block; width: 46%; height: 2px; margin: 18px auto 0; border-radius: 2px;
  background: var(--rouge-lumiere); box-shadow: 0 0 22px 3px var(--rouge-halo);
}
@keyframes panneau-balance {
  0%, 100% { transform: rotateX(5deg) rotateY(-9deg); }
  50% { transform: rotateX(-3deg) rotateY(8deg); }
}

/* Bloc final */
.final { position: relative; z-index: 8; padding: var(--e-6) var(--marge); }
.final-bloc { position: relative; max-width: 37.5rem; padding: clamp(1.5rem, 4vw, 2.75rem); border-radius: var(--rayon-pilule); }
.final-titre { font-size: clamp(2.5rem, 5.4vw, 4.75rem); }
.final .badges { margin: 1.75rem 0 1.4rem; }

/* Apparition des textes (avec JavaScript seulement) : chaque ligne de titre monte depuis un masque, une ligne
   après l'autre, vite et net ; les autres blocs suivent d'une courte montée. Aucun flou. */
.js .revele, .js .jeux li, .js .tuto-etape, .js .affiche {
  opacity: 0; transform: translateY(14px);
  transition: opacity 0.4s ease, transform 0.65s var(--courbe-nette);
}
.js .slide.active .revele, .js .slide.active .jeux li, .js .slide.active .tuto-etape, .js .slide.active .affiche,
.js .final.active .revele { opacity: 1; transform: none; }
.js .line { overflow: hidden; padding: 0.1em 0 0.1em; margin: -0.1em 0 -0.1em; white-space: nowrap; }
.js .line-inner {
  display: block; transform: translateY(112%); opacity: 0;
  transition: transform 0.4s ease-in, opacity 0.01s linear 0.4s;      /* sortie : la ligne redescend derrière son masque */
}
.js .slide.active .line-inner, .js .final.active .line-inner {
  transform: none; opacity: 1;
  transition: transform 0.75s var(--courbe-nette), opacity 0.01s linear;
}
.js .slide.active .line.rouge .line-inner, .js .final.active .line.rouge .line-inner { transition-delay: 0.09s, 0.09s; }
.js .slide.active .d2 { transition-delay: 0.22s; }
.js .slide.active .d3 { transition-delay: 0.34s; }
.js .slide.active .jeux li:nth-child(1) { transition-delay: 0.20s; }
.js .slide.active .jeux li:nth-child(2) { transition-delay: 0.30s; }
.js .slide.active .jeux li:nth-child(3) { transition-delay: 0.40s; }
.js .slide.active .jeux li:nth-child(4) { transition-delay: 0.50s; }
.js .slide.active .jeux li:nth-child(5) { transition-delay: 0.60s; }
.js .slide.active .jeux li:nth-child(6) { transition-delay: 0.70s; }

/* Passage d'un chapitre au suivant (mode 3D) : le texte qui part s'efface vite, celui qui arrive attend
   un court instant. Il y a toujours un texte à l'écran, jamais deux superposés. */
.mode-3d .slide:not(.active) .revele, .mode-3d .slide:not(.active) .jeux li,
.mode-3d .slide:not(.active) .line-inner, .mode-3d .slide:not(.active) .tuto-texte { transition-duration: 0.3s; transition-delay: 0s; }
.mode-3d .slide.active .line-inner { transition-delay: 0.1s; }
.mode-3d .slide.active .line.rouge .line-inner { transition-delay: 0.19s; }
.mode-3d .slide.active .revele { transition-delay: 0.12s; }
.mode-3d .slide.active .d2 { transition-delay: 0.24s; }
.mode-3d .slide.active .d3 { transition-delay: 0.34s; }
.mode-3d .slide.active .jeux li { transition-duration: 0.6s, 0.75s, 0.65s; }
.mode-3d .slide.active .jeux li:nth-child(1) { transition-delay: 0.36s; }
.mode-3d .slide.active .jeux li:nth-child(2) { transition-delay: 0.41s; }
.mode-3d .slide.active .jeux li:nth-child(3) { transition-delay: 0.46s; }
.mode-3d .slide.active .jeux li:nth-child(4) { transition-delay: 0.51s; }
.mode-3d .slide.active .jeux li:nth-child(5) { transition-delay: 0.56s; }
.mode-3d .slide.active .jeux li:nth-child(6) { transition-delay: 0.61s; }

/* Éléments réservés au mode 3D */
.loader[hidden] { display: none; }
#webgl, .scroll-stage, .defiler,
.entete-progression { display: none; }

/* =========================================================================
   Mode statique (par défaut)
   ========================================================================= */
html:not(.mode-3d) body.accueil::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(70% 55% at 82% -8%, var(--rouge-brume), transparent 70%),
    url("../img/fond-lignes.svg") center top / cover no-repeat;
}
html:not(.mode-3d) .slide {
  position: relative; max-width: calc(var(--largeur) + 2 * var(--marge)); margin: 0;
  padding: clamp(4rem, 10vw, 7.5rem) var(--marge);
}
html:not(.mode-3d) #accueil {
  min-height: 100vh; min-height: 100svh; padding-top: calc(var(--entete-h) + 3rem);
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr); align-items: center; gap: var(--e-4);
}
html:not(.mode-3d) .affiche {
  width: 100%; max-width: 28rem; height: auto; justify-self: center;
  -webkit-mask-image: radial-gradient(closest-side, var(--noir) 58%, transparent 100%);
  mask-image: radial-gradient(closest-side, var(--noir) 58%, transparent 100%);
}
html:not(.mode-3d) .tuto { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--e-4) var(--e-3); margin-top: var(--e-4); }
html:not(.mode-3d) .tuto-texte h3 { font-size: clamp(1.375rem, 2.2vw, 1.75rem); }
html:not(.mode-3d) #direct { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: var(--e-5); }
html:not(.mode-3d) .final { max-width: calc(var(--largeur) + 2 * var(--marge)); margin: 0; }
html:not(.mode-3d) .final-bloc {
  margin: 0 auto;                      /* bloc de fin centré : pas de moitié d'écran vide */
  border: 1px solid var(--neutre-contour);
  background: linear-gradient(to top, var(--neutre-bas), var(--neutre-haut));
}
@media (max-width: 900px) {
  html:not(.mode-3d) #accueil { grid-template-columns: 1fr; }
  html:not(.mode-3d) .affiche { max-width: 15rem; justify-self: start; order: -1; margin-bottom: -1rem; }
  html:not(.mode-3d) .tuto { grid-template-columns: 1fr; }
  html:not(.mode-3d) .tuto-etape { display: grid; grid-template-columns: minmax(0, 9.5rem) minmax(0, 1fr); gap: 1.25rem; align-items: center; }
  html:not(.mode-3d) #direct { grid-template-columns: 1fr; gap: var(--e-4); }
}
/* Téléphone : la capture de l'app en grand, lisible, le texte de l'étape dessous. */
@media (max-width: 599px) {
  html:not(.mode-3d) .tuto { gap: 5rem; }
  html:not(.mode-3d) .tuto-etape { grid-template-columns: 1fr; gap: 1.1rem; }
  html:not(.mode-3d) .tuto-ecran { width: min(74vw, 18rem); }
}

/* =========================================================================
   Mode 3D : chapitres plein écran pilotés par le scroll
   ========================================================================= */
.mode-3d, .mode-3d body { scrollbar-width: none; -ms-overflow-style: none; }
.mode-3d ::-webkit-scrollbar { display: none; width: 0; }

.mode-3d #webgl {
  display: block; position: fixed; top: 0; left: 0; z-index: 1;
  width: 100%; height: 100vh; height: 100lvh;
  outline: none; pointer-events: none;
  opacity: 0; transition: opacity 1.6s ease;   /* la scène apparaît en fondu quand elle est prête */
}
.mode-3d.scene-prete #webgl { opacity: 1; }
/* Captures de l'app : affichées (donc chargées) seulement après le hero. */
.mode-3d:not(.medias) .tuto, .mode-3d:not(.medias) .panneau { display: none; }
.mode-3d .scroll-stage { display: block; height: 1100vh; pointer-events: none; }
.mode-3d .scene { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
/* Les chapitres inactifs sont transparents (et non masqués) : les lecteurs d'écran lisent tout le contenu. */
.mode-3d .slide { position: absolute; top: var(--entete-h); right: var(--marge); bottom: 0; left: var(--marge); }
.mode-3d .slide.active a, .mode-3d .slide.active .panneau { pointer-events: auto; }
.mode-3d .slide-corps { position: absolute; }
.mode-3d .affiche { display: none; }

/* Chapitre 1 — hero : texte à gauche, éclair à droite */
.mode-3d #accueil .slide-corps { left: 0; top: 47%; transform: translateY(-50%); width: min(54vw, 52rem); }
.mode-3d .defiler {
  display: inline-flex; align-items: center; gap: 0.9rem; position: absolute; left: 0; bottom: 2.25rem;
  font-size: var(--t-mini); font-weight: 600; letter-spacing: 0.3em; text-transform: uppercase; color: var(--texte-faible);
}
.mode-3d .defiler::after {
  content: ""; width: 3rem; height: 1px; background: linear-gradient(90deg, var(--rouge-lumiere), transparent);
  animation: defiler 2.4s var(--courbe) infinite; transform-origin: left center;
}
@keyframes defiler { 0% { transform: scaleX(0); opacity: 1; } 70% { transform: scaleX(1); opacity: 1; } 100% { transform: scaleX(1); opacity: 0; } }

/* Chapitre 2 — les jeux : texte à droite, éclats à gauche */
.mode-3d #jeux .slide-corps { left: 51%; right: 0; top: 50%; transform: translateY(-50%); }

/* Chapitre 3 — le tutoriel : titre et étape à gauche, téléphone au premier plan */
.mode-3d #app .slide-corps { left: 0; bottom: 53%; width: min(46vw, 40rem); }
.mode-3d #app .slide-title { font-size: clamp(2.5rem, 4.8vw, 4.75rem); margin-bottom: 0; }
.mode-3d .tuto-etape { opacity: 1; transform: none; }


.mode-3d .tuto-texte {
  position: absolute; left: 0; top: 54%; width: min(40vw, 30rem);
  opacity: 0; transform: translateY(16px);
  transition: opacity 0.35s ease, transform 0.6s var(--courbe-nette);
}
.mode-3d .slide.active .tuto-etape.est-active .tuto-texte {
  opacity: 1; transform: none;
  transition: opacity 0.7s ease 0.25s, transform 1s var(--courbe) 0.25s, filter 0.8s var(--courbe) 0.25s;
}
.mode-3d .tuto-points { display: flex; gap: 0.5rem; position: absolute; left: 0; bottom: 2.5rem; opacity: 0; transition: opacity 0.6s ease; }
.mode-3d .slide.active .tuto-points { opacity: 1; }
.tuto-points span { width: 2.25rem; height: 2px; border-radius: 2px; background: var(--trait-fort); transition: background-color 0.4s ease, box-shadow 0.4s ease; }
.tuto-points span.est-actif { background: var(--rouge-lumiere); box-shadow: 0 0 12px 1px var(--rouge-halo); }

/* Chapitre 4 — le match en direct : texte à gauche, panneau incliné à droite */
.mode-3d #direct .slide-corps { left: 0; top: 50%; transform: translateY(-50%); width: min(40vw, 34rem); }
.mode-3d .panneau { position: absolute; right: 1%; top: 50%; width: min(36vw, 33rem); margin-top: -1rem; transform: translateY(-50%); }
.mode-3d .panneau.revele { transform: translateY(calc(-50% + 16px)); }
.mode-3d .slide.active .panneau.revele { transform: translateY(-50%); }

/* Chapitre 5 — final : dans le flux, la dalle de verre 3D se cale derrière le bloc */
.mode-3d .final {
  min-height: 100vh; min-height: 100lvh; display: grid; align-items: center; justify-items: end;
  padding: calc(var(--entete-h) + 3rem) var(--marge) 5rem;
}
.mode-3d .final-bloc {
  width: min(37.5rem, 100%);
  border: 1px solid var(--trait-fort);
  background: var(--verre);
  -webkit-backdrop-filter: blur(20px) saturate(150%); backdrop-filter: blur(20px) saturate(150%);
  box-shadow: 0 30px 80px var(--voile);
  opacity: 0; transform: translateY(34px);
  transition: opacity 0.6s var(--courbe-douce) 0.04s, transform 0.75s var(--courbe-douce) 0.04s;
}
.mode-3d .final.active .final-bloc { opacity: 1; transform: none; }
/* Quand la dalle 3D est active, le fond CSS s'efface : c'est le vrai verre qui se voit. */
.mode-3d body.has-glass-card .final-bloc { border-color: transparent; background: transparent; -webkit-backdrop-filter: none; backdrop-filter: none; box-shadow: none; }
.mode-3d body.has-glass-card .final-bloc::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; padding: 1px;
  -webkit-mask: linear-gradient(var(--noir) 0 0) content-box, linear-gradient(var(--noir) 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  background: linear-gradient(135deg, var(--reflet-fort) 0%, var(--neutre-contour) 28%, var(--neutre-contour) 60%, var(--rouge-contour) 100%);
}
/* Le pied de page en verre monte par-dessus le bloc final et l'éclair. Il reprend la marge de la barre du haut
   et des titres : une seule grille sur toute la page. */

.mode-3d .pied { background: var(--verre-menu); }

/* Indicateur : filet de progression sous l'en-tête */
.mode-3d .entete-progression { display: block; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; pointer-events: none; }
.mode-3d .entete-progression span {
  display: block; height: 100%; width: 100%; transform: scaleX(0); transform-origin: left center;
  background: linear-gradient(90deg, var(--rouge), var(--rouge-lumiere)); box-shadow: 0 0 10px var(--rouge-halo);
}


/* ---- Braise : une petite lumière rouge suit la souris avec inertie et s'ouvre en anneau sur ce qui se clique.
   Ordinateur uniquement ; le pointeur du système reste visible. ---- */
.braise { display: none; }
@media (hover: hover) and (pointer: fine) {
  .mode-3d .braise {
    display: block; position: fixed; top: 0; left: 0; z-index: 9998; pointer-events: none;
    width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; border: 1px solid transparent;
    background: var(--rouge-lumiere);
    box-shadow: inset 0 0 3px 1px var(--braise-coeur), 0 0 12px 2px var(--rouge-halo), 0 0 36px 10px var(--rouge-halo-doux);
    transition: width 0.4s var(--courbe), height 0.4s var(--courbe), margin 0.4s var(--courbe), background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease;
    will-change: transform;
  }
  body.cursor-hover .braise {
    width: 40px; height: 40px; margin: -20px 0 0 -20px;
    background: transparent; border-color: var(--rouge-lumiere);     /* anneau vide : le texte du lien reste net */
    box-shadow: 0 0 22px 2px var(--rouge-halo-doux);
  }
  body.cursor-hidden .braise { opacity: 0; }
}

/* ---- Indicateur de chargement de la scène : à l'emplacement de l'éclair, sans masquer la page ---- */
.loader {
  position: fixed; left: 72%; top: 50%; z-index: 12; transform: translate(-50%, -50%);
  pointer-events: none;
  transition: opacity 0.6s ease, visibility 0s linear 0.6s;
}
.loader.is-done { opacity: 0; visibility: hidden; }
.loader-inner { display: grid; justify-items: center; text-align: center; gap: 0.7rem; width: 8.5rem; }
.loader-label { font-size: 0.625rem; font-weight: 600; line-height: 1; letter-spacing: 0.32em; text-transform: uppercase; color: var(--texte-faible); animation: loader-pouls 1.5s ease-in-out infinite; }
@keyframes loader-pouls { 0%, 100% { opacity: 0.45; } 50% { opacity: 1; } }
.loader-value {
  position: relative; display: flex; align-items: baseline; justify-content: center; width: 100%; padding: 0.2em 0.35em 0.12em;
  border: 1px solid var(--neutre-contour); border-radius: 6px;
  background: linear-gradient(to bottom, var(--neutre-haut) calc(50% - 0.5px), var(--noir) calc(50% - 0.5px), var(--noir) calc(50% + 0.5px), var(--neutre-bas) calc(50% + 0.5px));
  font-family: var(--police-titre); font-size: 2.5rem; line-height: 1; letter-spacing: 0.04em; color: var(--blanc);
}
.loader-unit { font-size: 0.35em; margin-left: 0.12em; color: var(--texte-faible); }
.loader-bar { width: 100%; height: 2px; background: var(--trait); overflow: hidden; border-radius: 2px; }
.loader-bar span { display: block; width: 100%; height: 100%; background: var(--rouge-lumiere); box-shadow: 0 0 12px var(--rouge-halo); transform: scaleX(0); transform-origin: left center; }

/* =========================================================================
   Mode 3D — portrait et écrans étroits : composition empilée
   (la caméra suit la même alternance, voir cameraFrame() dans app.js)
   ========================================================================= */
@media (max-width: 900px), (max-aspect-ratio: 4/5) {
  .mode-3d .defiler { display: none; }
  .loader { left: 50%; top: 73%; }
  .mode-3d .slide-title { font-size: clamp(2.25rem, 11.5vw, 4.5rem); margin: 0.7rem 0 0.9rem; }
  .mode-3d #accueil .slide-title { font-size: clamp(2.75rem, 14.5vw, 6rem); }
  .mode-3d .slide-desc { font-size: 1rem; line-height: 1.55; max-width: 34ch; }
  .mode-3d .slide .badges { margin-top: 1.2rem; }

  /* 1 — texte en haut, éclair en bas */
  .mode-3d #accueil .slide-corps { left: 0; right: 0; top: 4%; width: auto; transform: none; }
  /* 2 — éclats en haut, texte en bas */
  .mode-3d #jeux .slide-corps { left: 0; right: 0; top: auto; bottom: 4.5%; transform: none; }
  .mode-3d .jeux { gap: 0 1.25rem; margin-bottom: 1rem; }
  .mode-3d .jeux li { font-size: clamp(1rem, 4.6vw, 1.375rem); padding: 0.5rem 0; gap: 0.5rem; }
  /* 3 — titre, téléphone, étape */
  .mode-3d #app .slide-corps { left: 0; right: 0; top: 2.5%; bottom: auto; width: auto; }
  .mode-3d #app .surtitre { display: none; }
  .mode-3d #app .slide-title { font-size: clamp(1.75rem, 8.6vw, 3rem); margin: 0; }
  .mode-3d .tuto-texte { left: 0; right: 0; top: 75.5%; width: auto; }
  .mode-3d .tuto-texte h3 { font-size: clamp(1.5rem, 7vw, 2.25rem); margin: 0.3rem 0 0.4rem; }
  .mode-3d .tuto-texte p { font-size: 0.9375rem; line-height: 1.5; max-width: 36ch; }
  .mode-3d .tuto-points { bottom: auto; top: 76.4%; left: auto; right: 0; }
  .mode-3d .tuto-points span { width: 1.25rem; }
  /* 4 — texte en haut, éclair au milieu, panneau en bas */
  .mode-3d #direct .slide-corps { left: 0; right: 0; top: 4%; width: auto; transform: none; }
  .mode-3d .panneau { left: 0; right: 0; top: auto; bottom: 4%; width: auto; max-width: 24rem; margin: 0 auto; transform: none; }
  .mode-3d .panneau.revele { transform: translateY(16px); }
  .mode-3d .slide.active .panneau.revele { transform: none; }
  /* 5 — éclair en haut, bloc en dessous */
  .mode-3d .final { min-height: 100vh; min-height: 100svh; justify-items: stretch; align-items: end; padding: calc(var(--entete-h) + 1rem) var(--marge) 1.25rem; }
  .mode-3d .final-bloc { width: auto; max-width: none; padding: 1.5rem 1.25rem; }
}
@media (max-width: 900px) and (max-height: 700px) {
  .mode-3d #accueil .slide-title { font-size: clamp(2.5rem, 12.5vw, 4.5rem); }
  .mode-3d .slide-desc { font-size: 0.9375rem; }
  /* Petit écran (barre d'adresse de Safari affichée) : panneau plus étroit pour laisser sa place à l'éclair. */
  .mode-3d .panneau { max-width: 19rem; }
}
/* Sur écran tactile : légère inclinaison automatique lente du panneau (pas de gyroscope) */
@media (hover: none), (pointer: coarse) {
  .slide.active .panneau-verre { animation: panneau-balance 9s ease-in-out infinite; }
}
@media (prefers-reduced-motion: reduce) {
  .slide.active .panneau-verre { animation: none; }
}

html:not(.mode-3d) .score { display: none; }

/* Image de secours si le contexte WebGL est perdu pour de bon : même place et même taille que l'éclair, en fondu. */
.affiche-secours {
  position: fixed; top: 0; left: 0; z-index: 1; width: auto; max-width: none; pointer-events: none;
  opacity: 0; transition: opacity 1.2s ease;
  -webkit-mask-image: radial-gradient(closest-side, var(--noir) 58%, transparent 100%);
  mask-image: radial-gradient(closest-side, var(--noir) 58%, transparent 100%);
}
.mode-3d.affiche-secours-visible #webgl { opacity: 0; }
.mode-3d.contexte-perdu #webgl { visibility: hidden; }
html:not(.mode-3d) .affiche-secours { display: none; }

/* =========================================================================
   iPhone du tutoriel : cadre entièrement vectoriel (SVG + CSS), titane sombre, Dynamic Island,
   boutons latéraux, reflet de verre. Un seul cadre ; les 4 écrans se fondent dessous.
   ========================================================================= */
.telephone { position: relative; aspect-ratio: 1000 / 2076; margin: 0; pointer-events: none; }
.telephone-cadre { display: block; width: 101.6%; height: 100%; margin-left: -0.8%; overflow: visible; }
.telephone::before {                      /* ombre portée douce + léger halo rouge, derrière le boîtier */
  content: ""; position: absolute; z-index: -1; inset: 2% 3% 1%; border-radius: 17% / 8.2%;
  box-shadow: 0 3rem 4.5rem var(--noir), 0 1rem 2rem var(--voile-fort), 0 0 8rem var(--tel-halo);
}
.tel-boitier { fill: url(#tel-titane); }
.tel-arete { fill: none; stroke: url(#tel-arete); stroke-width: 4; }
.tel-lisere-sombre { fill: none; stroke: var(--titane-ombre); stroke-width: 3; }
.tel-lisere-clair { fill: none; stroke: var(--titane-lisere); stroke-width: 1.6; }
.tel-boutons rect { fill: var(--titane-bouton); }
.tel-antennes rect { fill: var(--titane-ombre); opacity: 0.55; }
.tel-bord { fill: var(--noir); }
.tel-barre { fill: var(--ecran-app); }
.tel-ile { fill: var(--noir); }
.tel-objectif { fill: var(--titane-objectif); }
.tel-reflet { fill: url(#tel-reflet); }
.tel-t1 { stop-color: var(--titane-clair); } .tel-t2 { stop-color: var(--titane-moyen); } .tel-t3 { stop-color: var(--titane-sombre); } .tel-t4 { stop-color: var(--titane-ombre); }
.tel-a1 { stop-color: var(--titane-eclat); } .tel-a2 { stop-color: var(--titane-moyen); } .tel-a3 { stop-color: var(--noir); }
.tel-r1 { stop-color: var(--blanc); stop-opacity: 0.2; } .tel-r2 { stop-color: var(--blanc); stop-opacity: 0.05; }
.tel-etat { fill: var(--blanc); }
.tel-heure { fill: var(--blanc); font-family: var(--police-texte); font-weight: 600; font-size: 46px; letter-spacing: 0.5px; }
.tel-pile { fill: none; stroke: var(--texte-faible); stroke-width: 3; } .tel-r3 { stop-color: var(--blanc); stop-opacity: 0; }

.tuto-ecran { display: block; position: relative; }
.tuto-ecran img { display: block; width: 100%; height: auto; }

/* Mode statique : une capture par étape, dans un cadre simple. */
html:not(.mode-3d) .telephone { display: none; }
html:not(.mode-3d) .tuto-ecran {
  max-width: 15rem; margin-bottom: 1.5rem; overflow: hidden; border-radius: 1.5rem;
  border: 1px solid var(--trait-fort); box-shadow: 0 1.5rem 3rem var(--voile-fort);
}
@media (max-width: 900px) { html:not(.mode-3d) .tuto-ecran { margin-bottom: 0; border-radius: 1.1rem; } }

/* Mode 3D : le cadre et les écrans occupent exactement la même boîte (position en pixels entiers,
   aucune mise à l'échelle de l'image), et s'inclinent ensemble très légèrement avec la souris. */
.mode-3d:not(.medias) .telephone { display: none; }
.mode-3d #app {
  --tel-h: 70vh; --tel-w: calc(var(--tel-h) * 0.4817);
  --tel-x: calc(67.5vw - var(--marge) - var(--tel-w) / 2); --tel-y: calc(46vh - var(--tel-h) / 2 - var(--entete-h) / 2);
}
@supports (width: 1cqw) {
  .mode-3d #app {
    container-type: size;
    --tel-h: min(78cqh, 47rem);
    --tel-x: calc(67.5cqw - var(--tel-w) / 2); --tel-y: calc(49cqh - var(--tel-h) / 2);
  }
}
.mode-3d .telephone, .mode-3d .tuto-ecran {
  position: absolute; left: var(--tel-x); top: var(--tel-y); width: var(--tel-w); height: var(--tel-h);
  transform: perspective(1600px) rotateX(var(--tel-rx, 0deg)) rotateY(var(--tel-ry, 0deg));
  transform-origin: 50% 50%;
}
.mode-3d .tuto-ecran img { position: absolute; left: 4%; top: 7.32%; width: 92%; height: 90.75%; object-fit: cover; object-position: top center; }
/* Fondu croisé net : l'écran qui arrive passe au-dessus, celui qui part reste opaque dessous jusqu'à la fin. */
.mode-3d .tuto-ecran { opacity: 0; z-index: 1; transition: opacity 0.5s ease 0.5s; }
.mode-3d .slide.active .tuto-etape.est-active .tuto-ecran { opacity: 1; z-index: 2; transition: opacity 0.5s ease; }
.mode-3d .slide:not(.active) .tuto-ecran { transition: opacity 0.45s ease; }
.mode-3d .telephone { z-index: 3; opacity: 0; transition: opacity 0.6s ease; }
.mode-3d .slide.active .telephone { opacity: 1; }
@media (max-width: 900px), (max-aspect-ratio: 4/5) {
  .mode-3d #app { --tel-h: 62vh; --tel-x: calc(50vw - var(--marge) - var(--tel-w) / 2); --tel-y: 13vh; }
  @supports (width: 1cqw) {
    .mode-3d #app { --tel-h: 57cqh; --tel-x: calc(50cqw - var(--tel-w) / 2); --tel-y: 15.5cqh; }
  }
}
