/* =====================================================================
   APEX EMPIRE — motion layer
   Keyframes, scroll-reveal states, split-text scaffolding, a11y fallbacks
   ===================================================================== */

/* ---------- KEYFRAMES ---------------------------------------------- */
@keyframes riseIn {
  from {
    transform: translateY(110%);
  }

  to {
    transform: translateY(0);
  }
}

@keyframes fadeOutUp {
  to {
    opacity: 0;
    transform: translateY(-24px);
    visibility: hidden;
  }
}

@keyframes goldShift {
  to {
    background-position: 200% center;
  }
}

@keyframes pulseDot {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(212, 175, 55, .55);
  }

  55% {
    box-shadow: 0 0 0 9px rgba(212, 175, 55, 0);
  }
}

@keyframes ringPulse {
  0% {
    transform: scale(1);
    opacity: .8;
  }

  100% {
    transform: scale(1.55);
    opacity: 0;
  }
}

@keyframes bobY {

  0%,
  100% {
    transform: translateY(-4px);
  }

  50% {
    transform: translateY(4px);
  }
}

@keyframes spinSlow {
  to {
    transform: rotate(360deg);
  }
}

@keyframes auroraDrift {
  0% {
    transform: translate3d(-2%, -1%, 0) scale(1);
  }

  50% {
    transform: translate3d(2%, 2%, 0) scale(1.08);
  }

  100% {
    transform: translate3d(-1%, 1%, 0) scale(1.03);
  }
}

@keyframes grainShift {
  0% {
    transform: translate(0, 0);
  }

  25% {
    transform: translate(-3%, 2%);
  }

  50% {
    transform: translate(2%, -3%);
  }

  75% {
    transform: translate(-2%, -2%);
  }

  100% {
    transform: translate(0, 0);
  }
}

@keyframes marqueeScroll {
  from {
    transform: translate3d(0, 0, 0);
  }

  to {
    transform: translate3d(-50%, 0, 0);
  }
}

@keyframes pitemIn {
  from {
    opacity: 0;
    transform: translateY(26px) scale(.985);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes drawLine {
  from {
    stroke-dashoffset: var(--dash, 400);
  }

  to {
    stroke-dashoffset: 0;
  }
}

/* ---------- CSS-DRIVEN MARQUEE ------------------------------------- */
/* JS duplicates the track content, then this animation loops seamlessly */
.marquee__track.is-running {
  animation: marqueeScroll var(--duration, 40s) linear infinite;
}

.marquee__track.is-reverse {
  animation-direction: reverse;
}

.marquee:hover .marquee__track.is-running {
  animation-play-state: paused;
}

/* ---------- SCROLL REVEAL ------------------------------------------ */
/* Elements start hidden only once JS confirms it can animate them.
   Without JS (or with GSAP blocked) everything stays visible.          */
.can-animate [data-reveal] {
  opacity: 0;
  transform: translateY(38px);
}

.can-animate [data-reveal="fade"] {
  transform: none;
}

.can-animate [data-reveal="left"] {
  transform: translateX(-46px);
}

.can-animate [data-reveal="right"] {
  transform: translateX(46px);
}

.can-animate [data-reveal="scale"] {
  transform: scale(.94);
}

/* IntersectionObserver fallback used when GSAP is unavailable */
.can-animate.no-gsap [data-reveal] {
  transition: opacity .9s var(--ease), transform 1s var(--ease);
}

.can-animate.no-gsap [data-reveal].is-in {
  opacity: 1;
  transform: none;
}

/* ---------- SPLIT TEXT --------------------------------------------- */
/* JS wraps each word: <span class="word"><span class="word__i">…</span></span> */
.word {
  display: inline-block;
  overflow: hidden;
  vertical-align: top;
  padding-bottom: .06em;
  margin-bottom: -.06em;
}

.word__i {
  display: inline-block;
  will-change: transform;
}

/* Words that came from an <em>/<b> inside the headline keep the gold */
.word__i--accent {
  background: var(--grad-gold);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: goldShift 7s linear infinite;
}

/* Only the no-GSAP path sets the hidden state in CSS. When GSAP is
   present it calls gsap.set(yPercent:110) instead — getComputedStyle
   resolves a CSS percentage to px, which GSAP would then keep as a
   separate y offset and never animate away. */
.can-animate.no-gsap .word__i {
  transform: translateY(110%);
}

.can-animate.no-gsap .is-split-in .word__i {
  transform: translateY(0);
}

/* No-GSAP fallback: reveal split lines on scroll with pure CSS */
.can-animate.no-gsap [data-split] .word__i,
.can-animate.no-gsap [data-split-lines] .word__i {
  transition: transform .95s var(--ease);
  transition-delay: calc(var(--wi, 0) * 28ms);
}

.can-animate.no-gsap [data-split].is-in .word__i,
.can-animate.no-gsap [data-split-lines].is-in .word__i {
  transform: translateY(0);
}

/* Manifesto scrub words start dim and light up with scroll progress */
.manifesto__text .w {
  color: rgba(255, 255, 255, .14);
}

.no-gsap .manifesto__text .w,
.reduced .manifesto__text .w {
  color: var(--txt);
}

/* ---------- HOVER MOTION HELPERS ----------------------------------- */
[data-tilt] {
  transform-style: preserve-3d;
}

.magnetic {
  will-change: transform;
}

/* Draw-in stroke animation for icons entering the viewport */
.icon-draw path,
.icon-draw circle,
.icon-draw rect {
  stroke-dasharray: var(--dash, 400);
  stroke-dashoffset: var(--dash, 400);
}

.icon-draw.is-in path,
.icon-draw.is-in circle,
.icon-draw.is-in rect {
  animation: drawLine 1.2s var(--ease) forwards;
}

/* ---------- CINEMATIC CANVAS --------------------------------------- */
.cine {
  width: 100%;
  height: 100%;
  display: block;
  background: #080808;
}

/* ---------- REDUCED MOTION / NO-JS --------------------------------- */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }

  .can-animate [data-reveal],
  .can-animate .word__i {
    opacity: 1 !important;
    transform: none !important;
  }

  .fx-aurora,
  .fx-grain,
  .fx-particles {
    animation: none;
  }

  .marquee__track.is-running {
    animation: none;
  }

  .cursor {
    display: none;
  }

  .manifesto__text .w {
    color: var(--txt);
  }
}

/* Explicit class applied by JS when the user prefers reduced motion */
.reduced [data-reveal],
.reduced .word__i {
  opacity: 1 !important;
  transform: none !important;
}

.reduced .cursor,
.reduced .fx-particles {
  display: none;
}

.reduced .preloader {
  display: none;
}
