/* ═══════════════════════════════════════════════════════════════
   SolPoker — Animations & Visual Effects
   Casino-grade motion design for cards, chips, players, and UI.
   ═══════════════════════════════════════════════════════════════ */

/* ─── Card Dealing (from deck to player) ──────────────────── */
@keyframes dealCard {
    0%   { transform: translateY(-180px) scale(0.4) rotate(60deg); opacity: 0; }
    60%  { transform: translateY(10px) scale(1.05) rotate(-3deg); opacity: 1; }
    100% { transform: translateY(0) scale(1) rotate(0deg); opacity: 1; }
}

@keyframes dealBoardCard {
    0%   { transform: translate(0, -120px) scale(0.3) rotateY(180deg); opacity: 0; }
    50%  { transform: translate(0, -20px) scale(1.1) rotateY(90deg); opacity: 1; }
    100% { transform: translate(0, 0) scale(1) rotateY(0deg); opacity: 1; }
}

.card-deal-anim {
    animation: dealCard 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    opacity: 0;
}

.board-card-anim {
    animation: dealBoardCard 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    opacity: 0;
    transform-style: preserve-3d;
}

/* ─── Card Flip (hole cards face-up at showdown) ─────────── */
@keyframes cardFlip {
    0%   { transform: rotateY(0deg); }
    50%  { transform: rotateY(90deg); }
    100% { transform: rotateY(180deg); }
}

.card-flip-anim {
    animation: cardFlip 0.6s ease-in-out forwards;
    transform-style: preserve-3d;
}

/* ─── Card Muck (fold discard) ───────────────────────────── */
@keyframes cardMuck {
    0%   { transform: translate(0,0) scale(1) rotate(0deg); opacity: 1; }
    100% { transform: translate(20px, 30px) scale(0.5) rotate(25deg); opacity: 0.3; }
}

.card-muck-anim {
    animation: cardMuck 0.35s ease-in forwards;
}

/* ─── Chip Bet Animation ──────────────────────────────────── */
@keyframes chipToPot {
    0%   { transform: translate(0, 0) scale(1); opacity: 1; }
    70%  { transform: translate(var(--tx), var(--ty)) scale(0.7); opacity: 1; }
    100% { transform: translate(var(--tx), var(--ty)) scale(0); opacity: 0; }
}

.chip-bet-anim {
    position: absolute;
    z-index: 50;
    animation: chipToPot 0.55s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    pointer-events: none;
}

/* ─── Pot Collect (chips slide to winner) ─────────────────── */
@keyframes potCollect {
    0%   { transform: translate(0, 0) scale(1); opacity: 1; }
    60%  { transform: translate(var(--tx), var(--ty)) scale(1.15); opacity: 1; }
    100% { transform: translate(var(--tx), var(--ty)) scale(0); opacity: 0; }
}

.pot-collect-anim {
    animation: potCollect 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* ─── Active Player Turn Highlight ───────────────────────── */
@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 8px var(--accent-gold), 0 0 16px rgba(251,191,36,0.3); }
    50%      { box-shadow: 0 0 20px var(--accent-gold), 0 0 40px rgba(251,191,36,0.5); }
}

@keyframes pulseBorder {
    0%, 100% { border-color: var(--accent-gold); }
    50%      { border-color: rgba(251,191,36,0.3); }
}

.player-active-turn {
    animation: pulseGlow 1.5s ease-in-out infinite;
    position: relative;
}

.player-active-turn::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: inherit;
    border: 2px solid var(--accent-gold);
    animation: pulseBorder 1.5s ease-in-out infinite;
    pointer-events: none;
    z-index: 1;
}

/* ─── Turn Timer Bar ──────────────────────────────────────── */
@keyframes timerDrain {
    from { width: 100%; }
    to   { width: 0%; }
}

.timer-bar {
    height: 4px;
    background: linear-gradient(90deg, var(--accent-gold), #ef4444);
    border-radius: 2px;
    animation: timerDrain var(--timer-duration) linear forwards;
    transition: height 0.2s;
}

.timer-bar.urgent {
    height: 6px;
    background: #ef4444;
    animation: timerDrain 1s linear infinite;
}

/* ─── Winner Celebration (Confetti) ───────────────────────── */
@keyframes confettiFall {
    0%   { transform: translate(var(--start-x), -10vh) rotate(0deg); opacity: 1; }
    100% { transform: translate(var(--end-x), 100vh) rotate(var(--rot)); opacity: 0; }
}

.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    opacity: 0;
    z-index: 1000;
    pointer-events: none;
}

.confetti-anim {
    animation: confettiFall var(--duration) ease-in forwards;
}

/* ─── Hand Complete Overlay ───────────────────────────────── */
@keyframes overlaySlideIn {
    from { opacity: 0; transform: translateY(30px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes overlaySlideOut {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to   { opacity: 0; transform: translateY(-20px) scale(0.95); }
}

@keyframes winnerNamePulse {
    0%, 100% { text-shadow: 0 0 10px rgba(251,191,36,0.5); }
    50%      { text-shadow: 0 0 30px rgba(251,191,36,1), 0 0 60px rgba(251,191,36,0.5); }
}

.hand-complete-overlay {
    animation: overlaySlideIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 900;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(8px);
}

.hand-complete-overlay.dismiss {
    animation: overlaySlideOut 0.3s ease-in forwards;
}

.winner-name-glow {
    animation: winnerNamePulse 2s ease-in-out infinite;
    color: var(--accent-gold);
    font-size: 2rem;
    font-weight: 700;
}

/* ─── All-In Spotlight ────────────────────────────────────── */
@keyframes allInSpotlight {
    0%, 100% { box-shadow: 0 0 15px rgba(239,68,68,0.5), inset 0 0 15px rgba(239,68,68,0.1); }
    50%      { box-shadow: 0 0 35px rgba(239,68,68,0.8), inset 0 0 35px rgba(239,68,68,0.2); }
}

.player-all-in {
    animation: allInSpotlight 1s ease-in-out infinite;
}

/* ─── Chip Stack Bounce (on win) ──────────────────────────── */
@keyframes chipBounce {
    0%, 100% { transform: translateY(0); }
    25%      { transform: translateY(-6px); }
    75%      { transform: translateY(-2px); }
}

.chip-bounce {
    animation: chipBounce 0.6s ease-in-out 3;
    display: inline-block;
}

/* ─── Toast Notification ──────────────────────────────────── */
@keyframes toastSlideIn {
    from { opacity: 0; transform: translateX(100px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastSlideOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(100px); }
}

.toast-anim-in  { animation: toastSlideIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }
.toast-anim-out { animation: toastSlideOut 0.25s ease-in forwards; }

/* ─── Player Join/Leave ───────────────────────────────────── */
@keyframes playerJoin {
    from { opacity: 0; transform: scale(0.7); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes playerLeave {
    from { opacity: 1; transform: scale(1); }
    to   { opacity: 0; transform: scale(0.7); }
}

.player-join-anim  { animation: playerJoin 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }
.player-leave-anim { animation: playerLeave 0.3s ease-in forwards; }

/* ─── Countdown Timer ─────────────────────────────────────── */
@keyframes countdownPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50%      { transform: scale(1.15); opacity: 0.85; }
}

.countdown-pulse {
    animation: countdownPulse 1s ease-in-out infinite;
    color: var(--accent-gold);
    font-weight: 700;
}

/* ─── Dealer Button Rotation ──────────────────────────────── */
@keyframes dealerSlide {
    from { opacity: 0; transform: translateX(-20px); }
    to   { opacity: 1; transform: translateX(0); }
}

.dealer-btn {
    animation: dealerSlide 0.4s ease-out forwards;
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, var(--accent-gold), #d97706);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    color: #000;
    box-shadow: 0 2px 8px rgba(251,191,36,0.4);
}

/* ─── Responsive Animations ───────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ─── Button Press Effect ─────────────────────────────────── */
.btn:active {
    transform: scale(0.96);
    transition: transform 0.1s ease;
}

.action-btn-pressed {
    transform: scale(0.92) !important;
    filter: brightness(1.2);
    transition: all 0.15s ease;
}
