/* ========================================
   世界书 APP 官方网站 - 动画效果
======================================== */

/* ========================================
   Scroll Animations
======================================== */
.reveal {
    opacity: 0;
    transform: translateY(50px);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

.reveal-left {
    opacity: 0;
    transform: translateX(-50px);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal-left.active {
    opacity: 1;
    transform: translateX(0);
}

.reveal-right {
    opacity: 0;
    transform: translateX(50px);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal-right.active {
    opacity: 1;
    transform: translateX(0);
}

.reveal-scale {
    opacity: 0;
    transform: scale(0.9);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal-scale.active {
    opacity: 1;
    transform: scale(1);
}

/* ========================================
   Particle Animation
======================================== */
.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(139, 92, 246, 0.6);
    border-radius: 50%;
    pointer-events: none;
    animation: particleFloat 15s infinite linear;
}

.particle:nth-child(2) { left: 20%; animation-delay: -2s; background: rgba(6, 182, 212, 0.6); }
.particle:nth-child(3) { left: 40%; animation-delay: -4s; background: rgba(236, 72, 153, 0.6); }
.particle:nth-child(4) { left: 60%; animation-delay: -6s; }
.particle:nth-child(5) { left: 80%; animation-delay: -8s; background: rgba(6, 182, 212, 0.6); }
.particle:nth-child(6) { left: 10%; animation-delay: -10s; background: rgba(236, 72, 153, 0.6); }
.particle:nth-child(7) { left: 30%; animation-delay: -12s; }
.particle:nth-child(8) { left: 50%; animation-delay: -14s; background: rgba(6, 182, 212, 0.6); }
.particle:nth-child(9) { left: 70%; animation-delay: -16s; }
.particle:nth-child(10) { left: 90%; animation-delay: -18s; background: rgba(236, 72, 153, 0.6); }

@keyframes particleFloat {
    0% {
        transform: translateY(100vh) scale(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
        transform: translateY(90vh) scale(1);
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-10vh) scale(0);
        opacity: 0;
    }
}

/* ========================================
   Glow Pulse Animation
======================================== */
.glow-pulse {
    animation: glowPulse 3s ease-in-out infinite;
}

@keyframes glowPulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(139, 92, 246, 0.3);
    }
    50% {
        box-shadow: 0 0 40px rgba(139, 92, 246, 0.6), 0 0 60px rgba(6, 182, 212, 0.3);
    }
}

/* ========================================
   Button Hover Effects
======================================== */
.btn-glow {
    position: relative;
    overflow: hidden;
}

.btn-glow::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    transition: left 0.5s ease;
}

.btn-glow:hover::before {
    left: 100%;
}

/* ========================================
   Card Hover Effects
======================================== */
.card-hover-lift {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-hover-lift:hover {
    transform: translateY(-10px);
}

.card-border-glow {
    position: relative;
}

.card-border-glow::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 2px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.card-border-glow:hover::before {
    opacity: 1;
}

/* ========================================
   Text Gradient Animation
======================================== */
.text-gradient-animate {
    background: linear-gradient(
        90deg,
        #ffffff 0%,
        var(--primary) 25%,
        var(--accent) 50%,
        var(--primary) 75%,
        #ffffff 100%
    );
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: textGradient 4s linear infinite;
}

@keyframes textGradient {
    0% {
        background-position: 0% center;
    }
    100% {
        background-position: 200% center;
    }
}

/* ========================================
   Icon Bounce
======================================== */
.icon-bounce {
    display: inline-block;
    animation: iconBounce 2s ease-in-out infinite;
}

@keyframes iconBounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* ========================================
   Shimmer Effect
======================================== */
.shimmer {
    position: relative;
    overflow: hidden;
}

.shimmer::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.1),
        transparent
    );
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* ========================================
   Loading Spinner
======================================== */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ========================================
   Typing Effect
======================================== */
.typing-effect {
    overflow: hidden;
    border-right: 2px solid var(--primary);
    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(--primary);
    }
}

/* ========================================
   Scale on Scroll
======================================== */
.scale-on-scroll {
    transition: transform 0.3s ease;
}

.scale-on-scroll.scrolled {
    transform: scale(1.05);
}

/* ========================================
   Fade In Sequence
======================================== */
.fade-in-sequence > * {
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.6s ease forwards;
}

.fade-in-sequence > *:nth-child(1) { animation-delay: 0.1s; }
.fade-in-sequence > *:nth-child(2) { animation-delay: 0.2s; }
.fade-in-sequence > *:nth-child(3) { animation-delay: 0.3s; }
.fade-in-sequence > *:nth-child(4) { animation-delay: 0.4s; }
.fade-in-sequence > *:nth-child(5) { animation-delay: 0.5s; }
.fade-in-sequence > *:nth-child(6) { animation-delay: 0.6s; }

/* ========================================
   Magnetic Button
======================================== */
.magnetic {
    transition: transform 0.3s ease;
}

.magnetic:hover {
    transform: scale(1.05);
}

/* ========================================
   Marquee Effect
======================================== */
.marquee {
    overflow: hidden;
    white-space: nowrap;
}

.marquee-content {
    display: inline-block;
    animation: marquee 20s linear infinite;
}

@keyframes marquee {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(-50%);
    }
}

/* ========================================
   Blob Animation
======================================== */
.blob {
    position: absolute;
    filter: blur(60px);
    opacity: 0.4;
    animation: blobMove 10s ease-in-out infinite;
}

.blob-1 {
    background: var(--primary);
    width: 400px;
    height: 400px;
    top: -100px;
    left: -100px;
}

.blob-2 {
    background: var(--accent);
    width: 300px;
    height: 300px;
    bottom: -50px;
    right: -50px;
    animation-delay: -5s;
}

@keyframes blobMove {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    33% {
        transform: translate(30px, -50px) scale(1.1);
    }
    66% {
        transform: translate(-20px, 20px) scale(0.9);
    }
}

/* ========================================
   Progress Bar
======================================== */
.progress-bar {
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar .progress {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 2px;
    width: 0;
    transition: width 1.5s ease;
}

.progress-bar.animate .progress {
    width: var(--progress-width, 80%);
}

/* ========================================
   Hover Underline Animation
======================================== */
.hover-underline {
    position: relative;
    text-decoration: none;
    color: var(--text-primary);
}

.hover-underline::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--gradient-primary);
    transition: width 0.3s ease;
}

.hover-underline:hover::after {
    width: 100%;
}

/* ========================================
   Stagger Animation for Lists
======================================== */
.stagger-list li {
    opacity: 0;
    transform: translateX(-20px);
    animation: staggerIn 0.5s ease forwards;
}

.stagger-list li:nth-child(1) { animation-delay: 0.1s; }
.stagger-list li:nth-child(2) { animation-delay: 0.2s; }
.stagger-list li:nth-child(3) { animation-delay: 0.3s; }
.stagger-list li:nth-child(4) { animation-delay: 0.4s; }
.stagger-list li:nth-child(5) { animation-delay: 0.5s; }

@keyframes staggerIn {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ========================================
   Image Hover Zoom
======================================== */
.hover-zoom {
    overflow: hidden;
    border-radius: inherit;
}

.hover-zoom img {
    transition: transform 0.5s ease;
}

.hover-zoom:hover img {
    transform: scale(1.1);
}

/* ========================================
   Glitch Effect (for headings)
======================================== */
.glitch {
    position: relative;
}

.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.glitch::before {
    left: 2px;
    text-shadow: -2px 0 var(--primary);
    clip: rect(24px, 550px, 90px, 0);
    animation: glitch-anim 3s infinite linear alternate-reverse;
}

.glitch::after {
    left: -2px;
    text-shadow: -2px 0 var(--accent);
    clip: rect(85px, 550px, 140px, 0);
    animation: glitch-anim 2s infinite linear alternate-reverse;
}

@keyframes glitch-anim {
    0% {
        clip: rect(10px, 9999px, 30px, 0);
    }
    20% {
        clip: rect(80px, 9999px, 100px, 0);
    }
    40% {
        clip: rect(10px, 9999px, 50px, 0);
    }
    60% {
        clip: rect(60px, 9999px, 80px, 0);
    }
    80% {
        clip: rect(30px, 9999px, 60px, 0);
    }
    100% {
        clip: rect(70px, 9999px, 90px, 0);
    }
}
