/*
 * StreamNow Animations
 * Version: 2.0.0
 *
 * Animation keyframes, utility classes, delay helpers, and scroll-reveal
 * styles for the StreamNow theme. Loaded after the base style.css so
 * animations can be overridden by Tailwind utilities when available.
 */

/* ==========================================================================
   1. Keyframes
   ========================================================================== */

/* --- Float variations --- */
@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-20px);
    }
}

@keyframes float-delayed {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-15px);
    }
}

@keyframes float-slow {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    33% {
        transform: translateY(-10px) rotate(1deg);
    }
    66% {
        transform: translateY(5px) rotate(-1deg);
    }
}

/* --- Pulse / Glow --- */
@keyframes pulse-glow {
    0%, 100% {
        box-shadow:
            0 0 20px rgba(4, 107, 210, 0.3);
    }
    50% {
        box-shadow:
            0 0 40px rgba(4, 107, 210, 0.6),
            0 0 80px rgba(6, 182, 212, 0.2);
    }
}

@keyframes pulse-dot {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.5);
    }
}

/* --- Shimmer / Gradient --- */
@keyframes shimmer {
    0% {
        background-position: -200% center;
    }
    100% {
        background-position: 200% center;
    }
}

@keyframes gradient-x {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

/* --- Scanline --- */
@keyframes scanline {
    0% {
        transform: translateY(-100%);
    }
    100% {
        transform: translateY(100vh);
    }
}

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

/* --- Bounce --- */
@keyframes bounce-subtle {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-6px);
    }
}

/* --- Fade & Slide --- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

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

/* --- Particle --- */
@keyframes particle-float {
    0% {
        opacity: 0;
        transform: translateY(0) translateX(0);
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translateY(-100vh) translateX(20px);
    }
}

/* --- Popular glow (plan card) --- */
@keyframes popular-glow {
    0%, 100% {
        box-shadow:
            0 0 20px rgba(4, 107, 210, 0.2),
            0 0 40px rgba(139, 92, 246, 0.1);
    }
    50% {
        box-shadow:
            0 0 30px rgba(4, 107, 210, 0.4),
            0 0 60px rgba(139, 92, 246, 0.2),
            0 0 80px rgba(6, 182, 212, 0.1);
    }
}

/* --- Scroll indicator --- */
@keyframes scroll-indicator {
    0% {
        opacity: 1;
        transform: translateY(0);
    }
    50% {
        opacity: 0.5;
        transform: translateY(8px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Badge float --- */
@keyframes badge-float {
    0%, 100% {
        transform: translateY(0) rotate(-2deg);
    }
    50% {
        transform: translateY(-8px) rotate(2deg);
    }
}

/* --- Ping --- */
@keyframes ping {
    75%, 100% {
        transform: scale(2);
        opacity: 0;
    }
}

/* --- Scale in --- */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.85);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* --- Rotate in --- */
@keyframes rotateIn {
    from {
        opacity: 0;
        transform: rotate(-180deg) scale(0);
    }
    to {
        opacity: 1;
        transform: rotate(0deg) scale(1);
    }
}

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

/* ==========================================================================
   2. Animation Utility Classes
   ========================================================================== */

/* --- Float --- */
.animate-float {
    animation: float 6s ease-in-out infinite;
}

.animate-float-delayed {
    animation: float-delayed 8s ease-in-out infinite;
}

.animate-float-slow {
    animation: float-slow 10s ease-in-out infinite;
}

/* --- Pulse / Glow --- */
.animate-pulse-glow {
    animation: pulse-glow 4s ease-in-out infinite;
}

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

/* --- Shimmer / Gradient --- */
.animate-shimmer {
    animation: shimmer 3s linear infinite;
}

.animate-gradient-x {
    background-size: 200% 200%;
    animation: gradient-x 3s ease infinite;
}

/* --- Scanline --- */
.animate-scanline {
    animation: scanline 8s linear infinite;
}

/* --- Spin --- */
.animate-spin-slow {
    animation: spin-slow 3s linear infinite;
}

/* --- Bounce --- */
.animate-bounce-subtle {
    animation: bounce-subtle 2s ease-in-out infinite;
}

/* --- Fade --- */
.animate-fadeIn {
    animation: fadeIn 0.6s ease-out both;
}

.animate-fadeInUp {
    animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.animate-fadeInDown {
    animation: fadeInDown 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* --- Slide --- */
.animate-slideInLeft {
    animation: slideInLeft 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.animate-slideInRight {
    animation: slideInRight 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.animate-slideInUp {
    animation: slideInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.animate-slideInDown {
    animation: slideInDown 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* --- Scale --- */
.animate-scaleIn {
    animation: scaleIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* --- Particle --- */
.animate-particle-float {
    animation: particle-float 6s ease-in-out infinite;
}

/* --- Popular glow --- */
.animate-popular-glow {
    animation: popular-glow 4s ease-in-out infinite;
}

/* --- Scroll indicator --- */
.animate-scroll-indicator {
    animation: scroll-indicator 2s ease-in-out infinite;
}

/* --- Badge float --- */
.animate-badge-float {
    animation: badge-float 3s ease-in-out infinite;
}

/* --- Ping --- */
.animate-ping {
    animation: ping 1s cubic-bezier(0, 0, 0.2, 1) infinite;
}

/* --- Rotate --- */
.animate-rotateIn {
    animation: rotateIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* --- Blink (cursor) --- */
.animate-blink {
    animation: blink 1s step-end infinite;
}

/* --- Spin (alias for Tailwind compat) --- */
.animate-spin {
    animation: spin-slow 1s linear infinite;
}

/* ==========================================================================
   3. Animation Delay Utilities
   ========================================================================== */

.delay-100 { animation-delay: 100ms; }
.delay-200 { animation-delay: 200ms; }
.delay-300 { animation-delay: 300ms; }
.delay-400 { animation-delay: 400ms; }
.delay-500 { animation-delay: 500ms; }
.delay-600 { animation-delay: 600ms; }
.delay-700 { animation-delay: 700ms; }
.delay-800 { animation-delay: 800ms; }
.delay-900 { animation-delay: 900ms; }
.delay-1000 { animation-delay: 1000ms; }
.delay-1100 { animation-delay: 1100ms; }
.delay-1200 { animation-delay: 1200ms; }
.delay-1300 { animation-delay: 1300ms; }
.delay-1400 { animation-delay: 1400ms; }
.delay-1500 { animation-delay: 1500ms; }
.delay-1600 { animation-delay: 1600ms; }
.delay-1700 { animation-delay: 1700ms; }
.delay-1800 { animation-delay: 1800ms; }
.delay-1900 { animation-delay: 1900ms; }
.delay-2000 { animation-delay: 2000ms; }

/* Duration utilities */
.duration-100 { animation-duration: 100ms; }
.duration-200 { animation-duration: 200ms; }
.duration-300 { animation-duration: 300ms; }
.duration-500 { animation-duration: 500ms; }
.duration-700 { animation-duration: 700ms; }
.duration-1000 { animation-duration: 1000ms; }
.duration-1500 { animation-duration: 1500ms; }
.duration-2000 { animation-duration: 2000ms; }
.duration-3000 { animation-duration: 3000ms; }

/* Fill-mode utilities */
.fill-forwards { animation-fill-mode: forwards; }
.fill-backwards { animation-fill-mode: backwards; }
.fill-both { animation-fill-mode: both; }

/* Iteration utilities */
.iterate-once { animation-iteration-count: 1; }
.iterate-twice { animation-iteration-count: 2; }
.iterate-infinite { animation-iteration-count: infinite; }

/* Play state utilities */
.animation-paused { animation-play-state: paused; }
.animation-running { animation-play-state: running; }

/* ==========================================================================
   4. Scroll Reveal Styles
   ========================================================================== */

/*
 * Elements with .reveal start invisible and shifted down.
 * When IntersectionObserver adds .revealed they transition
 * into view.  JavaScript in main.js handles the observer.
 */

.reveal {
    opacity: 0;
    transform: translateY(40px);
    transition:
        opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: opacity, transform;
}

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

/* --- Left reveal --- */
.reveal-left {
    opacity: 0;
    transform: translateX(-40px);
    transition:
        opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: opacity, transform;
}

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

/* --- Right reveal --- */
.reveal-right {
    opacity: 0;
    transform: translateX(40px);
    transition:
        opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: opacity, transform;
}

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

/* --- Scale reveal --- */
.reveal-scale {
    opacity: 0;
    transform: scale(0.9);
    transition:
        opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: opacity, transform;
}

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

/* --- Rotate reveal --- */
.reveal-rotate {
    opacity: 0;
    transform: rotate(-5deg) scale(0.95);
    transition:
        opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: opacity, transform;
}

.reveal-rotate.revealed {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* --- Stagger reveal (applies delays to children) --- */
.reveal-stagger > * {
    opacity: 0;
    transform: translateY(30px);
    transition:
        opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: opacity, transform;
}

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

/* Stagger delays — up to 12 children */
.reveal-stagger.revealed > *:nth-child(1)  { transition-delay: 0ms; }
.reveal-stagger.revealed > *:nth-child(2)  { transition-delay: 80ms; }
.reveal-stagger.revealed > *:nth-child(3)  { transition-delay: 160ms; }
.reveal-stagger.revealed > *:nth-child(4)  { transition-delay: 240ms; }
.reveal-stagger.revealed > *:nth-child(5)  { transition-delay: 320ms; }
.reveal-stagger.revealed > *:nth-child(6)  { transition-delay: 400ms; }
.reveal-stagger.revealed > *:nth-child(7)  { transition-delay: 480ms; }
.reveal-stagger.revealed > *:nth-child(8)  { transition-delay: 560ms; }
.reveal-stagger.revealed > *:nth-child(9)  { transition-delay: 640ms; }
.reveal-stagger.revealed > *:nth-child(10) { transition-delay: 720ms; }
.reveal-stagger.revealed > *:nth-child(11) { transition-delay: 800ms; }
.reveal-stagger.revealed > *:nth-child(12) { transition-delay: 880ms; }

/* --- Stagger with wider gap (120ms) --- */
.reveal-stagger-lg.revealed > *:nth-child(1)  { transition-delay: 0ms; }
.reveal-stagger-lg.revealed > *:nth-child(2)  { transition-delay: 120ms; }
.reveal-stagger-lg.revealed > *:nth-child(3)  { transition-delay: 240ms; }
.reveal-stagger-lg.revealed > *:nth-child(4)  { transition-delay: 360ms; }
.reveal-stagger-lg.revealed > *:nth-child(5)  { transition-delay: 480ms; }
.reveal-stagger-lg.revealed > *:nth-child(6)  { transition-delay: 600ms; }
.reveal-stagger-lg.revealed > *:nth-child(7)  { transition-delay: 720ms; }
.reveal-stagger-lg.revealed > *:nth-child(8)  { transition-delay: 840ms; }
.reveal-stagger-lg.revealed > *:nth-child(9)  { transition-delay: 960ms; }

/* --- Stagger with narrow gap (50ms) --- */
.reveal-stagger-sm.revealed > *:nth-child(1)  { transition-delay: 0ms; }
.reveal-stagger-sm.revealed > *:nth-child(2)  { transition-delay: 50ms; }
.reveal-stagger-sm.revealed > *:nth-child(3)  { transition-delay: 100ms; }
.reveal-stagger-sm.revealed > *:nth-child(4)  { transition-delay: 150ms; }
.reveal-stagger-sm.revealed > *:nth-child(5)  { transition-delay: 200ms; }
.reveal-stagger-sm.revealed > *:nth-child(6)  { transition-delay: 250ms; }
.reveal-stagger-sm.revealed > *:nth-child(7)  { transition-delay: 300ms; }
.reveal-stagger-sm.revealed > *:nth-child(8)  { transition-delay: 350ms; }
.reveal-stagger-sm.revealed > *:nth-child(9)  { transition-delay: 400ms; }

/* ==========================================================================
   5. 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;
    }

    /* Force reveal elements to be visible immediately */
    .reveal,
    .reveal-left,
    .reveal-right,
    .reveal-scale,
    .reveal-rotate,
    .reveal-stagger > * {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
    }

    /* Disable specific animations */
    .animate-float,
    .animate-float-delayed,
    .animate-float-slow,
    .animate-pulse-glow,
    .animate-pulse-dot,
    .animate-shimmer,
    .animate-gradient-x,
    .animate-scanline,
    .animate-spin-slow,
    .animate-bounce-subtle,
    .animate-particle-float,
    .animate-popular-glow,
    .animate-scroll-indicator,
    .animate-badge-float,
    .animate-ping {
        animation: none !important;
    }
}

/* Also disable animations when the user's OS requests it */
@media (update: slow) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .reveal,
    .reveal-left,
    .reveal-right,
    .reveal-scale,
    .reveal-rotate,
    .reveal-stagger > * {
        opacity: 1 !important;
        transform: none !important;
    }
}

/* Allow the theme to disable animations via body class */
body:not(.animations-enabled) *,
body:not(.animations-enabled) *::before,
body:not(.animations-enabled) *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
}

body:not(.animations-enabled) .reveal,
body:not(.animations-enabled) .reveal-left,
body:not(.animations-enabled) .reveal-right,
body:not(.animations-enabled) .reveal-scale,
body:not(.animations-enabled) .reveal-rotate,
body:not(.animations-enabled) .reveal-stagger > * {
    opacity: 1 !important;
    transform: none !important;
}

/* End of animations.css */
