/* ==========================================================================
   Duskwyn.dev — animations.css
   Every animation here moves only transform / opacity / filter so it stays
   on the compositor (GPU) and never triggers layout.
   ========================================================================== */

/* ---------- Keyframes ---------------------------------------------------- */
@keyframes neon-pulse {
  0%, 100% {
    text-shadow:
      0 0 6px rgba(var(--accent-rgb), 0.55),
      0 0 22px rgba(var(--accent-rgb), 0.35),
      0 0 48px rgba(var(--accent-2-rgb), 0.25);
  }
  50% {
    text-shadow:
      0 0 10px rgba(var(--accent-rgb), 0.8),
      0 0 34px rgba(var(--accent-rgb), 0.5),
      0 0 80px rgba(var(--accent-2-rgb), 0.4);
  }
}

@keyframes gradient-pan {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

@keyframes float-y {
  0%, 100% { transform: translate3d(0, 0, 0); }
  50% { transform: translate3d(0, -12px, 0); }
}

@keyframes orb-drift-1 {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(-60px, 40px, 0) scale(1.1); }
}
@keyframes orb-drift-2 {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(70px, -30px, 0) scale(0.92); }
}
@keyframes orb-drift-3 {
  0%, 100% { transform: translate3d(0, 0, 0); }
  50% { transform: translate3d(-40px, -50px, 0); }
}

@keyframes grid-scroll {
  from { transform: perspective(600px) rotateX(55deg) translate3d(0, 0, 0); }
  to { transform: perspective(600px) rotateX(55deg) translate3d(0, 56px, 0); }
}

@keyframes fade-up {
  from { opacity: 0; transform: translate3d(0, 24px, 0); }
  to { opacity: 1; transform: none; }
}

@keyframes shimmer {
  from { transform: translateX(-120%) skewX(-20deg); }
  to { transform: translateX(220%) skewX(-20deg); }
}

@keyframes spin-slow { to { transform: rotate(360deg); } }

@keyframes ping {
  0% { transform: scale(1); opacity: 0.7; }
  80%, 100% { transform: scale(2.4); opacity: 0; }
}

@keyframes bar-grow {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

/* ---------- Applied animations ------------------------------------------ */

.neon-gradient {
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent-3), var(--accent));
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: gradient-pan 8s linear infinite;
  filter: drop-shadow(0 0 18px rgba(var(--accent-rgb), 0.45));
}

@keyframes btn-pan {
  from { background-position: 0% 50%; }
  to { background-position: 100% 50%; }
}

/* Background-position can't be GPU-composited, so an always-running pan would
   repaint every primary button (including the header CTA) on every frame.
   The pan now plays only while the button is hovered or focused. */
.btn-primary:hover,
.btn-primary:focus-visible { animation: btn-pan 1.6s ease-in-out infinite alternate; }

/* Pause the drifting background orbs while the page is scrolling: glass cards
   blur whatever is behind them, so a moving backdrop re-blurs every card each frame. */
.is-scrolling .bg-orb { animation-play-state: paused; }

.btn-primary::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  width: 40%;
  transform: translateX(-120%) skewX(-20deg);
  z-index: -1;
  pointer-events: none;
}
.btn-primary:hover::after { animation: shimmer 0.9s var(--ease-out); }

.float { animation: float-y 6s ease-in-out infinite; }

.orb-1 { animation: orb-drift-1 18s ease-in-out infinite; }
.orb-2 { animation: orb-drift-2 22s ease-in-out infinite; }
.orb-3 { animation: orb-drift-3 26s ease-in-out infinite; }

/* Perspective neon floor used on the home hero */
.neon-floor {
  position: absolute;
  left: -25%; right: -25%;
  bottom: -10%;
  height: 60%;
  background-image:
    linear-gradient(rgba(var(--accent-rgb), 0.35) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--accent-rgb), 0.35) 1px, transparent 1px);
  background-size: 56px 56px;
  transform-origin: center top;
  animation: grid-scroll 3s linear infinite;
  -webkit-mask-image: linear-gradient(to top, #000 0%, transparent 80%);
  mask-image: linear-gradient(to top, #000 0%, transparent 80%);
  opacity: 0.35;
  will-change: transform;
}

/* ---------- Scroll reveal ----------------------------------------------- */
/* Only hide content when JS has confirmed it can reveal it again. */
.js [data-reveal] {
  opacity: 0;
  transform: translate3d(0, 26px, 0);
  transition:
    opacity var(--dur-slow) var(--ease-out),
    transform var(--dur-slow) var(--ease-out);
  transition-delay: var(--reveal-delay, 0ms);
}
.js [data-reveal="fade"] { transform: none; }
.js [data-reveal="zoom"] { transform: scale(0.94); }
.js [data-reveal].is-visible { opacity: 1; transform: none; }

/* Hero entrance */
.hero [data-enter] { animation: fade-up 0.9s var(--ease-out) both; }
.hero [data-enter="2"] { animation-delay: 0.12s; }
.hero [data-enter="3"] { animation-delay: 0.24s; }
.hero [data-enter="4"] { animation-delay: 0.36s; }
.hero [data-enter="5"] { animation-delay: 0.48s; }

/* ---------- Reduced motion ---------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .js [data-reveal] { opacity: 1; transform: none; }
  
}

/* User-chosen "reduce motion" toggle (theme.js) mirrors the media query. */
:root[data-motion="reduced"] *,
:root[data-motion="reduced"] *::before,
:root[data-motion="reduced"] *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}
:root[data-motion="reduced"] .js [data-reveal],
:root[data-motion="reduced"] [data-reveal] { opacity: 1; transform: none; }
