/* ============================================================
   Trading Fight — Animations
   Keyframes, transitions & visual effects
   ============================================================ */

/* ============================================================
   KEYFRAMES
   ============================================================ */

/* Loading bar fill */
@keyframes loadingFill {
    0%   { width: 0%; }
    50%  { width: 60%; }
    100% { width: 100%; }
}

/* Fade in page */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Modal entrance */
@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Toast notifications */
@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}
@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* Spinner */
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Pulse */
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.05); }
}

/* Glow pulse for buttons */
@keyframes glowPulse {
    0%, 100% {
        box-shadow: 0 0 5px var(--color-green-glow);
    }
    50% {
        box-shadow: 0 0 20px var(--color-green-glow), 0 0 40px var(--color-green-glow);
    }
}

/* Glow bar for active games */
@keyframes glowBar {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.5; }
}

/* Countdown number pop */
@keyframes countdownPop {
    0%   { transform: scale(1.5); opacity: 0; }
    20%  { transform: scale(1); opacity: 1; }
    80%  { transform: scale(1); opacity: 1; }
    100% { transform: scale(0.8); opacity: 0; }
}

/* Countdown GO! */
@keyframes countdownGo {
    0%   { transform: scale(0.5); opacity: 0; }
    50%  { transform: scale(1.3); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* Victory celebration — green upward particles */
@keyframes victoryFloat {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateY(-200px) scale(0);
        opacity: 0;
    }
}

/* Defeat shake */
@keyframes defeatShake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* Candle grow animation */
@keyframes candleGrow {
    from {
        transform: scaleY(0);
        transform-origin: bottom;
    }
    to {
        transform: scaleY(1);
        transform-origin: bottom;
    }
}

/* Race car bounce */
@keyframes raceBounce {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-3px); }
}

/* Score change flash */
@keyframes scoreFlash {
    0%   { color: var(--color-yellow); transform: scale(1.3); }
    100% { color: inherit; transform: scale(1); }
}

/* Border glow */
@keyframes borderGlow {
    0%, 100% { border-color: var(--color-accent); }
    50%      { border-color: var(--color-green); }
}

/* Scanning line effect */
@keyframes scanLine {
    0%   { top: -5%; }
    100% { top: 105%; }
}

/* Background shimmer for loading states */
@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Blink for waiting status */
@keyframes blink {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.4; }
}

/* Slide up from bottom */
@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

/* Slide down off screen */
@keyframes slideDown {
    from { transform: translateY(0); opacity: 1; }
    to   { transform: translateY(30px); opacity: 0; }
}

/* Scale in (for badges, icons) */
@keyframes scaleIn {
    from { transform: scale(0); }
    to   { transform: scale(1); }
}

/* Rotate and scale (trophy reveal) */
@keyframes trophyReveal {
    0%   { transform: scale(0) rotate(-180deg); }
    60%  { transform: scale(1.2) rotate(10deg); }
    100% { transform: scale(1) rotate(0); }
}

/* ELO change display */
@keyframes eloChange {
    0%   { opacity: 0; transform: translateY(10px); }
    30%  { opacity: 1; transform: translateY(0); }
    70%  { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-20px); }
}

/* Typing dots (matchmaking) */
@keyframes typingDot {
    0%, 80%, 100% { transform: scale(0); }
    40%           { transform: scale(1); }
}

/* ============================================================
   TRANSITION UTILITIES
   ============================================================ */

/* Victory effect applied to game result */
.victory-effect {
    animation: victoryFloat 2s ease-out forwards;
}

/* Defeat effect */
.defeat-effect {
    animation: defeatShake 0.5s ease;
}

/* Trophy icon reveal */
.trophy-reveal {
    animation: trophyReveal 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* ELO change badge */
.elo-change {
    animation: eloChange 3s ease forwards;
    font-family: var(--font-mono);
    font-weight: 700;
}
.elo-change.positive {
    color: var(--color-green);
}
.elo-change.negative {
    color: var(--color-red);
}

/* Score flash */
.score-flash {
    animation: scoreFlash 0.5s ease;
}

/* Card stagger entrance */
.stagger-enter {
    animation: slideUp 0.4s ease backwards;
}
.stagger-enter:nth-child(1)  { animation-delay: 0ms; }
.stagger-enter:nth-child(2)  { animation-delay: 50ms; }
.stagger-enter:nth-child(3)  { animation-delay: 100ms; }
.stagger-enter:nth-child(4)  { animation-delay: 150ms; }
.stagger-enter:nth-child(5)  { animation-delay: 200ms; }
.stagger-enter:nth-child(6)  { animation-delay: 250ms; }
.stagger-enter:nth-child(7)  { animation-delay: 300ms; }
.stagger-enter:nth-child(8)  { animation-delay: 350ms; }
.stagger-enter:nth-child(9)  { animation-delay: 400ms; }
.stagger-enter:nth-child(10) { animation-delay: 450ms; }

/* Skeleton loader */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--color-bg-card) 25%,
        var(--color-bg-card-hover) 50%,
        var(--color-bg-card) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--border-radius);
}

/* Typing dots */
.typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: center;
}
.typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--color-accent);
    border-radius: 50%;
    animation: typingDot 1.4s ease-in-out infinite;
}
.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

/* Waiting blink */
.blink {
    animation: blink 1.5s ease-in-out infinite;
}

/* Scanline effect overlay */
.scanline-effect::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--color-green-glow), transparent);
    animation: scanLine 3s linear infinite;
    pointer-events: none;
}

/* Hover glow for cards */
.hover-glow {
    transition: box-shadow 0.3s ease, border-color 0.3s ease;
}
.hover-glow:hover {
    box-shadow: 0 0 15px var(--color-accent-glow);
    border-color: var(--color-accent);
}

/* Border glow animated */
.border-glow {
    animation: borderGlow 2s ease infinite;
}

/* Number counter (for live stats) */
.counter-animate {
    transition: all 0.3s ease;
}

/* Race runner animation */
.race-runner {
    animation: raceBounce 0.5s ease infinite;
}

/* ============================================================
   VICTORY CONFETTI (CSS-only fallback)
   ============================================================ */
.confetti-container {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    z-index: 6000;
    overflow: hidden;
}
.confetti-piece {
    position: absolute;
    width: 8px;
    height: 8px;
    top: -10px;
    animation: confettiFall linear forwards;
}

@keyframes confettiFall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Confetti color variants */
.confetti-piece:nth-child(odd) { background: var(--color-green); }
.confetti-piece:nth-child(even) { background: var(--color-accent); }
.confetti-piece:nth-child(3n) { background: var(--color-yellow); }
.confetti-piece:nth-child(5n) { background: var(--color-red); }
