/* Section 08-final — fichier propre à la section (base commune : ../styles.css).
   La finale est une scène sous un ciel étoilé : un rideau de velours se lève, deux projecteurs
   se croisent sur le formulaire, une portée de cinq fils lumineux le traverse (canvas, js/08-final.js),
   et une foule attend en contre-jour au bord d'un horizon lumineux qui se fond dans le pied de page. */

@property --final-angle { syntax: "<angle>"; inherits: false; initial-value: 0deg; }

.final {
  position: relative; isolation: isolate; overflow: hidden;
  background: var(--canvas-deep);
  padding-block: clamp(116px, 12vw, 168px) clamp(210px, 21vw, 300px);
  min-height: min(100svh, 1080px);
  display: flex; align-items: center;
}
.final-inner { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; text-align: center; }

/* ------------------------------------------------------------------ décor */
.final-scene { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.final-scene > * { position: absolute; }

/* Ciel : l'univers de l'en-tête, en lente dérive, assombri vers l'horizon */
.final-sky {
  inset: -4%;
  background:
    linear-gradient(180deg, rgb(6 8 10 / 35%) 0%, rgb(6 8 10 / 5%) 30%, rgb(6 8 10 / 55%) 70%, var(--canvas-deep) 96%),
    radial-gradient(60% 50% at 50% 0%, rgb(167 139 250 / 22%), transparent 70%),
    image-set(url("../assets/media/hero-universe.avif") type("image/avif"),
              url("../assets/media/hero-universe.webp") type("image/webp"),
              url("../assets/media/hero-universe.jpg") type("image/jpeg")) center 30% / cover no-repeat;
  opacity: .62;
  animation: final-sky 70s ease-in-out infinite alternate;
}
@keyframes final-sky { from { transform: scale(1.08) translate3d(-1.5%, 0, 0); } to { transform: scale(1.02) translate3d(1.5%, -1%, 0); } }

.final-canvas { inset: 0; width: 100%; height: 100%; }

/* Projecteurs : deux cônes de lumière aux bords doux qui se croisent sur le formulaire */
.final-beam {
  --L: clamp(900px, 110vw, 1500px);
  top: -3%; width: calc(var(--L) * 2); height: var(--L); transform-origin: 50% 0;
  mix-blend-mode: screen; opacity: .72;
  -webkit-mask-image: radial-gradient(var(--L) var(--L) at 50% 0, #000 10%, rgb(0 0 0 / 45%) 45%, transparent 75%);
  mask-image: radial-gradient(var(--L) var(--L) at 50% 0, #000 10%, rgb(0 0 0 / 45%) 45%, transparent 75%);
}
.final-beam--l { left: calc(9% - var(--L)); --b-from: -4deg; --b-to: 3deg;
  background: conic-gradient(from 136deg at 50% 0, transparent 0deg, rgb(26 255 234 / 22%) 7deg, rgb(160 255 246 / 42%) 11deg, rgb(26 255 234 / 22%) 15deg, transparent 22deg);
  animation: final-beam 11s ease-in-out infinite alternate; }
.final-beam--r { right: calc(9% - var(--L)); --b-from: 4deg; --b-to: -3deg;
  background: conic-gradient(from 202deg at 50% 0, transparent 0deg, rgb(167 139 250 / 24%) 7deg, rgb(214 200 255 / 42%) 11deg, rgb(167 139 250 / 24%) 15deg, transparent 22deg);
  animation: final-beam 13s ease-in-out -4s infinite alternate; }
@keyframes final-beam { from { transform: rotate(var(--b-from)); } to { transform: rotate(var(--b-to)); } }

/* Horizon : le bord d'une planète sombre, frangé de lumière, d'où monte une aurore */
.final-horizon {
  left: -30%; right: -30%; bottom: calc(clamp(64px, 8vw, 120px) - 58vw); height: 58vw;
  border-radius: 50%;
  background: var(--canvas-deep);
  box-shadow:
    0 -1px 0 rgb(190 255 248 / 85%),
    0 -3px 8px rgb(26 255 234 / 70%),
    0 -18px 50px rgb(26 255 234 / 32%),
    0 -60px 140px rgb(0 194 180 / 26%),
    0 -140px 260px rgb(167 139 250 / 16%);
}
.final-horizon::before { /* aurore au-dessus du point de fuite */
  content: ""; position: absolute; left: 50%; top: 0; width: 70%; height: 46vw; transform: translate(-50%, -62%);
  background:
    radial-gradient(closest-side, rgb(255 214 170 / 22%), transparent 40%),
    radial-gradient(closest-side, rgb(26 255 234 / 22%), rgb(0 194 180 / 8%) 55%, transparent 100%);
  filter: blur(6px);
  animation: final-aurora 9s ease-in-out infinite alternate;
}
@keyframes final-aurora { from { opacity: .7; transform: translate(-50%, -62%) scaleX(.94); } to { opacity: 1; transform: translate(-50%, -62%) scaleX(1.06); } }

/* Foule en contre-jour, raccordée en bas avec le pied de page */
.final-crowd {
  left: 0; right: 0; bottom: -2px; height: clamp(120px, 15vw, 230px);
  background: url("../assets/sections/08-final/crowd.svg") center bottom / auto 100% repeat-x;
  filter: drop-shadow(0 -1px 0 rgb(26 255 234 / 22%)) drop-shadow(0 -6px 14px rgb(0 194 180 / 14%));
}
.final-crowd::after { /* le pied de la foule se fond dans le sol (et dans le pied de page) */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 45%;
  background: linear-gradient(180deg, transparent, var(--canvas-deep) 85%);
}

/* Coulisses : pendrillons latéraux et lambrequin de velours nuit */
.final-drape {
  top: 0; bottom: 0; width: clamp(64px, 9vw, 150px); z-index: 1;
  background: url("../assets/sections/08-final/drape.svg") 0 0 / 100% 100% no-repeat;
  filter: drop-shadow(14px 0 24px rgb(0 0 0 / 70%));
  -webkit-mask-image: linear-gradient(180deg, #000 70%, transparent 98%);
  mask-image: linear-gradient(180deg, #000 70%, transparent 98%);
}
.final-drape--l { left: 0; }
.final-drape--r { right: 0; transform: scaleX(-1); }

.final-valance {
  top: 0; left: 0; right: 0; height: clamp(22px, 2.6vw, 38px); z-index: 3;
  background:
    linear-gradient(180deg, rgb(0 0 0 / 50%), transparent 60%),
    repeating-linear-gradient(90deg, #120D24 0, #241A42 16px, #120D24 32px);
  -webkit-mask: linear-gradient(#000 0 0) top / 100% 56% no-repeat, radial-gradient(50% 100% at 50% 0, #000 96%, transparent) left bottom / 64px 50% repeat-x;
  mask: linear-gradient(#000 0 0) top / 100% 56% no-repeat, radial-gradient(50% 100% at 50% 0, #000 96%, transparent) left bottom / 64px 50% repeat-x;
  filter: drop-shadow(0 6px 10px rgb(0 0 0 / 70%));
}

/* Rideau : couvre la scène, puis se lève quand la section entre à l'écran (seulement avec JS et animations) */
.final-curtain { display: none; }
.js .final-curtain {
  display: block; inset: 0; z-index: 2;
  background:
    linear-gradient(180deg, rgb(0 0 0 / 35%), transparent 30%, rgb(0 0 0 / 25%) 80%, rgb(0 0 0 / 55%)),
    repeating-linear-gradient(90deg, #0E0A1C 0, #1E1638 20px, #2C2050 30px, #171030 44px, #0E0A1C 60px);
  transform: translateY(0); transition: transform 2s cubic-bezier(.72, 0, .18, 1) .1s;
}
.js .final-curtain::after { /* ourlet : un fil de lumière */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: linear-gradient(90deg, transparent, var(--brand-bright) 20%, #fff 50%, var(--brand-bright) 80%, transparent);
  box-shadow: 0 0 18px var(--brand-bright), 0 0 50px rgb(26 255 234 / 50%);
}
.final.is-open .final-curtain { transform: translateY(-104%); }

/* ------------------------------------------------------------------ contenu */
.final-eyebrow { display: inline-flex; align-items: center; gap: 14px; color: var(--brand-bright); text-shadow: 0 0 18px rgb(26 255 234 / 45%); }
.final-eyebrow-line { width: clamp(24px, 5vw, 56px); height: 1px; background: linear-gradient(90deg, transparent, var(--brand-bright)); }
.final-eyebrow-line:last-child { background: linear-gradient(90deg, var(--brand-bright), transparent); }

.final-title {
  margin: 18px auto 0; max-width: 17ch; text-wrap: balance;
  font-size: clamp(38px, 6vw, 80px); line-height: 1.02; letter-spacing: -0.032em;
  color: var(--fg); text-shadow: 0 2px 30px rgb(6 8 10 / 80%), 0 0 60px rgb(26 255 234 / 14%);
}
.final-highlight { white-space: nowrap; }
.final-highlight, .final-highlight .final-word {
  background: linear-gradient(100deg, var(--brand-bright) 0%, #E8FFFC 55%, #CBB8FF 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.final-highlight .final-word { text-shadow: none; filter: drop-shadow(0 0 22px rgb(26 255 234 / 35%)); }
.final-highlight:has(.final-word) { background: none; color: inherit; }

/* Apparition des mots, l'un après l'autre (préparée par le script) */
.final-word { display: inline-block; }
.final-title.is-split .final-word {
  opacity: 0; transform: translateY(.55em) rotateX(-40deg); filter: blur(8px);
  transition: opacity .9s ease, transform 1s cubic-bezier(.2, .7, .2, 1), filter .9s ease;
  transition-delay: calc(.55s + var(--i) * 70ms);
}
.final-title.is-split.is-lit .final-word { opacity: 1; transform: none; filter: none; }
.final-title.is-split.is-lit .final-highlight .final-word { filter: drop-shadow(0 0 22px rgb(26 255 234 / 35%)); }

.final-lead { margin: 22px auto 0; max-width: 54ch; font-size: clamp(17px, 1.6vw, 19px); text-shadow: 0 1px 16px rgb(6 8 10 / 90%); }

/* Le formulaire, mis en scène au point où les projecteurs se croisent */
.final-stage {
  position: relative; margin-top: clamp(30px, 4vw, 46px); width: min(100%, 720px);
  padding: clamp(18px, 2.6vw, 28px); border-radius: 24px; text-align: left;
  background: linear-gradient(180deg, rgb(31 36 46 / 62%), rgb(13 16 20 / 80%));
  -webkit-backdrop-filter: blur(14px) saturate(1.2); backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: 0 0 0 1px rgb(56 66 82 / 70%), 0 30px 80px rgb(0 0 0 / 55%), 0 0 90px rgb(0 194 180 / 16%);
}
.final-stage::before { /* flaque de lumière sous le formulaire */
  content: ""; position: absolute; left: 6%; right: 6%; bottom: -46px; height: 70px; z-index: -1;
  background: radial-gradient(closest-side, rgb(26 255 234 / 30%), transparent); filter: blur(8px);
}
.final-stage-ring { /* bordure vivante : une lumière fait le tour du cadre */
  position: absolute; inset: 0; border-radius: inherit; padding: 1.5px; pointer-events: none;
  background: conic-gradient(from var(--final-angle), transparent 0deg, var(--brand-bright) 40deg, var(--violet) 90deg, transparent 140deg,
    transparent 180deg, rgb(255 136 79 / 80%) 220deg, var(--brand-bright) 260deg, transparent 320deg);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  animation: final-ring 9s linear infinite;
}
@keyframes final-ring { to { --final-angle: 360deg; } }
.final-stage:focus-within { box-shadow: 0 0 0 1px rgb(26 255 234 / 45%), 0 30px 80px rgb(0 0 0 / 55%), 0 0 110px rgb(26 255 234 / 22%); }

.final .waitlist { margin-top: 0; max-width: none; }
.final .waitlist-row { gap: 12px; }
.final .field {
  min-height: 58px; padding: 0 18px; font-size: 17px; border-radius: 14px;
  background: rgb(6 8 10 / 72%); border-color: var(--border-strong);
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.final .field:hover { border-color: var(--subtle); }
.final .field:focus { border-color: var(--brand-bright); background: rgb(6 8 10 / 90%); box-shadow: 0 0 0 4px rgb(26 255 234 / 12%), 0 0 34px rgb(26 255 234 / 16%); }
.final .field[aria-invalid="true"] { border-color: var(--warm); }
.final .waitlist .btn { min-height: 58px; padding: 0 26px; font-size: 16px; border-radius: 14px; }

.final .consent { margin-top: 16px; gap: 12px; font-size: 14px; line-height: 1.5; }
.final .consent input {
  -webkit-appearance: none; appearance: none; margin: 1px 0 0; width: 20px; height: 20px; flex: none; cursor: pointer;
  display: grid; place-content: center; border-radius: 6px;
  border: 1.5px solid var(--subtle); background: rgb(6 8 10 / 72%);
  transition: background .2s, border-color .2s, box-shadow .2s;
}
.final .consent input::before {
  content: ""; width: 10px; height: 5px; border-left: 2.2px solid #001614; border-bottom: 2.2px solid #001614;
  transform: translateY(-1px) rotate(-45deg) scale(0); transition: transform .2s cubic-bezier(.3, 1.6, .5, 1);
}
.final .consent:hover input { border-color: var(--brand-bright); }
.final .consent input:checked { background: var(--brand-bright); border-color: var(--brand-bright); box-shadow: 0 0 14px rgb(26 255 234 / 55%); }
.final .consent input:checked::before { transform: translateY(-1px) rotate(-45deg) scale(1); }
.final .form-status { margin-top: 12px; min-height: 0; }
.final .form-status:not(:empty) { padding: 10px 14px; border-radius: 10px; background: rgb(6 8 10 / 60%); border: 1px solid currentColor; }

/* ------------------------------------------------------------------ petits écrans */
@media (max-width: 700px) {
  .final { min-height: 0; padding-block: 96px 170px; }
  .final-drape { display: none; }
  .final-beam { opacity: .4; }
  .final-horizon { bottom: calc(70px - 90vw); height: 90vw; left: -40%; right: -40%; }
  .final-horizon::before { height: 80vw; width: 90%; }
  .final-title { max-width: none; font-size: clamp(32px, 9vw, 44px); text-wrap: wrap; }
  .final .waitlist .btn { padding: 0 14px; font-size: 15px; }
}

/* ------------------------------------------------------------------ réduire les animations */
@media (prefers-reduced-motion: reduce) {
  .final-sky, .final-beam, .final-horizon::before, .final-stage-ring { animation: none !important; }
  .js .final-curtain { display: none; }
  .final-title.is-split .final-word { opacity: 1; transform: none; filter: none; transition: none; }
}
