/*
   统一动画系统 - Sora视频生成平台
   版本: 1.0
   创建时间: 2026-01-20
*/

:root {
    /* 动画时长 */
    --duration-fast: 0.2s;
    --duration-normal: 0.3s;
    --duration-slow: 0.5s;

    /* 缓动函数 */
    --ease-in: cubic-bezier(0.4, 0, 1, 1);
    --ease-out: cubic-bezier(0, 0, 0.2, 1);
    --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ==================== 核心动画关键帧 ==================== */

/* 淡入淡出 */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

/* 滑动动画 */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

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

/* 缩放动画 */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

@keyframes scalePulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

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

@keyframes spin3D {
    0% {
        transform: rotate3d(0, 1, 0, 0deg);
    }
    100% {
        transform: rotate3d(0, 1, 0, 360deg);
    }
}

/* 弹跳效果 */
@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* 脉冲效果 */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(0.95);
    }
}

@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 0 0 20px rgba(249, 115, 22, 0.3);
    }
    50% {
        box-shadow: 0 0 40px rgba(249, 115, 22, 0.6);
    }
}

/* 波纹扩散 */
@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

@keyframes ringPulse {
    0% {
        transform: scale(0.8);
        opacity: 0.8;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* 骨架屏加载 */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* 进度条动画 */
@keyframes progress {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

@keyframes progressBar {
    from {
        width: 0%;
    }
    to {
        width: 100%;
    }
}

/* 抖动效果 */
@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

/* Logo专属动画 */
@keyframes logoFloat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

@keyframes logoGlow {
    0%, 100% {
        box-shadow:
            0 0 20px rgba(249, 115, 22, 0.3),
            0 0 40px rgba(249, 115, 22, 0.2),
            inset 0 0 20px rgba(249, 115, 22, 0.1);
        filter: brightness(1);
    }
    50% {
        box-shadow:
            0 0 30px rgba(249, 115, 22, 0.5),
            0 0 60px rgba(249, 115, 22, 0.3),
            inset 0 0 30px rgba(249, 115, 22, 0.2);
        filter: brightness(1.2);
    }
}

@keyframes logoRotate {
    0% {
        transform: rotate3d(0, 1, 0, 0deg);
    }
    100% {
        transform: rotate3d(0, 1, 0, 360deg);
    }
}

@keyframes logoParticle {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--x, 20px), var(--y, -40px)) scale(0);
        opacity: 0;
    }
}

/* 渐变移动 */
@keyframes gradientMove {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

@keyframes gradientShift {
    0% {
        background-position: 0% 0%;
    }
    50% {
        background-position: 100% 100%;
    }
    100% {
        background-position: 0% 0%;
    }
}

/* 翻转效果 */
@keyframes flip {
    0% {
        transform: perspective(400px) rotateY(0);
    }
    100% {
        transform: perspective(400px) rotateY(360deg);
    }
}

@keyframes flipIn {
    0% {
        transform: perspective(400px) rotateY(90deg);
        opacity: 0;
    }
    100% {
        transform: perspective(400px) rotateY(0);
        opacity: 1;
    }
}

/* 闪烁效果 */
@keyframes blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.3;
    }
}

/* 数字滚动 */
@keyframes countUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==================== 应用类 ==================== */

/* 基础动画 */
.animate-fade-in {
    animation: fadeIn var(--duration-normal) var(--ease-out) forwards;
}

.animate-fade-out {
    animation: fadeOut var(--duration-normal) var(--ease-in) forwards;
}

.animate-slide-up {
    animation: slideUp var(--duration-normal) var(--ease-out) forwards;
}

.animate-slide-down {
    animation: slideDown var(--duration-normal) var(--ease-out) forwards;
}

.animate-slide-left {
    animation: slideInLeft var(--duration-normal) var(--ease-out) forwards;
}

.animate-slide-right {
    animation: slideInRight var(--duration-normal) var(--ease-out) forwards;
}

.animate-scale-in {
    animation: scaleIn var(--duration-normal) var(--ease-bounce) forwards;
}

.animate-scale-out {
    animation: scaleOut var(--duration-normal) var(--ease-in) forwards;
}

.animate-bounce {
    animation: bounce 1s ease-in-out infinite;
}

.animate-bounce-in {
    animation: bounceIn var(--duration-slow) var(--ease-out);
}

/* 加载动画 */
.animate-spin {
    animation: spin 1s linear infinite;
}

.animate-pulse {
    animation: pulse 2s var(--ease-in-out) infinite;
}

.animate-shimmer {
    background: linear-gradient(
        90deg,
        rgba(255,255,255,0.05) 0%,
        rgba(255,255,255,0.1) 50%,
        rgba(255,255,255,0.05) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* ==================== 组件动画 ==================== */

/* 卡片入场动画 */
.task-card {
    animation: slideUp 0.4s var(--ease-out);
}

.task-card:nth-child(1) { animation-delay: 0s; }
.task-card:nth-child(2) { animation-delay: 0.05s; }
.task-card:nth-child(3) { animation-delay: 0.1s; }
.task-card:nth-child(4) { animation-delay: 0.15s; }
.task-card:nth-child(5) { animation-delay: 0.2s; }
.task-card:nth-child(6) { animation-delay: 0.25s; }
.task-card:nth-child(n+7) { animation-delay: 0.3s; }

/* 模态框动画 */
.modal {
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--duration-normal) var(--ease-out);
}

.modal.active {
    opacity: 1;
    pointer-events: auto;
}

.modal.active .modal-content {
    animation: scaleIn 0.4s var(--ease-bounce);
}

/* Toast通知动画 */
.toast {
    animation: slideInRight var(--duration-normal) var(--ease-out);
}

.toast.removing {
    animation: slideInRight var(--duration-normal) var(--ease-in) reverse;
}

/* 按钮ripple效果 */
.btn {
    position: relative;
    overflow: hidden;
}

.btn .ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transform: scale(0);
    animation: ripple 0.6s ease-out;
    pointer-events: none;
}

/* 状态指示器 */
.status-badge.processing::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255,255,255,0.2),
        transparent
    );
    animation: progress 1.5s infinite;
}

/* 错误提示动画 */
.error-message {
    animation: slideDown var(--duration-normal) var(--ease-out);
}

.form-group input.error,
.form-group textarea.error {
    animation: shake 0.4s;
}

/* 加载指示器 */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px;
}

.spinner-circle {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(249, 115, 22, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-text {
    color: var(--text-muted);
    font-size: 14px;
    animation: pulse 2s infinite;
}

/* 骨架屏 */
.skeleton {
    background: linear-gradient(
        90deg,
        rgba(255,255,255,0.05) 0%,
        rgba(255,255,255,0.1) 50%,
        rgba(255,255,255,0.05) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}

.skeleton-card {
    width: 100%;
    height: 200px;
    margin-bottom: 20px;
}

.skeleton-text {
    height: 16px;
    margin-bottom: 8px;
    width: 100%;
}

.skeleton-text:last-child {
    width: 60%;
}

/* ==================== 页面过渡 ==================== */

.page-section {
    animation: fadeIn 0.3s var(--ease-out);
}

.page-exit {
    animation: fadeOut 0.3s var(--ease-in) forwards;
}

.page-enter {
    animation: slideUp 0.4s var(--ease-out);
}

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

/* 硬件加速提示 */
.animate-fade-in,
.animate-slide-up,
.animate-slide-down,
.animate-scale-in,
.task-card,
.modal-content {
    will-change: transform, opacity;
}

/* 动画完成后移除will-change */
.animation-complete {
    will-change: auto;
}

/* ==================== 可访问性 ==================== */

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

    .animate-spin,
    .animate-pulse,
    .animate-bounce {
        animation: none !important;
    }
}

/* ==================== 高级效果 ==================== */

/* 3D翻转效果 */
.flip-card {
    perspective: 1000px;
}

.flip-card-inner {
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.flip-card:hover .flip-card-inner {
    transform: rotateY(180deg);
}

/* 粒子效果 */
@keyframes particle {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--x), var(--y)) scale(0);
        opacity: 0;
    }
}

.particle {
    animation: particle 1s ease-out forwards;
}

/* 文字渐显效果 */
@keyframes textReveal {
    from {
        clip-path: polygon(0 0, 0 0, 0 100%, 0 100%);
    }
    to {
        clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
    }
}

.text-reveal {
    animation: textReveal 0.6s var(--ease-out) forwards;
}

/* 数字计数动画 */
.counter {
    animation: countUp 0.6s var(--ease-out);
}
