/* ==========================================================================
   3TECH RACING EVOLUTION — Animations
   Keyframe definitions, utility classes, and scroll-triggered effects
   ========================================================================== */

/* ==========================================================================
   1. KEYFRAME ANIMATIONS
   ========================================================================== */

/* ── Fade In Up ── */
@keyframes fadeInUp {
  0% {
    opacity: 0;
    transform: translateY(30px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Fade In Down ── */
@keyframes fadeInDown {
  0% {
    opacity: 0;
    transform: translateY(-30px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Fade In Left ── */
@keyframes fadeInLeft {
  0% {
    opacity: 0;
    transform: translateX(-40px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ── Fade In Right ── */
@keyframes fadeInRight {
  0% {
    opacity: 0;
    transform: translateX(40px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ── Fade In (simple) ── */
@keyframes fadeIn {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

/* ── Scale In ── */
@keyframes scaleIn {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* ── Scale In Bounce ── */
@keyframes scaleInBounce {
  0% {
    opacity: 0;
    transform: scale(0.5);
  }
  60% {
    opacity: 1;
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

/* ── Slide Down (for menus/dropdowns) ── */
@keyframes slideDown {
  0% {
    opacity: 0;
    max-height: 0;
    overflow: hidden;
  }
  100% {
    opacity: 1;
    max-height: 500px;
    overflow: visible;
  }
}

/* ── Slide Up ── */
@keyframes slideUp {
  0% {
    opacity: 1;
    max-height: 500px;
  }
  100% {
    opacity: 0;
    max-height: 0;
    overflow: hidden;
  }
}

/* ── Slide In Right (mobile menu) ── */
@keyframes slideInRight {
  0% {
    transform: translateX(100%);
  }
  100% {
    transform: translateX(0);
  }
}

/* ── Slide In Left ── */
@keyframes slideInLeft {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(0);
  }
}

/* ── Pulse (WhatsApp button) ── */
@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 4px 20px rgba(37, 211, 102, 0.4);
  }
  50% {
    transform: scale(1.08);
    box-shadow: 0 6px 30px rgba(37, 211, 102, 0.6);
  }
}

/* ── Pulse Ring ── */
@keyframes pulseRing {
  0% {
    transform: scale(1);
    opacity: 0.8;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

/* ── Glow (CTA buttons) ── */
@keyframes glow {
  0%, 100% {
    box-shadow: 0 0 5px rgba(233, 69, 96, 0.3),
                0 0 10px rgba(233, 69, 96, 0.2),
                0 0 20px rgba(233, 69, 96, 0.1);
  }
  50% {
    box-shadow: 0 0 10px rgba(233, 69, 96, 0.5),
                0 0 20px rgba(233, 69, 96, 0.3),
                0 0 40px rgba(233, 69, 96, 0.2);
  }
}

/* ── Glow Accent ── */
@keyframes glowAccent {
  0%, 100% {
    box-shadow: 0 0 5px rgba(255, 107, 53, 0.3),
                0 0 10px rgba(255, 107, 53, 0.2);
  }
  50% {
    box-shadow: 0 0 15px rgba(255, 107, 53, 0.5),
                0 0 30px rgba(255, 107, 53, 0.3);
  }
}

/* ── Float (hero elements, subtle bob) ── */
@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

/* ── Float Slow ── */
@keyframes floatSlow {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  33% {
    transform: translateY(-8px) rotate(1deg);
  }
  66% {
    transform: translateY(-4px) rotate(-1deg);
  }
}

/* ── Reveal Text (clip-path) ── */
@keyframes revealText {
  0% {
    clip-path: inset(0 100% 0 0);
  }
  100% {
    clip-path: inset(0 0 0 0);
  }
}

/* ── Reveal From Left ── */
@keyframes revealFromLeft {
  0% {
    clip-path: inset(0 100% 0 0);
    opacity: 0;
  }
  100% {
    clip-path: inset(0 0 0 0);
    opacity: 1;
  }
}

/* ── Reveal From Bottom ── */
@keyframes revealFromBottom {
  0% {
    clip-path: inset(100% 0 0 0);
    opacity: 0;
  }
  100% {
    clip-path: inset(0 0 0 0);
    opacity: 1;
  }
}

/* ── Shimmer (loading skeleton) ── */
@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* ── Spin (loading spinner) ── */
@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* ── Shake (error feedback) ── */
@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateX(-5px);
  }
  20%, 40%, 60%, 80% {
    transform: translateX(5px);
  }
}

/* ── Count Up (stat counter placeholder animation) ── */
@keyframes countUp {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Sound Wave (audio bars) ── */
@keyframes soundWave {
  0%, 100% {
    height: 4px;
  }
  25% {
    height: 20px;
  }
  50% {
    height: 10px;
  }
  75% {
    height: 28px;
  }
}

@keyframes soundWaveAlt {
  0%, 100% {
    height: 8px;
  }
  30% {
    height: 24px;
  }
  60% {
    height: 6px;
  }
  85% {
    height: 18px;
  }
}

@keyframes soundWaveSlow {
  0%, 100% {
    height: 6px;
  }
  40% {
    height: 16px;
  }
  70% {
    height: 12px;
  }
}

/* ── Exhaust Smoke (particle drift) ── */
@keyframes exhaustSmoke {
  0% {
    opacity: 0.6;
    transform: translate(0, 0) scale(1);
  }
  50% {
    opacity: 0.3;
    transform: translate(15px, -20px) scale(1.5);
  }
  100% {
    opacity: 0;
    transform: translate(30px, -40px) scale(2);
  }
}

/* ── Gradient Shift ── */
@keyframes gradientShift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

/* ── Border Rotate ── */
@keyframes borderRotate {
  0% {
    --angle: 0deg;
  }
  100% {
    --angle: 360deg;
  }
}

/* ── Bounce ── */
@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-15px);
  }
  60% {
    transform: translateY(-8px);
  }
}

/* ── Typewriter Blink ── */
@keyframes blink {
  0%, 100% {
    border-right-color: transparent;
  }
  50% {
    border-right-color: var(--color-primary);
  }
}

/* ── Ripple ── */
@keyframes ripple {
  0% {
    transform: scale(0);
    opacity: 0.5;
  }
  100% {
    transform: scale(4);
    opacity: 0;
  }
}

/* ── Morph Blob ── */
@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% 60%;
  }
  75% {
    border-radius: 60% 40% 60% 30% / 70% 40% 50% 60%;
  }
}

/* ── Rotate Slow ── */
@keyframes rotateSlow {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}


/* ==========================================================================
   2. SCROLL-TRIGGERED ANIMATION CLASSES
   ========================================================================== */

/* Base: elements start hidden and are revealed by JS (IntersectionObserver) */
.animate-on-scroll {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.animate-on-scroll.animated {
  opacity: 1;
  transform: translateY(0);
}

/* Direction variants */
.animate-on-scroll[data-animation="fadeInLeft"] {
  transform: translateX(-40px);
}
.animate-on-scroll[data-animation="fadeInLeft"].animated {
  transform: translateX(0);
}

.animate-on-scroll[data-animation="fadeInRight"] {
  transform: translateX(40px);
}
.animate-on-scroll[data-animation="fadeInRight"].animated {
  transform: translateX(0);
}

.animate-on-scroll[data-animation="fadeInDown"] {
  transform: translateY(-30px);
}
.animate-on-scroll[data-animation="fadeInDown"].animated {
  transform: translateY(0);
}

.animate-on-scroll[data-animation="scaleIn"] {
  transform: scale(0.8);
}
.animate-on-scroll[data-animation="scaleIn"].animated {
  transform: scale(1);
}

.animate-on-scroll[data-animation="revealFromLeft"] {
  clip-path: inset(0 100% 0 0);
  transform: none;
  opacity: 1;
}
.animate-on-scroll[data-animation="revealFromLeft"].animated {
  clip-path: inset(0 0 0 0);
}

.animate-on-scroll[data-animation="revealFromBottom"] {
  clip-path: inset(100% 0 0 0);
  transform: none;
  opacity: 1;
}
.animate-on-scroll[data-animation="revealFromBottom"].animated {
  clip-path: inset(0 0 0 0);
}


/* ==========================================================================
   3. ANIMATION DELAY CLASSES
   ========================================================================== */

.delay-100 { transition-delay: 100ms; }
.delay-200 { transition-delay: 200ms; }
.delay-300 { transition-delay: 300ms; }
.delay-400 { transition-delay: 400ms; }
.delay-500 { transition-delay: 500ms; }
.delay-600 { transition-delay: 600ms; }
.delay-700 { transition-delay: 700ms; }
.delay-800 { transition-delay: 800ms; }
.delay-900 { transition-delay: 900ms; }
.delay-1000 { transition-delay: 1000ms; }


/* ==========================================================================
   4. ANIMATION DURATION CLASSES
   ========================================================================== */

.duration-fast {
  transition-duration: 0.2s;
  animation-duration: 0.2s;
}

.duration-normal {
  transition-duration: 0.4s;
  animation-duration: 0.4s;
}

.duration-slow {
  transition-duration: 0.8s;
  animation-duration: 0.8s;
}

.duration-slower {
  transition-duration: 1.2s;
  animation-duration: 1.2s;
}


/* ==========================================================================
   5. HOVER UTILITY CLASSES
   ========================================================================== */

/* Lift on hover (translateY) */
.hover-lift {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.hover-lift:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
}

/* Glow on hover */
.hover-glow {
  transition: box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.hover-glow:hover {
  box-shadow: 0 0 20px rgba(233, 69, 96, 0.4),
              0 0 40px rgba(233, 69, 96, 0.2);
}

/* Scale on hover */
.hover-scale {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.hover-scale:hover {
  transform: scale(1.05);
}

/* Rotate on hover */
.hover-rotate {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.hover-rotate:hover {
  transform: rotate(5deg);
}

/* Border glow on hover */
.hover-border-glow {
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.hover-border-glow:hover {
  border-color: rgba(233, 69, 96, 0.5);
  box-shadow: inset 0 0 20px rgba(233, 69, 96, 0.05),
              0 0 15px rgba(233, 69, 96, 0.15);
}

/* Gradient border on hover */
.hover-gradient-border {
  position: relative;
  transition: all 0.3s ease;
}

.hover-gradient-border::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: var(--gradient-primary);
  border-radius: inherit;
  z-index: -1;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.hover-gradient-border:hover::before {
  opacity: 1;
}

/* Underline expand on hover */
.hover-underline {
  position: relative;
}

.hover-underline::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--gradient-primary);
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.hover-underline:hover::after {
  width: 100%;
}


/* ==========================================================================
   6. PAGE TRANSITION
   ========================================================================== */

.page-transition {
  animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.page-transition-exit {
  animation: fadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) reverse both;
}


/* ==========================================================================
   7. SOUND WAVE BARS (for Sound Player)
   ========================================================================== */

.sound-wave {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 32px;
}

.sound-wave__bar {
  width: 3px;
  height: 4px;
  background: var(--gradient-primary);
  border-radius: 2px;
  transition: height 0.1s ease;
}

.sound-wave.playing .sound-wave__bar:nth-child(1) {
  animation: soundWave 0.8s ease-in-out infinite;
}
.sound-wave.playing .sound-wave__bar:nth-child(2) {
  animation: soundWaveAlt 0.7s ease-in-out infinite 0.1s;
}
.sound-wave.playing .sound-wave__bar:nth-child(3) {
  animation: soundWaveSlow 0.9s ease-in-out infinite 0.05s;
}
.sound-wave.playing .sound-wave__bar:nth-child(4) {
  animation: soundWave 0.65s ease-in-out infinite 0.15s;
}
.sound-wave.playing .sound-wave__bar:nth-child(5) {
  animation: soundWaveAlt 0.85s ease-in-out infinite 0.2s;
}
.sound-wave.playing .sound-wave__bar:nth-child(6) {
  animation: soundWaveSlow 0.75s ease-in-out infinite;
}
.sound-wave.playing .sound-wave__bar:nth-child(7) {
  animation: soundWave 0.7s ease-in-out infinite 0.1s;
}
.sound-wave.playing .sound-wave__bar:nth-child(8) {
  animation: soundWaveAlt 0.8s ease-in-out infinite 0.25s;
}


/* ==========================================================================
   8. EXHAUST SMOKE PARTICLES (CSS-only decorative)
   ========================================================================== */

.smoke-container {
  position: absolute;
  bottom: 0;
  right: 10%;
  width: 60px;
  height: 80px;
  pointer-events: none;
  z-index: 1;
}

.smoke-particle {
  position: absolute;
  bottom: 0;
  width: 10px;
  height: 10px;
  background: radial-gradient(circle, rgba(176, 176, 192, 0.3), transparent);
  border-radius: 50%;
  animation: exhaustSmoke 3s ease-out infinite;
}

.smoke-particle:nth-child(1) {
  left: 0;
  animation-delay: 0s;
}

.smoke-particle:nth-child(2) {
  left: 15px;
  animation-delay: 0.8s;
  width: 14px;
  height: 14px;
}

.smoke-particle:nth-child(3) {
  left: 30px;
  animation-delay: 1.5s;
  width: 8px;
  height: 8px;
}

.smoke-particle:nth-child(4) {
  left: 10px;
  animation-delay: 2.2s;
  width: 12px;
  height: 12px;
}


/* ==========================================================================
   9. LOADING SPINNER
   ========================================================================== */

.spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner--sm {
  width: 18px;
  height: 18px;
  border-width: 2px;
}

.spinner--lg {
  width: 48px;
  height: 48px;
  border-width: 4px;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 46, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  transition: opacity 0.3s ease;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}


/* ==========================================================================
   10. GRADIENT ANIMATION BACKGROUNDS
   ========================================================================== */

.animated-gradient {
  background: linear-gradient(-45deg, #E94560, #FF6B35, #53354A, #0F3460);
  background-size: 400% 400%;
  animation: gradientShift 8s ease infinite;
}

.animated-gradient-text {
  background: linear-gradient(-45deg, #E94560, #FF6B35, #E94560);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradientShift 4s linear infinite;
}


/* ==========================================================================
   11. STAGGER CHILDREN
   ========================================================================== */

/* Apply to parent: children get staggered entrance */
.stagger-children > * {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.stagger-children.animated > *:nth-child(1)  { transition-delay: 0.0s; }
.stagger-children.animated > *:nth-child(2)  { transition-delay: 0.1s; }
.stagger-children.animated > *:nth-child(3)  { transition-delay: 0.2s; }
.stagger-children.animated > *:nth-child(4)  { transition-delay: 0.3s; }
.stagger-children.animated > *:nth-child(5)  { transition-delay: 0.4s; }
.stagger-children.animated > *:nth-child(6)  { transition-delay: 0.5s; }
.stagger-children.animated > *:nth-child(7)  { transition-delay: 0.6s; }
.stagger-children.animated > *:nth-child(8)  { transition-delay: 0.7s; }
.stagger-children.animated > *:nth-child(9)  { transition-delay: 0.8s; }
.stagger-children.animated > *:nth-child(10) { transition-delay: 0.9s; }

.stagger-children.animated > * {
  opacity: 1;
  transform: translateY(0);
}


/* ==========================================================================
   12. MORPHING BLOB (decorative)
   ========================================================================== */

.morph-blob {
  width: 300px;
  height: 300px;
  background: var(--gradient-primary);
  border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
  animation: morphBlob 8s ease-in-out infinite;
  opacity: 0.1;
  filter: blur(40px);
  position: absolute;
  pointer-events: none;
}


/* ==========================================================================
   13. PREFERS REDUCED MOTION
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .animate-on-scroll {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .animate-on-scroll[data-animation] {
    transform: none;
    clip-path: none;
    opacity: 1;
  }

  .sound-wave__bar,
  .smoke-particle,
  .morph-blob,
  .animated-gradient,
  .animated-gradient-text {
    animation: none !important;
  }

  .hover-lift:hover,
  .hover-scale:hover,
  .hover-rotate:hover {
    transform: none;
  }

  .stagger-children > * {
    opacity: 1;
    transform: none;
    transition: none;
  }
}
