/* Mobile Navigation - This is the primary controller */
#hamburger-btn,
.hamburger {
    display: none; /* Hidden by default, shown in media query */
    flex-direction: column;
    justify-content: space-around;
    width: 2rem;
    height: 2rem;
    background: transparent;
    border: none; /* remove debug border */
    cursor: pointer;
    padding: 0.5rem; /* Add some padding for better touch targets */
    z-index: 10001; /* Above everything */
    position: relative;
    border-radius: 4px;
}

.hamburger-line {
    width: 1.5rem;
    height: 0.25rem;
    background: #00B4D8; /* Solid color instead of CSS variable */
    border-radius: 10px;
    transition: all 0.3s ease-in-out;
    transform-origin: center;
    display: block;
}

#hamburger-btn.active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

#hamburger-btn.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

#hamburger-btn.active .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* ULTIMATE MOBILE NAVIGATION FIX - COMPLETELY REWRITTEN */
#mobile-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(10, 25, 41, 0.95);
    z-index: 9999; /* Extremely high z-index */
    
    /* Initially hidden */
    display: none;
}

/* When active, show the mobile nav */
#mobile-nav.active {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Style the navigation content */
#mobile-nav .mobile-nav-content {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

#mobile-nav .mobile-nav-content ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

#mobile-nav .mobile-nav-content ul li {
    margin: 0;
}

#mobile-nav .mobile-nav-content ul li a {
    color: #FFFFFF;
    font-size: 1.8rem;
    font-weight: 600;
    text-decoration: none;
    padding: 1rem 2rem;
    border-radius: 8px;
    display: block;
    text-align: center;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

#mobile-nav .mobile-nav-content ul li a:hover,
#mobile-nav .mobile-nav-content ul li a.active {
    color: #FF6B35;
    background: rgba(255, 255, 255, 0.1);
    border-color: #FF6B35;
}

/* Mobile Responsive - FORCE HAMBURGER VISIBILITY */
@media (max-width: 768px) {
    .nav-desktop,
    .desktop-nav {
        display: none !important;
    }

    #hamburger-btn {
        display: flex !important; /* FORCE show the hamburger button on mobile */
        position: relative !important;
        z-index: 10001 !important;
    }

    .nav-container {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
    }

    .header-container {
        padding: 0.75rem 1rem;
    }

    .logo {
        font-size: 1.25rem;
    }

    /* Improve mobile touch targets */
    .hamburger {
        padding: 0.5rem;
        margin: -0.5rem;
    }

    .mobile-nav-item a {
        padding: 1rem 2rem;
        border-radius: 0.5rem;
        transition: all 0.3s ease;
    }

    .mobile-nav-item a:hover,
    .mobile-nav-item a.active {
        background: rgba(255, 255, 255, 0.1);
        color: var(--secondary-color, #FF6B35);
    }
}

/* Small mobile devices - EXTRA SAFETY */
@media (max-width: 480px) {
    #hamburger-btn {
        display: flex !important; /* FORCE show on small devices */
        width: 2rem !important;
        height: 2rem !important;
        padding: 0.25rem !important;
    }

    .hamburger-line {
        width: 1.5rem !important;
        height: 0.2rem !important;
    }

    .header-container {
        padding: 0.5rem;
    }

    .logo {
        font-size: 1.125rem;
    }

    .mobile-nav-item a {
        font-size: 1.25rem;
        padding: 0.75rem 1.5rem;
    }

    .hamburger {
        width: 1.75rem;
        height: 1.75rem;
    }
}

/* UNIVERSAL MOBILE FALLBACK - Show hamburger on any screen smaller than 769px */
@media screen and (max-width: 769px) {
    #hamburger-btn,
    .hamburger {
        display: flex !important;
        /* remove debug background and border */
        background: transparent !important;
        border: none !important;
    }
    
    .desktop-nav,
    .nav-desktop {
        display: none !important;
    }
}

/* Ensure hamburger is visible up to 1200px (tablet widths) */
@media (max-width: 1200px) {
  #hamburger-btn,
  .hamburger {
    display: flex !important;
    background: transparent !important;
    border: none !important;
    margin-right: 0 !important; /* neutralize negative margins from other styles */
    margin-left: auto !important; /* push to the far right */
    align-self: center;
  }
  #hamburger-btn .hamburger-line,
  .hamburger .hamburger-line {
    background: #00B4D8 !important; /* ensure visible on white header */
    opacity: 1 !important;
  }
}

/* Position hamburger to the far right and ensure it’s visible */
@media (max-width: 900px) {
  #hamburger-btn,
  .hamburger {
    display: flex !important;
    margin-left: auto !important;
    margin-right: 0 !important;
    align-self: center;
  }
}

/* Focus states for accessibility */
.hamburger:focus {
    outline: 2px solid var(--primary-color, #00B4D8);
    outline-offset: 2px;
}

.desktop-nav-item a:focus,
.mobile-nav-item a:focus {
    outline: 2px solid var(--primary-color, #00B4D8);
    outline-offset: 2px;
}

/* Animation for smooth transitions */
.header {
    transition: transform 0.3s ease;
}

.header.scrolled {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

/* Global Search (header) */
.site-search {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: 1rem;
    flex: 1 1 380px;
    max-width: 520px;
}

.site-search .search-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.site-search input[type="search"] {
    width: 100%;
    padding: 0.6rem 2.25rem 0.6rem 2.25rem;
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: 999px;
    background: #fff;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.site-search input[type="search"]::placeholder {
    color: #98a2b3;
}

.site-search input[type="search"]:focus {
    border-color: #00B4D8;
    box-shadow: 0 0 0 3px rgba(0,180,216,0.15);
}

.site-search .search-icon {
    position: absolute;
    left: 0.65rem;
    width: 1.1rem;
    height: 1.1rem;
    color: #64748b;
    pointer-events: none;
}

.site-search .clear-btn {
    position: absolute;
    right: 0.4rem;
    display: none;
    width: 1.6rem;
    height: 1.6rem;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: #64748b;
    cursor: pointer;
}

.site-search .clear-btn:hover { color: #0f172a; }

.site-search .results {
    position: absolute;
    top: calc(100% + 0.4rem);
    left: 0;
    right: 0;
    z-index: 10002;
    background: #ffffff;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(2, 8, 23, 0.12);
    overflow: hidden;
    display: none;
    max-height: 60vh;
    overflow-y: auto;
}

.site-search .results.visible { display: block; }

.site-search .result-item {
    display: flex;
    align-items: start;
    gap: 0.6rem;
    padding: 0.65rem 0.9rem;
    text-decoration: none;
    color: #0f172a;
    border-bottom: 1px solid rgba(0,0,0,0.04);
}

.site-search .result-item:last-child { border-bottom: none; }

.site-search .result-item:hover,
.site-search .result-item.active {
    background: #f1fbff;
}

.site-search .result-title { font-weight: 600; font-size: 0.95rem; }
.site-search .result-desc { color: #475569; font-size: 0.85rem; }
.site-search .result-meta { color: #64748b; font-size: 0.78rem; }

.site-search .result-icon {
    width: 1.1rem;
    height: 1.1rem;
    color: #00B4D8;
    margin-top: 0.15rem;
}

.site-search .empty-state {
    padding: 0.8rem 1rem;
    color: #64748b;
    font-size: 0.9rem;
}

/* Layout adjustments: keep nav tidy */
.nav-container { gap: 1rem; }
.desktop-nav { flex: 0 1 auto; }

/* Responsive behavior */
@media (max-width: 1024px) {
    .site-search { flex: 1 1 260px; max-width: none; }
}

@media (max-width: 768px) {
    .site-search { order: 3; width: 100%; margin: 0.75rem 0 0; }
    .site-search .results { position: fixed; left: 1rem; right: 1rem; top: auto; margin-top: 0.25rem; }
    .nav-container { flex-wrap: wrap; }
}
