/* Navbar Stability Fix - Prevents visual glitches during page transitions */

/* Ensure navbar is always stable and properly rendered */
.header {
    /* Force stable positioning and prevent layout shifts */
    position: sticky !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    
    /* Ensure proper stacking and prevent z-index issues */
    z-index: 10000 !important;
    
    /* Force stable background and prevent transparency issues */
    background: var(--bg-secondary) !important;
    backdrop-filter: blur(10px) !important;
    
    /* Prevent any transform or animation glitches */
    transform: none !important;
    animation: none !important;
    
    /* Ensure consistent border and shadow */
    border-bottom: 2px solid var(--border-color) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
}

.nav {
    /* Force stable layout and prevent flexbox glitches */
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    flex-wrap: wrap !important;
    gap: var(--spacing-sm) !important;
    
    /* Prevent positioning issues */
    position: relative !important;
    z-index: 10001 !important;
    
    /* Force stable dimensions */
    width: 100% !important;
    min-height: 60px !important;
    
    /* Prevent any transform glitches */
    transform: none !important;
    animation: none !important;
}

.nav-brand {
    /* Force stable brand positioning */
    position: relative !important;
    z-index: 10002 !important;
    
    /* Prevent text rendering glitches */
    font-family: 'Press Start 2P', cursive !important;
    font-size: 1.3rem !important;
    color: var(--accent-primary) !important;
    
    /* Force stable dimensions */
    flex-shrink: 0 !important;
    min-width: 200px !important;
    
    /* Prevent any hover effects from causing glitches */
    transition: color 0.2s ease !important;
}

.nav-menu {
    /* Force stable menu positioning */
    display: flex !important;
    list-style: none !important;
    gap: var(--spacing-sm) !important;
    align-items: center !important;
    flex: 1 !important;
    justify-content: flex-start !important;
    flex-wrap: wrap !important;
    
    /* Prevent positioning glitches */
    position: relative !important;
    z-index: 10001 !important;
    
    /* Force stable dimensions */
    margin: 0 !important;
    padding: 0 !important;
    min-height: 40px !important;
    
    /* Prevent any transform glitches */
    transform: none !important;
    animation: none !important;
}

.nav-link {
    /* Force stable link rendering */
    position: relative !important;
    z-index: 10002 !important;
    
    /* Prevent text rendering glitches */
    color: var(--text-secondary) !important;
    font-size: 0.85rem !important;
    font-weight: 500 !important;
    
    /* Force stable dimensions and prevent layout shifts */
    padding: 6px 10px !important;
    min-height: 32px !important;
    min-width: 60px !important;
    
    /* Prevent transition glitches */
    transition: color 0.2s ease, background-color 0.2s ease !important;
    
    /* Ensure proper text rendering */
    white-space: nowrap !important;
    text-decoration: none !important;
    
    /* Prevent any transform glitches */
    transform: none !important;
    animation: none !important;
}

.nav-link:hover {
    /* Smooth hover effects without glitches */
    color: var(--accent-primary) !important;
    background: var(--bg-tertiary) !important;
    transform: translateY(-1px) !important;
    transition: color 0.2s ease, background-color 0.2s ease, transform 0.2s ease !important;
}

.nav-link.active {
    /* Force stable active state */
    color: var(--accent-primary) !important;
    background: var(--bg-tertiary) !important;
    box-shadow: 0 2px 4px var(--shadow-color) !important;
}

/* Mobile menu toggle stability */
.mobile-menu-toggle {
    /* Force stable mobile toggle */
    position: relative !important;
    z-index: 10002 !important;
    
    /* Prevent positioning glitches */
    display: none !important; /* Hidden by default on desktop */
    
    /* Force stable dimensions */
    min-height: 48px !important;
    min-width: 48px !important;
    
    /* Prevent any transform glitches */
    transform: none !important;
    animation: none !important;
}

/* User dropdown stability */
.user-dropdown {
    /* Force stable dropdown positioning */
    position: relative !important;
    z-index: 10003 !important;
    
    /* Prevent positioning glitches */
    display: flex !important;
    align-items: center !important;
}

.user-button {
    /* Force stable button rendering */
    position: relative !important;
    z-index: 10002 !important;
    
    /* Prevent any transform glitches */
    transform: none !important;
    animation: none !important;
    
    /* Smooth transitions */
    transition: background-color 0.2s ease, transform 0.2s ease !important;
}

.dropdown-menu {
    /* Force stable dropdown menu */
    position: absolute !important;
    top: 100% !important;
    right: 0 !important;
    z-index: 10004 !important;
    
    /* Prevent positioning glitches */
    background: var(--bg-secondary) !important;
    border: 2px solid var(--border-color) !important;
    border-radius: var(--border-radius-md) !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3) !important;
    
    /* Force stable dimensions */
    min-width: 200px !important;
    
    /* Prevent any transform glitches */
    transform: none !important;
    animation: none !important;
}

/* Prevent any CSS animations or transitions from causing glitches */
.header *,
.nav *,
.nav-menu *,
.nav-link * {
    /* Ensure all navbar elements have stable rendering */
    backface-visibility: hidden !important;
    -webkit-backface-visibility: hidden !important;
    
    /* Prevent any unexpected animations */
    animation: none !important;
    
    /* Only allow specific transitions */
    transition: color 0.2s ease, background-color 0.2s ease, transform 0.2s ease !important;
}

/* Force stable rendering during page load */
body.loading .header,
body.transitioning .header {
    /* Ensure navbar stays stable even during page transitions */
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
}

/* Prevent any hover effects from causing layout shifts */
.nav-link:hover,
.user-button:hover,
.mobile-menu-toggle:hover {
    /* Ensure hover effects don't cause positioning issues */
    position: relative !important;
    z-index: 10005 !important;
}

/* Mobile-specific stability fixes */
@media (max-width: 1024px) {
    .mobile-menu-toggle {
        /* Show mobile toggle on mobile */
        display: block !important;
    }
    
    .nav-menu {
        /* Force stable mobile menu positioning */
        position: absolute !important;
        top: 100% !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        
        /* Prevent any positioning glitches */
        z-index: 99999 !important;
        
        /* Force stable background */
        background: var(--bg-secondary) !important;
        border: 2px solid var(--accent-primary) !important;
        border-top: none !important;
        border-radius: 0 0 12px 12px !important;
        
        /* Prevent any transform glitches */
        transform: none !important;
        animation: none !important;
    }
    
    .nav-menu.active {
        /* Force stable active mobile menu */
        max-height: 800px !important;
        opacity: 1 !important;
        visibility: visible !important;
        
        /* Prevent any positioning glitches */
        position: absolute !important;
        top: 100% !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        z-index: 99999 !important;
    }
}

/* Critical fix: Prevent any CSS transitions from causing visual glitches */
.header,
.nav,
.nav-menu,
.nav-link,
.user-dropdown,
.mobile-menu-toggle {
    /* Force hardware acceleration and prevent glitches */
    will-change: auto !important;
    transform: translateZ(0) !important;
    -webkit-transform: translateZ(0) !important;
    
    /* Ensure stable rendering */
    contain: layout style paint !important;
} 