/* =========================================
   Global Animations
   Optimized keyframes + motion utilities
   Depends on tokens.css
   ========================================= */

/* -----------------------------------------
   Keyframes
   ----------------------------------------- */
@keyframes nx-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes nx-fade-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes nx-fade-down {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes nx-scale-in {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes nx-slide-in-right {
  from {
    opacity: 0;
    transform: translateX(24px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes nx-slide-in-left {
  from {
    opacity: 0;
    transform: translateX(-24px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes nx-pulse-soft {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.92;
    transform: scale(1.01);
  }
}

@keyframes nx-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes nx-light-sweep {
  from {
    transform: translateX(-140%) skewX(-18deg);
  }
  to {
    transform: translateX(140%) skewX(-18deg);
  }
}

@keyframes nx-light-drift {
  0%, 100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

@keyframes nx-glow-pulse {
  0%, 100% {
    box-shadow: var(--nx-glow-shadow-rest, 0 10px 24px rgba(0, 0, 0, 0.14));
  }
  50% {
    box-shadow: var(--nx-glow-shadow-active, 0 16px 34px rgba(84, 166, 255, 0.24));
  }
}

/* -----------------------------------------
   Shared animation base
   ----------------------------------------- */
[class*="nx-anim-"] {
  animation-duration: var(--nx-anim-duration, var(--nx-duration-normal));
  animation-timing-function: var(--nx-anim-ease, var(--nx-ease-out));
  animation-fill-mode: both;
}

.nx-anim-fade-in { animation-name: nx-fade-in; }
.nx-anim-fade-up { animation-name: nx-fade-up; }
.nx-anim-fade-down { animation-name: nx-fade-down; }
.nx-anim-scale-in { animation-name: nx-scale-in; }

.nx-anim-slide-in-right,
.nx-anim-slide-in-left {
  --nx-anim-duration: var(--nx-duration-slow);
}

.nx-anim-slide-in-right { animation-name: nx-slide-in-right; }
.nx-anim-slide-in-left { animation-name: nx-slide-in-left; }

.nx-anim-pulse-soft {
  animation-name: nx-pulse-soft;
  animation-duration: 1.6s;
  animation-timing-function: var(--nx-ease-in-out);
  animation-iteration-count: infinite;
}

.nx-anim-spin {
  animation-name: nx-spin;
  animation-duration: 1s;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}

.nx-anim-light-drift {
  animation-name: nx-light-drift;
  animation-duration: var(--nx-light-drift-duration, 5.5s);
  animation-timing-function: var(--nx-ease-in-out);
  animation-iteration-count: infinite;
}

.nx-anim-glow-pulse {
  animation-name: nx-glow-pulse;
  animation-duration: var(--nx-glow-pulse-duration, 2.8s);
  animation-timing-function: var(--nx-ease-in-out);
  animation-iteration-count: infinite;
}

/* -----------------------------------------
   Shared transition base
   ----------------------------------------- */
:root {
  --nx-transition-properties:
    color,
    background-color,
    border-color,
    box-shadow,
    opacity,
    transform;
  --nx-hover-lift-y: -2px;
  --nx-hover-scale: 1.015;
  --nx-hover-shadow: 0 14px 32px rgba(0, 0, 0, 0.18);
  --nx-press-y: 0;
  --nx-light-sweep-width: 44%;
  --nx-light-sweep-opacity: 0.32;
  --nx-light-sweep-duration: 850ms;
}

.nx-transition-fast,
.nx-transition,
.nx-transition-slow {
  transition-property: var(--nx-transition-properties);
  transition-timing-function: var(--nx-ease-standard);
}

.nx-transition-fast { transition-duration: var(--nx-duration-fast); }
.nx-transition { transition-duration: var(--nx-duration-normal); }
.nx-transition-slow { transition-duration: var(--nx-duration-slow); }

/* -----------------------------------------
   Delay helpers
   ----------------------------------------- */
.nx-delay-1 { animation-delay: 60ms; }
.nx-delay-2 { animation-delay: 120ms; }
.nx-delay-3 { animation-delay: 180ms; }
.nx-delay-4 { animation-delay: 240ms; }

/* -----------------------------------------
   Hover motion helpers
   ----------------------------------------- */
.nx-hover-lift,
.nx-hover-grow,
.nx-hover-glow,
.nx-hover-button {
  transition-property: transform, box-shadow;
  transition-duration: var(--nx-duration-normal);
  transition-timing-function: var(--nx-ease-out);
  will-change: transform;
}

.nx-hover-lift:hover {
  transform: translateY(var(--nx-hover-lift-y));
}

.nx-hover-grow {
  transition-property: transform;
}

.nx-hover-grow:hover {
  transform: scale(var(--nx-hover-scale));
}

.nx-hover-glow:hover {
  box-shadow: var(--nx-hover-shadow);
}

.nx-hover-button:hover {
  transform: translateY(var(--nx-hover-lift-y));
  box-shadow: var(--nx-hover-shadow);
}

.nx-hover-button:active {
  transform: translateY(var(--nx-press-y)) scale(0.99);
}

/* -----------------------------------------
   Light movement helpers
   ----------------------------------------- */
.nx-light-sweep,
.nx-hover-sweep {
  position: relative;
  isolation: isolate;
  overflow: hidden;
}

.nx-light-sweep::after,
.nx-hover-sweep::after {
  content: "";
  position: absolute;
  inset: -28% auto -28% 0;
  z-index: 1;
  width: var(--nx-light-sweep-width);
  pointer-events: none;
  background:
    linear-gradient(
      90deg,
      transparent,
      rgba(255, 255, 255, var(--nx-light-sweep-opacity)),
      transparent
    );
  transform: translateX(-140%) skewX(-18deg);
}

.nx-light-sweep::after {
  animation: nx-light-sweep var(--nx-light-sweep-duration) var(--nx-ease-out) both;
}

.nx-hover-sweep:hover::after,
.nx-hover-sweep:focus-visible::after {
  animation: nx-light-sweep var(--nx-light-sweep-duration) var(--nx-ease-out) both;
}

/* -----------------------------------------
   Scroll reveal animation system
   ----------------------------------------- */
.nx-scroll-animate {
  --nx-scroll-animation-duration: 620ms;
  --nx-scroll-animation-delay: 0ms;
  --nx-scroll-animation-distance: 18px;
  --nx-scroll-animation-ease: var(--nx-ease-out);
  --nx-scroll-hidden-transform: translateY(var(--nx-scroll-animation-distance));
  opacity: 0;
  transform: var(--nx-scroll-hidden-transform);
  transition:
    opacity var(--nx-scroll-animation-duration) var(--nx-scroll-animation-ease) var(--nx-scroll-animation-delay),
    transform var(--nx-scroll-animation-duration) var(--nx-scroll-animation-ease) var(--nx-scroll-animation-delay);
  will-change: opacity, transform;
}

.nx-scroll-animate.is-scroll-visible {
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
}

.nx-scroll-animate--fade {
  --nx-scroll-hidden-transform: none;
}

.nx-scroll-animate--slide,
.nx-scroll-animate--slide-up {
  --nx-scroll-hidden-transform: translateY(var(--nx-scroll-animation-distance));
}

.nx-scroll-animate--slide-down {
  --nx-scroll-hidden-transform: translateY(calc(var(--nx-scroll-animation-distance) * -1));
}

.nx-scroll-animate--slide-left {
  --nx-scroll-hidden-transform: translateX(var(--nx-scroll-animation-distance));
}

.nx-scroll-animate--slide-right {
  --nx-scroll-hidden-transform: translateX(calc(var(--nx-scroll-animation-distance) * -1));
}

.nx-scroll-animate--zoom,
.nx-scroll-animate--scale {
  --nx-scroll-hidden-transform: scale(0.96);
}

.nx-scroll-animate--jump {
  --nx-scroll-hidden-transform: translateY(calc(var(--nx-scroll-animation-distance) * 1.25)) scale(0.98);
  --nx-scroll-animation-ease: cubic-bezier(0.2, 1.35, 0.32, 1);
}

/* -----------------------------------------
   Reduced motion accessibility
   ----------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  [class*="nx-anim-"] {
    animation: none !important;
  }

  .nx-transition-fast,
  .nx-transition,
  .nx-transition-slow,
  .nx-hover-lift,
  .nx-hover-grow,
  .nx-hover-glow,
  .nx-hover-button {
    transition: none !important;
  }

  .nx-hover-lift:hover,
  .nx-hover-grow:hover,
  .nx-hover-button:hover,
  .nx-hover-button:active {
    transform: none !important;
  }

  .nx-light-sweep::after,
  .nx-hover-sweep::after,
  .nx-hover-sweep:hover::after,
  .nx-hover-sweep:focus-visible::after {
    animation: none !important;
    transform: none !important;
  }

  .nx-scroll-animate {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}
