/* ==========================================================================
   Navigation Core Styles (Desktop First)
   ========================================================================== */

/* Main Header Container alignment fixes */
.site-navigation {
    display: block;
}

/* Hide mobile hamburger toggle on desktop screens */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    flex-direction: column;
    gap: 5px;
    z-index: 999;
}

.hamburger-bar {
    display: block;
    width: 25px;
    height: 3px;
    background-color: #4A4A4A; /* Brand Dark Grey */
    transition: all 0.3s ease-in-out;
}

/* Primary Horizontal Row Layout */
.main-menu {
    list-style: none !important;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 25px;
}

.main-menu li {
    margin: 0;
    padding: 0;
    list-style-type: none !important;
    position: relative; /* Anchor for absolute positioned submenus */
}

.main-menu li a {
    text-decoration: none;
    color: #4A4A4A;
    font-size: 0.95rem;
    font-weight: bold;
    transition: color 0.2s ease;
    display: inline-block;
}

.main-menu li a:hover {
    color: #699881; /* Brand Green */
}

/* --- Desktop Dropdown Sub-Menus --- */
@media (min-width: 769px) {
    /* Hide sub-menu list box initially */
    .main-menu ul.sub-menu {
        position: absolute;
        top: 100%;
        left: 0;
        background-color: #ffffff;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
        border: 1px solid #D1E3DC;
        min-width: 180px;
        padding: 10px 0;
        margin: 0;
        list-style: none !important;
        display: none;
        z-index: 999;
    }

    /* Force nested options back to a vertical row stack */
    .main-menu ul.sub-menu li {
        display: block;
        width: 100%;
    }

    .main-menu ul.sub-menu li a {
        display: block;
        padding: 8px 20px;
        font-weight: normal;
        font-size: 0.9rem;
        white-space: nowrap;
    }

    /* Reveal sub-menus safely using native hover mechanics */
    .main-menu li:hover > ul.sub-menu {
        display: block;
    }
}


/* --- Desktop Dropdown Arrow Indicator --- */
@media (min-width: 769px) {
    /* Add padding to the right of parent links to make room for the arrow */
    .main-menu .menu-item-has-children > a {
        position: relative;
        padding-right: 14px; 
    }

    /* Append a mini down arrow using a pseudo-element */
    .main-menu .menu-item-has-children > a::after {
        content: '▾';
        position: absolute;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
        font-size: 0.75rem;
        color: inherit; /* Automatically matches the link color (grey or green on hover) */
        transition: transform 0.2s ease;
    }

    /* Optional: Rotate the arrow slightly when hovering over the menu item */
    .main-menu .menu-item-has-children:hover > a::after {
        transform: translateY(-50%) rotate(180deg);
    }
}

/* ==========================================================================
   Mobile Responsive Rules (768px and down)
   ========================================================================== */
@media (max-width: 768px) {
    /* Critical parent anchors for positioning absolute panels */
    .header-container {
        position: relative !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        width: 100% !important;
    }

    .site-navigation {
        position: static !important; /* Lets the panel calculate layout directly from header container */
    }

    .menu-toggle {
        display: flex !important; /* Expose the hamburger button icon */
    }

    /* Transform standard row into an absolute floating canvas block */
    .main-menu {
        display: none !important; /* Kept hidden until hamburger is clicked */
        flex-direction: column !important;
        width: 100%;
        position: absolute;
        top: 100%; /* Sits exactly flush under the white header header bar */
        left: 0;
        background-color: #ffffff;
        padding: 20px !important;
        box-sizing: border-box;
        box-shadow: 0 10px 15px rgba(0, 0, 0, 0.05);
        border-top: 1px solid #D1E3DC;
        border-bottom: 2px solid #D1E3DC;
        z-index: 99999 !important; /* Force panel above page layout content */
        gap: 20px !important;
    }

    /* Reveal list drawer seamlessly when active */
    .site-navigation.toggled .main-menu {
        display: flex !important;
    }

    /* --- Clean, Open Mobile Sub-Menus --- */
    .main-menu ul.sub-menu {
        list-style: none !important;
        padding: 10px 0 0 15px !important; /* Clean offset indentation layout */
        margin: 0 !important;
        display: flex !important; /* ALWAYS wide open and visible */
        flex-direction: column !important;
        gap: 12px !important;
    }

    .main-menu ul.sub-menu li {
        display: block !important;
        width: 100% !important;
    }

    .main-menu ul.sub-menu li a {
        font-weight: normal !important;
        font-size: 0.9rem !important;
        color: #666666 !important; /* Soft distinct subitem color */
    }

    /* Morphing Hamburger animation styles */
    .site-navigation.toggled .hamburger-bar:nth-child(1) {
        transform: translateY(8px) rotate(45deg);
    }
    .site-navigation.toggled .hamburger-bar:nth-child(2) {
        opacity: 0;
    }
    .site-navigation.toggled .hamburger-bar:nth-child(3) {
        transform: translateY(-8px) rotate(-45deg);
    }
}
