/* 由后往前冲出动画 - 3D 透视效果 */
@keyframes flyIn {
    0% {
        transform: translateZ(-500px) scale(0.3);  /* 从远处开始，很小 */
        opacity: 0;                                 /* 透明 */
        filter: blur(5px);                          /* 模糊 */
    }
    60% {
        transform: translateZ(0) scale(1.1);        /* 冲到前面，稍大 */
        opacity: 1;
        filter: blur(0);
    }
    100% {
        transform: translateZ(0) scale(1);          /* 回到正常大小 */
        opacity: 0.8;
        filter: blur(0);
    }
}

/* 缓慢漂浮动画 - 为名片添加随机移动效果 */
@keyframes float {
    0%, 100% {
        transform: translate(0, 0);
    }
    25% {
        transform: translate(10px, -10px);
    }
    50% {
        transform: translate(-5px, 5px);
    }
    75% {
        transform: translate(5px, 10px);
    }
}

/* 应用漂浮动画到所有名片（待机状态） */
.card-wall .name-card {
    animation: float 8s ease-in-out infinite;
}

/* 为不同名片添加不同延迟和时长，增加自然感 */
.card-wall .name-card:nth-child(odd) {
    animation-duration: 10s;
    animation-delay: 0s;
}

.card-wall .name-card:nth-child(even) {
    animation-duration: 12s;
    animation-delay: 1s;
}

.card-wall .name-card:nth-child(3n) {
    animation-duration: 9s;
    animation-delay: 2s;
}

/* 抽奖时：停止漂浮，应用飞入动画 */
.card-wall.rolling .name-card {
    animation: flyIn 0.4s ease-out infinite;
}

/* 抽奖时不同名片的延迟（增加错落感）*/
.card-wall.rolling .name-card:nth-child(10n+1) { animation-delay: 0s; }
.card-wall.rolling .name-card:nth-child(10n+2) { animation-delay: 0.05s; }
.card-wall.rolling .name-card:nth-child(10n+3) { animation-delay: 0.1s; }
.card-wall.rolling .name-card:nth-child(10n+4) { animation-delay: 0.15s; }
.card-wall.rolling .name-card:nth-child(10n+5) { animation-delay: 0.2s; }
.card-wall.rolling .name-card:nth-child(10n+6) { animation-delay: 0.25s; }
.card-wall.rolling .name-card:nth-child(10n+7) { animation-delay: 0.3s; }
.card-wall.rolling .name-card:nth-child(10n+8) { animation-delay: 0.35s; }
.card-wall.rolling .name-card:nth-child(10n+9) { animation-delay: 0.4s; }
.card-wall.rolling .name-card:nth-child(10n+10) { animation-delay: 0.45s; }

/* 中奖闪烁动画 */
@keyframes winnerGlow {
    0%, 100% {
        box-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
        transform: scale(1);
    }
    25% {
        box-shadow: 0 0 40px rgba(0, 255, 255, 0.8);
        transform: scale(1.1);
    }
    50% {
        box-shadow: 0 0 60px rgba(0, 255, 255, 1);
        transform: scale(1.15);
    }
    75% {
        box-shadow: 0 0 40px rgba(0, 255, 255, 0.8);
        transform: scale(1.1);
    }
}

/* 淡入动画 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 历史记录项淡入 */
.history-item {
    animation: fadeIn 0.4s ease-out;
}

/* 按钮按下效果 */
@keyframes buttonPress {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(0.95);
    }
    100% {
        transform: scale(1);
    }
}

.btn:active:not(:disabled) {
    animation: buttonPress 0.2s ease;
}

/* 光晕呼吸效果 */
@keyframes breathe {
    0%, 100% {
        box-shadow: 0 0 20px rgba(0, 212, 255, 0.2);
    }
    50% {
        box-shadow: 0 0 40px rgba(0, 212, 255, 0.4);
    }
}

.panel-card {
    animation: breathe 3s ease-in-out infinite;
}

.header {
    animation: breathe 4s ease-in-out infinite;
}

/* 标题光效动画 */
@keyframes titleShine {
    0% {
        text-shadow: 0 0 20px rgba(0, 212, 255, 0.5);
    }
    50% {
        text-shadow: 0 0 40px rgba(0, 212, 255, 0.8), 0 0 60px rgba(0, 102, 255, 0.6);
    }
    100% {
        text-shadow: 0 0 20px rgba(0, 212, 255, 0.5);
    }
}

.title {
    animation: titleShine 3s ease-in-out infinite;
}

/* 统计数字跳动 */
@keyframes numberBounce {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
}

.stat-value.update {
    animation: numberBounce 0.5s ease;
}

/* 减速停止效果 - 通过 JavaScript 动态添加的类 */
.card-wall.slowing .name-card {
    animation-duration: 0.8s;
    animation-timing-function: ease-out;
}

.card-wall.stopping .name-card {
    animation-duration: 1.2s;
    animation-timing-function: ease-out;
}

.card-wall.stopped .name-card {
    animation: float 8s ease-in-out infinite;  /* 恢复漂浮动画 */
    opacity: 1;
    transform: translateZ(0) scale(1);
}

/* 名单项淡入淡出过渡 */
.name-card .name,
.name-card .student-id {
    transition: all 0.15s ease;
}

/* 成功提示闪烁 */
@keyframes successFlash {
    0%, 100% {
        background: rgba(0, 255, 136, 0.1);
    }
    50% {
        background: rgba(0, 255, 136, 0.3);
    }
}

.success-flash {
    animation: successFlash 0.5s ease 3;
}

/* 错误提示抖动 */
@keyframes errorShake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-10px);
    }
    75% {
        transform: translateX(10px);
    }
}

.error-shake {
    animation: errorShake 0.4s ease;
}

/* 旋转加载动画 */
@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.loading {
    animation: rotate 1s linear infinite;
}

/* 边框流光效果 */
@keyframes borderFlow {
    0% {
        border-color: rgba(0, 212, 255, 0.3);
    }
    50% {
        border-color: rgba(0, 212, 255, 0.8);
    }
    100% {
        border-color: rgba(0, 212, 255, 0.3);
    }
}

.name-card {
    animation: borderFlow 2s ease-in-out infinite;
}

/* 滚动条平滑滚动 */
.history-list {
    scroll-behavior: smooth;
}

/* 悬停放大效果 */
.btn:hover:not(:disabled) {
    transform: translateY(-2px) scale(1.02);
    transition: all 0.3s ease;
}

/* 全屏过渡 */
.container {
    transition: padding 0.3s ease;
}

:fullscreen .container {
    padding: 10px;
}

:-webkit-full-screen .container {
    padding: 10px;
}

:-moz-full-screen .container {
    padding: 10px;
}

/* 响应式动画性能优化 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==================== 中奖卡片动画（页面内展示） ==================== */

/* 中奖卡片弹入动画 */
@keyframes winnerPopIn {
    0% {
        opacity: 0;
        transform: scale(0.5) translateY(-50px);
    }
    70% {
        transform: scale(1.1) translateY(0);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.winner-item {
    animation: winnerPopIn 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) backwards;
}

/* 依次弹入 */
.winner-item:nth-child(1) { animation-delay: 0.1s; }
.winner-item:nth-child(2) { animation-delay: 0.2s; }
.winner-item:nth-child(3) { animation-delay: 0.3s; }
.winner-item:nth-child(4) { animation-delay: 0.4s; }
.winner-item:nth-child(5) { animation-delay: 0.5s; }
.winner-item:nth-child(6) { animation-delay: 0.6s; }
.winner-item:nth-child(7) { animation-delay: 0.7s; }
.winner-item:nth-child(8) { animation-delay: 0.8s; }
.winner-item:nth-child(9) { animation-delay: 0.9s; }
.winner-item:nth-child(n+10) { animation-delay: 1s; }

/* 持续发光效果 */
.winner-item {
    animation: winnerPopIn 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) backwards,
               winnerGlow 2s ease-in-out infinite 0.6s;
}
