/* ==========================================================================
   WayUp v2.1 - Animations
   ========================================================================== */

/* ==========================================================================
   SCROLL REVEAL ANIMATIONS
   ========================================================================== */

[data-animate] {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-animate].visible {
  opacity: 1;
  transform: translateY(0);
}

/* Staggered children */
[data-stagger] > * {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-stagger].visible > *:nth-child(1) { transition-delay: 0ms; }
[data-stagger].visible > *:nth-child(2) { transition-delay: 100ms; }
[data-stagger].visible > *:nth-child(3) { transition-delay: 200ms; }
[data-stagger].visible > *:nth-child(4) { transition-delay: 300ms; }
[data-stagger].visible > *:nth-child(5) { transition-delay: 400ms; }
[data-stagger].visible > *:nth-child(6) { transition-delay: 500ms; }

[data-stagger].visible > * {
  opacity: 1;
  transform: translateY(0);
}

/* Fade variations */
[data-animate="fade-up"] {
  transform: translateY(40px);
}

[data-animate="fade-down"] {
  transform: translateY(-40px);
}

[data-animate="fade-left"] {
  transform: translateX(40px);
}

[data-animate="fade-right"] {
  transform: translateX(-40px);
}

[data-animate="fade-scale"] {
  transform: scale(0.95);
}

[data-animate].visible {
  transform: translate(0) scale(1);
}

/* ==========================================================================
   HERO TEXT ANIMATION
   ========================================================================== */

.hero-text-reveal {
  overflow: hidden;
}

.hero-text-reveal span {
  display: inline-block;
  transform: translateY(100%);
  animation: revealUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.hero-text-reveal span:nth-child(2) { animation-delay: 0.1s; }
.hero-text-reveal span:nth-child(3) { animation-delay: 0.2s; }

@keyframes revealUp {
  to { transform: translateY(0); }
}

/* ==========================================================================
   FLOATING ANIMATIONS
   ========================================================================== */

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

.float-delayed {
  animation: floatY 6s ease-in-out infinite;
  animation-delay: -3s;
}

.float-slow {
  animation: floatY 8s ease-in-out infinite;
}

@keyframes floatY {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-15px); }
}

/* Rotate float */
.float-rotate {
  animation: floatRotate 8s ease-in-out infinite;
}

@keyframes floatRotate {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-10px) rotate(5deg); }
}

/* ==========================================================================
   GRADIENT ANIMATIONS
   ========================================================================== */

.animate-gradient {
  background-size: 200% 200%;
  animation: gradientShift 8s ease infinite;
}

@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* Text gradient animation */
.animate-text-gradient {
  background: linear-gradient(
    90deg,
    var(--primary-400),
    var(--accent-cyan),
    var(--primary-400)
  );
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: textGradient 4s linear infinite;
}

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

/* ==========================================================================
   PULSE & GLOW EFFECTS
   ========================================================================== */

.pulse-glow {
  animation: pulseGlow 2s ease-in-out infinite;
}

@keyframes pulseGlow {
  0%, 100% {
    box-shadow: 0 0 20px var(--glow-primary);
  }
  50% {
    box-shadow: 0 0 40px var(--glow-primary), 0 0 60px var(--glow-secondary);
  }
}

/* Ping animation for notifications/badges */
.ping {
  position: relative;
}

.ping::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: inherit;
  animation: ping 1.5s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes ping {
  75%, 100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

/* ==========================================================================
   LOADING ANIMATIONS
   ========================================================================== */

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-default);
  border-top-color: var(--primary-500);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Dots loading */
.loading-dots {
  display: flex;
  gap: 4px;
}

.loading-dots span {
  width: 8px;
  height: 8px;
  background: var(--primary-500);
  border-radius: 50%;
  animation: loadingDot 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes loadingDot {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

/* ==========================================================================
   MORPHING SHAPES
   ========================================================================== */

.morph-blob {
  animation: morphBlob 8s ease-in-out infinite;
}

@keyframes morphBlob {
  0%, 100% {
    border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
  }
  25% {
    border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%;
  }
  50% {
    border-radius: 50% 60% 30% 60% / 30% 50% 70% 50%;
  }
  75% {
    border-radius: 60% 40% 60% 40% / 70% 30% 50% 60%;
  }
}

/* ==========================================================================
   LINE DRAWING
   ========================================================================== */

.draw-line {
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  animation: drawLine 2s ease forwards;
}

@keyframes drawLine {
  to { stroke-dashoffset: 0; }
}

/* ==========================================================================
   COUNTER ANIMATION
   ========================================================================== */

.count-up {
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   PAGE TRANSITIONS
   ========================================================================== */

.page-enter {
  opacity: 0;
  transform: translateY(20px);
}

.page-enter-active {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.4s, transform 0.4s;
}

.page-exit {
  opacity: 1;
}

.page-exit-active {
  opacity: 0;
  transition: opacity 0.2s;
}

/* ==========================================================================
   MOBILE OPTIMIZATIONS
   ========================================================================== */

@media (max-width: 768px) {
  /* Disable animations on mobile to prevent layout issues */
  [data-animate],
  [data-animate="fade-up"],
  [data-animate="fade-down"],
  [data-animate="fade-left"],
  [data-animate="fade-right"],
  [data-animate="fade-scale"],
  [data-stagger] > * {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  [data-animate].visible,
  [data-stagger].visible > * {
    opacity: 1 !important;
    transform: none !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],
  [data-stagger] > * {
    opacity: 1;
    transform: none;
  }
}
