/* ===============================================
   动画配置变量
   =============================================== */
:root {
    /* 动画时长 */
    --animate-duration: 1.2s;
    --animate-duration-fast: 0.6s;
    --animate-duration-slow: 1.8s;
    
    /* 动画延迟基础值（用于交错动画） */
    --animate-delay: 0s;
    --animate-stagger: 0.15s;
    
    /* 现代缓动曲线 */
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
    --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-in-out-circ: cubic-bezier(0.85, 0, 0.15, 1);
    --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* ===============================================
   关键帧动画
   =============================================== */

@keyframes buttonSpread {
    from {
        box-shadow: 0 0 0 rgba(54, 112, 249, .5);
    }
    to {
        box-shadow: 0 0 0 16px rgba(54, 112, 249, 0);
    }
}

@keyframes buttonPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(54, 112, 249, 0.4);
    }
    50% {
        transform: scale(1.02);
        box-shadow: 0 8px 24px rgba(54, 112, 249, 0.3);
    }
}

@keyframes width2full {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@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 fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes roomIn {
    from {
        transform: scale(0.85);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes roomOut {
    from {
        transform: scale(1);
        opacity: 1;
    }
    to {
        transform: scale(0.85);
        opacity: 0;
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes slideOut {
    from {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateX(-30px) scale(0.95);
    }
}

/* 弹性缩放动画 */
@keyframes scaleInBounce {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }
    50% {
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.95);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* 模糊入场动画 */
@keyframes blurIn {
    from {
        opacity: 0;
        filter: blur(10px);
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        filter: blur(0);
        transform: scale(1);
    }
}

/* 旋转入场 */
@keyframes rotateIn {
    from {
        opacity: 0;
        transform: rotate(-10deg) scale(0.9);
    }
    to {
        opacity: 1;
        transform: rotate(0) scale(1);
    }
}

/* 弹跳效果 */
@keyframes bounce {
    0%, 20%, 53%, 100% {
        animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
        transform: translateY(0);
    }
    40%, 43% {
        animation-timing-function: cubic-bezier(0.755, 0.05, 0.855, 0.06);
        transform: translateY(-20px);
    }
    70% {
        animation-timing-function: cubic-bezier(0.755, 0.05, 0.855, 0.06);
        transform: translateY(-10px);
    }
    80% {
        transform: translateY(0);
    }
    90% {
        transform: translateY(-4px);
    }
}

/* 抖动效果（用于错误提示等） */
@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

/* 脉冲发光效果 */
@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(54, 112, 249, 0.2),
                    0 0 20px rgba(54, 112, 249, 0.1);
    }
    50% {
        box-shadow: 0 0 20px rgba(54, 112, 249, 0.4),
                    0 0 40px rgba(54, 112, 249, 0.2);
    }
}

/* 悬浮效果 */
@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* 渐变背景动画 */
@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* ===============================================
   入场动画基础类
   =============================================== */
.animate-on-scroll {
    opacity: 0;
    transition: 
        opacity var(--animate-duration) var(--ease-out-expo),
        transform var(--animate-duration) var(--ease-out-expo),
        filter var(--animate-duration) var(--ease-out-expo);
    transition-delay: var(--animate-delay);
    will-change: opacity, transform;
}

/* 方向变体 */
.slide-in-left {
    transform: translateX(-50px);
}

.slide-in-right {
    transform: translateX(50px);
}

.slide-in-up {
    transform: translateY(50px);
}

.slide-in-down {
    transform: translateY(-50px);
}

.scale-in {
    transform: scale(0.85);
}

.scale-in-up {
    transform: scale(0.85) translateY(30px);
}

.fade-up {
    transform: translateY(20px);
}

/* 模糊入场 */
.blur-in {
    filter: blur(8px);
    transform: scale(0.95);
}

/* 旋转入场 */
.rotate-in {
    transform: rotate(-5deg) scale(0.9);
}

/* 可见状态 */
.animate-on-scroll.visible {
    opacity: 1;
    transform: translate(0, 0) scale(1) rotate(0);
    filter: blur(0);
}

/* ===============================================
   交错动画延迟类
   =============================================== */
.stagger-1 { --animate-delay: calc(var(--animate-stagger) * 1); }
.stagger-2 { --animate-delay: calc(var(--animate-stagger) * 2); }
.stagger-3 { --animate-delay: calc(var(--animate-stagger) * 3); }
.stagger-4 { --animate-delay: calc(var(--animate-stagger) * 4); }
.stagger-5 { --animate-delay: calc(var(--animate-stagger) * 5); }
.stagger-6 { --animate-delay: calc(var(--animate-stagger) * 6); }
.stagger-7 { --animate-delay: calc(var(--animate-stagger) * 7); }
.stagger-8 { --animate-delay: calc(var(--animate-stagger) * 8); }

/* ===============================================
   动画速度变体
   =============================================== */
.animate-fast {
    --animate-duration: var(--animate-duration-fast);
}

.animate-slow {
    --animate-duration: var(--animate-duration-slow);
}

/* ===============================================
   特殊效果类（用于悬停等交互）
   =============================================== */

/* 卡片悬浮效果 */
.hover-lift {
    transition: 
        transform 0.3s var(--ease-out-expo),
        box-shadow 0.3s var(--ease-out-expo);
}

.hover-lift:hover {
    transform: translateY(-8px);
    box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.08),
        0 8px 16px rgba(0, 0, 0, 0.04);
}

/* 按钮发光效果 */
.hover-glow {
    transition: 
        transform 0.3s var(--ease-out-expo),
        box-shadow 0.3s var(--ease-out-expo);
}

.hover-glow:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 8px 24px rgba(54, 112, 249, 0.35),
        0 4px 8px rgba(54, 112, 249, 0.2);
}

/* 缩放效果 */
.hover-scale {
    transition: transform 0.3s var(--ease-out-back);
}

.hover-scale:hover {
    transform: scale(1.05);
}

/* 图片悬浮效果 */
.hover-zoom {
    overflow: hidden;
}

.hover-zoom img {
    transition: transform 0.5s var(--ease-out-expo);
}

.hover-zoom:hover img {
    transform: scale(1.08);
}

/* 下划线动画 */
.hover-underline {
    position: relative;
}

.hover-underline::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--theme, #2460ed);
    transition: width 0.4s var(--ease-out-expo);
}

.hover-underline:hover::after {
    width: 100%;
}

/* ===============================================
   循环动画
   =============================================== */
.animate-float {
    animation: float 3s ease-in-out infinite;
}

.animate-pulse {
    animation: buttonPulse 2s ease-in-out infinite;
}

.animate-glow {
    animation: glow 2s ease-in-out infinite;
}

.animate-bounce {
    animation: bounce 1s ease-in-out;
}

.animate-shake {
    animation: shake 0.6s ease-in-out;
}

/* ===============================================
   响应式优化
   =============================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .animate-on-scroll {
        opacity: 1;
        transform: none;
        filter: none;
    }
}

/* 移动端优化：减少动画偏移量 */
@media (max-width: 768px) {
    .slide-in-left {
        transform: translateX(-30px);
    }

    .slide-in-right {
        transform: translateX(30px);
    }

    .slide-in-up {
        transform: translateY(30px);
    }
    
    .slide-in-down {
        transform: translateY(-30px);
    }
    
    :root {
        --animate-duration: 1s;
        --animate-stagger: 0.12s;
    }
}
