/* ================================
   HEADER & NAVIGATION
   Navigation bar, mobile menu, sticky header
   ================================ */

/* ===== SITE HEADER ===== */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: var(--color-white);
    box-shadow: var(--shadow-sm);
    z-index: var(--z-sticky);
    transition: var(--transition-base);
    max-width: 100vw; /* Prevent header from exceeding viewport */
    overflow-x: hidden; /* Clip any overflow */
    box-sizing: border-box;
    height: auto; /* Only cover the height of the header content */
    pointer-events: auto; /* Header itself can receive clicks */
}

.site-header.scrolled {
    padding: 0.5rem 0;
    box-shadow: var(--shadow-lg);
}

/* ===== NAVIGATION ===== */
.navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding-left: var(--container-padding);
    padding-right: var(--container-padding);
    width: 100%; /* Ensure nav respects container width */
    box-sizing: border-box;
}

/* ===== LOGO ===== */
.logo {
    display: flex;
    align-items: center;
    font-size: var(--font-size-xl);
    font-family: var(--font-heading);
    font-weight: var(--font-weight-bold);
    color: var(--color-primary);
    text-decoration: none;
    transition: var(--transition-base);
}

.logo:hover {
    color: var(--color-primary-dark);
}

.logo img {
    height: 50px;
    width: auto;
    margin-right: var(--spacing-sm);
    transition: var(--transition-base);
}

.site-header.scrolled .logo img {
    height: 40px;
}

/* ===== NAV MENU ===== */
.nav-menu {
    display: flex;
    list-style: none;
    gap: var(--spacing-lg);
    align-items: center;
}

.nav-item {
    position: relative;
}

.nav-link {
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-primary);
    text-decoration: none;
    padding: 0.5rem 0;
    display: block;
    position: relative;
    transition: var(--transition-base);
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--color-primary);
    transition: width 0.3s ease;
}

.nav-link:hover,
.nav-link.active {
    color: var(--color-primary);
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 100%;
}

/* ===== CTA BUTTON IN NAV ===== */
.nav-cta {
    margin-left: var(--spacing-md);
}

.nav-cta .btn {
    padding: 0.625rem 1.5rem;
    font-size: var(--font-size-sm);
}

/* ===== MOBILE MENU TOGGLE ===== */
.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    z-index: var(--z-sticky);
}

.menu-toggle span {
    width: 28px;
    height: 3px;
    background: var(--color-primary);
    border-radius: 3px;
    transition: var(--transition-base);
}

/* Hamburger Animation */
.menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(8px, 8px);
}

.menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

/* ===== MOBILE MENU OVERLAY ===== */
.mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: calc(var(--z-sticky) - 1);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none; /* Don't block clicks when inactive */
}

.mobile-menu-overlay.active {
    opacity: 1;
    pointer-events: auto; /* Allow clicks only when active */
}

/* ===== RESPONSIVE NAVIGATION ===== */
@media (max-width: 1024px) {
    .menu-toggle {
        display: flex;
    }

    /* Ensure header and navigation fit on mobile */
    .site-header {
        width: 100vw;
        max-width: 100vw;
        height: auto; /* Critical: only cover header height */
        pointer-events: auto; /* Header can receive clicks */
    }

    .navigation {
        padding-left: 1rem;
        padding-right: 1rem;
        width: 100%;
        pointer-events: auto; /* Nav items clickable */
    }

    .logo {
        font-size: var(--font-size-lg);
        max-width: 70%; /* Prevent logo from taking too much space */
    }

    .nav-menu {
        position: fixed;
        top: 0;
        right: -100%;
        width: 280px;
        height: 100vh;
        background: var(--color-white);
        flex-direction: column;
        padding: 5rem 2rem 2rem;
        gap: var(--spacing-md);
        box-shadow: var(--shadow-2xl);
        transition: right 0.3s ease;
        overflow-y: auto;
        align-items: flex-start;
        pointer-events: auto; /* Menu items clickable */
    }

    .nav-menu.active {
        right: 0;
    }

    .nav-link {
        font-size: var(--font-size-lg);
        width: 100%;
        padding: var(--spacing-sm) 0;
    }

    .nav-cta {
        margin-left: 0;
        margin-top: var(--spacing-md);
        width: 100%;
    }

    .nav-cta .btn {
        width: 100%;
        padding: 0.875rem 1.5rem;
        font-size: var(--font-size-base);
    }

    .mobile-menu-overlay {
        display: block;
    }
}

/* Extra mobile fixes for very small screens */
@media (max-width: 480px) {
    .navigation {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .logo {
        font-size: var(--font-size-base);
    }

    .nav-menu {
        width: 250px; /* Slightly narrower on small screens */
    }
}

/* ===== DROPDOWN MENU (if needed for future) ===== */
.nav-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--color-white);
    box-shadow: var(--shadow-lg);
    border-radius: var(--border-radius-md);
    padding: var(--spacing-sm);
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
}

.nav-item:hover .nav-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.nav-dropdown-item {
    display: block;
    padding: var(--spacing-sm);
    color: var(--color-text-primary);
    text-decoration: none;
    border-radius: var(--border-radius-sm);
    transition: var(--transition-base);
}

.nav-dropdown-item:hover {
    background: var(--color-bg-secondary);
    color: var(--color-primary);
}

/* ===== SCROLL PROGRESS BAR ===== */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 3px;
    background: var(--gradient-secondary);
    z-index: calc(var(--z-sticky) + 1);
    transition: width 0.1s ease;
    pointer-events: none; /* Allow clicks to pass through */
}

/* ===== SKIP TO CONTENT (Accessibility) ===== */
.skip-to-content {
    position: absolute;
    top: -100px;
    left: 0;
    background: var(--color-primary);
    color: var(--color-white);
    padding: var(--spacing-sm) var(--spacing-md);
    text-decoration: none;
    border-radius: var(--border-radius-md);
    z-index: var(--z-tooltip);
    transition: top 0.3s ease;
}

.skip-to-content:focus {
    top: var(--spacing-sm);
}
