/* ============================================
   SignumEssentials v30 - Animations
   ============================================ */

/* ========================================
   ENTRANCE ANIMATIONS
   ======================================== */

/* Fade In */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.animate-fade-in {
  animation: fadeIn var(--duration-500) var(--ease-out) forwards;
}

/* Fade Up */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(40px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-fade-up {
  animation: fadeUp var(--duration-700) var(--ease-out) forwards;
}

/* Fade Down */
@keyframes fadeDown {
  from {
    opacity: 0;
    transform: translateY(-40px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-fade-down {
  animation: fadeDown var(--duration-700) var(--ease-out) forwards;
}

/* Fade Left */
@keyframes fadeLeft {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.animate-fade-left {
  animation: fadeLeft var(--duration-700) var(--ease-out) forwards;
}

/* Fade Right */
@keyframes fadeRight {
  from {
    opacity: 0;
    transform: translateX(-40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.animate-fade-right {
  animation: fadeRight var(--duration-700) var(--ease-out) forwards;
}

/* Scale In */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.animate-scale-in {
  animation: scaleIn var(--duration-500) var(--ease-spring) forwards;
}

/* Scale Up (Dramatic) */
@keyframes scaleUp {
  from {
    opacity: 0;
    transform: scale(0.5);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.animate-scale-up {
  animation: scaleUp var(--duration-500) var(--ease-bounce) forwards;
}

/* Blur In */
@keyframes blurIn {
  from {
    opacity: 0;
    filter: blur(12px);
  }
  to {
    opacity: 1;
    filter: blur(0);
  }
}

.animate-blur-in {
  animation: blurIn var(--duration-700) var(--ease-out) forwards;
}

/* Rotate In */
@keyframes rotateIn {
  from {
    opacity: 0;
    transform: rotate(-10deg) scale(0.9);
  }
  to {
    opacity: 1;
    transform: rotate(0) scale(1);
  }
}

.animate-rotate-in {
  animation: rotateIn var(--duration-500) var(--ease-spring) forwards;
}

/* ========================================
   3D ENTRANCE ANIMATIONS
   ======================================== */

/* Flip In */
@keyframes flipInX {
  from {
    opacity: 0;
    transform: perspective(400px) rotateX(-90deg);
  }
  to {
    opacity: 1;
    transform: perspective(400px) rotateX(0);
  }
}

.animate-flip-in-x {
  animation: flipInX var(--duration-700) var(--ease-spring) forwards;
  transform-style: preserve-3d;
}

@keyframes flipInY {
  from {
    opacity: 0;
    transform: perspective(400px) rotateY(-90deg);
  }
  to {
    opacity: 1;
    transform: perspective(400px) rotateY(0);
  }
}

.animate-flip-in-y {
  animation: flipInY var(--duration-700) var(--ease-spring) forwards;
  transform-style: preserve-3d;
}

/* Zoom In 3D */
@keyframes zoomIn3D {
  from {
    opacity: 0;
    transform: perspective(1000px) translateZ(-200px);
  }
  to {
    opacity: 1;
    transform: perspective(1000px) translateZ(0);
  }
}

.animate-zoom-in-3d {
  animation: zoomIn3D var(--duration-700) var(--ease-out) forwards;
}

/* ========================================
   CONTINUOUS ANIMATIONS
   ======================================== */

/* Float */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-20px); }
}

.animate-float {
  animation: float 6s ease-in-out infinite;
}

/* Gentle Float */
@keyframes floatGentle {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-12px) rotate(1deg);
  }
}

.animate-float-gentle {
  animation: floatGentle 8s ease-in-out infinite;
}

/* Float with Rotation */
@keyframes floatRotate {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  25% {
    transform: translateY(-10px) rotate(2deg);
  }
  50% {
    transform: translateY(-20px) rotate(0deg);
  }
  75% {
    transform: translateY(-10px) rotate(-2deg);
  }
}

.animate-float-rotate {
  animation: floatRotate 10s ease-in-out infinite;
}

/* Pulse */
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.05); }
}

.animate-pulse {
  animation: pulse 2s ease-in-out infinite;
}

/* Pulse Glow */
@keyframes pulseGlow {
  0%, 100% {
    box-shadow: var(--shadow-primary);
  }
  50% {
    box-shadow: var(--shadow-primary-lg), var(--glow-primary);
  }
}

.animate-pulse-glow {
  animation: pulseGlow 2s ease-in-out infinite;
}

/* Shimmer */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.animate-shimmer {
  background: linear-gradient(
    120deg,
    transparent 0%,
    rgba(255, 255, 255, 0.6) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: shimmer 2s linear infinite;
}

/* Rotate */
@keyframes rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.animate-rotate {
  animation: rotate 20s linear infinite;
}

.animate-rotate-slow {
  animation: rotate 40s linear infinite;
}

.animate-rotate-reverse {
  animation: rotate 20s linear infinite reverse;
}

/* Bounce */
@keyframes bounce {
  0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-10px); }
  60% { transform: translateY(-5px); }
}

.animate-bounce {
  animation: bounce 2s ease-in-out infinite;
}

/* ========================================
   GRADIENT ANIMATIONS
   ======================================== */

/* Gradient Shift */
@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.animate-gradient {
  background-size: 200% 200%;
  animation: gradientShift 8s ease infinite;
}

/* Gradient Wave */
@keyframes gradientWave {
  0% { background-position: 0% 0%; }
  50% { background-position: 100% 100%; }
  100% { background-position: 0% 0%; }
}

.animate-gradient-wave {
  background-size: 400% 400%;
  animation: gradientWave 15s ease infinite;
}

/* Aurora Animation */
@keyframes aurora {
  0% { background-position: 0% 50%; }
  25% { background-position: 50% 100%; }
  50% { background-position: 100% 50%; }
  75% { background-position: 50% 0%; }
  100% { background-position: 0% 50%; }
}

.animate-aurora {
  background-size: 400% 400%;
  animation: aurora 10s ease infinite;
}

/* ========================================
   TEXT ANIMATIONS
   ======================================== */

/* Text Reveal */
@keyframes textReveal {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}

.animate-text-reveal {
  animation: textReveal var(--duration-700) var(--ease-out) forwards;
}

/* Typewriter */
@keyframes typewriter {
  from { width: 0; }
  to { width: 100%; }
}

@keyframes blinkCaret {
  0%, 100% { border-right-color: transparent; }
  50% { border-right-color: var(--accent-primary); }
}

.animate-typewriter {
  overflow: hidden;
  white-space: nowrap;
  border-right: 3px solid var(--accent-primary);
  animation:
    typewriter 3s steps(40) forwards,
    blinkCaret 0.75s step-end infinite;
}

/* Letter Pop */
@keyframes letterPop {
  0% {
    opacity: 0;
    transform: scale(0) rotate(-180deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0);
  }
}

/* Word Stagger */
.word-stagger {
  display: inline-block;
  opacity: 0;
  transform: translateY(30px);
  transition: all var(--duration-500) var(--ease-out);
}

.word-stagger.animate {
  opacity: 1;
  transform: translateY(0);
}

/* ========================================
   SVG/DRAWING ANIMATIONS
   ======================================== */

/* SVG Line Draw */
@keyframes drawLine {
  from { stroke-dashoffset: 1000; }
  to { stroke-dashoffset: 0; }
}

.animate-draw {
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  animation: drawLine 2s var(--ease-out) forwards;
}

/* Circle Fill */
@keyframes circleFill {
  from { stroke-dashoffset: 314; }
  to { stroke-dashoffset: 0; }
}

.animate-circle-fill {
  stroke-dasharray: 314;
  stroke-dashoffset: 314;
  animation: circleFill 1.5s var(--ease-out) forwards;
}

/* Checkmark */
@keyframes checkmark {
  0% { stroke-dashoffset: 50; }
  100% { stroke-dashoffset: 0; }
}

.animate-checkmark {
  stroke-dasharray: 50;
  stroke-dashoffset: 50;
  animation: checkmark 0.5s var(--ease-out) forwards 0.2s;
}

/* ========================================
   SUCCESS/ERROR ANIMATIONS
   ======================================== */


/* Error Shake */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-6px); }
  20%, 40%, 60%, 80% { transform: translateX(6px); }
}

.animate-shake {
  animation: shake 0.5s ease-in-out;
}

/* ========================================
   PARTICLE ANIMATIONS
   ======================================== */

/* Particle Drift */
@keyframes particleDrift {
  0%, 100% {
    transform: translate(0, 0);
  }
  25% {
    transform: translate(10px, -20px);
  }
  50% {
    transform: translate(-5px, -40px);
  }
  75% {
    transform: translate(15px, -20px);
  }
}

/* Particle Rise */
@keyframes particleRise {
  0% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateY(-100px) scale(0);
    opacity: 0;
  }
}

/* Particle Burst */
@keyframes particleBurst {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(var(--tx, 50px), var(--ty, -50px)) scale(0);
    opacity: 0;
  }
}

/* ========================================
   SCROLL-TRIGGERED ANIMATION STATES
   ======================================== */

/* Initial states for scroll animations */
[data-animate] {
  opacity: 0;
  transition: opacity var(--duration-700) var(--ease-out),
              transform var(--duration-700) var(--ease-out),
              filter var(--duration-700) var(--ease-out);
}

[data-animate="fade-up"] {
  transform: translateY(30px);
}

[data-animate="fade-down"] {
  transform: translateY(-30px);
}

[data-animate="fade-left"] {
  transform: translateX(30px);
}

[data-animate="fade-right"] {
  transform: translateX(-30px);
}

[data-animate="scale"] {
  transform: scale(0.95);
}

[data-animate="blur"] {
  filter: blur(8px);
}

[data-animate="chars"],
[data-animate="words"] {
  transform: translateY(20px);
}

[data-animate="flip-x"] {
  transform: perspective(400px) rotateX(-30deg);
}

[data-animate="flip-y"] {
  transform: perspective(400px) rotateY(-30deg);
}

/* Fallback: auto-show content after 1.5s if JS hasn't triggered */
@keyframes autoReveal {
  to {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

[data-animate] {
  animation: autoReveal 0.8s ease forwards;
  animation-delay: 0.3s;
}

/* Stagger delays */
[data-delay="1"] { animation-delay: 0.4s; }
[data-delay="2"] { animation-delay: 0.5s; }
[data-delay="3"] { animation-delay: 0.6s; }
[data-delay="4"] { animation-delay: 0.7s; }
[data-delay="5"] { animation-delay: 0.8s; }
[data-delay="6"] { animation-delay: 0.9s; }
[data-delay="7"] { animation-delay: 1.0s; }
[data-delay="8"] { animation-delay: 1.1s; }

/* Visible state should override animation */
[data-animate].is-visible {
  animation: none;
  opacity: 1;
  transform: none;
  filter: none;
}


/* ========================================
   GSAP HELPER CLASSES
   ======================================== */

.split-text {
  overflow: hidden;
}

.split-text .line {
  overflow: hidden;
}

.split-text .word,
.split-text .char {
  display: inline-block;
}

/* Magnetic button container */
.magnetic {
  position: relative;
  transition: transform var(--duration-300) var(--ease-out);
}

/* Parallax helpers */
.parallax-layer {
  will-change: transform;
}

/* ========================================
   TRANSITION UTILITIES
   ======================================== */

.transition-none { transition: none !important; }
.transition-all { transition: all var(--transition-normal); }
.transition-fast { transition: all var(--transition-fast); }
.transition-slow { transition: all var(--transition-slow); }
.transition-smooth { transition: all var(--transition-smooth); }
.transition-spring { transition: all var(--transition-spring); }

/* ========================================
   WILL-CHANGE OPTIMIZATIONS
   ======================================== */

.will-change-transform { will-change: transform; }
.will-change-opacity { will-change: opacity; }
.will-change-auto { will-change: auto; }

/* ========================================
   GPU ACCELERATION
   ======================================== */

.gpu-accelerated {
  transform: translateZ(0);
  backface-visibility: hidden;
}

/* ========================================
   ANIMATION PLAY STATE
   ======================================== */

.animation-paused { animation-play-state: paused !important; }
.animation-running { animation-play-state: running !important; }

/* Pause animations when not visible */
.not-in-view * {
  animation-play-state: paused !important;
}

/* ========================================
   REDUCED MOTION
   ======================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  [data-animate] {
    opacity: 1;
    transform: none;
    filter: none;
    transition: none;
  }

  .animate-float,
  .animate-float-gentle,
  .animate-float-rotate,
  .animate-pulse,
  .animate-pulse-glow,
  .animate-shimmer,
  .animate-rotate,
  .animate-rotate-slow,
  .animate-bounce,
  .animate-gradient,
  .animate-gradient-wave,
  .animate-aurora {
    animation: none !important;
  }
}
