/* Desktop-specific back-to-top button optimization */

/* Enhanced back-to-top button with better performance */
.back-to-top-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 50px;
    height: 50px;
    background: #39ff14;
    color: #000;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(57, 255, 20, 0.3);
    will-change: transform, opacity;
    transform: translateZ(0); /* Enable hardware acceleration */
    /* Remove box-shadow during scroll for better performance */
    content-visibility: auto;
    contain: layout style paint;
}

.back-to-top-btn.visible {
    opacity: 1;
    visibility: visible;
    transform: translateZ(0);
}

.back-to-top-btn:hover {
    transform: translateY(-5px) translateZ(0);
    box-shadow: 0 6px 20px rgba(57, 255, 20, 0.5);
}

/* Optimize the button during scroll events */
body.scrolling .back-to-top-btn {
    /* Reduce visual effects during scroll for better performance */
    transition: opacity 0.1s ease;
    box-shadow: 0 2px 6px rgba(57, 255, 20, 0.2);
}

/* Performance optimized smooth scrolling for desktop */
html {
    scroll-behavior: auto; /* Let JavaScript handle smooth scrolling for better control */
}

/* Optimized button positioning for desktop */
@media (min-width: 1025px) {
    .back-to-top-btn {
        bottom: 2.5rem;
        right: 2.5rem;
        width: 60px;
        height: 60px;
        font-size: 1.8rem;
        transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    }
}

/* High DPI display optimization */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .back-to-top-btn {
        backface-visibility: hidden;
        -webkit-backface-visibility: hidden;
    }
}

/* Reduce motion preference support */
@media (prefers-reduced-motion: reduce) {
    .back-to-top-btn {
        transition: none;
    }

    .back-to-top-btn:hover {
        transform: none;
    }
}

/* ===================================
   DESKTOP SCROLL OPTIMIZATIONS
   Enhanced performance for desktop browsers
   ================================== */

@media screen and (min-width: 1025px) {
    /* Enhanced scroll behavior for desktop */
    html {
        scroll-behavior: smooth;
        scroll-padding-top: 80px;
    }

    body {
        /* Optimize scroll performance */
        overflow-x: hidden;
        scroll-behavior: smooth;
    }

    /* Hardware acceleration for critical elements */
    .hero-section,
    .tokens-section,
    .features-section,
    .section-container {
        transform: translateZ(0);
        will-change: scroll-position;
        contain: layout style paint;
        backface-visibility: hidden;
        perspective: 1000px;
    }
    
    /* Special optimized handling for exchange section */
    .exchange-section {
        transform: translateZ(0);
        will-change: auto; /* Let CSS handle this to avoid conflicts */
        contain: layout style; /* Remove 'paint' to reduce optimization overhead */
        backface-visibility: hidden;
        /* Remove perspective to avoid interference with widget */
    }

    /* Optimize background elements for smooth scroll */
    #terminal-background,
    .retro-terminal-bg,
    .floating-particles,
    .sparkle-container,
    .scanlines {
        will-change: scroll-position;
        transform: translateZ(0);
        contain: layout style; /* Changed from 'strict' to reduce optimization overhead */
        /* Reduce complexity during scroll */
        transition: opacity 0.2s ease;
    }

    /* Optimize particle systems for desktop scroll */
    .floating-particles,
    .energy-orb {
        will-change: transform, opacity;
        transform: translateZ(0);
        /* Pause animations during fast scroll */
        animation-play-state: running;
    }

    /* Smooth hover effects without affecting scroll */
    .token-card,
    .feature-card,
    .content-card {
        transition: transform 0.3s ease, box-shadow 0.3s ease;
        will-change: transform;
    }

    .token-card:hover,
    .feature-card:hover,
    .content-card:hover {
        transform: translateY(-5px) translateZ(0);
        box-shadow: 0 10px 30px rgba(57, 255, 20, 0.2);
    }

    /* Optimize fixed elements */
    .ticker-wrap {
        will-change: transform;
        transform: translateZ(0);
        contain: layout style;
    }

    /* Optimize images for scroll performance */
    img {
        will-change: auto;
        transform: translateZ(0);
        image-rendering: optimizeSpeed;
    }

    /* Reduce motion during scroll for performance (excluding exchange widget) */
    .scrolling .floating-particles {
        animation-play-state: paused;
        opacity: 0.3;
    }

    .scrolling .energy-orb {
        animation-play-state: paused;
        opacity: 0.5;
    }

    .scrolling .retro-terminal-bg {
        opacity: 0.5;
    }
    
    /* Special handling for exchange widget during scroll - don't interfere */
    .scrolling .exchange-widget-wrapper {
        /* Keep backdrop-filter minimal during scroll */
        backdrop-filter: blur(5px) !important;
        -webkit-backdrop-filter: blur(5px) !important;
        /* Don't change opacity or positioning */
    }

    /* Optimize text rendering during scroll (but not for exchange widget) */
    .scrolling :not(.exchange-section):not(.exchange-widget-wrapper):not(.exchange-widget-wrapper *) {
        text-rendering: optimizeSpeed;
    }
}