/* Mobile fixes to prevent unwanted refreshing */
html, body {
    overscroll-behavior: contain;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body.menu-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* Static backgrounds for mobile */
@media (max-width: 650px) {
    /* Prevent animations from running */
    .static-bg {
        background: #0a0f1e;
    }
    
    /* Improve touch response */
    .hamburger-btn {
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: transparent !important;
        padding: 20px !important;
        z-index: 1000 !important;
        cursor: pointer !important;
    }
    
    /* Smooth scroll */
    html {
        scroll-behavior: smooth !important;
    }
    
    /* Reduce motion for better performance */
    * {
        -webkit-transition-duration: 0.2s !important;
        transition-duration: 0.2s !important;
        animation-duration: 0.2s !important;
    }
    
    /* Hide heavy animation elements */
    #globeContainer, .tech-globe-container, #synapseCanvas {
        display: none !important;
    }
    
    /* Optimize scrolling */
    body {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: auto;
    }
    
    /* Remove scroll-based section layouts */
    section {
        min-height: auto !important;
        height: auto !important;
        scroll-snap-align: none !important;
    }
    
    /* Hide scroll indicators */
    .scroll-indicator, .scroll-down-indicator, .scroll-arrow,
    [class*="scroll-"], [id*="scroll-"] {
        display: none !important;
    }
    
    /* Disable scroll snapping */
    html, body {
        scroll-snap-type: none !important;
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
    
    /* Prevent memory leaks from heavy elements */
    .timeline-container, .nexus-container, .certificates-grid {
        will-change: auto !important;
        transform: none !important;
    }
    
    /* Force hardware acceleration off for stability */
    * {
        -webkit-transform: none !important;
        transform: none !important;
        will-change: auto !important;
    }
    
    /* Prevent iOS bounce and zoom */
    html {
        -webkit-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
    }
    
    /* Disable problematic CSS properties */
    .glass-side-box, .certificate-card, .mobile-nav-link {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }
    
    /* Ensure content is visible without scrolling effects */
    #hero-section, #synapse-section, #timeline-section, #certificates-section {
        padding: 60px 20px !important;
        margin: 0 !important;
    }

    .hamburger-btn {
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        background: rgba(0,0,0,0.9) !important;
        border: 1px solid rgba(255,255,255,0.1) !important;
        width: 50px !important;
        height: 50px !important;
        position: fixed !important;
        top: 20px !important;
        right: 20px !important;
        z-index: 1001 !important;
        padding: 10px !important;
    }
    .hamburger-btn span {
        width: 24px !important;
        height: 3px !important;
        background: #fff !important;
        margin: 3px 0 !important;
        border-radius: 4px !important;
        display: block !important;
        opacity: 1 !important;
        box-shadow: 0 0 5px rgba(255,255,255,0.3) !important;
    }
    .hamburger-btn span {
        background: #fff !important;
        color: #fff !important;
    }
    .hamburger-btn {
        pointer-events: auto !important;
        z-index: 1002 !important;
    }
    .hamburger-btn {
        z-index: 9999 !important;
        pointer-events: auto !important;
    }
    .mobile-overlay {
        pointer-events: none !important;
    }
    .mobile-overlay.active {
        pointer-events: auto !important;
    }
    .left-hamburger-btn {
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        background: rgba(0,0,0,0.9) !important;
        border: 1px solid rgba(255,255,255,0.1) !important;
        width: 50px !important;
        height: 50px !important;
        position: fixed !important;
        top: 20px !important;
        left: 20px !important;
        z-index: 9999 !important;
        padding: 10px !important;
        pointer-events: auto !important;
    }
    .left-hamburger-btn span {
        width: 24px !important;
        height: 3px !important;
        background: #fff !important;
        margin: 3px 0 !important;
        border-radius: 4px !important;
        display: block !important;
        opacity: 1 !important;
        box-shadow: 0 0 5px rgba(255,255,255,0.3) !important;
    }
    .left-hamburger-btn {
        display: flex !important;
    }
    /* Hide original hamburger button on mobile if needed */
    /* .hamburger-btn {
        display: none !important;
    } */
    .dot-navbar {
        display: none !important;
    }
    .dot-nav-dot {
        width: 14px;
        height: 14px;
        border-radius: 50%;
        background: #7dd3fc;
        opacity: 0.5;
        transition: opacity 0.3s, background 0.3s;
        display: block;
        border: 2px solid #0ea5e9;
    }
    .dot-nav-dot.active {
        opacity: 1;
        background: #0ea5e9;
        border-color: #7dd3fc;
    }
    .left-hamburger-btn {
        display: none !important;
    }
}
@media (min-width: 651px) {
    .left-hamburger-btn {
        display: none !important;
    }
    .dot-navbar {
        display: none !important;
    }
}

/* Mobile overlay styles */
.mobile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 15, 30, 0.85);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.mobile-overlay.active {
    opacity: 1;
    visibility: visible;
}

.mobile-overlay::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, rgba(0, 212, 255, 0.08) 0%, transparent 70%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.8s ease;
}

.mobile-overlay.active::before {
    opacity: 1;
}

.mobile-nav-menu {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    width: 85%;
    max-width: 400px;
    transform: translateY(30px);
    opacity: 0;
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    transition-delay: 0.1s;
}

.mobile-overlay.active .mobile-nav-menu {
    transform: translateY(0);
    opacity: 1;
}

.mobile-nav-link {
    color: #ffffff;
    text-decoration: none;
    font-size: 1.25rem;
    font-weight: 600;
    padding: 1.2rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    text-align: center;
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
    transition: all 0.4s ease;
    transform: translateY(20px);
    opacity: 0;
}

.mobile-overlay.active .mobile-nav-link {
    transform: translateY(0);
    opacity: 1;
}

.mobile-overlay.active .mobile-nav-link:nth-child(1) { transition-delay: 0.1s; }
.mobile-overlay.active .mobile-nav-link:nth-child(2) { transition-delay: 0.2s; }
.mobile-overlay.active .mobile-nav-link:nth-child(3) { transition-delay: 0.3s; }
.mobile-overlay.active .mobile-nav-link:nth-child(4) { transition-delay: 0.4s; }

.mobile-nav-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 212, 255, 0.15), transparent);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
}

.mobile-nav-link:hover::before {
    transform: translateX(100%);
}

.mobile-nav-link:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-3px) !important;
    box-shadow: 0 10px 25px rgba(0, 212, 255, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.mobile-nav-link.active {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.25), inset 0 0 10px rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

/* Mobile Nav Logo */
.mobile-nav-logo {
    font-family: 'Orbitron', monospace;
    font-size: 2rem;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 2.5rem;
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
    letter-spacing: 1px;
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    transition-delay: 0.05s;
}

.mobile-overlay.active .mobile-nav-logo {
    transform: translateY(0);
    opacity: 1;
}