/* ========================================
   Beijing Digital Square - Animations
   Rich Animation Effects (Audi-inspired)
   ======================================== */

/* ========================================
   KEYFRAME ANIMATIONS
   ======================================== */

/* Fade In Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-40px);
    }
    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 fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Slide Animations */
@keyframes slideInFromLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideInFromRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideInFromTop {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideInFromBottom {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Bounce Animations */
@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-30px);
    }
    60% {
        transform: translateY(-15px);
    }
}

@keyframes bounceIn {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }
    50% {
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes bounceInUp {
    0% {
        transform: translateY(100px);
        opacity: 0;
    }
    60% {
        transform: translateY(-20px);
        opacity: 1;
    }
    80% {
        transform: translateY(10px);
    }
    100% {
        transform: translateY(0);
    }
}

/* Rotate Animations */
@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes rotateIn {
    from {
        transform: rotate(-180deg);
        opacity: 0;
    }
    to {
        transform: rotate(0deg);
        opacity: 1;
    }
}

/* Pulse Animations */
@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes pulseGlow {
    0% {
        box-shadow: 0 0 20px rgba(230, 57, 70, 0.4);
    }
    50% {
        box-shadow: 0 0 40px rgba(230, 57, 70, 0.8);
    }
    100% {
        box-shadow: 0 0 20px rgba(230, 57, 70, 0.4);
    }
}

/* Float Animation */
@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-20px);
    }
}

/* Shimmer Effect */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

/* Count Up Animation */
@keyframes countUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Parallax Effect */
@keyframes parallaxSlow {
    0% {
        transform: translateY(0);
    }
    100% {
        transform: translateY(-20%);
    }
}

@keyframes parallaxMedium {
    0% {
        transform: translateY(0);
    }
    100% {
        transform: translateY(-10%);
    }
}

/* Gradient Animation */
@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* Hero Background Animation */
@keyframes heroZoom {
    0% {
        transform: scale(1);
    }
    100% {
        transform: scale(1.1);
    }
}

/* Text Reveal Animation */
@keyframes textReveal {
    0% {
        clip-path: inset(0 100% 0 0);
    }
    100% {
        clip-path: inset(0 0 0 0);
    }
}

/* Line Animation */
@keyframes lineExpand {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

/* Scale In Center */
@keyframes scaleInCenter {
    from {
        transform: scale(0);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* ========================================
   ANIMATION CLASSES
   ======================================== */

/* Base Animation Classes */
.animate-fade-in {
    animation: fadeIn 1s ease forwards;
}

.animate-fade-in-up {
    animation: fadeInUp 1s ease forwards;
}

.animate-fade-in-down {
    animation: fadeInDown 1s ease forwards;
}

.animate-fade-in-left {
    animation: fadeInLeft 1s ease forwards;
}

.animate-fade-in-right {
    animation: fadeInRight 1s ease forwards;
}

.animate-fade-in-scale {
    animation: fadeInScale 0.8s ease forwards;
}

.animate-bounce {
    animation: bounce 2s ease-in-out infinite;
}

.animate-bounce-in {
    animation: bounceIn 1s ease forwards;
}

.animate-bounce-in-up {
    animation: bounceInUp 1s ease forwards;
}

.animate-rotate {
    animation: rotate 2s linear infinite;
}

.animate-rotate-in {
    animation: rotateIn 1s ease forwards;
}

.animate-pulse {
    animation: pulse 2s ease-in-out infinite;
}

.animate-pulse-glow {
    animation: pulseGlow 2s ease-in-out infinite;
}

.animate-float {
    animation: float 3s ease-in-out infinite;
}

.animate-shimmer {
    animation: shimmer 2s linear infinite;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.2) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    background-size: 1000px 100%;
}

.animate-gradient {
    background-size: 200% 200%;
    animation: gradientShift 5s ease infinite;
}

.animate-hero-zoom {
    animation: heroZoom 20s ease-in-out infinite alternate;
}

.animate-scale-in-center {
    animation: scaleInCenter 0.5s ease forwards;
}

/* Delay Classes */
.delay-100 { animation-delay: 100ms; }
.delay-200 { animation-delay: 200ms; }
.delay-300 { animation-delay: 300ms; }
.delay-400 { animation-delay: 400ms; }
.delay-500 { animation-delay: 500ms; }
.delay-600 { animation-delay: 600ms; }
.delay-700 { animation-delay: 700ms; }
.delay-800 { animation-delay: 800ms; }
.delay-900 { animation-delay: 900ms; }
.delay-1000 { animation-delay: 1000ms; }

/* Duration Classes */
.duration-fast { animation-duration: 0.3s; }
.duration-normal { animation-duration: 0.5s; }
.duration-slow { animation-duration: 1s; }
.duration-very-slow { animation-duration: 2s; }

/* ========================================
   SCROLL-TRIGGERED ANIMATIONS
   ======================================== */

/* Intersection Observer Animation */
.scroll-animate {
    opacity: 0;
    transform: translateY(50px);
    transition: all 0.8s ease;
}

.scroll-animate.active {
    opacity: 1;
    transform: translateY(0);
}

.scroll-animate-left {
    opacity: 0;
    transform: translateX(-50px);
    transition: all 0.8s ease;
}

.scroll-animate-left.active {
    opacity: 1;
    transform: translateX(0);
}

.scroll-animate-right {
    opacity: 0;
    transform: translateX(50px);
    transition: all 0.8s ease;
}

.scroll-animate-right.active {
    opacity: 1;
    transform: translateX(0);
}

.scroll-animate-scale {
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.8s ease;
}

.scroll-animate-scale.active {
    opacity: 1;
    transform: scale(1);
}

/* Stagger Animation for Grid Items */
.stagger-item {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.6s ease;
}

.stagger-item.active {
    opacity: 1;
    transform: translateY(0);
}

.stagger-item:nth-child(1) { transition-delay: 0ms; }
.stagger-item:nth-child(2) { transition-delay: 100ms; }
.stagger-item:nth-child(3) { transition-delay: 200ms; }
.stagger-item:nth-child(4) { transition-delay: 300ms; }
.stagger-item:nth-child(5) { transition-delay: 400ms; }
.stagger-item:nth-child(6) { transition-delay: 500ms; }
.stagger-item:nth-child(7) { transition-delay: 600ms; }
.stagger-item:nth-child(8) { transition-delay: 700ms; }
.stagger-item:nth-child(9) { transition-delay: 800ms; }

/* ========================================
   HOVER ANIMATIONS
   ======================================== */

/* Card Hover Effects */
.card-hover {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-hover:hover {
    transform: translateY(-10px);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.4);
}

/* Icon Hover */
.icon-hover {
    transition: all 0.3s ease;
}

.icon-hover:hover {
    transform: scale(1.2) rotate(5deg);
    color: var(--accent-color);
}

/* Button Hover Effects */
.btn-hover-lift {
    transition: all 0.3s ease;
}

.btn-hover-lift:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(230, 57, 70, 0.3);
}

/* Link Underline Animation */
.link-underline {
    position: relative;
    display: inline-block;
}

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

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

/* Image Hover Effects */
.img-zoom {
    overflow: hidden;
}

.img-zoom img {
    transition: transform 0.5s ease;
}

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

/* ========================================
   PAGE LOAD ANIMATIONS
   ======================================== */

.page-load-animation {
    opacity: 0;
}

.page-loaded .page-load-animation {
    animation: fadeInUp 0.8s ease forwards;
}

.page-loaded .page-load-animation:nth-child(1) { animation-delay: 0ms; }
.page-loaded .page-load-animation:nth-child(2) { animation-delay: 100ms; }
.page-loaded .page-load-animation:nth-child(3) { animation-delay: 200ms; }
.page-loaded .page-load-animation:nth-child(4) { animation-delay: 300ms; }
.page-loaded .page-load-animation:nth-child(5) { animation-delay: 400ms; }
.page-loaded .page-load-animation:nth-child(6) { animation-delay: 500ms; }

/* Hero Text Animation */
.hero-text-animate {
    opacity: 0;
    transform: translateY(30px);
    animation: heroTextReveal 1s ease forwards;
}

@keyframes heroTextReveal {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hero-text-animate:nth-child(1) { animation-delay: 0.2s; }
.hero-text-animate:nth-child(2) { animation-delay: 0.4s; }
.hero-text-animate:nth-child(3) { animation-delay: 0.6s; }
.hero-text-animate:nth-child(4) { animation-delay: 0.8s; }

/* ========================================
   PARALLAX EFFECTS
   ======================================== */

.parallax-container {
    position: relative;
    overflow: hidden;
}

.parallax-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 120%;
    background-size: cover;
    background-position: center;
    will-change: transform;
}

.parallax-slow {
    animation: parallaxSlow 10s ease-in-out infinite alternate;
}

.parallax-medium {
    animation: parallaxMedium 8s ease-in-out infinite alternate;
}

/* ========================================
   LOADING ANIMATIONS
   ======================================== */

.loader {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(230, 57, 70, 0.3);
    border-top: 3px solid var(--accent-color);
    border-radius: 50%;
    animation: rotate 1s linear infinite;
}

.loader-dots {
    display: flex;
    gap: 8px;
}

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

.loader-dots span:nth-child(1) { animation-delay: -0.32s; }
.loader-dots span:nth-child(2) { animation-delay: -0.16s; }

/* ========================================
   SCROLL INDICATOR
   ======================================== */

.scroll-indicator {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    animation: bounce 2s ease-in-out infinite;
}

.scroll-indicator::before {
    content: '';
    display: block;
    width: 24px;
    height: 24px;
    border-right: 3px solid var(--text-primary);
    border-bottom: 3px solid var(--text-primary);
    transform: rotate(45deg);
    margin: -8px;
    animation: scrollArrow 2s ease-in-out infinite;
}

@keyframes scrollArrow {
    0%, 100% {
        opacity: 0;
        transform: rotate(45deg) translate(-5px, -5px);
    }
    50% {
        opacity: 1;
    }
    100% {
        transform: rotate(45deg) translate(5px, 5px);
    }
}

/* ========================================
   TEXT ANIMATIONS
   ======================================== */

.typing-effect {
    overflow: hidden;
    border-right: 3px solid var(--accent-color);
    white-space: nowrap;
    animation: typing 3s steps(40) 1s forwards, blink 0.75s step-end infinite;
    width: 0;
}

@keyframes typing {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes blink {
    50% { border-color: transparent; }
}

.text-gradient-animate {
    background: linear-gradient(
        90deg,
        var(--text-primary) 0%,
        var(--accent-color) 50%,
        var(--text-primary) 100%
    );
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 3s linear infinite;
}

/* ========================================
   SPECIAL EFFECTS
   ======================================== */

/* Glassmorphism Effect */
.glass-effect {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.glass-effect:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Particle Effect Container */
.particles-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--accent-color);
    border-radius: 50%;
    opacity: 0.6;
    animation: float 6s ease-in-out infinite;
}

.particle:nth-child(1) { left: 10%; animation-delay: 0s; }
.particle:nth-child(2) { left: 20%; animation-delay: 1s; }
.particle:nth-child(3) { left: 30%; animation-delay: 2s; }
.particle:nth-child(4) { left: 40%; animation-delay: 3s; }
.particle:nth-child(5) { left: 50%; animation-delay: 4s; }
.particle:nth-child(6) { left: 60%; animation-delay: 5s; }
.particle:nth-child(7) { left: 70%; animation-delay: 0.5s; }
.particle:nth-child(8) { left: 80%; animation-delay: 1.5s; }
.particle:nth-child(9) { left: 90%; animation-delay: 2.5s; }

/* ========================================
   REDUCED MOTION
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .scroll-animate,
    .scroll-animate-left,
    .scroll-animate-right,
    .scroll-animate-scale {
        opacity: 1;
        transform: none;
    }
    
    .parallax-bg {
        animation: none;
    }
}
