/*
 * PRATSWAP — Animation System
 * "Nothing happens instantly — but nothing lags."
 * 
 * Motion that feels like time passing, arrivals from far away.
 */

/* ═══════════════════════════════════════════════════════════════════════════
   KEYFRAMES: COSMIC MOTION
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Arrival: Fading in from distance (GPU-optimized) ─── */
@keyframes arrive {
    0% {
        opacity: 0;
        transform: translateY(20px) translateZ(0);
    }

    100% {
        opacity: 1;
        transform: translateY(0) translateZ(0);
    }
}

@keyframes arrive-slow {
    0% {
        opacity: 0;
        transform: translateY(30px) translateZ(0);
    }

    100% {
        opacity: 1;
        transform: translateY(0) translateZ(0);
    }
}

/* ─── Drift: Gentle cosmic movement ─── */
@keyframes drift {

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

    25% {
        transform: translate(2px, -3px);
    }

    50% {
        transform: translate(-1px, 2px);
    }

    75% {
        transform: translate(-2px, -1px);
    }
}

@keyframes drift-slow {

    0%,
    100% {
        transform: translate(0, 0) rotate(0deg);
    }

    33% {
        transform: translate(5px, -5px) rotate(0.5deg);
    }

    66% {
        transform: translate(-3px, 3px) rotate(-0.5deg);
    }
}

/* ─── Pulse: Star breathing ─── */
@keyframes pulse-star {

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

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

@keyframes pulse-gentle {

    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }
}

/* ─── Breathe: Expansion and contraction ─── */
@keyframes breathe {

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

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

@keyframes breathe-deep {

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

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

/* ─── Fade: Graceful disappearance ─── */
@keyframes fade-out {
    0% {
        opacity: 1;
        transform: scale(1);
    }

    100% {
        opacity: 0;
        transform: scale(0.95);
    }
}

@keyframes fade-up {
    0% {
        opacity: 1;
        transform: translateY(0);
    }

    100% {
        opacity: 0;
        transform: translateY(-20px);
    }
}

/* ─── Twinkle: Star shimmer (GPU-optimized) ─── */
@keyframes twinkle {

    0%,
    100% {
        opacity: 0.4;
    }

    50% {
        opacity: 1;
    }
}

/* ─── Float: Suspended in space ─── */
@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

/* ─── Rotate: Celestial spin ─── */
@keyframes rotate-slow {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* ─── Entrance: Page load ─── */
@keyframes entrance {
    0% {
        opacity: 0;
    }

    100% {
        opacity: 1;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   ANIMATION CLASSES
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Arrivals ─── */
.animate-arrive {
    animation: arrive 0.8s var(--ease-arrive) forwards;
    opacity: 0;
    will-change: transform, opacity;
}

.animate-arrive-slow {
    animation: arrive-slow 1.5s var(--ease-arrive) forwards;
    opacity: 0;
    will-change: transform, opacity;
}

.animate-arrive-delay-1 {
    animation-delay: 0.3s;
}

.animate-arrive-delay-2 {
    animation-delay: 0.6s;
}

.animate-arrive-delay-3 {
    animation-delay: 0.9s;
}

.animate-arrive-delay-4 {
    animation-delay: 1.2s;
}

/* ─── Drifting ─── */
.animate-drift {
    animation: drift var(--drift-speed) ease-in-out infinite;
}

.animate-drift-slow {
    animation: drift-slow calc(var(--drift-speed) * 2) ease-in-out infinite;
}

/* ─── Pulsing ─── */
.animate-pulse {
    animation: pulse-star 4s ease-in-out infinite;
}

.animate-pulse-gentle {
    animation: pulse-gentle 6s ease-in-out infinite;
}

/* ─── Breathing ─── */
.animate-breathe {
    animation: breathe 8s ease-in-out infinite;
}

.animate-breathe-deep {
    animation: breathe-deep 10s ease-in-out infinite;
}

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

/* ─── Twinkling ─── */
.animate-twinkle {
    animation: twinkle 3s ease-in-out infinite;
}

/* ─── Rotation ─── */
.animate-rotate {
    animation: rotate-slow 120s linear infinite;
}

/* ─── Entrance ─── */
.animate-entrance {
    animation: entrance 2s ease-out forwards;
}

/* ═══════════════════════════════════════════════════════════════════════════
   STAGGER SYSTEM
   ═══════════════════════════════════════════════════════════════════════════ */

.stagger>*:nth-child(1) {
    animation-delay: 0.1s;
}

.stagger>*:nth-child(2) {
    animation-delay: 0.2s;
}

.stagger>*:nth-child(3) {
    animation-delay: 0.3s;
}

.stagger>*:nth-child(4) {
    animation-delay: 0.4s;
}

.stagger>*:nth-child(5) {
    animation-delay: 0.5s;
}

.stagger>*:nth-child(6) {
    animation-delay: 0.6s;
}

.stagger>*:nth-child(7) {
    animation-delay: 0.7s;
}

.stagger>*:nth-child(8) {
    animation-delay: 0.8s;
}

.stagger>*:nth-child(9) {
    animation-delay: 0.9s;
}

.stagger>*:nth-child(10) {
    animation-delay: 1s;
}

.stagger-slow>*:nth-child(1) {
    animation-delay: 0.2s;
}

.stagger-slow>*:nth-child(2) {
    animation-delay: 0.4s;
}

.stagger-slow>*:nth-child(3) {
    animation-delay: 0.6s;
}

.stagger-slow>*:nth-child(4) {
    animation-delay: 0.8s;
}

.stagger-slow>*:nth-child(5) {
    animation-delay: 1s;
}

/* ═══════════════════════════════════════════════════════════════════════════
   TRANSITION UTILITIES
   ═══════════════════════════════════════════════════════════════════════════ */

.transition-all {
    transition: all var(--fade-speed) var(--ease-drift);
}

.transition-fast {
    transition: all var(--gravity-speed) var(--ease-gravity);
}

.transition-slow {
    transition: all var(--arrive-speed) var(--ease-arrive);
}

.transition-opacity {
    transition: opacity var(--fade-speed) var(--ease-drift);
}

.transition-transform {
    transition: transform var(--gravity-speed) var(--ease-gravity);
}

/* ═══════════════════════════════════════════════════════════════════════════
   HOVER STATES: GRAVITY RESPONSE
   ═══════════════════════════════════════════════════════════════════════════ */

.hover-lift {
    transition: transform var(--gravity-speed) var(--ease-gravity);
}

.hover-lift:hover {
    transform: translateY(-2px);
}

.hover-glow {
    transition: box-shadow var(--fade-speed) var(--ease-drift);
}

.hover-glow:hover {
    box-shadow: 0 0 30px var(--nebula-glow);
}

.hover-scale {
    transition: transform var(--gravity-speed) var(--ease-gravity);
}

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

.hover-opacity {
    transition: opacity var(--fade-speed) var(--ease-drift);
}

.hover-opacity:hover {
    opacity: 1;
}

/* ═══════════════════════════════════════════════════════════════════════════
   PAGE TRANSITIONS
   ═══════════════════════════════════════════════════════════════════════════ */

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

.page-enter-active {
    opacity: 1;
    transform: translateY(0);
    transition: all 1s var(--ease-arrive);
}

.page-exit {
    opacity: 1;
}

.page-exit-active {
    opacity: 0;
    transition: opacity 0.5s var(--ease-drift);
}

/* ═══════════════════════════════════════════════════════════════════════════
   RITUAL ANIMATIONS
   ═══════════════════════════════════════════════════════════════════════════ */

@keyframes ritual-complete {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }

    100% {
        transform: scale(0.8);
        opacity: 0;
    }
}

.ritual-complete {
    animation: ritual-complete 1.5s var(--ease-arrive) forwards;
}

@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 0.6;
    }

    100% {
        transform: scale(2);
        opacity: 0;
    }
}

.ripple {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--nebula-glow);
    animation: ripple 1s var(--ease-arrive) forwards;
    pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
   LOADING STATE
   ═══════════════════════════════════════════════════════════════════════════ */

.loading {
    position: fixed;
    inset: 0;
    background: var(--moonlight);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 1s var(--ease-drift);
}

.loading.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-star {
    width: 8px;
    height: 8px;
    background: var(--starlight);
    border-radius: 50%;
    animation: pulse-star 1.5s ease-in-out infinite;
}