/**
 * Qifu Fangsheng Animations
 */

/* ===========================
   Merit Popup Animation
   =========================== */

.qifu-merit-popup {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: #28a745;
    color: #fff;
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 16px;
    white-space: nowrap;
    z-index: 1000;
    animation: meritFloat 1.5s ease-out forwards;
    pointer-events: none;
}

@keyframes meritFloat {
    0% {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(-50px);
    }
}

/* ===========================
   Fish Release Animation
   =========================== */

.qifu-fish-animation {
    position: fixed;
    bottom: 50%;
    left: 50%;
    transform: translate(-50%, 50%);
    font-size: 80px;
    z-index: 1000;
    opacity: 0;
    animation: fishAppear 0.3s ease-out forwards;
    pointer-events: none;
}

.qifu-fish-animation.swimming {
    animation: fishSwim 2s ease-in-out forwards;
}

@keyframes fishAppear {
    0% {
        opacity: 0;
        transform: translate(-50%, 50%) scale(0);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, 50%) scale(1);
    }
}

@keyframes fishSwim {
    0% {
        opacity: 1;
        transform: translate(-50%, 50%) scale(1) rotate(0deg);
    }
    50% {
        transform: translate(100%, -100%) scale(1.2) rotate(20deg);
    }
    100% {
        opacity: 0;
        transform: translate(200%, -200%) scale(0.5) rotate(40deg);
    }
}

/* ===========================
   Wooden Fish Tap Animation
   =========================== */

.wooden-fish-image {
    position: relative;
}

.wooden-fish-image::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 3px solid #d2691e;
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
}

.wooden-fish-image.clicking::after {
    animation: tapRipple 0.6s ease-out;
}

@keyframes tapRipple {
    0% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 0;
    }
}

/* ===========================
   Fish Option Hover Effect
   =========================== */

.fish-option {
    position: relative;
    overflow: hidden;
}

.fish-option::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(34, 113, 177, 0.1), transparent);
    transition: left 0.5s ease;
}

.fish-option:hover::before {
    left: 100%;
}

/* ===========================
   Button Pulse Animation
   =========================== */

.qifu-button {
    position: relative;
    overflow: hidden;
}

.qifu-button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.qifu-button:active::before {
    width: 300px;
    height: 300px;
}

/* ===========================
   Leaderboard Entry Animation
   =========================== */

#qifu-leaderboard tbody tr {
    animation: fadeInUp 0.5s ease-out backwards;
}

#qifu-leaderboard tbody tr:nth-child(1) { animation-delay: 0.05s; }
#qifu-leaderboard tbody tr:nth-child(2) { animation-delay: 0.1s; }
#qifu-leaderboard tbody tr:nth-child(3) { animation-delay: 0.15s; }
#qifu-leaderboard tbody tr:nth-child(4) { animation-delay: 0.2s; }
#qifu-leaderboard tbody tr:nth-child(5) { animation-delay: 0.25s; }

@keyframes fadeInUp {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===========================
   Stat Card Number Update
   =========================== */

.stat-value {
    transition: all 0.3s ease;
}

.stat-value.updating {
    animation: numberPulse 0.5s ease;
}

@keyframes numberPulse {
    0%, 100% {
        transform: scale(1);
        color: #2271b1;
    }
    50% {
        transform: scale(1.2);
        color: #28a745;
    }
}

/* ===========================
   Loading States
   =========================== */

.qifu-loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #2271b1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===========================
   Success/Error Message Slide
   =========================== */

.qifu-message {
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    0% {
        opacity: 0;
        transform: translateY(-20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===========================
   Rank Badge Shine
   =========================== */

.top-rank-1,
.top-rank-2,
.top-rank-3 {
    position: relative;
    overflow: hidden;
}

.top-rank-1::after,
.top-rank-2::after,
.top-rank-3::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shine 3s infinite;
}

@keyframes shine {
    0% {
        transform: translateX(-100%) translateY(-100%) rotate(45deg);
    }
    100% {
        transform: translateX(100%) translateY(100%) rotate(45deg);
    }
}

/* ===========================
   Stat Card Entrance
   =========================== */

.stat-card {
    animation: zoomIn 0.5s ease-out backwards;
}

.stat-card:nth-child(1) { animation-delay: 0.1s; }
.stat-card:nth-child(2) { animation-delay: 0.2s; }
.stat-card:nth-child(3) { animation-delay: 0.3s; }
.stat-card:nth-child(4) { animation-delay: 0.4s; }
.stat-card:nth-child(5) { animation-delay: 0.5s; }
.stat-card:nth-child(6) { animation-delay: 0.6s; }

@keyframes zoomIn {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}
