/**
 * 🎬 动效系统 - Animations
 * 版本: 1.1.0
 * 基于: 通用产品设计规范
 */

/* ==================== 基础动画关键帧 ==================== */

/* 淡入上移 */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 淡入下移 */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* 缩放弹出 */
@keyframes scaleUp {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* 从右滑入 */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* 从左滑入 */
@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* 从下滑入 */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

/* 脉冲动画 */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* 霓虹发光呼吸 */
@keyframes glowPulse {
    0%, 100% {
        box-shadow: 0 0 20px var(--primary-glow);
    }
    50% {
        box-shadow: 0 0 40px var(--primary-glow), 0 0 60px var(--primary-glow);
    }
}

/* 文字发光 */
@keyframes textGlow {
    0%, 100% {
        text-shadow: 0 0 20px var(--primary-glow);
    }
    50% {
        text-shadow: 0 0 40px var(--primary-glow), 0 0 60px var(--primary-glow);
    }
}

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

/* 弹跳 */
@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
        animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
    }
    50% {
        transform: translateY(-15px);
        animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
    }
}

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

/* 心跳 */
@keyframes heartbeat {
    0% { transform: scale(1); }
    14% { transform: scale(1.15); }
    28% { transform: scale(1); }
    42% { transform: scale(1.15); }
    70% { transform: scale(1); }
}

/* 点赞心形动画 */
@keyframes likeHeart {
    0% { transform: scale(1); }
    15% { transform: scale(1.4); }
    30% { transform: scale(1.2); }
    45% { transform: scale(1.35); }
    60% { transform: scale(1); }
}

/* 漂浮动画 */
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

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

/* 进度条 */
@keyframes progressBar {
    from { width: 0; }
}

/* 进度条无限 */
@keyframes progressIndeterminate {
    0% {
        width: 0;
        margin-left: 0;
    }
    50% {
        width: 70%;
        margin-left: 15%;
    }
    100% {
        width: 0;
        margin-left: 100%;
    }
}

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

/* 轮播指示器进度 */
@keyframes indicatorProgress {
    to { width: 100%; }
}

/* Logo呼吸 */
@keyframes logoBreath {
    0%, 100% { 
        transform: scale(1);
        opacity: 1;
    }
    50% { 
        transform: scale(1.1);
        opacity: 0.8;
    }
}

/* 加载点弹跳 */
@keyframes pulseBounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Toast滑入 */
@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

/* ==================== 动画工具类 ==================== */

/* 淡入上移 */
.animate-fade-in-up {
    animation: fadeInUp 0.6s var(--ease-out) forwards;
}

/* 淡入下移 */
.animate-fade-in-down {
    animation: fadeInDown 0.6s var(--ease-out) forwards;
}

/* 淡入缩放 */
.animate-scale-in {
    animation: scaleIn 0.4s var(--ease-spring) forwards;
}

/* 缩放弹出 */
.animate-scale-up {
    animation: scaleUp 0.5s var(--ease-spring) forwards;
}

/* 从右滑入 */
.animate-slide-right {
    animation: slideInRight 0.5s var(--ease-out) forwards;
}

/* 从左滑入 */
.animate-slide-left {
    animation: slideInLeft 0.5s var(--ease-out) forwards;
}

/* 从下滑入 */
.animate-slide-up {
    animation: slideInUp 0.5s var(--ease-out) forwards;
}

/* 淡入 */
.animate-fade-in {
    animation: fadeIn 0.4s ease forwards;
}

/* 淡出 */
.animate-fade-out {
    animation: fadeOut 0.3s ease forwards;
}

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

/* 发光脉冲 */
.animate-glow-pulse {
    animation: glowPulse 2s var(--ease-in-out) infinite;
}

/* 文字发光 */
.animate-text-glow {
    animation: textGlow 2s var(--ease-in-out) infinite;
}

/* 旋转 */
.animate-spin {
    animation: spin 1s linear infinite;
}

/* 弹跳 */
.animate-bounce {
    animation: bounce 1s infinite;
}

/* 摇晃 */
.animate-shake {
    animation: shake 0.5s ease;
}

/* 心跳 */
.animate-heartbeat {
    animation: heartbeat 1.5s ease-in-out infinite;
}

/* 点赞 */
.animate-like {
    animation: likeHeart 0.8s var(--ease-out);
}

/* 漂浮 */
.animate-float {
    animation: float 3s ease-in-out infinite;
}

/* 闪烁 */
.animate-blink {
    animation: blink 1s step-end infinite;
}

/* ==================== 交错动画 ==================== */
.stagger-animation > * {
    opacity: 0;
    animation: fadeInUp 0.6s var(--ease-out) forwards;
}

.stagger-animation > *:nth-child(1) { animation-delay: 0.1s; }
.stagger-animation > *:nth-child(2) { animation-delay: 0.2s; }
.stagger-animation > *:nth-child(3) { animation-delay: 0.3s; }
.stagger-animation > *:nth-child(4) { animation-delay: 0.4s; }
.stagger-animation > *:nth-child(5) { animation-delay: 0.5s; }
.stagger-animation > *:nth-child(6) { animation-delay: 0.6s; }
.stagger-animation > *:nth-child(7) { animation-delay: 0.7s; }
.stagger-animation > *:nth-child(8) { animation-delay: 0.8s; }
.stagger-animation > *:nth-child(9) { animation-delay: 0.9s; }
.stagger-animation > *:nth-child(10) { animation-delay: 1s; }

/* ==================== 骨架屏 ==================== */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-elevated) 25%,
        var(--bg-surface) 50%,
        var(--bg-elevated) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
}

.skeleton-title {
    height: 1.5em;
    width: 60%;
    margin-bottom: 1em;
}

.skeleton-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
}

.skeleton-card {
    aspect-ratio: 2/3;
    border-radius: var(--radius-xl);
}

.skeleton-image {
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: var(--radius-lg);
}

/* ==================== 微交互效果 ==================== */

/* 按钮点击效果 */
.btn-press:active {
    transform: scale(0.96);
}

/* 卡片悬停抬升 */
.card-hover-lift {
    transition: transform 0.4s var(--ease-smooth),
                box-shadow 0.4s var(--ease-smooth);
}

.card-hover-lift:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-xl);
}

/* 卡片悬停发光 */
.card-hover-glow {
    transition: all 0.4s var(--ease-smooth);
}

.card-hover-glow:hover {
    box-shadow: var(--shadow-glow-primary);
}

/* 图标弹跳 */
.icon-bounce {
    transition: transform 0.3s var(--ease-spring);
}

.icon-bounce:hover {
    transform: scale(1.2);
}

/* 输入框聚焦发光 */
.input-glow:focus {
    outline: none;
    box-shadow: var(--border-glow);
}

/* 链接下划线动画 */
.link-underline {
    position: relative;
    text-decoration: none;
}

.link-underline::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary);
    transition: width 0.3s var(--ease-out);
}

.link-underline:hover::after {
    width: 100%;
}

/* 涟漪效果 */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease, opacity 0.4s ease;
}

.ripple:active::after {
    width: 300%;
    height: 300%;
    opacity: 0;
}

/* 图片悬停缩放 */
.img-zoom {
    transition: transform 0.6s var(--ease-smooth);
}

.img-zoom:hover {
    transform: scale(1.08);
}

/* 图片悬停亮度 */
.img-brighten {
    transition: filter 0.3s ease;
}

.img-brighten:hover {
    filter: brightness(1.1);
}

/* ==================== 加载器 ==================== */

/* Spinner加载器 */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--bg-elevated);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

.spinner-lg {
    width: 56px;
    height: 56px;
    border-width: 4px;
}

/* 双环加载器 */
.spinner-dual {
    position: relative;
    width: 48px;
    height: 48px;
}

.spinner-dual::before,
.spinner-dual::after {
    content: '';
    position: absolute;
    inset: 0;
    border: 3px solid transparent;
    border-radius: 50%;
}

.spinner-dual::before {
    border-top-color: var(--primary);
    animation: spin 1s linear infinite;
}

.spinner-dual::after {
    border-bottom-color: var(--secondary);
    animation: spin 1s linear infinite reverse;
}

/* 脉冲加载器 */
.loader-pulse {
    display: flex;
    gap: var(--space-2);
}

.loader-pulse span {
    width: 12px;
    height: 12px;
    background: var(--primary);
    border-radius: 50%;
    animation: pulseBounce 1.4s ease-in-out infinite both;
}

.loader-pulse span:nth-child(1) { animation-delay: 0s; }
.loader-pulse span:nth-child(2) { animation-delay: 0.2s; }
.loader-pulse span:nth-child(3) { animation-delay: 0.4s; }

/* 进度条加载 */
.loader-progress {
    width: 100%;
    height: 4px;
    background: var(--bg-elevated);
    border-radius: 2px;
    overflow: hidden;
}

.loader-progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    animation: progressIndeterminate 1.5s ease-in-out infinite;
}

/* ==================== 滚动触发动画 ==================== */
[data-animate] {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.6s var(--ease-out);
}

[data-animate].animate-visible {
    opacity: 1;
    transform: translateY(0);
}

[data-animate="fade"] {
    transform: none;
}

[data-animate="slide-left"] {
    transform: translateX(-50px);
}

[data-animate="slide-left"].animate-visible {
    transform: translateX(0);
}

[data-animate="slide-right"] {
    transform: translateX(50px);
}

[data-animate="slide-right"].animate-visible {
    transform: translateX(0);
}

[data-animate="scale"] {
    transform: scale(0.9);
}

[data-animate="scale"].animate-visible {
    transform: scale(1);
}

/* ==================== 动画延迟工具类 ==================== */
.delay-100 { animation-delay: 0.1s; }
.delay-200 { animation-delay: 0.2s; }
.delay-300 { animation-delay: 0.3s; }
.delay-400 { animation-delay: 0.4s; }
.delay-500 { animation-delay: 0.5s; }
.delay-600 { animation-delay: 0.6s; }
.delay-700 { animation-delay: 0.7s; }
.delay-800 { animation-delay: 0.8s; }
.delay-900 { animation-delay: 0.9s; }
.delay-1000 { animation-delay: 1s; }

/* ==================== 动画持续时间工具类 ==================== */
.duration-fast { animation-duration: 0.2s !important; }
.duration-normal { animation-duration: 0.4s !important; }
.duration-slow { animation-duration: 0.6s !important; }
.duration-slower { animation-duration: 0.8s !important; }
.duration-slowest { animation-duration: 1s !important; }

