/**
 * BYD Shares and Stocks - Animation Styles
 * 
 * Keyframes, scroll animations, and interactive effects.
 * Respects prefers-reduced-motion.
 */

/* ============================================
   1. KEYFRAMES
   ============================================ */

/* Fade In */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Fade In Up */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fade In Down */
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fade In Left */
@keyframes fadeInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Fade In Right */
@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Scale In */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Scale In Bounce */
@keyframes scaleInBounce {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Float */
@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

/* Pulse */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Pulse Scale */
@keyframes pulseScale {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

/* Spin */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Orbit rings (hero) */
@keyframes orbitRotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes orbitPulse {
  0%, 100% {
    opacity: 0.35;
  }
  50% {
    opacity: 0.75;
  }
}

/* Shimmer (for skeleton loading) */
@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Wave animation for hero background */
@keyframes wave {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-50%);
  }
}

/* Gradient shift */
@keyframes gradientShift {
  0%, 100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

/* Glow pulse */
@keyframes glowPulse {
  0%, 100% {
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.3);
  }
  50% {
    box-shadow: 0 0 40px rgba(212, 175, 55, 0.5);
  }
}

/* ============================================
   2. SCROLL ANIMATIONS BASE CLASSES
   ============================================ */

/* Base state - hidden until animated */
.animate-on-scroll {
  opacity: 0;
  transform: translateY(30px);
  transition: 
    opacity var(--duration-slow) var(--ease-out),
    transform var(--duration-slow) var(--ease-out);
}

/* Animated state - visible */
.animate-on-scroll.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Animation variants */
.animate-fade-up {
  opacity: 0;
  transform: translateY(40px);
}

.animate-fade-up.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.animate-fade-down {
  opacity: 0;
  transform: translateY(-40px);
}

.animate-fade-down.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.animate-fade-left {
  opacity: 0;
  transform: translateX(-40px);
}

.animate-fade-left.is-visible {
  opacity: 1;
  transform: translateX(0);
}

.animate-fade-right {
  opacity: 0;
  transform: translateX(40px);
}

.animate-fade-right.is-visible {
  opacity: 1;
  transform: translateX(0);
}

.animate-scale {
  opacity: 0;
  transform: scale(0.9);
}

.animate-scale.is-visible {
  opacity: 1;
  transform: scale(1);
}

.animate-fade {
  opacity: 0;
}

.animate-fade.is-visible {
  opacity: 1;
}

/* ============================================
   3. STAGGER ANIMATION DELAYS
   ============================================ */
.stagger-1 { transition-delay: 100ms; }
.stagger-2 { transition-delay: 200ms; }
.stagger-3 { transition-delay: 300ms; }
.stagger-4 { transition-delay: 400ms; }
.stagger-5 { transition-delay: 500ms; }
.stagger-6 { transition-delay: 600ms; }

/* Auto stagger for grid children */
.stagger-children > *:nth-child(1) { transition-delay: 0ms; }
.stagger-children > *:nth-child(2) { transition-delay: 100ms; }
.stagger-children > *:nth-child(3) { transition-delay: 200ms; }
.stagger-children > *:nth-child(4) { transition-delay: 300ms; }
.stagger-children > *:nth-child(5) { transition-delay: 400ms; }
.stagger-children > *:nth-child(6) { transition-delay: 500ms; }
.stagger-children > *:nth-child(7) { transition-delay: 600ms; }
.stagger-children > *:nth-child(8) { transition-delay: 700ms; }

/* ============================================
   4. HOVER EFFECTS
   ============================================ */

/* Lift on hover */
.hover-lift {
  transition: transform var(--duration-normal) var(--ease-out),
              box-shadow var(--duration-normal) var(--ease-out);
}

.hover-lift:hover {
  transform: translateY(-4px);
}

/* Scale on hover */
.hover-scale {
  transition: transform var(--duration-normal) var(--ease-out);
}

.hover-scale:hover {
  transform: scale(1.05);
}

/* Glow on hover */
.hover-glow {
  transition: box-shadow var(--duration-normal) var(--ease-out);
}

.hover-glow:hover {
  box-shadow: var(--shadow-gold);
}

/* Rotate icon on hover */
.hover-rotate-icon:hover svg {
  transform: rotate(15deg);
}

/* ============================================
   5. INTERACTIVE ELEMENT ANIMATIONS
   ============================================ */

/* Button ripple effect */
.btn-ripple {
  position: relative;
  overflow: hidden;
}

.btn-ripple::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 70%);
  transform: scale(0);
  opacity: 0;
  transition: transform 0.5s, opacity 0.3s;
}

.btn-ripple:active::after {
  transform: scale(2);
  opacity: 1;
  transition: 0s;
}

/* Input focus animation */
.input-animate:focus {
  animation: pulseScale 0.3s ease;
}

/* ============================================
   6. HERO BACKGROUND ANIMATIONS
   ============================================ */

/* Wave container */
.hero-waves {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 300px;
  overflow: hidden;
  pointer-events: none;
}

.wave {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 200%;
  height: 100%;
  background-repeat: repeat-x;
  animation: wave 25s linear infinite;
}

.wave:nth-child(1) {
  opacity: 0.5;
  animation-duration: 20s;
}

.wave:nth-child(2) {
  opacity: 0.3;
  animation-duration: 30s;
  animation-direction: reverse;
}

.wave:nth-child(3) {
  opacity: 0.2;
  animation-duration: 40s;
}

/* Floating elements */
.float {
  animation: float 6s ease-in-out infinite;
}

.float-slow {
  animation: float 8s ease-in-out infinite;
}

.float-fast {
  animation: float 4s ease-in-out infinite;
}

/* Particle container */
.particles {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background-color: var(--color-primary);
  border-radius: var(--radius-full);
  opacity: 0.3;
  animation: float 10s ease-in-out infinite;
}

/* ============================================
   7. COUNTER ANIMATION
   ============================================ */
.counter {
  display: inline-block;
}

.counter.is-counting {
  animation: pulseScale 0.5s ease;
}

/* ============================================
   8. ACCORDION ANIMATIONS
   ============================================ */
.accordion-content {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--duration-normal) var(--ease-out);
}

.accordion-item.is-open .accordion-content {
  grid-template-rows: 1fr;
}

.accordion-body {
  overflow: hidden;
}

.accordion-icon {
  transition: transform var(--duration-normal) var(--ease-out);
}

.accordion-item.is-open .accordion-icon {
  transform: rotate(180deg);
}

/* ============================================
   9. PAGE TRANSITIONS
   ============================================ */
.page-enter {
  animation: fadeInUp var(--duration-slow) var(--ease-out);
}

.page-content {
  animation: fadeIn var(--duration-normal) var(--ease-out);
}

/* ============================================
   10. LOADING ANIMATIONS
   ============================================ */

/* Page loading overlay */
.page-loader {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--color-bg-primary);
  z-index: 9999;
  transition: opacity var(--duration-slow) var(--ease-out);
}

.page-loader.is-hidden {
  opacity: 0;
  pointer-events: none;
}

/* Logo animation for loader */
.loader-logo {
  animation: pulseScale 1.5s ease-in-out infinite;
}

/* ============================================
   11. GOLD SHINE EFFECT
   ============================================ */
.gold-shine {
  position: relative;
  overflow: hidden;
}

.gold-shine::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(212, 175, 55, 0.3) 50%,
    transparent 100%
  );
  animation: shine 3s infinite;
}

@keyframes shine {
  0% {
    left: -100%;
  }
  50%, 100% {
    left: 100%;
  }
}

/* ============================================
   12. REDUCED MOTION
   ============================================ */
@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;
  }
  
  .animate-on-scroll,
  .animate-fade-up,
  .animate-fade-down,
  .animate-fade-left,
  .animate-fade-right,
  .animate-scale,
  .animate-fade {
    opacity: 1;
    transform: none;
  }
  
  .hero-waves,
  .particles,
  .float,
  .float-slow,
  .float-fast {
    animation: none;
  }
}

