/* This file contains HEADER CSS rules that are identical across all pages of the website. */
/* HEADER RULES: header, logo-text, theme-toggle, submenu, burger-menu, dropdown-menu */
/* Common Header Layout and Styling */
header {
    margin-bottom: 40px;
    border-bottom: 1px solid var(--border-color);
    position: relative;
    position: sticky;
    top: 0; /* Ensures it sticks to the top of the viewport */
    z-index: 50; /* Needs to be a high value to sit above page content, but lower than the modal */
    background-color: var(--header-bg); 
}

header::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Set z-index below the header content but above page content */
    z-index: -1; 
    
    /* Apply the transparent background and blur */
    background-color: var(--header-bg); /* Uses the transparent variable you already defined */
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    
    /* Ensure the pseudo-element also has the bottom border */
    box-sizing: border-box; 
    border-bottom: 1px solid var(--border-color); 
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px;
    display: flex; /* NEW: Layout for header contents */
    justify-content: space-between;
    align-items: center;
}

/* START NAV LINKS STYLES */
.logo-text {
    font-family: var(--font-family-header);
    font-size: 1.8em;
    letter-spacing: 3px;
    text-transform: none; /* Allows for mixed case, overriding default uppercase */
    font-style: italic; /* Makes the entire logo italic */
    color: var(--color-primary);
    text-decoration: none; /* Ensure logo link doesn't have underline */
    white-space: nowrap;
}

.header-nav {
    display: block;
    gap: 0px; /* Space between links */
}

.header-nav a {
    font-family: var(--font-family-body); /* Uses updated body font */
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--color-primary);
    text-decoration: none;
    padding: 5px 0;
    position: relative;
    transition: color 0.3s ease;
}

.header-nav a:hover {
    color: var(--color-primary); /* Stays primary color */
}

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

.header-nav a:hover::after {
    width: 100%;
}

.header-nav a.active {
/* Optional: Change color for active state if desired */
    color: var(--color-primary);
    font-weight: bold;
}

.header-nav a.active::after {
    width: 100%; /* Makes the underline appear on the active page */
}

.header-nav .nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex; /* Re-introduce flex to the list */
    gap: 30px; /* Space between links, moved from .header-nav */
    justify-content: flex-start; /* Align items to the left/start */
}

.header-nav .nav-list li {
    position: relative; /* Crucial for desktop absolute positioning of dropdown */
}

.submenu-toggle-btn {
    background: none;
    border: none;
    color: var(--color-primary); /* Inherit header text color */
    cursor: pointer;
    height: 25px;
    width: 25px;
    padding: 0;
    line-height: 1; 
    transition: transform 0.3s ease;
    flex-shrink: 0; /* Prevent it from shrinking */
}

.submenu-toggle-btn .fa-chevron-down {
    transition: transform 0.3s ease;
}
.submenu-toggle-btn[aria-expanded="true"] .fa-chevron-down {
    transform: rotate(180deg);
}
/* END NAV LINKS STYLES */

.theme-toggle {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--color-primary);
    padding: 10px 10px;
    cursor: pointer;
    font-family: var(--font-family-body); /* Uses updated body font */
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.3s ease;
}
.theme-toggle:hover {
    background-color: var(--color-primary);
    color: var(--color-secondary);
}

/* BURGER MENU STYLES */
.burger-menu {
    display: none; /* Hide by default */
    background: none;
    border: 1px solid var(--border-color);
    cursor: pointer;
    padding: 10px;
}

.burger-menu .bar {
    width: 16px;
    height: 1px;
    background-color: var(--color-primary);
    margin: 5px 0;
    transition: all 0.3s ease;
}


/* NEW MEDIA QUERY for intermediate screens (950px down to 769px) */
@media (max-width: 950px) {
    .logo-text {
        font-size: 1.5em; /* Reduces font size for smaller screens */
    }
    
    /* Reduce padding/size of the theme toggle button */
    .theme-toggle {
        padding: 8px 8px; /* Reduced padding */
        font-size: 0.8em; /* Slightly smaller text */
    }

    /* Reduce the gap between navigation links to pack them tighter */
    .header-nav {
        gap: 15px; /* Reduced from 30px */
    }

    /* Slightly reduce the font size of the navigation links */
    .header-nav a {
        font-size: 0.9em; 
    }
}

@media (max-width: 844px) {
    .logo-text {
        font-size: 1.4em; /* Reduces font size for smaller screens */
    }

    /* Reduce the gap between navigation links to pack them tighter */
    .header-nav {
        gap: 12px; /* Reduced from 30px */
    }

    /* Slightly reduce the font size of the navigation links */
    .header-nav a {
        font-size: 0.8em; 
    }
}

/* === MEDIA QUERIES :: +++ DESKTOP +++ === */
@media (min-width: 769px) {
    .submenu-toggle-btn {
        display: none;
    }

    .nav-item.has-submenu {
        position: relative; /* Context for absolute positioning */
    }

    .dropdown-menu[hidden] { 
        display: block !important; 
    }
    
    /* Dropdown Menu Style (The Disclosure Panel) */
    .dropdown-menu {
        position: absolute;
        top: 100%; /* Places the menu precisely below the link */
        left: 0;
        z-index: 20; /* Ensures it overlays page content */
        /* min-width: 150px; */
        background-color: var(--header-bg); 
        padding: 10px 0;
        border: 1px solid var(--border-color);
        list-style: none;

        /* Override mobile visibility/clipping properties */
        max-height: none; 
        overflow: visible;

        /* Hidden State: Uses opacity/visibility for smooth transition */
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
        backdrop-filter: blur(2px);
    }

    /* Submenu Links */
    .dropdown-menu a {
        display: block;
        width: fit-content;
        padding: 8px 15px; /* Adjust padding for better desktop link spacing */
    }

    /* Display Trigger (On Hover) */
    .nav-item.has-submenu:hover > .dropdown-menu {
        opacity: 1;
        visibility: visible;
    }

    /* Submenu Links Styling */
    .dropdown-menu a {
        display: block;
        padding: 8px 15px; 
    }
}


/* === MEDIA QUERIES :: RESPONSIVE DESIGN === */
@media (max-width: 768px) {
    .logo-text {
        font-size: 1.5em; /* Reduces font size for smaller screens */
    }
    
    header {
        flex-direction: row; /* Change to row */
        justify-content: space-between; /* Space out items */
        align-items: center; /* Vertically align */
        gap: 10px;
        margin-bottom: 0px;
    }

    .theme-toggle { 
        font-size: 0.8em;
    }

    /* Adjust nav links for mobile */
    .header-nav {
        display: none; /* Keep hidden by default */
        position: fixed; /* Use fixed position */
        top: 0;
        left: 0;
        width: 100%;
        height: 100%; /* Full height of the viewport */
        background-color: var(--color-secondary);
        flex-direction: column;
        justify-content: center; /* Vertically center links */
        align-items: center; /* Horizontally center links */
        gap: 30px; /* Increase gap between links for better touch targets */
        z-index: 95; /* Lower than burger menu but higher than other content */
        transition: transform 0.3s ease-in-out;
        transform: translateX(100%); /* Start off-screen */
    }

    .header-nav.active {
        display: flex; /* Display when active */
        transform: translateX(0); /* Slide into view */
        background-color: rgba(0, 0, 0, 0.4); /* Semi-transparent black */
        backdrop-filter: blur(15px); /* Blurs the content behind the menu */
    }

    .header-nav a {
        font-size: 2em; /* Make links larger for mobile */
        padding: 10px; /* Add padding for larger touch area */
    }

    .header-nav a::after {
        height: 1px;
        bottom: 2px;
    }

    .header-nav .nav-list {
        display: flex; 
        flex-direction: column; /* Stack items vertically in the modal */
        gap: 25px;

        width: 100%; 
        /* padding-top: 50px; Push content down from the fixed close button */
        /* overflow-y: auto; Allow scrolling if the menu is long */
    }

    .nav-item.has-submenu {
        display: flex;
        justify-content: space-between;
        align-items: center; /* Ensures button aligns with the link's vertical center */
    }

    .submenu-toggle-btn {
        height: 44px; 
        width: 44px;
        position: absolute; 
        top: 3px;

        margin: auto 0; /* Flexbox standard for vertical centering */
        padding: 0; /* Ensure internal padding doesn't affect 44x44 size */
        flex-shrink: 0;

    }

    .nav-item, .header-nav .nav-list li {
        display: block;
        width: fit-content; /* Ensure full-width blocks */
        align-content: center;
        /* border-bottom: 1px solid var(--border-color);  Visual separators */
    }

    .nav-link-primary {
        flex-grow: 1; /* Link takes up most of the space */
        padding: 15px 0; /* Vertical padding for large touch area */
        /* Remove redundant underline animation on mobile if desired */
        /* .nav-link-primary::after { content: none; } */
    }

    /* Accordion Dropdown Styles */
    .dropdown-menu {
        width: 100%; 
        list-style: none;
        padding: 0;
        margin: 0;
        /* Transition properties for the push-down effect */
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.4s ease-in-out;
        background-color: color-mix(in srgb, var(--header-bg) 95%, transparent);
        border-left: 1px solid var(--border-color); /* Final separator for the group */
        padding: 0 20px; /* Horizontal padding for the row */
    }

    .dropdown-menu:not([hidden]) {
        max-height: 500px; /* Value must be greater than content height */
    }

    .dropdown-menu li a {
        display: block;
        width: fit-content;
        /* padding: 15px 20px 15px 40px; Increased left padding for indentation */
    }

    .header-content {
        padding: 10px;
    }

    .burger-menu {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        /* Standardize the button dimensions to match the burger menu */
        height: 40px;
        width: 40px;
        padding: 0;
    }

    /* Standardize the burger menu line dimensions */
    .burger-menu span {
        width: 28px;
        height: 2px;
        margin: 4px 0;
    }

    /* Modal Close button */
    .close-button {
        display: block;
        top: 10px;
        right: 10px;
    }
}