/* ==========================================================================
   AstroCalc - Animations & Keyframes
   ========================================================================== */

/* ---------- Keyframes ---------- */
@keyframes twinkle {
    0%, 100% { opacity: 0.3; }
    50%      { opacity: 1.0; }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-12px); }
}

@keyframes glow-pulse {
    0%, 100% { box-shadow: 0 0 5px rgba(124, 77, 255, 0.2), 0 0 15px rgba(124, 77, 255, 0.1); }
    50%      { box-shadow: 0 0 15px rgba(124, 77, 255, 0.4), 0 0 40px rgba(124, 77, 255, 0.2); }
}

@keyframes rotate-slow {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

@keyframes slide-up {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slide-in-right {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes scale-in {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* ---------- Animation Classes ---------- */
.fade-in-up {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.fade-in-up.visible {
    opacity: 1;
    transform: translateY(0);
}

.star-twinkle {
    animation: twinkle 3s ease-in-out infinite;
}

.star-twinkle:nth-child(2n)  { animation-delay: 0.5s; animation-duration: 2.5s; }
.star-twinkle:nth-child(3n)  { animation-delay: 1.2s; animation-duration: 4s; }
.star-twinkle:nth-child(5n)  { animation-delay: 0.8s; animation-duration: 3.5s; }
.star-twinkle:nth-child(7n)  { animation-delay: 1.8s; animation-duration: 2.8s; }
.star-twinkle:nth-child(11n) { animation-delay: 0.3s; animation-duration: 4.5s; }

.float-gentle {
    animation: float 6s ease-in-out infinite;
}

.glow-pulse {
    animation: glow-pulse 3s ease-in-out infinite;
}

.orbit-path {
    animation: rotate-slow 60s linear infinite;
    transform-origin: center center;
}

.orbit-path-fast {
    animation: rotate-slow 20s linear infinite;
    transform-origin: center center;
}

.orbit-path-reverse {
    animation: rotate-slow 45s linear infinite reverse;
    transform-origin: center center;
}

.slide-in-right {
    animation: slide-in-right 0.5s ease-out forwards;
}

.scale-in {
    animation: scale-in 0.4s ease-out forwards;
}

/* ---------- Staggered children ---------- */
.stagger-children > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-children > *:nth-child(2) { animation-delay: 0.10s; }
.stagger-children > *:nth-child(3) { animation-delay: 0.15s; }
.stagger-children > *:nth-child(4) { animation-delay: 0.20s; }
.stagger-children > *:nth-child(5) { animation-delay: 0.25s; }
.stagger-children > *:nth-child(6) { animation-delay: 0.30s; }
.stagger-children > *:nth-child(7) { animation-delay: 0.35s; }
.stagger-children > *:nth-child(8) { animation-delay: 0.40s; }

/* ---------- Loading Skeleton ---------- */
.skeleton {
    background: linear-gradient(90deg,
        var(--astro-card) 25%,
        rgba(255, 255, 255, 0.05) 50%,
        var(--astro-card) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.8s ease-in-out infinite;
    border-radius: var(--border-radius-sm);
}

/* ---------- Animation Canvas ---------- */
.animation-canvas {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: var(--border-radius);
    background: var(--astro-surface);
    border: 1px solid var(--astro-border);
}

.animation-canvas canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.animation-canvas .canvas-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 40%, var(--astro-surface) 100%);
}

.animation-canvas .canvas-controls {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.5rem;
    z-index: 5;
}

.animation-canvas .canvas-controls button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--astro-border);
    background: rgba(10, 14, 26, 0.8);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.animation-canvas .canvas-controls button:hover {
    background: var(--astro-card);
    color: var(--text-primary);
    border-color: var(--color-planets);
}

/* ---------- 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;
    }

    .fade-in-up {
        opacity: 1;
        transform: none;
    }

    .star-twinkle {
        animation: none;
        opacity: 0.7;
    }

    .orbit-path,
    .orbit-path-fast,
    .orbit-path-reverse {
        animation: none;
    }

    .float-gentle {
        animation: none;
    }

    .skeleton {
        animation: none;
    }
}
