/* Animations centralisées. Étendues au fur et à mesure des features
   (notamment ouverture de boîte, drops, transitions de pages). */

@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fade-in-up {
    from {
        opacity: 0;
        transform: translateY(24px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 16px rgba(212, 175, 55, 0.3);
    }
    50% {
        box-shadow: 0 0 32px rgba(212, 175, 55, 0.6);
    }
}

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

.fade-in {
    animation: fade-in var(--transition) ease-out both;
}

.fade-in-up {
    animation: fade-in-up var(--transition-slow) var(--ease-out-back) both;
}

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

/* ============================================================
   Box opening — animations dramatiques (4 phases)
============================================================ */

/* --- Rayons divergents derrière la boîte (anticipation) --- */
@keyframes rays-spin {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to   { transform: translate(-50%, -50%) rotate(360deg); }
}

/* --- Tremblement de la boîte (anticipation) --- */
@keyframes box-shake {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    10% { transform: translate(-2px, -1px) rotate(-1deg); }
    20% { transform: translate(3px, 1px) rotate(1deg); }
    30% { transform: translate(-2px, 2px) rotate(-1deg); }
    40% { transform: translate(2px, -2px) rotate(1deg); }
    50% { transform: translate(-3px, 1px) rotate(-1deg); }
    60% { transform: translate(2px, 2px) rotate(1deg); }
    70% { transform: translate(-1px, -2px) rotate(-1deg); }
    80% { transform: translate(3px, 1px) rotate(1deg); }
    90% { transform: translate(-2px, -1px) rotate(-1deg); }
}

/* --- Tremblement écran (jackpot) --- */
@keyframes screen-shake {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(-4px, 3px); }
    50% { transform: translate(4px, -3px); }
    75% { transform: translate(-3px, -4px); }
}
body.is-shaking { animation: screen-shake 0.4s ease-in-out 3; }

/* --- Item reveal (commun) : pop in avec bounce --- */
@keyframes item-pop-in {
    0%   { opacity: 0; transform: scale(0.4) translateY(40px); }
    60%  { opacity: 1; transform: scale(1.08) translateY(-4px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* --- Item reveal (jackpot) : entrée dramatique --- */
@keyframes jackpot-pop-in {
    0%   { opacity: 0; transform: scale(0.2) rotate(-15deg); filter: brightness(2); }
    40%  { opacity: 1; transform: scale(1.25) rotate(5deg); filter: brightness(1.5); }
    70%  { transform: scale(0.95) rotate(-2deg); filter: brightness(1.2); }
    100% { opacity: 1; transform: scale(1) rotate(0deg); filter: brightness(1); }
}

/* --- Particules dorées (jackpot) ou blanches (commun) --- */
.cm-particle {
    position: fixed;
    width: 8px;
    height: 8px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    pointer-events: none;
    z-index: 9999;
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.8);
    animation: particle-fly 1s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
    --dx: 0px;
    --dy: 0px;
}
.cm-particle.is-golden {
    background: #f5d465;
    box-shadow: 0 0 16px rgba(212, 175, 55, 0.9), 0 0 32px rgba(212, 175, 55, 0.4);
    width: 10px;
    height: 10px;
}
@keyframes particle-fly {
    0%   { opacity: 1; transform: translate(0, 0) scale(1); }
    80%  { opacity: 1; }
    100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.3); }
}

/* --- Stage transitions --- */
.opening-stage {
    transition: opacity 200ms;
}
.opening-stage.is-leaving {
    opacity: 0;
}

@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;
    }
}
