/* Reflexlux Opening v6 — real hero version
   Difference from v5:
   - no artificial final hero
   - no duplicated claim/buttons/product
   - overlay is mounted inside the existing .hero
   - existing .hero-content is revealed at the end
   - existing .hero-media img /assets/reflex-wall.webp remains the final scene
*/

:root {
  --rfl-opening-word-width: min(500px, 50vw);
  --rfl-opening-x-start-w: clamp(82px, 8vw, 104px);
  --rfl-opening-x-start-center: -210px;
  --rfl-opening-word-start-center: 112px;
  --rfl-opening-x-zoom-scale: 5.5;
}

/* JS adds this to section.hero */
.hero.rfl-opening-host {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

/* The real hero content is not duplicated. It is only temporarily hidden and then revealed. */
body.rfl-opening-active .hero.rfl-opening-host.rfl-opening-playing .hero-content {
  opacity: 0;
  transform: translateY(120px);
  animation: rfl-real-hero-content-in 5.70s forwards cubic-bezier(.2,.7,.2,1) !important;
  will-change: opacity, transform;
}

/* Keep the real wall image pixel-aligned; the overlay handles the temporary darkening. */
body.rfl-opening-active .hero.rfl-opening-host.rfl-opening-playing .hero-media {
  filter: none;
  transform: none;
}

/* Overlay sits exactly over the existing hero, not under the global header. */
.rfl-opening-root {
  position: absolute;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  overflow: hidden;
}

/* Darkening layer over the real wall image. It fades away shortly before the final hero is released. */
.rfl-opening-root::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(900px 620px at 78% 46%, rgba(190,225,230,.10), rgba(0,0,0,0) 55%),
    linear-gradient(90deg, rgba(0,0,0,.58), rgba(0,0,0,.34) 48%, rgba(0,0,0,.20));
  animation: rfl-opening-scrim-out 5.70s forwards cubic-bezier(.2,.7,.2,1);
}

/* No grain here: the real hero image should stay visually identical to the final state. */
.rfl-opening-root::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0;
  background: none;
  pointer-events: none;
}

.rfl-opening-mark {
  position: absolute;
  inset: 0;
  z-index: 4;
}

.rfl-opening-logo-x {
  position: absolute;
  z-index: 5;
  left: calc(50% + var(--rfl-opening-x-start-center));
  top: 42%;
  width: var(--rfl-opening-x-start-w);
  height: auto;
  max-width: none;
  transform: translate(-50%, -50%);
  opacity: 0;
  transform-origin: center center;
  animation: rfl-opening-x-meet-zoom 5.70s forwards cubic-bezier(.2,.7,.2,1);
  will-change: transform, opacity;
}

.rfl-opening-word-shell {
  position: absolute;
  z-index: 4;
  left: calc(50% + var(--rfl-opening-word-start-center));
  top: 42%;
  width: var(--rfl-opening-word-width);
  overflow: hidden;
  transform: translate(-50%, -50%);
  opacity: 0;
  animation: rfl-opening-word-fade 5.70s forwards cubic-bezier(.2,.7,.2,1);
  will-change: opacity, filter;
}

.rfl-opening-word {
  display: block;
  width: 100%;
  height: auto;
  max-width: none;
}

.rfl-opening-skip {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  pointer-events: auto;
  appearance: none;
  border: 1px solid rgba(255,255,255,.45);
  background: rgba(0,0,0,.22);
  color: rgba(255,255,255,.86);
  border-radius: 999px;
  padding: 9px 13px;
  font: 600 12px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  cursor: pointer;
  backdrop-filter: blur(10px);
  opacity: 0;
  animation: rfl-opening-skip-in .30s ease 1.0s forwards;
}

.rfl-opening-root.is-done,
.rfl-opening-root.is-skipped {
  display: none;
}

@keyframes rfl-opening-x-meet-zoom {
  0% {
    opacity: 0;
    left: calc(50% + var(--rfl-opening-x-start-center));
    transform: translate(-50%, -50%) scale(.98);
  }
  5% {
    opacity: 1;
    left: calc(50% + var(--rfl-opening-x-start-center));
    transform: translate(-50%, -50%) scale(1);
  }
  40% {
    opacity: 1;
    left: calc(50% + var(--rfl-opening-x-start-center));
    transform: translate(-50%, -50%) scale(1);
  }
  52%, 56% {
    opacity: 1;
    left: 50%;
    transform: translate(-50%, -50%) scale(1);
  }
  65% {
    opacity: 1;
    left: 50%;
    transform: translate(-50%, -50%) scale(var(--rfl-opening-x-zoom-scale));
  }
  72% {
    opacity: 0;
    left: 50%;
    transform: translate(-50%, -50%) scale(var(--rfl-opening-x-zoom-scale));
  }
  100% {
    opacity: 0;
    left: 50%;
    transform: translate(-50%, -50%) scale(var(--rfl-opening-x-zoom-scale));
  }
}

@keyframes rfl-opening-word-fade {
  0% {
    opacity: 0;
    filter: blur(0);
    left: calc(50% + var(--rfl-opening-word-start-center));
    transform: translate(-50%, -50%);
  }
  5% {
    opacity: 1;
    filter: blur(0);
    left: calc(50% + var(--rfl-opening-word-start-center));
    transform: translate(-50%, -50%);
  }
  22% {
    opacity: 1;
    filter: blur(0);
    left: calc(50% + var(--rfl-opening-word-start-center));
    transform: translate(-50%, -50%);
  }
  32% {
    opacity: 0;
    filter: blur(.8px);
    left: calc(50% + var(--rfl-opening-word-start-center));
    transform: translate(-50%, -50%);
  }
  100% {
    opacity: 0;
    filter: blur(.8px);
    left: calc(50% + var(--rfl-opening-word-start-center));
    transform: translate(-50%, -50%);
  }
}

/* Text/buttons are the real .hero-content and come up only after the X has left. */
@keyframes rfl-real-hero-content-in {
  0%, 72% {
    opacity: 0;
    transform: translateY(120px);
  }
  88% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes rfl-opening-scrim-out {
  0%, 64% {
    opacity: 1;
  }
  84% {
    opacity: 0;
  }
  100% {
    opacity: 0;
  }
}

@keyframes rfl-opening-skip-in {
  to { opacity: .85; }
}

@media (max-width: 900px) {
  :root {
    --rfl-opening-word-width: min(360px, 66vw);
    --rfl-opening-x-start-w: 76px;
    --rfl-opening-x-start-center: -162px;
    --rfl-opening-word-start-center: 88px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rfl-opening-root {
    display: none !important;
  }

  body.rfl-opening-active .hero.rfl-opening-host.rfl-opening-playing .hero-content,
  body.rfl-opening-active .hero.rfl-opening-host.rfl-opening-playing .hero-media {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
  }
}
