/**
 * 动画效果库 - 大幅升级版
 * 包含：骨架屏(脉冲光效)、入场动画(3D翻转)、涟漪、弹跳、Toast、粒子效果、页面切换等
 */

/* ========== CSS变量 ========== */
:root {
    --anim-duration: 0.4s;
    --anim-easing: cubic-bezier(0.4, 0, 0.2, 1);
    --anim-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --anim-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* ========== 骨架屏（脉冲光效增强） ========== */
.skeleton-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #F0F2F5;
    z-index: 9999;
    transition: opacity 0.4s ease;
}
.skeleton-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}
.skeleton-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}
.skeleton-nav {
    height: 56px;
    background: linear-gradient(90deg, #E2E8F0 25%, #F1F5F9 50%, #E2E8F0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 12px;
    margin-bottom: 20px;
}
.skeleton-content { padding: 0 10px; }
.skeleton-line {
    height: 16px;
    background: linear-gradient(90deg, #E2E8F0 25%, #F1F5F9 50%, #E2E8F0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 8px;
    margin-bottom: 12px;
}
.skeleton-line.w-80 { width: 80%; }
.skeleton-line.w-60 { width: 60%; }
.skeleton-line.w-50 { width: 50%; }
.skeleton-line.w-90 { width: 90%; }
.skeleton-rect {
    height: 180px;
    background: linear-gradient(90deg, #E2E8F0 25%, #F1F5F9 50%, #E2E8F0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 16px;
    margin-bottom: 16px;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* 骨架屏脉冲光效 */
@keyframes shimmerPulse {
    0% { background-position: 200% 0; opacity: 0.7; }
    50% { opacity: 1; }
    100% { background-position: -200% 0; opacity: 0.7; }
}

/* ========== 入场动画 ========== */
.animate-fadeInUp {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity var(--anim-duration) var(--anim-easing),
                transform var(--anim-duration) var(--anim-easing);
}
.animate-fadeInUp.visible {
    opacity: 1;
    transform: translateY(0);
}

.animate-fadeInLeft {
    opacity: 0;
    transform: translateX(-30px);
    transition: opacity var(--anim-duration) var(--anim-easing),
                transform var(--anim-duration) var(--anim-easing);
}
.animate-fadeInLeft.visible {
    opacity: 1;
    transform: translateX(0);
}

.animate-fadeInRight {
    opacity: 0;
    transform: translateX(30px);
    transition: opacity var(--anim-duration) var(--anim-easing),
                transform var(--anim-duration) var(--anim-easing);
}
.animate-fadeInRight.visible {
    opacity: 1;
    transform: translateX(0);
}

.animate-fadeIn {
    opacity: 0;
    transition: opacity var(--anim-duration) var(--anim-easing);
}
.animate-fadeIn.visible { opacity: 1; }

.animate-scaleIn {
    opacity: 0;
    transform: scale(0.9);
    transition: opacity var(--anim-duration) var(--anim-easing),
                transform var(--anim-duration) var(--anim-spring);
}
.animate-scaleIn.visible {
    opacity: 1;
    transform: scale(1);
}

/* 3D翻转入场 (PC端) */
.animate-flipIn {
    opacity: 0;
    transform: perspective(800px) rotateY(-15deg);
    transition: opacity 0.5s var(--anim-easing),
                transform 0.5s var(--anim-spring);
}
.animate-flipIn.visible {
    opacity: 1;
    transform: perspective(800px) rotateY(0);
}
/* 手机端简化为淡入 */
@media (max-width: 991px) {
    .animate-flipIn {
        opacity: 0;
        transform: translateY(20px);
        transition: opacity var(--anim-duration) var(--anim-easing),
                    transform var(--anim-duration) var(--anim-easing);
    }
    .animate-flipIn.visible {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-slideIn {
    animation: slideIn 0.4s var(--anim-easing) forwards;
}

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

/* 延迟 */
.anim-delay-1 { transition-delay: 0.1s !important; animation-delay: 0.1s !important; }
.anim-delay-2 { transition-delay: 0.2s !important; animation-delay: 0.2s !important; }
.anim-delay-3 { transition-delay: 0.3s !important; animation-delay: 0.3s !important; }
.anim-delay-4 { transition-delay: 0.4s !important; animation-delay: 0.4s !important; }
.anim-delay-5 { transition-delay: 0.5s !important; animation-delay: 0.5s !important; }

/* ========== 页面切换过渡 ========== */
.page-transition {
    animation: pageSlideIn 0.35s var(--anim-easing);
}
@keyframes pageSlideIn {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ========== 涟漪效果 ========== */
.btn-ripple {
    position: relative;
    overflow: hidden;
}
.btn-ripple::after {
    content: '';
    position: absolute;
    width: 100%; height: 100%;
    top: 0; left: 0;
    pointer-events: none;
    background-image: radial-gradient(circle, rgba(255,255,255,0.3) 10%, transparent 10.01%);
    background-repeat: no-repeat;
    background-position: 50%;
    transform: scale(10, 10);
    opacity: 0;
    transition: transform 0.5s, opacity 1s;
}
.btn-ripple:active::after {
    transform: scale(0, 0);
    opacity: 0.3;
    transition: 0s;
}

/* ========== 弹跳动画 ========== */
@keyframes bounce {
    0%, 100% { transform: scale(1); }
    25% { transform: scale(1.3); }
    50% { transform: scale(0.9); }
    75% { transform: scale(1.1); }
}

@keyframes bounceHeart {
    0% { transform: scale(1); }
    15% { transform: scale(1.3); }
    30% { transform: scale(1); }
    45% { transform: scale(1.2); }
    60% { transform: scale(1); }
}

.animate-bounce {
    animation: bounce 0.5s var(--anim-bounce);
}
.animate-bounce-heart {
    animation: bounceHeart 0.6s ease;
}

/* ========== 脉冲动画 ========== */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
.animate-pulse {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulseScale {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}
.animate-pulse-scale {
    animation: pulseScale 2s ease-in-out infinite;
}

/* ========== 旋转动画 ========== */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.animate-spin {
    animation: spin 1s linear infinite;
}

/* ========== Toast通知动画 ========== */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 1080;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.toast-item {
    background: #fff;
    border-radius: 12px;
    padding: 14px 20px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 280px;
    max-width: 400px;
    transform: translateX(120%);
    transition: transform 0.4s var(--anim-spring), opacity 0.3s ease;
    pointer-events: auto;
    border-left: 4px solid #4F46E5;
}
.toast-item.show { transform: translateX(0); }
.toast-item.hiding { transform: translateX(120%); opacity: 0; }
.toast-item.success { border-left-color: #10B981; }
.toast-item.error { border-left-color: #EF4444; }
.toast-item.warning { border-left-color: #F59E0B; }
.toast-item .toast-icon { font-size: 1.2rem; }
.toast-item.success .toast-icon { color: #10B981; }
.toast-item.error .toast-icon { color: #EF4444; }
.toast-item.warning .toast-icon { color: #F59E0B; }
.toast-item .toast-text { flex: 1; font-size: 0.9rem; color: #1E293B; }
.toast-item .toast-close { background: none; border: none; color: #94A3B8; cursor: pointer; padding: 4px; font-size: 1rem; }

/* 手机端Toast居中 */
@media (max-width: 991px) {
    .toast-container {
        top: auto;
        bottom: 80px;
        right: 50%;
        transform: translateX(50%);
        left: 0;
        align-items: center;
    }
    .toast-item {
        min-width: 260px;
        transform: translateY(60px);
        opacity: 0;
    }
    .toast-item.show { transform: translateY(0); opacity: 1; }
    .toast-item.hiding { transform: translateY(60px); opacity: 0; }
}

/* ========== 下拉刷新（旋转动画增强） ========== */
.pull-refresh-indicator {
    position: fixed;
    top: 0;
    left: 0; right: 0;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(10px);
    z-index: 1000;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
    color: #4F46E5;
    font-size: 0.85rem;
}
.pull-refresh-indicator.pulling { transform: translateY(0); }
.pull-refresh-indicator.refreshing .pull-refresh-icon {
    animation: spin 0.8s linear infinite;
}
.pull-refresh-indicator.refreshing .pull-refresh-icon i::before {
    content: "\f110";
}

/* ========== 数字增长动画 ========== */
.number-animate {
    display: inline-block;
    transition: all 0.3s ease;
}
.number-animate.changing {
    transform: translateY(-5px);
    opacity: 0.5;
}

/* ========== 图片懒加载淡入 ========== */
.lazy-image {
    opacity: 0;
    transition: opacity 0.5s ease, transform 0.5s ease;
    transform: scale(0.95);
}
.lazy-image.loaded {
    opacity: 1;
    transform: scale(1);
}

/* ========== 卡片悬停效果 ========== */
.card-hover {
    transition: transform 0.3s var(--anim-easing), box-shadow 0.3s ease;
    will-change: transform;
}
.card-hover:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(79, 70, 229, 0.12);
}

/* ========== Tab切换动画 ========== */
.tab-content-animated {
    animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========== 加载更多脉冲 ========== */
.load-more-btn {
    position: relative;
    overflow: hidden;
}
.load-more-btn.loading::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: loadingSweep 1.5s ease infinite;
}
@keyframes loadingSweep {
    to { left: 100%; }
}

/* ========== 点赞/收藏动画 ========== */
.like-btn.active i,
.fav-btn.active i {
    animation: bounceHeart 0.6s ease;
}
.like-btn.active i { color: #EF4444; }
.fav-btn.active i { color: #F59E0B; }

/* ========== 点赞爆炸粒子效果 ========== */
.like-particle {
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    font-size: 1rem;
    animation: particleExplode 0.8s ease-out forwards;
}
@keyframes particleExplode {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(var(--px), var(--py)) scale(0.3);
    }
}

/* ========== 骨架卡片（脉冲光效增强） ========== */
.skeleton-card {
    background: #fff;
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 12px;
}
.skeleton-card .sk-row {
    height: 14px;
    background: linear-gradient(90deg, #E2E8F0 25%, #F1F5F9 50%, #E2E8F0 75%);
    background-size: 200% 100%;
    animation: shimmerPulse 1.8s ease-in-out infinite;
    border-radius: 6px;
    margin-bottom: 10px;
}
.skeleton-card .sk-row:last-child { margin-bottom: 0; }
.skeleton-card .sk-row.w40 { width: 40%; }
.skeleton-card .sk-row.w60 { width: 60%; }
.skeleton-card .sk-row.w80 { width: 80%; }
.skeleton-card .sk-row.w100 { width: 100%; }
.skeleton-card .sk-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: linear-gradient(90deg, #E2E8F0 25%, #F1F5F9 50%, #E2E8F0 75%);
    background-size: 200% 100%;
    animation: shimmerPulse 1.8s ease-in-out infinite;
}

/* ========== 统计数字增长动画 ========== */
.stat-number-animate {
    animation: statPopIn 0.6s var(--anim-spring) forwards;
}
@keyframes statPopIn {
    0% { opacity: 0; transform: translateY(10px) scale(0.8); }
    60% { transform: translateY(-3px) scale(1.05); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}
