/**
 * StarryStories Web App - Animations
 * Scroll reveals, hover effects, background animations
 */

/* ============================================
   SCROLL REVEAL ANIMATIONS
   ============================================ */

/* Base state for animated elements */
.animate-on-scroll {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.animate-on-scroll.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Staggered animations for lists */
.animate-stagger>*:nth-child(1) {
    transition-delay: 0ms;
}

.animate-stagger>*:nth-child(2) {
    transition-delay: 100ms;
}

.animate-stagger>*:nth-child(3) {
    transition-delay: 200ms;
}

.animate-stagger>*:nth-child(4) {
    transition-delay: 300ms;
}

.animate-stagger>*:nth-child(5) {
    transition-delay: 400ms;
}

.animate-stagger>*:nth-child(6) {
    transition-delay: 500ms;
}

/* Fade in from different directions */
.fade-up {
    transform: translateY(40px);
}

.fade-down {
    transform: translateY(-40px);
}

.fade-left {
    transform: translateX(40px);
}

.fade-right {
    transform: translateX(-40px);
}

.fade-up.visible,
.fade-down.visible,
.fade-left.visible,
.fade-right.visible {
    transform: translate(0);
}

/* Scale in */
.scale-in {
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

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

/* ============================================
   BACKGROUND ANIMATIONS
   ============================================ */

/* Floating particles container */
.particles-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

/* Individual particle/star */
.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    animation: twinkle 3s ease-in-out infinite;
}

@keyframes twinkle {

    0%,
    100% {
        opacity: 0.2;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* Floating orbs */
.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.4;
    animation: float 20s ease-in-out infinite;
}

.orb-1 {
    width: 300px;
    height: 300px;
    background: linear-gradient(135deg, #5B7CFA, #8B5CF6);
    top: 10%;
    left: -5%;
    animation-delay: 0s;
}

.orb-2 {
    width: 250px;
    height: 250px;
    background: linear-gradient(135deg, #8B5CF6, #EC4899);
    bottom: 20%;
    right: -5%;
    animation-delay: -7s;
}

.orb-3 {
    width: 200px;
    height: 200px;
    background: linear-gradient(135deg, #5B7CFA, #06B6D4);
    top: 60%;
    left: 30%;
    animation-delay: -14s;
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    25% {
        transform: translate(30px, -30px) scale(1.05);
    }

    50% {
        transform: translate(-20px, 20px) scale(0.95);
    }

    75% {
        transform: translate(20px, 10px) scale(1.02);
    }
}

/* ============================================
   HOVER EFFECTS
   ============================================ */

/* Card hover lift */
.hover-lift {
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

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

/* Button press effect */
.hover-press {
    transition: transform var(--transition-fast);
}

.hover-press:active {
    transform: scale(0.97);
}

/* Glow on hover */
.hover-glow {
    transition: box-shadow var(--transition-normal);
}

.hover-glow:hover {
    box-shadow: var(--shadow-glow);
}

/* Scale on hover */
.hover-scale {
    transition: transform var(--transition-normal);
}

.hover-scale:hover {
    transform: scale(1.03);
}

/* ============================================
   LOADING ANIMATIONS
   ============================================ */

/* Shimmer effect */
.shimmer {
    background: linear-gradient(90deg,
            var(--bg-surface) 0%,
            var(--bg-surface-alt) 50%,
            var(--bg-surface) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* Pulse animation */
.pulse {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* Spin animation */
.spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   PAGE TRANSITIONS
   ============================================ */

.page-enter {
    opacity: 0;
    transform: translateY(20px);
}

.page-enter-active {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* ============================================
   AUDIO PLAYER ANIMATIONS
   ============================================ */

/* Breathing glow for now playing */
.breathing-glow {
    animation: breathe 4s ease-in-out infinite;
}

@keyframes breathe {

    0%,
    100% {
        box-shadow: 0 0 20px rgba(91, 124, 250, 0.3);
    }

    50% {
        box-shadow: 0 0 40px rgba(91, 124, 250, 0.6);
    }
}

/* Progress bar fill animation */
.progress-fill {
    transition: width 0.1s linear;
}

/* Play button pulse */
.play-pulse {
    animation: playPulse 1.5s ease-in-out infinite;
}

@keyframes playPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

/* ============================================
   CLICK RIPPLE ANIMATION
   ============================================ */

/* Ripple effect container */
.ripple-container {
    position: relative;
    overflow: hidden;
}

.ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transform: scale(0);
    animation: rippleEffect 0.6s ease-out;
    pointer-events: none;
}

@keyframes rippleEffect {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* Global loading overlay */
.page-loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(14, 15, 19, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.page-loading-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.page-loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--accent-primary, #5B7CFA);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Click feedback for buttons and cards */
.btn,
.language-card,
.category-card,
.story-card,
.english-card,
.collapsible-header,
.voice-option {
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.btn:active,
.language-card:active,
.category-card:active,
.story-card:active,
.english-card:active {
    transform: scale(0.98);
}