/* ==========================================================================
   Intro d'ouverture : la façade de l'institut (images/intro/facade.jpg) à la tombée
   du jour. Les lumières s'allument, un reflet glisse sur l'enseigne, on s'avance
   vers la porte qui s'ouvre sur la lumière de l'intérieur, et le site se dévoile.
   Durée totale ≈ 5,8 s (façade ≈ 3,2 s, puis la porte s'ouvre et l'on entre). Pilotée par public/js/intro.js (classe html.intro-playing).

   Toutes les positions sont exprimées en % de la photo (1670 × 942) :
   porte vitrée ≈ x 45,6 → 60 %, y 42 → 90,7 % ; centre de la porte ≈ 52,7 % / 66 %.
   ========================================================================== */

.intro { display: none; }

html.intro-playing { overflow: hidden; }

html.intro-playing .intro {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 1000;
  overflow: hidden;
  background: #24161A;
  animation: intro-out .6s var(--ease-in-out) 5.2s forwards;
}

/* Tant que la photo n'est pas prête, la scène attend (voir intro.js). */
.intro:not(.is-ready),
.intro:not(.is-ready) * { animation-play-state: paused !important; }

/* Fond flouté : comble le haut et le bas de l'écran en portrait */
.intro__backdrop {
  position: absolute;
  inset: -8%;
  background: url("/images/intro/facade.jpg") 53% 50% / cover no-repeat;
  filter: blur(28px) brightness(.4) saturate(.8);
  animation: intro-fade 1.2s ease both;
}

/* — La scène : la photo couvre l'écran, centrée sur la porte — */
.intro__stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: max(100vw, 100vh * 1670 / 942);
  aspect-ratio: 1670 / 942;
  transform: translate(-52.7%, -50%);
}
@media (max-aspect-ratio: 4 / 5) {
  /* Écran vertical : on garde l'enseigne et la porte lisibles plutôt que de rogner à l'extrême */
  .intro__stage { width: 180vw; transform: translate(-52.7%, -54%); }
}

/* La « caméra » : apparition puis travelling vers la porte */
.intro__cam {
  position: absolute;
  inset: 0;
  transform-origin: 52.7% 66%;
  animation:
    intro-in 1.1s var(--ease-out) both,
    intro-dolly 1.65s cubic-bezier(.6, 0, .85, .35) 3.65s forwards;
}

.intro__facade {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  /* Crépuscule : la façade est éteinte, puis l'éclairage s'allume */
  filter: brightness(.38) saturate(.65) contrast(1.05);
  animation: intro-lights-on 1.8s var(--ease-in-out) .4s forwards;
}

/* Halos lumineux (spots du bandeau et appliques murales) */
.intro__halo {
  position: absolute;
  left: var(--x);
  border-radius: 50%;
  pointer-events: none;
  mix-blend-mode: screen;
  transform: translate(-50%, -50%);
  opacity: 0;
  animation:
    intro-halo .5s ease-out var(--d) forwards,
    intro-flicker 2.2s ease-in-out calc(var(--d) + .5s) infinite alternate;
}
.intro__halo--spot {
  top: 9%;
  width: 14%;
  aspect-ratio: 1 / 1.3;
  background: radial-gradient(closest-side, rgb(255 226 200 / .55), rgb(255 200 170 / .18) 55%, transparent);
}
.intro__halo--sconce {
  top: 47%;
  width: 11%;
  aspect-ratio: 1 / 1.6;
  background: radial-gradient(closest-side, rgb(255 230 205 / .6), rgb(255 196 160 / .2) 50%, transparent);
}

/* Reflet qui glisse sur l'enseigne « Aly's Nails » */
.intro__sweep {
  position: absolute;
  left: 33%;
  top: 7%;
  width: 36%;
  height: 22%;
  pointer-events: none;
  mix-blend-mode: screen;
  background: linear-gradient(105deg, transparent 43%, rgb(255 238 228 / .6) 50%, transparent 57%) no-repeat;
  background-size: 250% 100%;
  background-position: 130% 0;
  -webkit-mask-image: radial-gradient(closest-side, #000 45%, transparent);
  mask-image: radial-gradient(closest-side, #000 45%, transparent);
  animation: intro-sweep 1.5s var(--ease-in-out) 1.7s forwards;
}

/* — La porte —
   Battant (cadre noir + vitre + poignée) dans la photo : x 746 → 1016 px, y 382 → 878 px.
   Poignée à gauche → charnières à droite ; le battant pivote vers l'intérieur. */
.intro__doorway {
  --l: 44.64;  /* gauche, en % de la photo */
  --t: 40.6;  /* haut */
  --w: 16.16;  /* largeur */
  --h: 52.71;  /* hauteur */
  position: absolute;
  left: calc(var(--l) * 1%);
  top: calc(var(--t) * 1%);
  width: calc(var(--w) * 1%);
  height: calc(var(--h) * 1%);
  container-type: size;
}
.intro__hinge {
  position: absolute;
  inset: 0;
  perspective: 800px;
  perspective: 340cqw;
  perspective-origin: 50% 45%;
}

/* L'intérieur de l'institut, baigné de lumière */
.intro__inside {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(90% 40% at 50% 18%, #FFFFFF, rgb(255 247 241 / 0) 70%),
    linear-gradient(#FFF6F0, #F9E3DA 62%, #EFC9BE);
  filter: brightness(.75);
  animation: intro-inside-glow 1.3s var(--ease-in-out) 3.45s forwards;
}
.intro__inside-floor {
  position: absolute;
  inset: 72% -30% 0;
  background: linear-gradient(#F3D3C8, #E4B6AA);
  transform: perspective(200px) rotateX(38deg);
  transform-origin: 50% 0;
  box-shadow: 0 -1px 0 rgb(201 146 138 / .45);
}
.intro__inside-lamp {
  position: absolute;
  left: 50%;
  top: 9%;
  width: 70%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(closest-side, #FFFFFF, rgb(255 240 228 / .5) 45%, transparent);
}

/* Le battant : une découpe exacte de la photo, posée par-dessus, qui pivote en 3D */
.intro__leaf {
  position: absolute;
  inset: 0;
  transform-origin: 100% 50%;
  transform-style: preserve-3d;
  animation: intro-leaf-open 1.45s 3.25s forwards;
}
.intro__leaf-face {
  position: absolute;
  inset: 0;
  background: url("/images/intro/facade.jpg") no-repeat;
  background-size: calc(10000% / var(--w)) calc(10000% / var(--h));
  background-position:
    calc(var(--l) / (100 - var(--w)) * 100%)
    calc(var(--t) / (100 - var(--h)) * 100%);
  /* même éclairage que la façade, pour être invisible tant que la porte est fermée */
  filter: brightness(.38) saturate(.65) contrast(1.05);
  animation: intro-lights-on 1.8s var(--ease-in-out) .4s forwards;
}
/* Le battant s'assombrit en tournant le dos à la rue */
.intro__leaf-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgb(28 14 18 / .7), rgb(28 14 18 / .25) 70%, rgb(255 230 215 / .15));
  opacity: 0;
  animation: intro-halo 1.2s ease-in 3.4s forwards;
}
/* Épaisseur du battant, visible sur la tranche */
.intro__leaf-edge {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 4%;
  background: linear-gradient(#3B2A2C, #1E1416);
  transform-origin: 0 50%;
  transform: rotateY(90deg);
}
/* Filet de lumière qui passe par l'entrebâillement, côté poignée */
.intro__gap {
  position: absolute;
  top: 1%;
  bottom: 1%;
  left: 0;
  width: 3%;
  background: linear-gradient(#FFFFFF, #FFE9DE);
  box-shadow: 0 0 12px 3px rgb(255 236 222 / .8);
  opacity: 0;
  animation: intro-gap .7s ease-out 3.38s forwards;
}

/* Lumière qui se répand sur le trottoir devant la porte */
.intro__spill {
  position: absolute;
  left: 40%;
  top: 93.2%;
  width: 26%;
  height: 7%;
  pointer-events: none;
  mix-blend-mode: screen;
  background: radial-gradient(60% 120% at 42% 0%, rgb(255 236 220 / .85), rgb(255 205 185 / .3) 55%, transparent 80%);
  clip-path: polygon(18% 0, 82% 0, 100% 100%, 0 100%);
  transform-origin: 18% 0;
  transform: scaleX(0);
  opacity: 0;
  animation: intro-spill 1.2s var(--ease-out) 3.45s forwards;
}

/* Poussières de lumière qui s'échappent de l'institut */
.intro__motes {
  position: absolute;
  left: 44.64%;
  top: 40.6%;
  width: 16.16%;
  height: 52.71%;
  pointer-events: none;
  container-type: size;
}
.intro__motes i {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 9%;
  aspect-ratio: 1;
  background: #FFF6EE;
  clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%);
  filter: drop-shadow(0 0 4px #FFE6D8) drop-shadow(0 0 10px rgb(255 220 200 / .8));
  opacity: 0;
  animation: intro-mote 1.3s var(--ease-out) var(--d) forwards;
}
.intro__motes i:nth-child(even) { width: 6%; }

.intro__door-glow {
  position: absolute;
  left: 52.8%;
  top: 66%;
  width: 38%;
  aspect-ratio: 1 / 1.25;
  border-radius: 50%;
  pointer-events: none;
  mix-blend-mode: screen;
  transform: translate(-50%, -50%);
  background: radial-gradient(closest-side, rgb(255 236 222 / .75), rgb(255 210 190 / .25) 50%, transparent);
  opacity: 0;
  animation: intro-halo 1s ease-out 3.6s forwards;
}

/* Vignettage cinéma */
.intro__vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 90% at 50% 55%, transparent 55%, rgb(20 10 12 / .55));
  animation: intro-vignette-out .8s ease 4s forwards;
}

/* — Lumière qui envahit l'écran au passage de la porte — */
.intro__light {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 55%, #FFFFFF, var(--c-ivory) 60%, #F8EDEF);
  opacity: 0;
  animation: intro-light .65s var(--ease-in-out) 4.6s forwards;
}

/* — Bouton « Passer » — */
.intro__skip {
  position: absolute;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 2;
  padding: .55rem 1.1rem;
  border: 1px solid rgb(243 214 204 / .55);
  border-radius: var(--radius-pill);
  background: rgb(36 22 26 / .4);
  color: var(--c-gold-light);
  font: 500 var(--t-micro) / 1 var(--f-sans);
  letter-spacing: .12em;
  text-transform: uppercase;
  cursor: pointer;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: intro-fade .5s ease .8s both;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.intro__skip:hover { background: rgb(36 22 26 / .65); color: var(--c-ivory); }
.intro__skip:focus-visible { outline: none; box-shadow: 0 0 0 2px #24161A, 0 0 0 4px var(--c-gold-light); }

/* Sortie anticipée (bouton « Passer » ou Échap) */
html.intro-playing .intro.is-leaving { animation: intro-out .45s var(--ease-out) forwards; }
.intro.is-leaving * { animation-play-state: paused; }

/* — Images clés — */
@keyframes intro-in { from { opacity: 0; transform: scale(1.07); } to { opacity: 1; transform: scale(1); } }
@keyframes intro-dolly { from { transform: scale(1); } to { transform: scale(6.5); } }
@keyframes intro-lights-on { to { filter: brightness(1) saturate(1) contrast(1); } }
@keyframes intro-halo { to { opacity: 1; } }
@keyframes intro-flicker { from { filter: brightness(.9); } to { filter: brightness(1.08); } }
@keyframes intro-sweep { to { background-position: -30% 0; } }
/* Déverrouillage (petit à-coup), léger recul, puis grande ouverture amortie */
@keyframes intro-leaf-open {
  0%   { transform: rotateY(0); animation-timing-function: cubic-bezier(.3, 0, .4, 1); }
  10%  { transform: rotateY(-4deg); animation-timing-function: ease-in-out; }
  18%  { transform: rotateY(-2.5deg); animation-timing-function: cubic-bezier(.55, 0, .2, 1); }
  100% { transform: rotateY(-86deg); }
}
@keyframes intro-inside-glow { to { filter: brightness(1.15); } }
@keyframes intro-gap { 0% { opacity: 0; } 30% { opacity: 1; } 100% { opacity: 0; } }
@keyframes intro-spill { to { transform: scaleX(1); opacity: 1; } }
@keyframes intro-mote {
  0%   { opacity: 0; transform: translate(0, 0) scale(.4) rotate(0); }
  30%  { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(var(--dx) * 1cqw), 28cqh) scale(1.1) rotate(90deg); }
}
@keyframes intro-vignette-out { to { opacity: 0; } }
@keyframes intro-light { to { opacity: 1; } }
@keyframes intro-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes intro-out { to { opacity: 0; visibility: hidden; } }

@media (prefers-reduced-motion: reduce) {
  html.intro-playing .intro { display: none; }
}
