/* ===================================
   动画效果 - 页面动画和过渡效果
   =================================== */

/* ----------------
   渐入动画
   ---------------- */
.fade-in {
    animation: fadeIn 1s ease-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-delay {
    opacity: 0;
    animation: fadeIn 1s ease-out 0.3s forwards;
}

/* ----------------
   滚动触发动画
   ---------------- */
[data-animate] {
    opacity: 0;
    transform: translateY(50px);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-animate].animate-in {
    opacity: 1;
    transform: translateY(0);
}

/* ----------------
   打字机效果
   ---------------- */
.typewriter {
    overflow: hidden;
    border-right: 2px solid var(--color-white);
    white-space: nowrap;
    animation: typing 3s steps(40, end), blink-caret 0.75s step-end infinite;
}

@keyframes typing {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

@keyframes blink-caret {
    from, to {
        border-color: transparent;
    }
    50% {
        border-color: var(--color-white);
    }
}

/* ----------------
   脉冲动画
   ---------------- */
@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.pulse {
    animation: pulse 2s ease-in-out infinite;
}

/* ----------------
   悬浮动画
   ---------------- */
@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.float {
    animation: float 3s ease-in-out infinite;
}

/* ----------------
   旋转动画
   ---------------- */
@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.rotate {
    animation: rotate 20s linear infinite;
}

/* ----------------
   渐变背景动画
   ---------------- */
@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.gradient-animate {
    background-size: 200% 200%;
    animation: gradientShift 15s ease infinite;
}

/* ----------------
   波纹效果
   ---------------- */
@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.ripple:active::before {
    width: 300px;
    height: 300px;
}

/* ----------------
   滑入动画（从左侧）
   ---------------- */
@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.slide-in-left {
    animation: slideInLeft 0.8s ease-out;
}

/* ----------------
   滑入动画（从右侧）
   ---------------- */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.slide-in-right {
    animation: slideInRight 0.8s ease-out;
}

/* ----------------
   缩放进入动画
   ---------------- */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.scale-in {
    animation: scaleIn 0.6s ease-out;
}

/* ----------------
   光晕效果
   ---------------- */
@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(255, 255, 255, 0.5),
                    0 0 10px rgba(255, 255, 255, 0.3),
                    0 0 15px rgba(255, 255, 255, 0.2);
    }
    50% {
        box-shadow: 0 0 10px rgba(255, 255, 255, 0.8),
                    0 0 20px rgba(255, 255, 255, 0.6),
                    0 0 30px rgba(255, 255, 255, 0.4);
    }
}

.glow {
    animation: glow 2s ease-in-out infinite;
}

/* ----------------
   摇摆动画
   ---------------- */
@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

.shake {
    animation: shake 0.5s ease-in-out;
}

/* ----------------
   延迟动画类
   ---------------- */
.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }
.delay-4 { animation-delay: 0.4s; }
.delay-5 { animation-delay: 0.5s; }

/* ----------------
   加载动画
   ---------------- */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--color-white);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ----------------
   进度条动画
   ---------------- */
@keyframes progressBar {
    from {
        width: 0;
    }
    to {
        width: var(--progress-width);
    }
}

.progress-animate {
    animation: progressBar 1.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* ----------------
   闪烁动画
   ---------------- */
@keyframes blink {
    0%, 50%, 100% {
        opacity: 1;
    }
    25%, 75% {
        opacity: 0;
    }
}

.blink {
    animation: blink 2s ease-in-out infinite;
}

/* ----------------
   划线动画（用于标题下划线）
   ---------------- */
@keyframes drawLine {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

.draw-line {
    position: relative;
}

.draw-line::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 2px;
    background-color: currentColor;
    animation: drawLine 0.8s ease-out forwards;
}

/* ----------------
   视差效果
   ---------------- */
.parallax {
    will-change: transform;
    transition: transform 0.1s ease-out;
}

/* ----------------
   性能优化
   ---------------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ----------------
   GPU加速
   ---------------- */
.hardware-accelerate {
    transform: translateZ(0);
    will-change: transform;
}

