/* ============================================================
   魔法森林电子游戏社区 - 动画样式文件
   magic-animations.css
   四大独特动画：萤火飞舞、符文闪烁、藤蔓生长、迷雾飘动
   ============================================================ */

/* === 动画一：萤火飞舞（Firefly Dance） ===
   页面核心模块加载时触发，元素表面随机出现飞舞的萤火虫效果 */

@keyframes magic-firefly-float {
    0% {
        transform: translate(0, 0) scale(0);
        opacity: 0;
    }
    20% {
        opacity: 1;
        transform: translate(10px, -20px) scale(1);
    }
    50% {
        opacity: 0.8;
        transform: translate(-15px, -50px) scale(0.8);
    }
    80% {
        opacity: 0.4;
        transform: translate(20px, -80px) scale(0.6);
    }
    100% {
        opacity: 0;
        transform: translate(-10px, -120px) scale(0);
    }
}

@keyframes magic-firefly-glow {
    0%, 100% {
        box-shadow: 0 0 4px 2px rgba(241, 196, 15, 0.6);
    }
    50% {
        box-shadow: 0 0 8px 4px rgba(241, 196, 15, 0.9);
    }
}

.magic-firefly-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 4;
}

.magic-firefly {
    position: absolute;
    width: 6px;
    height: 6px;
    background: #F1C40F;
    border-radius: 50%;
    animation: magic-firefly-float 3s ease-in-out infinite, magic-firefly-glow 1.5s ease-in-out infinite;
    opacity: 0;
}

.magic-firefly:nth-child(1) { left: 10%; top: 80%; animation-delay: 0s; animation-duration: 3.5s; }
.magic-firefly:nth-child(2) { left: 25%; top: 70%; animation-delay: 0.5s; animation-duration: 4s; }
.magic-firefly:nth-child(3) { left: 40%; top: 85%; animation-delay: 1s; animation-duration: 3s; }
.magic-firefly:nth-child(4) { left: 55%; top: 75%; animation-delay: 1.5s; animation-duration: 3.8s; }
.magic-firefly:nth-child(5) { left: 70%; top: 90%; animation-delay: 0.3s; animation-duration: 4.2s; }
.magic-firefly:nth-child(6) { left: 85%; top: 65%; animation-delay: 0.8s; animation-duration: 3.2s; }
.magic-firefly:nth-child(7) { left: 15%; top: 60%; animation-delay: 2s; animation-duration: 3.6s; }
.magic-firefly:nth-child(8) { left: 60%; top: 55%; animation-delay: 1.2s; animation-duration: 4.5s; }

/* === 动画二：符文闪烁（Rune Flicker） ===
   加载动画或特定图标的持续动画，魔法符文闪烁效果 */

@keyframes magic-rune-flicker {
    0%, 100% {
        opacity: 0.4;
        text-shadow: 0 0 4px rgba(46, 204, 113, 0.3);
    }
    25% {
        opacity: 1;
        text-shadow: 0 0 12px rgba(46, 204, 113, 0.8), 0 0 24px rgba(241, 196, 15, 0.4);
    }
    50% {
        opacity: 0.6;
        text-shadow: 0 0 6px rgba(241, 196, 15, 0.5);
    }
    75% {
        opacity: 0.9;
        text-shadow: 0 0 16px rgba(46, 204, 113, 0.6), 0 0 32px rgba(46, 204, 113, 0.2);
    }
}

@keyframes magic-rune-border-flicker {
    0%, 100% {
        border-color: rgba(46, 204, 113, 0.3);
        box-shadow: 0 0 5px rgba(46, 204, 113, 0.1);
    }
    50% {
        border-color: rgba(46, 204, 113, 0.8);
        box-shadow: 0 0 15px rgba(46, 204, 113, 0.4), 0 0 30px rgba(46, 204, 113, 0.1);
    }
}

.magic-rune-text {
    animation: magic-rune-flicker 3s ease-in-out infinite;
}

.magic-rune-border {
    animation: magic-rune-border-flicker 4s ease-in-out infinite;
}

/* 加载动画 - 符文旋转 */
@keyframes magic-rune-spin {
    0% {
        transform: rotate(0deg);
        opacity: 0.5;
    }
    50% {
        opacity: 1;
        text-shadow: 0 0 20px rgba(46, 204, 113, 0.8);
    }
    100% {
        transform: rotate(360deg);
        opacity: 0.5;
    }
}

.magic-loading-rune {
    display: inline-block;
    font-size: 2rem;
    color: var(--magic-emerald);
    animation: magic-rune-spin 2s linear infinite;
}

/* === 动画三：藤蔓生长（Vine Growth） ===
   鼠标悬停在卡片或按钮上时触发，角落出现藤蔓生长效果 */

@keyframes magic-vine-grow-tl {
    0% {
        width: 0;
        height: 0;
        opacity: 0;
    }
    100% {
        width: 30px;
        height: 30px;
        opacity: 1;
    }
}

@keyframes magic-vine-grow-br {
    0% {
        width: 0;
        height: 0;
        opacity: 0;
    }
    100% {
        width: 30px;
        height: 30px;
        opacity: 1;
    }
}

.magic-vine-hover {
    position: relative;
    overflow: hidden;
}

.magic-vine-hover::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    border-top: 2px solid var(--magic-emerald);
    border-left: 2px solid var(--magic-emerald);
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: 1;
    pointer-events: none;
}

.magic-vine-hover::after {
    content: "";
    position: absolute;
    bottom: 0;
    right: 0;
    width: 0;
    height: 0;
    border-bottom: 2px solid var(--magic-emerald);
    border-right: 2px solid var(--magic-emerald);
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: 1;
    pointer-events: none;
}

.magic-vine-hover:hover::before {
    width: 40px;
    height: 40px;
    opacity: 1;
    box-shadow: -5px -5px 10px rgba(46, 204, 113, 0.2);
}

.magic-vine-hover:hover::after {
    width: 40px;
    height: 40px;
    opacity: 1;
    box-shadow: 5px 5px 10px rgba(46, 204, 113, 0.2);
}

/* 按钮藤蔓效果 */
.magic-btn.magic-vine-hover::before,
.magic-btn.magic-vine-hover::after {
    border-color: var(--magic-starlight);
}

.magic-btn.magic-vine-hover:hover::before {
    box-shadow: -5px -5px 10px rgba(241, 196, 15, 0.2);
}

.magic-btn.magic-vine-hover:hover::after {
    box-shadow: 5px 5px 10px rgba(241, 196, 15, 0.2);
}

/* === 动画四：迷雾飘动（Mist Flutter） ===
   特定区域持续运行的装饰动画，模拟漂浮在森林中的神秘迷雾 */

@keyframes magic-mist-drift-left {
    0% {
        transform: translateX(-10%) translateY(0);
        opacity: 0.15;
    }
    50% {
        transform: translateX(5%) translateY(-10px);
        opacity: 0.25;
    }
    100% {
        transform: translateX(-10%) translateY(0);
        opacity: 0.15;
    }
}

@keyframes magic-mist-drift-right {
    0% {
        transform: translateX(10%) translateY(0);
        opacity: 0.1;
    }
    50% {
        transform: translateX(-5%) translateY(8px);
        opacity: 0.2;
    }
    100% {
        transform: translateX(10%) translateY(0);
        opacity: 0.1;
    }
}

.magic-mist-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 1;
}

.magic-mist-layer {
    position: absolute;
    width: 120%;
    height: 60%;
    border-radius: 50%;
    filter: blur(40px);
}

.magic-mist-layer--top {
    top: -20%;
    left: -10%;
    background: radial-gradient(ellipse, rgba(46, 204, 113, 0.08) 0%, transparent 70%);
    animation: magic-mist-drift-left 8s ease-in-out infinite;
}

.magic-mist-layer--bottom {
    bottom: -20%;
    right: -10%;
    background: radial-gradient(ellipse, rgba(30, 58, 43, 0.15) 0%, transparent 70%);
    animation: magic-mist-drift-right 10s ease-in-out infinite;
}

.magic-mist-layer--mid {
    top: 30%;
    left: -5%;
    width: 80%;
    height: 40%;
    background: radial-gradient(ellipse, rgba(46, 204, 113, 0.05) 0%, transparent 60%);
    animation: magic-mist-drift-left 12s ease-in-out infinite;
    animation-delay: 2s;
}

/* === 页面入场动画 === */
@keyframes magic-fade-in-up {
    0% {
        opacity: 0;
        transform: translateY(30px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes magic-fade-in {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

.magic-animate-in {
    opacity: 0;
    animation: magic-fade-in-up 0.8s ease forwards;
}

.magic-animate-in--delay-1 { animation-delay: 0.2s; }
.magic-animate-in--delay-2 { animation-delay: 0.4s; }
.magic-animate-in--delay-3 { animation-delay: 0.6s; }
.magic-animate-in--delay-4 { animation-delay: 0.8s; }

/* === 发光树叶图标动画 === */
@keyframes magic-leaf-glow {
    0%, 100% {
        opacity: 0.5;
        filter: brightness(0.8);
    }
    50% {
        opacity: 1;
        filter: brightness(1.3);
    }
}

.magic-leaf-icon {
    display: inline-block;
    animation: magic-leaf-glow 2s ease-in-out infinite;
}

/* === 数字滚动效果 === */
@keyframes magic-number-pulse {
    0%, 100% {
        text-shadow: 0 0 10px rgba(241, 196, 15, 0.3);
    }
    50% {
        text-shadow: 0 0 25px rgba(241, 196, 15, 0.7), 0 0 50px rgba(241, 196, 15, 0.3);
    }
}

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

/* === 脉冲发光效果（用于徽章） === */
@keyframes magic-badge-pulse {
    0%, 100% {
        box-shadow: 0 0 10px rgba(241, 196, 15, 0.3);
    }
    50% {
        box-shadow: 0 0 25px rgba(241, 196, 15, 0.6), 0 0 50px rgba(241, 196, 15, 0.2);
    }
}

.magic-badge-glow {
    animation: magic-badge-pulse 3s ease-in-out infinite;
}

/* === 文字渐显效果 === */
@keyframes magic-text-reveal {
    0% {
        clip-path: inset(0 100% 0 0);
    }
    100% {
        clip-path: inset(0 0 0 0);
    }
}

.magic-text-reveal {
    animation: magic-text-reveal 1s ease forwards;
}

/* === 减少动画偏好 === */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
