/**
 * 动画效果样式
 *
 * 包含触摸反馈、页面转场、加载动画等
 */

/* ============================================
   触摸反馈动画
   ============================================ */

/* 按钮按下效果 */
button:active {
    animation: pressDown 0.1s ease-out;
}

@keyframes pressDown {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(0.95);
    }
    100% {
        transform: scale(1);
    }
}

/* 卡片触摸效果 */
.lottery-card:active {
    animation: cardPress 0.2s ease-out;
}

@keyframes cardPress {
    0% {
        transform: scale(1);
        box-shadow: var(--shadow-sm);
    }
    50% {
        transform: scale(0.98);
        box-shadow: var(--shadow-md);
    }
    100% {
        transform: scale(1);
        box-shadow: var(--shadow-sm);
    }
}

/* ============================================
   淡入淡出动画
   ============================================ */

.fade-in {
    animation: fadeIn 0.3s ease-in;
}

.fade-out {
    animation: fadeOut 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* ============================================
   滑动动画
   ============================================ */

.slide-up {
    animation: slideUp 0.3s ease-out;
}

.slide-down {
    animation: slideDown 0.3s ease-out;
}

.slide-left {
    animation: slideLeft 0.3s ease-out;
}

.slide-right {
    animation: slideRight 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

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

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

@keyframes slideRight {
    from {
        transform: translateX(-20px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ============================================
   缩放动画
   ============================================ */

.scale-in {
    animation: scaleIn 0.2s ease-out;
}

.scale-out {
    animation: scaleOut 0.2s ease-out;
}

@keyframes scaleIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes scaleOut {
    from {
        transform: scale(1);
        opacity: 1;
    }
    to {
        transform: scale(0.9);
        opacity: 0;
    }
}

/* ============================================
   旋转动画
   ============================================ */

.spin {
    animation: spin 1s linear infinite;
}

.spin-slow {
    animation: spin 2s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   脉冲动画（用于加载状态）
   ============================================ */

.pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* ============================================
   弹跳动画
   ============================================ */

.bounce {
    animation: bounce 1s infinite;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(-5%);
        animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
    }
    50% {
        transform: translateY(0);
        animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
    }
}

/* ============================================
   震动动画（用于错误提示）
   ============================================ */

.shake {
    animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes shake {
    10%, 90% {
        transform: translateX(-1px);
    }
    20%, 80% {
        transform: translateX(2px);
    }
    30%, 50%, 70% {
        transform: translateX(-4px);
    }
    40%, 60% {
        transform: translateX(4px);
    }
}

/* ============================================
   加载动画
   ============================================ */

/* 旋转加载器 */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-sm {
    width: 16px;
    height: 16px;
}

.spinner-lg {
    width: 32px;
    height: 32px;
}

/* 点状加载器 */
.dots {
    display: inline-flex;
    gap: var(--spacing-xs);
}

.dots span {
    width: 8px;
    height: 8px;
    background: var(--primary-color);
    border-radius: 50%;
    animation: dotsBounce 1.4s infinite ease-in-out both;
}

.dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes dotsBounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ============================================
   卡片进入动画
   ============================================ */

.lottery-cards .lottery-card {
    animation: cardEnter 0.3s ease-out backwards;
}

.lottery-cards .lottery-card:nth-child(1) { animation-delay: 0.05s; }
.lottery-cards .lottery-card:nth-child(2) { animation-delay: 0.1s; }
.lottery-cards .lottery-card:nth-child(3) { animation-delay: 0.15s; }
.lottery-cards .lottery-card:nth-child(4) { animation-delay: 0.2s; }
.lottery-cards .lottery-card:nth-child(5) { animation-delay: 0.25s; }

@keyframes cardEnter {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   表格行进入动画
   ============================================ */

.lottery-table tbody tr {
    animation: tableRowEnter 0.2s ease-out backwards;
}

@keyframes tableRowEnter {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ============================================
   筛选面板动画
   ============================================ */

.filter-panel:not(.hidden) .panel-overlay {
    animation: fadeIn 0.3s ease-out;
}

.filter-panel:not(.hidden) .panel-content {
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ============================================
   过渡辅助类
   ============================================ */

.transition-all {
    transition: all var(--transition-base);
}

.transition-colors {
    transition: color var(--transition-fast),
                background-color var(--transition-fast),
                border-color var(--transition-fast);
}

.transition-transform {
    transition: transform var(--transition-base);
}

.transition-opacity {
    transition: opacity var(--transition-base);
}

/* ============================================
   减少动画模式（尊重用户偏好）
   ============================================ */

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

/* ============================================
   性能优化
   ============================================ */

/* 使用GPU加速 */
.gpu-accelerated {
    transform: translateZ(0);
    will-change: transform;
}

/* 避免布局抖动 */
.layout-stable {
    contain: layout style paint;
}

/* ============================================
   特殊效果
   ============================================ */

/* 新记录高亮效果 */
.new-record {
    animation: newRecordHighlight 2s ease-out;
}

@keyframes newRecordHighlight {
    0% {
        background-color: rgba(46, 204, 113, 0.3);
    }
    100% {
        background-color: transparent;
    }
}

/* 错误震动效果（配合shake） */
.error-shake {
    animation: shake 0.5s, fadeIn 0.3s;
    border-color: var(--danger-color);
}

/* 成功提示效果 */
.success-flash {
    animation: successFlash 0.5s ease-out;
}

@keyframes successFlash {
    0% {
        background-color: rgba(46, 204, 113, 0.2);
    }
    100% {
        background-color: transparent;
    }
}

/* ============================================
   暗色模式动画调整
   ============================================ */

@media (prefers-color-scheme: dark) {
    .new-record {
        animation-name: newRecordHighlightDark;
    }

    @keyframes newRecordHighlightDark {
        0% {
            background-color: rgba(46, 204, 113, 0.15);
        }
        100% {
            background-color: transparent;
        }
    }
}

/* ============================================
   打印时禁用所有动画
   ============================================ */

@media print {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}
