/* ===================================
   CUTTING-EDGE ANIMATIONS & INTERACTIONS
   ================================== */

/* Smooth Scrolling Override */
html {
    scroll-behavior: auto !important; /* Let Lenis handle smooth scrolling */
}

html.lenis {
    height: auto;
}

.lenis.lenis-smooth {
    scroll-behavior: auto;
}

.lenis.lenis-smooth [data-lenis-prevent] {
    overscroll-behavior: contain;
}

.lenis.lenis-stopped {
    overflow: hidden;
}

.lenis.lenis-scrolling iframe {
    pointer-events: none;
}

/* Exception: Allow Tally form to remain interactive */
.contact-form-container,
.contact-form-container iframe {
    pointer-events: auto !important;
}

/* Ensure form container doesn't block interactions */
.contact-wrapper {
    position: relative;
    z-index: 10;
}

/* Make sure cursor doesn't block form */
.contact-form-container ~ .cursor-dot,
.contact-form-container ~ .cursor-outline {
    pointer-events: none !important;
}

/* Custom Cursor - Enhanced */
.cursor-dot,
.cursor-outline {
    pointer-events: none;
    position: fixed;
    top: 0;
    left: 0;
    border-radius: 50%;
    opacity: 0;
    transform: translate(-50%, -50%);
    transition: opacity 0.5s ease-in-out;
    z-index: 10000;
}

.cursor-dot {
    width: 12px;
    height: 12px;
    background: radial-gradient(circle, #10b981, #2563eb);
    box-shadow:
        0 0 20px rgba(16, 185, 129, 0.8),
        0 0 40px rgba(37, 99, 235, 0.6),
        0 0 60px rgba(16, 185, 129, 0.4);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        box-shadow:
            0 0 20px rgba(16, 185, 129, 0.8),
            0 0 40px rgba(37, 99, 235, 0.6),
            0 0 60px rgba(16, 185, 129, 0.4);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2);
        box-shadow:
            0 0 30px rgba(16, 185, 129, 1),
            0 0 60px rgba(37, 99, 235, 0.8),
            0 0 90px rgba(16, 185, 129, 0.6);
    }
}

.cursor-outline {
    width: 40px;
    height: 40px;
    border: 2px solid rgba(16, 185, 129, 0.6);
    background: radial-gradient(circle, rgba(16, 185, 129, 0.1), transparent 70%);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.cursor-dot.active,
.cursor-outline.active {
    opacity: 1;
}

/* Cursor hover states */
.cursor-dot.hover {
    width: 16px;
    height: 16px;
    background: radial-gradient(circle, #10b981, #2563eb, #10b981);
    animation: pulseHover 1s ease-in-out infinite;
}

@keyframes pulseHover {
    0%, 100% {
        box-shadow:
            0 0 30px rgba(16, 185, 129, 1),
            0 0 60px rgba(37, 99, 235, 0.8),
            0 0 90px rgba(16, 185, 129, 0.6),
            0 0 120px rgba(37, 99, 235, 0.4);
    }
    50% {
        box-shadow:
            0 0 40px rgba(16, 185, 129, 1),
            0 0 80px rgba(37, 99, 235, 1),
            0 0 120px rgba(16, 185, 129, 0.8),
            0 0 160px rgba(37, 99, 235, 0.6);
    }
}

.cursor-outline.hover {
    width: 60px;
    height: 60px;
    border-color: rgba(16, 185, 129, 0.8);
    background: radial-gradient(circle, rgba(16, 185, 129, 0.2), transparent 70%);
}

/* Hide cursor on mobile */
@media (max-width: 768px) {
    .cursor-dot,
    .cursor-outline {
        display: none;
    }
}

/* Animated Gradient Canvas */
.gradient-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    opacity: 0.95;
}

/* CRITICAL FIX: Prevent disappearing content while allowing fade-in
   Override styles.css .reveal opacity:0 for all sections except hero */

/* Sections start slightly faded and slide up */
section.reveal:not(.hero):not(.revealed) {
    opacity: 0.1;
    transform: translateY(30px);
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Revealed sections are fully visible */
section.reveal.revealed {
    opacity: 1 !important;
    transform: translateY(0) !important;
}

/* Hero can still animate in */
section.reveal.hero {
    /* Let styles.css handle this */
}

/* Non-section reveals (navbar, etc) - let JS handle them */
.reveal:not(section) {
    /* Original behavior from styles.css applies */
}

.hero {
    position: relative;
    background: linear-gradient(135deg, #1e40af 0%, #047857 100%);
}

.hero-container {
    position: relative;
    z-index: 2;
}

/* Kinetic Typography */
.hero-title {
    overflow: hidden;
}

.hero-word {
    display: block;
    opacity: 0;
    transform: translateY(100px) rotateX(-80deg);
    transform-origin: center bottom;
    perspective: 1000px;
}

.hero-word.animate {
    animation: wordReveal 1s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

@keyframes wordReveal {
    to {
        opacity: 1;
        transform: translateY(0) rotateX(0deg);
    }
}

/* Stagger animation for each word */
.hero-word:nth-child(1) { animation-delay: 0.1s; }
.hero-word:nth-child(2) { animation-delay: 0.2s; }
.hero-word:nth-child(3) { animation-delay: 0.3s; }

/* Magnetic Buttons */
.magnetic-btn {
    position: relative;
    transition: transform 0.3s cubic-bezier(0.23, 1, 0.32, 1);
    will-change: transform;
}

.magnetic-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: inherit;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, transparent 70%);
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

.magnetic-btn:hover::before {
    width: 300px;
    height: 300px;
}

.magnetic-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 20px 40px rgba(37, 99, 235, 0.3);
}

/* Enhanced 3D Tilt Cards */
.tilt-card {
    transform-style: preserve-3d;
    transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
    position: relative;
    overflow: hidden;
}

.tilt-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.1), rgba(16, 185, 129, 0.1));
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 1;
}

.tilt-card:hover::before {
    opacity: 1;
}

.tilt-card:hover {
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.3);
    transform: translateY(-8px);
}

/* Service Card Glow Effect */
.service-card {
    position: relative;
    overflow: hidden;
}

.service-card::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.2) 0%, transparent 70%);
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
    pointer-events: none;
}

.service-card:hover::after {
    width: 400px;
    height: 400px;
}

.service-icon {
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

.service-card:hover .service-icon {
    transform: scale(1.2) rotate(5deg);
}

.service-card:hover .service-icon i {
    background: linear-gradient(135deg, #2563eb, #10b981);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Animated Stat Numbers */
.stat-number {
    font-weight: 700;
    background: linear-gradient(135deg, #2563eb, #10b981);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    position: relative;
}

.stat-number::after {
    content: '+';
    position: absolute;
    right: -15px;
    top: 0;
    opacity: 0;
    animation: plusPulse 2s ease-in-out infinite;
}

@keyframes plusPulse {
    0%, 100% { opacity: 0; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.2); }
}

/* Process Timeline Enhancements */
.process-step {
    position: relative;
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

.process-step:hover {
    transform: scale(1.02);
}

.step-number {
    position: relative;
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

.process-step:hover .step-number {
    transform: rotate(360deg) scale(1.1);
    background: linear-gradient(135deg, #2563eb, #10b981);
    color: white;
}

/* Smooth Scroll Indicator */
.scroll-indicator {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    z-index: 9999;
}

.scroll-progress {
    height: 100%;
    background: linear-gradient(90deg, #2563eb, #10b981);
    width: 0%;
    transition: width 0.1s ease;
}

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

.hero-features .feature-item {
    animation: float 3s ease-in-out infinite;
}

.hero-features .feature-item:nth-child(1) { animation-delay: 0s; }
.hero-features .feature-item:nth-child(2) { animation-delay: 0.2s; }
.hero-features .feature-item:nth-child(3) { animation-delay: 0.4s; }
.hero-features .feature-item:nth-child(4) { animation-delay: 0.6s; }

/* Parallax Effect for Sections */
.parallax-section {
    transform: translateZ(0);
    will-change: transform;
}

/* Enhanced Button Ripple Effect */
.btn {
    overflow: hidden;
    position: relative;
    z-index: 1;
}

.btn::after {
    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;
}

.btn:active::after {
    width: 300px;
    height: 300px;
}

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

.gradient-text {
    background: linear-gradient(90deg, #2563eb, #10b981, #2563eb);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gradientShift 3s ease infinite;
}

/* Glitch Effect for Special Elements */
@keyframes glitch {
    0% { transform: translate(0); }
    20% { transform: translate(-2px, 2px); }
    40% { transform: translate(-2px, -2px); }
    60% { transform: translate(2px, 2px); }
    80% { transform: translate(2px, -2px); }
    100% { transform: translate(0); }
}

.glitch-hover:hover {
    animation: glitch 0.3s infinite;
}

/* Noise Background Effect */
@keyframes noise {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-5%, -10%); }
    20% { transform: translate(-15%, 5%); }
    30% { transform: translate(7%, -25%); }
    40% { transform: translate(-5%, 25%); }
    50% { transform: translate(-15%, 10%); }
    60% { transform: translate(15%, 0%); }
    70% { transform: translate(0%, 15%); }
    80% { transform: translate(3%, 35%); }
    90% { transform: translate(-10%, 10%); }
}

/* Blob Morphing */
@keyframes blobMorph {
    0%, 100% { border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%; }
    25% { border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%; }
    50% { border-radius: 50% 60% 30% 60% / 30% 60% 70% 40%; }
    75% { border-radius: 60% 40% 60% 40% / 70% 30% 50% 60%; }
}

/* Interactive Underline Effect */
.interactive-link {
    position: relative;
    text-decoration: none;
}

.interactive-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, #2563eb, #10b981);
    transition: width 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

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

/* Fade In Up Animation (GSAP Alternative) */
.fade-in-up {
    opacity: 0;
    transform: translateY(40px);
}

/* Scale In Animation */
.scale-in {
    opacity: 0;
    transform: scale(0.8);
}

/* Loading State */
.loading {
    position: relative;
    overflow: hidden;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    animation: loading 1.5s infinite;
}

@keyframes loading {
    to { left: 100%; }
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .hero-word {
        transform: translateY(50px) rotateX(-40deg);
    }

    .tilt-card:hover {
        transform: translateY(-4px);
    }

    .magnetic-btn:hover {
        transform: scale(1.02);
    }
}

/* Performance Optimization */
.tilt-card,
.magnetic-btn,
.service-card,
.process-step {
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Grain Texture Overlay */
.grain-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    opacity: 0.05;
    pointer-events: none;
    mix-blend-mode: overlay;
}
