/**
 * Shared Header Styles for Virtual Runaway
 * Consistent header styling across all pages
 */

/* Reset body margins and add header spacing */
body {
    margin: 0 !important;
    padding-top: 80px !important; /* Header height + extra spacing */
}

/* Ensure no extra spacing from containers */
.container {
    margin-top: 0 !important;
    padding-top: 1rem !important; /* Add some breathing room */
}

/* Add proper spacing for main content areas */
main, .page-content, .main-content {
    padding-top: 1rem !important;
}

/* Ensure headings have proper spacing from header */
h1, h2 {
    margin-top: 0 !important;
    padding-top: 0.5rem !important;
}

/* Header Container */
.shared-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 255, 65, 0.3);
    box-shadow: 0 2px 10px rgba(0, 255, 65, 0.1);
    margin: 0;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 0.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    gap: 0.5rem;
}

/* Safe zone for mobile devices */
@supports (padding: max(0px)) {
    .header-container {
        padding-left: max(0.5rem, env(safe-area-inset-left));
        padding-right: max(0.5rem, env(safe-area-inset-right));
    }
}

/* Logo Section */
.logo-section {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.logo-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: inherit;
    transition: opacity 0.2s ease;
}

.logo-link:hover {
    opacity: 0.8;
}

.logo-image {
    height: 40px; /* larger for better detail visibility */
    width: auto;
    object-fit: contain;
}

.site-title {
    font-family: 'Courier New', monospace;
    font-size: 1.25rem;
    font-weight: bold;
    color: #00ff41;
    margin: 0;
    white-space: nowrap;
}

/* Desktop Navigation - Hidden on mobile, visible on desktop */
.desktop-nav {
    display: none;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    justify-content: center;
    max-width: 600px;
}

/* High-specificity rules scoped to the shared header only to avoid page-level overrides (e.g., index.html inline .nav-link) */
header.shared-header .nav-link {
    display: flex;
    align-items: center;
    /* lock exact dimensions so all pages match visually */
    padding: 8px 16px; /* was 0.5rem 1rem, rem can vary by page */
    color: #00ff41;
    text-decoration: none;
    font-family: 'Courier New', monospace;
    font-size: 14px; /* fixed px to avoid page root font differences */
    font-weight: 500;
    border-radius: 6px;
    border: 1px solid rgb(0, 255, 65) !important; /* Force solid green border regardless of page CSS */
    background: rgba(0, 255, 65, 0.1);
    transition: all 0.2s ease;
    white-space: nowrap;
    min-height: 44px;
    line-height: 1; /* prevent vertical growth from line-height */
    box-sizing: border-box; /* consistent sizing across pages */
    justify-content: center;
}

header.shared-header .nav-link:hover {
    background: rgba(0, 255, 65, 0.2);
    border-color: rgb(0, 255, 65);
    box-shadow: 0 0 10px rgba(0, 255, 65, 0.3);
}

header.shared-header .nav-link.active {
    background: rgb(0, 255, 65);
    border-color: rgb(0, 255, 65);
    color: rgb(0, 0, 0);
}

/* Auth Section */
.auth-section {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

header.shared-header .auth-button {
    padding: 8px 16px; /* lock to px so it matches exactly */
    background: rgba(0, 255, 65, 0.1);
    border: 1px solid rgb(0, 255, 65) !important; /* Force consistency */
    color: #00ff41;
    font-family: 'Courier New', monospace;
    font-size: 14px; /* match nav-link */
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px;
    min-width: 60px;
    white-space: nowrap;
    flex-shrink: 0;
    margin-right: 0;
    line-height: 1;
    box-sizing: border-box;
}

/* Responsive adjustments for small screens */
@media (max-width: 400px) {
    .header-container {
        gap: 0.25rem;
        padding-left: max(0.25rem, env(safe-area-inset-left));
        padding-right: max(0.25rem, env(safe-area-inset-right));
    }

    .auth-button {
        font-size: 0.7rem;
        padding: 0.35rem 0.4rem;
        min-width: 45px;
        min-height: 32px;
    }

    .site-title {
        font-size: 0.9rem;
    }
}

/* Extra small screens */
@media (max-width: 320px) {
    .header-container {
        gap: 0.125rem;
        padding-left: max(0.125rem, env(safe-area-inset-left));
        padding-right: max(0.125rem, env(safe-area-inset-right));
    }

    .auth-button {
        font-size: 0.65rem;
        padding: 0.3rem 0.35rem;
        min-width: 40px;
        min-height: 30px;
    }

    .site-title {
        font-size: 0.8rem;
    }
}

.auth-button:hover {
    background: rgba(0, 255, 65, 0.2);
    border-color: rgb(0, 255, 65);
    box-shadow: 0 0 10px rgba(0, 255, 65, 0.3);
}

.sign-out-btn {
    border-color: rgba(255, 65, 65, 0.5);
    color: rgba(255, 65, 65, 0.8);
}

.sign-out-btn:hover {
    background: rgba(255, 65, 65, 0.1);
    border-color: #ff4141;
    color: #ff4141;
}

/* Mobile Menu Toggle - Only visible on mobile, no border for perfect centering */
.mobile-menu-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 44px;
    height: 44px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    margin: 0;
    position: relative;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.mobile-menu-toggle:hover {
    background: rgba(0, 255, 65, 0.05);
}

.mobile-menu-toggle:active {
    transform: scale(0.95);
}

/* Hamburger icon container */
.hamburger-line {
    display: block;
    width: 20px;
    height: 2px;
    background: #00ff41;
    position: relative;
    transition: all 0.3s ease;
    border-radius: 1px;
}

/* Create the three lines using pseudo-elements */
.hamburger-line::before,
.hamburger-line::after {
    content: '';
    position: absolute;
    left: 0;
    width: 20px;
    height: 2px;
    background: #00ff41;
    border-radius: 1px;
    transition: all 0.3s ease;
    transform-origin: center center;
}

.hamburger-line::before {
    top: -7px;
}

.hamburger-line::after {
    top: 7px;
}

/* Animation for open state - Perfect X shape */
.mobile-menu-toggle.open .hamburger-line {
    background: transparent;
}

.mobile-menu-toggle.open .hamburger-line::before {
    transform: rotate(45deg);
    top: 0;
}

.mobile-menu-toggle.open .hamburger-line::after {
    transform: rotate(-45deg);
    top: 0;
}

/* Mobile Navigation */
.mobile-nav {
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.98);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 255, 65, 0.3);
    transform: translateY(-100%);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    max-height: calc(100vh - 64px);
    overflow-y: auto;
    z-index: 999;
}

.mobile-nav.open {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
}

.mobile-nav-content {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.mobile-nav .nav-link {
    padding: 1rem;
    text-align: center;
    border: 1px solid rgba(0, 255, 65, 0.2);
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

.mobile-auth {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(0, 255, 65, 0.2);
}

.mobile-auth .auth-button {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
}

/* Prevent body scroll when mobile menu is open */
body.mobile-menu-open {
    overflow: hidden;
}

/* Desktop Styles */
@media (min-width: 768px) {
    body {
        padding-top: 88px !important; /* Larger header + extra spacing */
    }

    .header-container {
        padding: 0 2rem;
        height: 72px;
    }

    /* Show desktop navigation */
    .desktop-nav {
        display: flex !important;
    }

    /* Hide mobile menu toggle completely */
    .mobile-menu-toggle {
        display: none !important;
    }

    /* Hide mobile navigation */
    .mobile-nav {
        display: none !important;
        top: 72px;
        max-height: calc(100vh - 72px);
    }



    .site-title {
        font-size: 1.5rem;
    }

    .logo-image {
        height: 48px; /* bump on desktop for extra clarity */
    }
}

/* Large Desktop Styles */
@media (min-width: 1024px) {
    body {
        padding-top: 96px !important; /* Even larger header + extra spacing */
    }

    .header-container {
        height: 80px;
    }

    header.shared-header .nav-link {
        padding: 8px 16px; /* keep identical across all pages */
        font-size: 14px;
        line-height: 14px;
        box-sizing: border-box;
    }

    header.shared-header .auth-button {
        padding: 8px 16px;
        font-size: 14px;
        line-height: 14px;
        box-sizing: border-box;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .shared-header {
        border-bottom-color: #00ff41;
    }
    
    .nav-link {
        border: 1px solid transparent;
    }
    
    .nav-link:hover,
    .nav-link.active {
        border-color: #00ff41;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .nav-link,
    .auth-button,
    .mobile-nav,
    .hamburger-line {
        transition: none;
    }
}
