/* 页面切换动画 */
.page {
    animation-duration: 0.4s;
    animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    animation-fill-mode: both;
}

.page.active {
    animation-name: slideInUp;
}

@keyframes slideInUp {
    0% {
        opacity: 0;
        transform: translateY(30px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 角色卡片动画 */
.role-card {
    animation: fadeInScale 0.6s ease-out;
    animation-fill-mode: both;
}

.role-card:nth-child(1) { animation-delay: 0.1s; }
.role-card:nth-child(2) { animation-delay: 0.2s; }
.role-card:nth-child(3) { animation-delay: 0.3s; }
.role-card:nth-child(4) { animation-delay: 0.4s; }
.role-card:nth-child(5) { animation-delay: 0.5s; }

@keyframes fadeInScale {
    0% {
        opacity: 0;
        transform: scale(0.8) translateY(20px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* 卡片翻转动画 */
.email-card {
    animation: cardAppear 0.8s ease-out;
    animation-fill-mode: both;
}

.email-card:nth-child(1) { animation-delay: 0.1s; }
.email-card:nth-child(2) { animation-delay: 0.2s; }
.email-card:nth-child(3) { animation-delay: 0.3s; }
.email-card:nth-child(4) { animation-delay: 0.4s; }
.email-card:nth-child(5) { animation-delay: 0.5s; }
.email-card:nth-child(6) { animation-delay: 0.6s; }

@keyframes cardAppear {
    0% {
        opacity: 0;
        transform: rotateY(-90deg) scale(0.8);
    }
    50% {
        opacity: 0.5;
        transform: rotateY(-45deg) scale(0.9);
    }
    100% {
        opacity: 1;
        transform: rotateY(0deg) scale(1);
    }
}

.email-card.flipping {
    animation: cardFlip 0.6s ease-in-out;
}

@keyframes cardFlip {
    0% { transform: rotateY(0deg) scale(1); }
    50% { transform: rotateY(90deg) scale(1.05); }
    100% { transform: rotateY(180deg) scale(1); }
}

/* 模态框动画 */
.email-modal {
    animation-duration: 0.3s;
    animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

.email-modal.active {
    animation-name: modalFadeIn;
}

@keyframes modalFadeIn {
    0% {
        opacity: 0;
        backdrop-filter: blur(0px);
    }
    100% {
        opacity: 1;
        backdrop-filter: blur(8px);
    }
}

.email-modal-content {
    animation-duration: 0.4s;
    animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

.email-modal.active .email-modal-content {
    animation-name: modalSlideIn;
}

@keyframes modalSlideIn {
    0% {
        opacity: 0;
        transform: scale(0.8) translateY(40px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* 按钮悬停动画 */
.btn {
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

.btn:hover::before {
    left: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    background-size: 200% 200%;
    animation: gradientShift 3s ease infinite;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* 进度条动画 */
.progress-fill {
    position: relative;
    overflow: hidden;
}

.progress-fill::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, 
        rgba(255,255,255,0) 0%, 
        rgba(255,255,255,0.3) 50%, 
        rgba(255,255,255,0) 100%);
    transform: translateX(-100%);
    animation: progressShine 2s ease-in-out infinite;
}

@keyframes progressShine {
    0% { transform: translateX(-100%); }
    50% { transform: translateX(100%); }
    100% { transform: translateX(100%); }
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-light);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 消息提示动画 */
.message {
    animation: messageSlideIn 0.3s ease-out;
}

@keyframes messageSlideIn {
    0% {
        opacity: 0;
        transform: translateY(-20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 响应式动画优化 */
@media (max-width: 768px) {
    .page {
        animation-duration: 0.3s;
    }
    
    .role-card,
    .email-card {
        animation-duration: 0.4s;
    }
    
    .email-modal-content {
        animation-duration: 0.3s;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}