/**
 * Animations
 * Keyframes and transition effects
 */

/* ==========================================
   KEYFRAME ANIMATIONS
   ========================================== */

/* Cursor blink */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Bounce for scroll indicator */
@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: rotate(45deg) translateY(0);
  }
  40% {
    transform: rotate(45deg) translateY(-10px);
  }
  60% {
    transform: rotate(45deg) translateY(-5px);
  }
}

/* Spin for loading */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Fade in */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Fade in up */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fade in scale */
@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Pulse glow */
@keyframes pulseGlow {
  0%, 100% {
    box-shadow: 0 0 5px rgba(255, 69, 0, 0.3);
  }
  50% {
    box-shadow: 0 0 20px rgba(255, 69, 0, 0.6);
  }
}

/* Number counting shimmer */
@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* Tower sway (for CSS fallback) */
@keyframes towerSway {
  0%, 100% {
    transform: rotate(0deg);
  }
  25% {
    transform: rotate(0.5deg);
  }
  75% {
    transform: rotate(-0.5deg);
  }
}

/* Slider knob bounce - attention grabber */
@keyframes sliderBounce {
  0%, 100% {
    transform: translateX(-50%) scale(1);
  }
  50% {
    transform: translateX(-50%) scale(1.2);
  }
}

@keyframes sliderBounceHorizontal {
  0%, 100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-4px);
  }
  75% {
    transform: translateX(4px);
  }
}

/* Cable tension pulse */
@keyframes cablePulse {
  0%, 100% {
    stroke-opacity: 0.6;
  }
  50% {
    stroke-opacity: 1;
  }
}

/* ==========================================
   ANIMATION UTILITY CLASSES
   ========================================== */

.animate-fade-in {
  animation: fadeIn var(--transition-base) ease forwards;
}

.animate-fade-in-up {
  animation: fadeInUp var(--transition-slow) ease forwards;
}

.animate-fade-in-scale {
  animation: fadeInScale var(--transition-slow) ease forwards;
}

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

/* Staggered animation delays */
.animate-delay-1 { animation-delay: 100ms; }
.animate-delay-2 { animation-delay: 200ms; }
.animate-delay-3 { animation-delay: 300ms; }
.animate-delay-4 { animation-delay: 400ms; }
.animate-delay-5 { animation-delay: 500ms; }

/* ==========================================
   SCROLL-TRIGGERED ANIMATIONS
   ========================================== */

/* Elements start invisible and animate when in view */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: 
    opacity var(--transition-slow) ease,
    transform var(--transition-slow) ease;
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Reveal from left */
.reveal-left {
  opacity: 0;
  transform: translateX(-30px);
  transition: 
    opacity var(--transition-slow) ease,
    transform var(--transition-slow) ease;
}

.reveal-left.visible {
  opacity: 1;
  transform: translateX(0);
}

/* Reveal from right */
.reveal-right {
  opacity: 0;
  transform: translateX(30px);
  transition: 
    opacity var(--transition-slow) ease,
    transform var(--transition-slow) ease;
}

.reveal-right.visible {
  opacity: 1;
  transform: translateX(0);
}

/* Scale reveal */
.reveal-scale {
  opacity: 0;
  transform: scale(0.9);
  transition: 
    opacity var(--transition-slow) ease,
    transform var(--transition-slow) ease;
}

.reveal-scale.visible {
  opacity: 1;
  transform: scale(1);
}

/* ==========================================
   MICRO-INTERACTIONS
   ========================================== */

/* Button press effect */
.btn-press {
  transition: transform 50ms ease;
}

.btn-press:active {
  transform: scale(0.98);
}

/* Link underline animation */
.link-animated {
  position: relative;
}

.link-animated::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 1px;
  background-color: currentColor;
  transition: width var(--transition-base) ease;
}

.link-animated:hover::after {
  width: 100%;
}

/* Icon hover rotation */
.icon-rotate {
  transition: transform var(--transition-base) ease;
}

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

/* Card lift effect */
.card-lift {
  transition: 
    transform var(--transition-base) ease,
    box-shadow var(--transition-base) ease;
}

.card-lift:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-lg);
}

/* ==========================================
   REDUCED MOTION
   ========================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .reveal,
  .reveal-left,
  .reveal-right,
  .reveal-scale {
    opacity: 1;
    transform: none;
  }
  
  .scroll-arrow {
    animation: none;
  }
  
  .terminal-cursor {
    animation: none;
    opacity: 1;
  }
  
  .logo-accent {
    animation: none;
  }
}

/* ==========================================
   SCHEMATIC MODE (for reduced motion)
   ========================================== */

/* When reduced motion is preferred, show static schematic instead of animated tower */
@media (prefers-reduced-motion: reduce) {
  .tower-canvas {
    display: none;
  }
  
  .tower-schematic {
    display: block !important;
  }
}

.tower-schematic {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tower-schematic svg {
  max-width: 100%;
  max-height: 100%;
}

/* Force vectors in schematic mode */
.force-vector {
  stroke: var(--accent-green);
  stroke-width: 2;
  fill: none;
  marker-end: url(#arrowhead);
}

.force-vector-wind {
  stroke: var(--accent-blue);
}

.force-vector-tension {
  stroke: var(--accent-orange);
}

/* ==========================================
   PHYSICS-BASED EASING CURVES
   ========================================== */

/* These can be used in JS for more natural motion */
:root {
  /* Spring-like bounce */
  --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
  
  /* Heavy/weighted feel */
  --ease-heavy: cubic-bezier(0.7, 0, 0.84, 0);
  
  /* Snap into place */
  --ease-snap: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  
  /* Smooth deceleration */
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  
  /* Gradual acceleration */
  --ease-in-expo: cubic-bezier(0.7, 0, 0.84, 0);
}
