/**
 * ==========================================================================
 * ANIMATIONS CSS
 * Noteworthy News - Premium Animation System
 * ==========================================================================
 *
 * This file provides reusable animation utilities for creating engaging,
 * polished interactions throughout the site.
 *
 * Table of Contents:
 *   1. CSS Custom Properties (Timing & Easing)
 *   2. Base Animation Classes
 *   3. Hero Entrance Animations
 *   4. Scroll-Triggered Reveals
 *   5. Card Micro-interactions
 *   6. Stagger Utilities
 *   7. Accent Glow Effects
 *   8. Reduced Motion Support
 *
 * ==========================================================================
 */

/* ==========================================================================
   1. CSS CUSTOM PROPERTIES
   ========================================================================== */

:root {
  /* Timing */
  --anim-duration-fast: 200ms;
  --anim-duration-normal: 400ms;
  --anim-duration-slow: 600ms;
  --anim-duration-slower: 800ms;
  --anim-duration-slowest: 1000ms;
  
  /* Easing curves */
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-in-out-quart: cubic-bezier(0.76, 0, 0.24, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Accent Colors for animations */
  --accent-cyan: #06B6D4;
  --accent-blue: #3B82F6;
  --accent-gradient: linear-gradient(135deg, var(--accent-cyan) 0%, var(--accent-blue) 100%);
  --glow-cyan: rgba(6, 182, 212, 0.5);
  --glow-blue: rgba(59, 130, 246, 0.5);
}

/* ==========================================================================
   2. BASE ANIMATION CLASSES
   ========================================================================== */

/* Fade In */
.anim-fade-in {
  animation: fadeIn var(--anim-duration-normal) var(--ease-out-expo) forwards;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Fade Up */
.anim-fade-up {
  animation: fadeUp var(--anim-duration-slow) var(--ease-out-expo) forwards;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fade Down */
.anim-fade-down {
  animation: fadeDown var(--anim-duration-slow) var(--ease-out-expo) forwards;
}

@keyframes fadeDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Scale In */
.anim-scale-in {
  animation: scaleIn var(--anim-duration-normal) var(--ease-spring) forwards;
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ==========================================================================
   3. HERO ENTRANCE ANIMATIONS
   ========================================================================== */

/* Hero content reveal with blur-to-focus */
.hero-entrance {
  opacity: 0;
  animation: heroReveal var(--anim-duration-slowest) var(--ease-out-expo) forwards;
}

@keyframes heroReveal {
  from {
    opacity: 0;
    filter: blur(10px);
    transform: translateY(40px) scale(0.98);
  }
  to {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0) scale(1);
  }
}

/* Logo entrance with glow pulse */
.hero-logo-entrance {
  opacity: 0;
  animation: logoReveal 1.2s var(--ease-out-expo) forwards;
}

@keyframes logoReveal {
  0% {
    opacity: 0;
    filter: blur(20px);
    transform: scale(0.8);
  }
  50% {
    opacity: 1;
    filter: blur(0);
    transform: scale(1.02);
  }
  100% {
    opacity: 1;
    filter: blur(0);
    transform: scale(1);
  }
}

/* Hero title with typewriter-like reveal */
.hero-title-entrance {
  opacity: 0;
  animation: titleReveal var(--anim-duration-slower) var(--ease-out-expo) 0.3s forwards;
}

@keyframes titleReveal {
  from {
    opacity: 0;
    transform: translateY(20px);
    letter-spacing: 0.1em;
  }
  to {
    opacity: 1;
    transform: translateY(0);
    letter-spacing: -0.02em;
  }
}

/* Breaking News badge pulse */
.breaking-badge {
  position: relative;
  animation: badgePulse 2s ease-in-out infinite;
}

.breaking-badge::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: var(--accent-gradient);
  border-radius: inherit;
  opacity: 0;
  animation: badgeGlow 2s ease-in-out infinite;
  z-index: -1;
}

@keyframes badgePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

@keyframes badgeGlow {
  0%, 100% { opacity: 0; filter: blur(8px); }
  50% { opacity: 0.6; filter: blur(12px); }
}

/* ==========================================================================
   4. SCROLL-TRIGGERED REVEALS
   ========================================================================== */

/* Base state for scroll reveals */
.scroll-reveal {
  opacity: 0;
  transform: translateY(40px);
  transition: 
    opacity var(--anim-duration-slow) var(--ease-out-expo),
    transform var(--anim-duration-slow) var(--ease-out-expo);
}

.scroll-reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* Slide up variant */
.scroll-reveal-up {
  opacity: 0;
  transform: translateY(60px);
  transition: 
    opacity var(--anim-duration-slower) var(--ease-out-expo),
    transform var(--anim-duration-slower) var(--ease-out-expo);
}

.scroll-reveal-up.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* Slide from left */
.scroll-reveal-left {
  opacity: 0;
  transform: translateX(-40px);
  transition: 
    opacity var(--anim-duration-slow) var(--ease-out-expo),
    transform var(--anim-duration-slow) var(--ease-out-expo);
}

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

/* Slide from right */
.scroll-reveal-right {
  opacity: 0;
  transform: translateX(40px);
  transition: 
    opacity var(--anim-duration-slow) var(--ease-out-expo),
    transform var(--anim-duration-slow) var(--ease-out-expo);
}

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

/* Scale reveal */
.scroll-reveal-scale {
  opacity: 0;
  transform: scale(0.9);
  transition: 
    opacity var(--anim-duration-slow) var(--ease-out-expo),
    transform var(--anim-duration-slow) var(--ease-spring);
}

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

/* ==========================================================================
   5. CARD MICRO-INTERACTIONS
   ========================================================================== */

/* Card hover lift effect */
.card-hover {
  transition: 
    transform var(--anim-duration-normal) var(--ease-out-expo),
    box-shadow var(--anim-duration-normal) var(--ease-out-expo);
}

.card-hover:hover {
  transform: translateY(-8px);
  box-shadow: 
    0 20px 40px rgba(0, 0, 0, 0.3),
    0 0 40px rgba(6, 182, 212, 0.1);
}

/* Card with border glow on hover */
.card-glow {
  position: relative;
  transition: 
    transform var(--anim-duration-normal) var(--ease-out-expo),
    box-shadow var(--anim-duration-normal) var(--ease-out-expo);
}

.card-glow::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: var(--accent-gradient);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity var(--anim-duration-normal) var(--ease-out-expo);
  pointer-events: none;
}

.card-glow:hover {
  transform: translateY(-6px);
  box-shadow: 
    0 16px 32px rgba(0, 0, 0, 0.25),
    0 0 30px rgba(6, 182, 212, 0.15);
}

.card-glow:hover::before {
  opacity: 1;
}

/* Image zoom on card hover */
.card-image-zoom {
  overflow: hidden;
}

.card-image-zoom img {
  transition: transform var(--anim-duration-slow) var(--ease-out-expo);
}

.card-image-zoom:hover img {
  transform: scale(1.08);
}

/* Focus states for accessibility */
.card-hover:focus-visible,
.card-glow:focus-visible {
  outline: 2px solid var(--accent-cyan);
  outline-offset: 4px;
}

/* ==========================================================================
   6. STAGGER UTILITIES
   ========================================================================== */

/* Stagger children animation delays */
.stagger-children > * {
  opacity: 0;
  transform: translateY(20px);
  transition: 
    opacity var(--anim-duration-slow) var(--ease-out-expo),
    transform var(--anim-duration-slow) var(--ease-out-expo);
}

.stagger-children.revealed > *:nth-child(1) { transition-delay: 0ms; }
.stagger-children.revealed > *:nth-child(2) { transition-delay: 80ms; }
.stagger-children.revealed > *:nth-child(3) { transition-delay: 160ms; }
.stagger-children.revealed > *:nth-child(4) { transition-delay: 240ms; }
.stagger-children.revealed > *:nth-child(5) { transition-delay: 320ms; }
.stagger-children.revealed > *:nth-child(6) { transition-delay: 400ms; }
.stagger-children.revealed > *:nth-child(7) { transition-delay: 480ms; }
.stagger-children.revealed > *:nth-child(8) { transition-delay: 560ms; }
.stagger-children.revealed > *:nth-child(9) { transition-delay: 640ms; }
.stagger-children.revealed > *:nth-child(10) { transition-delay: 720ms; }

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

/* Faster stagger for grids */
.stagger-fast > * {
  opacity: 0;
  transform: translateY(15px);
  transition: 
    opacity var(--anim-duration-normal) var(--ease-out-expo),
    transform var(--anim-duration-normal) var(--ease-out-expo);
}

.stagger-fast.revealed > *:nth-child(1) { transition-delay: 0ms; }
.stagger-fast.revealed > *:nth-child(2) { transition-delay: 50ms; }
.stagger-fast.revealed > *:nth-child(3) { transition-delay: 100ms; }
.stagger-fast.revealed > *:nth-child(4) { transition-delay: 150ms; }
.stagger-fast.revealed > *:nth-child(5) { transition-delay: 200ms; }
.stagger-fast.revealed > *:nth-child(6) { transition-delay: 250ms; }

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

/* ==========================================================================
   7. ACCENT GLOW EFFECTS
   ========================================================================== */

/* Accent text gradient */
.accent-text {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Glowing border */
.accent-border {
  border: 1px solid transparent;
  background: 
    linear-gradient(var(--color-bg-dark, #07152a), var(--color-bg-dark, #07152a)) padding-box,
    var(--accent-gradient) border-box;
}

/* Glow button */
.accent-glow-btn {
  position: relative;
  background: var(--accent-gradient);
  color: white;
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: 
    transform var(--anim-duration-fast) var(--ease-out-expo),
    box-shadow var(--anim-duration-fast) var(--ease-out-expo);
}

.accent-glow-btn:hover {
  transform: translateY(-2px);
  box-shadow: 
    0 10px 30px var(--glow-cyan),
    0 0 20px var(--glow-blue);
}

.accent-glow-btn:active {
  transform: translateY(0);
}

/* Subtle pulsing glow for important elements */
.glow-pulse {
  animation: glowPulse 3s ease-in-out infinite;
}

@keyframes glowPulse {
  0%, 100% {
    box-shadow: 
      0 0 20px rgba(6, 182, 212, 0.2),
      0 0 40px rgba(6, 182, 212, 0.1);
  }
  50% {
    box-shadow: 
      0 0 30px rgba(6, 182, 212, 0.4),
      0 0 60px rgba(59, 130, 246, 0.2);
  }
}

/* ==========================================================================
   8. 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-reveal,
  .scroll-reveal-up,
  .scroll-reveal-left,
  .scroll-reveal-right,
  .scroll-reveal-scale,
  .stagger-children > *,
  .stagger-fast > * {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
  
  .hero-entrance,
  .hero-logo-entrance,
  .hero-title-entrance {
    opacity: 1 !important;
    filter: none !important;
    transform: none !important;
    animation: none !important;
  }
}

/* ==========================================================================
   9. COUNTER ANIMATION (For stats)
   ========================================================================== */

.counter-animate {
  display: inline-block;
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   10. PARALLAX UTILITIES
   ========================================================================== */

.parallax-slow {
  will-change: transform;
  transition: transform 0.1s linear;
}

.parallax-medium {
  will-change: transform;
  transition: transform 0.05s linear;
}

/* ==========================================================================
   11. SHIMMER LOADING EFFECT
   ========================================================================== */

.shimmer {
  position: relative;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
}

.shimmer::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.08) 50%,
    transparent 100%
  );
  animation: shimmerMove 1.5s ease-in-out infinite;
}

@keyframes shimmerMove {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}
