/* Advanced Animations for Modern Rust Affiliate Site */

/* Smooth scroll behavior */
html {
  scroll-behavior: smooth;
}

/* Page load animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Gradient text animation */
@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.gradient-text-animated {
  background: linear-gradient(-45deg, #00d4ff, #7c3aed, #ff6b35, #00d4ff);
  background-size: 400% 400%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradientShift 3s ease infinite;
}

/* Glowing effects */
@keyframes glow {
  0% { box-shadow: 0 0 5px rgba(0, 212, 255, 0.5); }
  50% { box-shadow: 0 0 20px rgba(0, 212, 255, 0.8), 0 0 30px rgba(0, 212, 255, 0.6); }
  100% { box-shadow: 0 0 5px rgba(0, 212, 255, 0.5); }
}

.glow-animation {
  animation: glow 2s ease-in-out infinite alternate;
}

/* Pulse animation */
@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.pulse-animation {
  animation: pulse 2s ease-in-out infinite;
}

/* Floating animation */
@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-20px); }
}

.float-animation {
  animation: float 3s ease-in-out infinite;
}

/* Rotate animation */
@keyframes rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.rotate-animation {
  animation: rotate 10s linear infinite;
}

/* Card hover animations */
.card-hover-lift {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-hover-lift:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 212, 255, 0.3);
}

/* Button animations */
.btn-animate {
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.btn-animate::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

.btn-animate:hover::before {
  left: 100%;
}

.btn-animate:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3), 0 0 30px rgba(0, 212, 255, 0.5);
}

/* Loading spinner */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(0, 212, 255, 0.3);
  border-top: 2px solid #00d4ff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Text typing animation */
@keyframes typing {
  from { width: 0; }
  to { width: 100%; }
}

@keyframes blink {
  0%, 50% { border-color: transparent; }
  51%, 100% { border-color: #00d4ff; }
}

.typing-text {
  overflow: hidden;
  border-right: 2px solid #00d4ff;
  white-space: nowrap;
  animation: typing 3s steps(40, end), blink 0.75s step-end infinite;
}

/* Parallax scroll effects */
.parallax-element {
  transform: translateZ(0);
  transition: transform 0.1s ease-out;
}

/* Reveal animations */
.reveal-element {
  opacity: 0;
  transform: translateY(50px);
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal-element.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger animations */
.stagger-item {
  opacity: 0;
  transform: translateY(30px);
  animation: fadeInUp 0.6s ease forwards;
}

.stagger-item:nth-child(1) { animation-delay: 0.1s; }
.stagger-item:nth-child(2) { animation-delay: 0.2s; }
.stagger-item:nth-child(3) { animation-delay: 0.3s; }
.stagger-item:nth-child(4) { animation-delay: 0.4s; }
.stagger-item:nth-child(5) { animation-delay: 0.5s; }

/* Morphing shapes */
@keyframes morph {
  0%, 100% { border-radius: 40% 60% 70% 30% / 40% 40% 60% 50%; }
  34% { border-radius: 70% 30% 50% 50% / 30% 30% 70% 70%; }
  67% { border-radius: 100% 60% 60% 100% / 100% 100% 60% 60%; }
}

.morphing-shape {
  animation: morph 8s ease-in-out infinite;
}

/* Particle effects */
@keyframes particle {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(-100vh) rotate(360deg);
    opacity: 0;
  }
}

.particle {
  position: absolute;
  pointer-events: none;
  animation: particle 3s linear infinite;
}

/* Number counter animation */
@keyframes countUp {
  from { opacity: 0; }
  to { opacity: 1; }
}

.counter-number {
  animation: countUp 0.5s ease-out;
}

/* Progress bar animation */
@keyframes progressBar {
  from { width: 0%; }
  to { width: var(--progress-width); }
}

.progress-bar {
  animation: progressBar 2s ease-out forwards;
}

/* Sliding text reveal */
@keyframes slideReveal {
  0% {
    transform: translateX(-100%);
    opacity: 0;
  }
  100% {
    transform: translateX(0);
    opacity: 1;
  }
}

.slide-reveal {
  animation: slideReveal 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Background gradient animation */
@keyframes gradientBackground {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.animated-gradient-bg {
  background: linear-gradient(-45deg, #0a0a0f, #111118, #1a1a24, #15151f);
  background-size: 400% 400%;
  animation: gradientBackground 15s ease infinite;
}

/* Ripple effect */
@keyframes ripple {
  0% {
    transform: scale(0);
    opacity: 1;
  }
  100% {
    transform: scale(4);
    opacity: 0;
  }
}

.ripple-effect {
  position: relative;
  overflow: hidden;
}

.ripple-effect::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(0, 212, 255, 0.5);
  transform: translate(-50%, -50%);
  animation: ripple 0.6s ease-out;
}

/* Shake animation */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-2px); }
  20%, 40%, 60%, 80% { transform: translateX(2px); }
}

.shake-animation {
  animation: shake 0.5s ease-in-out;
}

/* Zoom in animation */
@keyframes zoomIn {
  from {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    opacity: 1;
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.zoom-in {
  animation: zoomIn 0.5s ease-out;
}

/* Flip animation */
@keyframes flip {
  0% { transform: perspective(400px) rotateY(0); }
  40% { transform: perspective(400px) translateZ(150px) rotateY(170deg); }
  50% { transform: perspective(400px) translateZ(150px) rotateY(190deg); }
  80% { transform: perspective(400px) rotateY(360deg); }
  100% { transform: perspective(400px) rotateY(360deg); }
}

.flip-animation {
  animation: flip 1s ease-in-out;
}

/* Bounce animation */
@keyframes bounce {
  0%, 20%, 53%, 80%, 100% {
    animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
    transform: translate3d(0, 0, 0);
  }
  40%, 43% {
    animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060);
    transform: translate3d(0, -30px, 0);
  }
  70% {
    animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060);
    transform: translate3d(0, -15px, 0);
  }
  90% {
    transform: translate3d(0, -4px, 0);
  }
}

.bounce-animation {
  animation: bounce 1s ease-in-out;
}

/* Elastic animation */
@keyframes elastic {
  0% {
    transform: scale(0);
  }
  55% {
    transform: scale(1);
  }
  70% {
    transform: scale(0.9);
  }
  80% {
    transform: scale(1.02);
  }
  90% {
    transform: scale(0.98);
  }
  100% {
    transform: scale(1);
  }
}

.elastic-animation {
  animation: elastic 0.6s ease-out;
}

/* Slide animations */
@keyframes slideInLeft {
  from {
    transform: translate3d(-100%, 0, 0);
    visibility: visible;
  }
  to {
    transform: translate3d(0, 0, 0);
  }
}

@keyframes slideInRight {
  from {
    transform: translate3d(100%, 0, 0);
    visibility: visible;
  }
  to {
    transform: translate3d(0, 0, 0);
  }
}

.slide-in-left {
  animation: slideInLeft 0.5s ease-out;
}

.slide-in-right {
  animation: slideInRight 0.5s ease-out;
}

/* Tilt animation */
@keyframes tilt {
  0% { transform: rotate(0deg); }
  25% { transform: rotate(1deg); }
  75% { transform: rotate(-1deg); }
  100% { transform: rotate(0deg); }
}

.tilt-animation {
  animation: tilt 0.5s ease-in-out;
}

/* Neon glow animation */
@keyframes neonGlow {
  0%, 100% {
    text-shadow: 
      0 0 5px #00d4ff,
      0 0 10px #00d4ff,
      0 0 15px #00d4ff,
      0 0 20px #00d4ff;
  }
  50% {
    text-shadow: 
      0 0 2px #00d4ff,
      0 0 5px #00d4ff,
      0 0 8px #00d4ff,
      0 0 12px #00d4ff;
  }
}

.neon-glow {
  animation: neonGlow 2s ease-in-out infinite alternate;
}

/* Loading dots animation */
@keyframes loadingDots {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

.loading-dots {
  display: inline-block;
  position: relative;
  width: 80px;
  height: 80px;
}

.loading-dots div {
  position: absolute;
  top: 33px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #00d4ff;
  animation-timing-function: cubic-bezier(0, 1, 1, 0);
}

.loading-dots div:nth-child(1) {
  left: 8px;
  animation: loadingDots 0.6s infinite;
}

.loading-dots div:nth-child(2) {
  left: 8px;
  animation: loadingDots 0.6s infinite;
  animation-delay: -0.2s;
}

.loading-dots div:nth-child(3) {
  left: 32px;
  animation: loadingDots 0.6s infinite;
  animation-delay: -0.1s;
}

/* Reveal on scroll */
.reveal-on-scroll {
  opacity: 0;
  transform: translateY(50px);
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal-on-scroll.revealed {
  opacity: 1;
  transform: translateY(0);
}

.loading-dots div:nth-child(3) {
  left: 32px;
  animation: loadingDots 0.6s infinite;
  animation-delay: -0.1s;
}

/* Mobile-specific animation classes */
.mobile-optimized .gradient-text-animated,
.mobile-optimized .glow-animation,
.mobile-optimized .pulse-animation,
.mobile-optimized .float-animation,
.mobile-optimized .rotate-animation {
  animation: none !important;
}

.mobile-optimized .card-hover-lift {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.mobile-optimized .card-hover-lift:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Simplified mobile animations */
@keyframes mobileSlideIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes mobileFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.mobile-slide-in {
  animation: mobileSlideIn 0.3s ease-out forwards;
}

.mobile-fade-in {
  animation: mobileFadeIn 0.3s ease-out forwards;
}

/* Reveal on scroll */
.reveal-on-scroll {
  opacity: 0;
  transform: translateY(50px);
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Performance optimizations */
.will-change-transform {
  will-change: transform;
}

.will-change-opacity {
  will-change: opacity;
}

.gpu-accelerated {
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  
  .parallax-element {
    transform: none !important;
  }
  
 /* Mobile Performance Optimizations */
/* Add this section at the end of animations.css */

@media (max-width: 768px) {
  /* Disable resource-intensive animations */
  .gradient-text-animated,
  .glow-animation,
  .pulse-animation,
  .float-animation,
  .rotate-animation,
  .morphing-shape,
  .animated-gradient-bg,
  .neon-glow {
    animation: none !important;
  }
  
  /* Simplify card hover effects */
  .card-hover-lift:hover {
    transform: translateY(-4px) scale(1);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    transition-duration: 0.2s;
  }
  
  /* Reduce button animation complexity */
  .btn-animate::before {
    display: none;
  }
  
  .btn-animate:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  }
  
  /* Disable particle effects */
  .particle,
  .loading-dots,
  .ripple-effect::after {
    display: none !important;
  }
  
  /* Simplify reveal animations */
  .reveal-element,
  .reveal-on-scroll {
    transition-duration: 0.3s;
  }
  
  /* Reduce stagger delays */
  .stagger-item {
    animation-duration: 0.4s;
  }
  
  .stagger-item:nth-child(1) { animation-delay: 0.05s; }
  .stagger-item:nth-child(2) { animation-delay: 0.1s; }
  .stagger-item:nth-child(3) { animation-delay: 0.15s; }
  .stagger-item:nth-child(4) { animation-delay: 0.2s; }
  .stagger-item:nth-child(5) { animation-delay: 0.25s; }
  
  /* Keep only essential loading animations */
  .loading-spinner {
    animation-duration: 0.8s;
  }
  
  /* Disable complex 3D animations */
  .flip-animation,
  .bounce-animation,
  .elastic-animation {
    animation: none !important;
    opacity: 1;
    transform: none;
  }
  
  /* Simplify slide animations */
  .slide-in-left,
  .slide-in-right {
    animation-duration: 0.3s;
  }
  
  /* Remove GPU-intensive effects */
  .gpu-accelerated {
    transform: none;
    backface-visibility: visible;
    perspective: none;
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  /* Remove hover-dependent animations */
  .card-hover-lift:hover,
  .btn-animate:hover {
    transform: none;
    box-shadow: none;
  }
  
  /* Disable hover-triggered effects */
  .glow-animation,
  .pulse-animation {
    animation: none;
  }
  
  /* Keep only tap-friendly interactions */
  .card-hover-lift:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
  }
}

/* Ultra low-end device support */
@media (max-width: 480px) {
  /* Disable all non-essential animations */
  * {
    animation-duration: 0s !important;
    transition-duration: 0.1s !important;
  }
  
  /* Keep only critical animations */
  .loading-spinner,
  .reveal-element.revealed,
  .reveal-on-scroll.revealed {
    animation-duration: 0.3s !important;
    transition-duration: 0.3s !important;
  }
  
  /* Remove all transform effects */
  .parallax-element {
    transform: none !important;
  }
} 

/* Performance monitoring styles */
.performance-warning {
  display: none;
  position: fixed;
  top: 10px;
  right: 10px;
  background: rgba(239, 68, 68, 0.9);
  color: white;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 12px;
  z-index: 10000;
}

/* Show warning on very low-end devices */
@media (max-width: 320px) {
  .performance-warning {
    display: block;
  }
}

/* Fallback for browsers that don't support backdrop-filter */
@supports not (backdrop-filter: blur(20px)) {
  .mobile-optimized .nav-menu {
    background: rgba(10, 10, 15, 0.95);
    backdrop-filter: none;
  }
}
}