/**
 * HBC Menu Navigation Fix
 * Location: C:\xampp\htdocs\hbc\assets\css\menu_fix.css
 * Purpose: Fix dropdown menus showing all at once, add border-radius
 */

/* ===== MAIN NAVIGATION FIXES ===== */

/* Add border-radius to main navigation */
.main-navigation {
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    overflow: hidden; /* Ensure border-radius clips content */
}

/* Add border-radius to main menu items (first/last) */
.nav-menu > li:first-child .nav-link {
    border-top-left-radius: 10px;
}

.nav-menu > li:last-child .nav-link {
    border-top-right-radius: 10px;
}

/* ===== DROPDOWN MENU FIXES ===== */

/* CRITICAL: Hide all dropdown menus by default */
.dropdown-menu,
ul.dropdown-menu,
.nav-dropdown .dropdown-menu,
[class*="dropdown-menu"] {
    display: none !important; /* Force hide */
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 220px;
    background: white;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
    list-style: none;
    z-index: 9999;
    margin: 0;
    padding: 0;
    border-radius: 10px; /* Add border-radius */
    overflow: hidden; /* Ensure border-radius clips content */
}

/* Show dropdown ONLY on hover of parent */
.nav-dropdown:hover > .dropdown-menu,
.nav-dropdown:hover > ul.dropdown-menu,
li:hover > .dropdown-menu,
li:hover > ul.dropdown-menu {
    display: block !important; /* Force show on hover */
}

/* Ensure dropdown items look correct */
.dropdown-menu li {
    border-bottom: 1px solid #e0e0e0;
    margin: 0;
    padding: 0;
}

.dropdown-menu li:first-child a {
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
}

.dropdown-menu li:last-child {
    border-bottom: none;
}

.dropdown-menu li:last-child a {
    border-bottom-left-radius: 10px;
    border-bottom-right-radius: 10px;
}

.dropdown-menu a {
    display: block;
    padding: 0.75rem 1rem;
    color: #1a1a1a;
    text-decoration: none;
    transition: background 0.2s ease, padding-left 0.2s ease;
}

.dropdown-menu a:hover {
    background: #e3f2fd;
    padding-left: 1.25rem;
    text-decoration: none;
}

/* Ensure parent container doesn't clip dropdowns */
.main-navigation,
.nav-menu,
.nav-menu > li {
    overflow: visible !important;
}

/* Remove any conflicting styles */
.nav-dropdown {
    position: relative;
}

/* ===== RESPONSIVE MOBILE FIXES ===== */

@media (max-width: 768px) {

    /* rev8 (2026-07-02): this file loads LAST, so it is the single authority for
       the mobile menu. We only set structural bits here; the full drill-down
       behaviour is defined in the rev8 block appended at the very end of this
       file so nothing can override it. Do NOT reveal submenus on hover here. */
    .main-navigation {
        border-radius: 0;
    }

    .nav-menu {
        flex-direction: column;
    }

    .dropdown-menu {
        position: static;
        box-shadow: none;
        background: #ffffff;
        border-radius: 0;
    }
}

/* ===== Z-INDEX HIERARCHY ===== */

/* Ensure proper stacking order */
.main-navigation {
    z-index: 1000;
}

.nav-menu {
    z-index: 1001;
}

.dropdown-menu {
    z-index: 9999;
}

/* ===== ADDITIONAL SAFETY OVERRIDES ===== */

/* Override any global dropdown styles that might interfere */
nav .dropdown-menu,
nav ul.dropdown-menu,
header .dropdown-menu {
    display: none !important;
}

nav .nav-dropdown:hover .dropdown-menu,
nav .nav-dropdown:hover ul.dropdown-menu,
header .nav-dropdown:hover .dropdown-menu {
    display: block !important;
}

/* Ensure visibility is not forced elsewhere */
.dropdown-menu[style*="display: block"] {
    /* This will be overridden by hover state */
}

/* Clean up any JavaScript-added inline styles */
.dropdown-menu {
    visibility: hidden !important;
    opacity: 0;
    transition: opacity 0.2s ease, visibility 0s linear 0.2s;
}

.nav-dropdown:hover .dropdown-menu {
    visibility: visible !important;
    opacity: 1;
    transition: opacity 0.2s ease, visibility 0s linear 0s;
}



/* =============================================================================
   MOBILE NAVIGATION — AUTHORITATIVE DRILL-DOWN (rev 8, 2026-07-02)
   This block lives at the END of menu_fix.css, which is the LAST stylesheet
   loaded by index.php (main.css, layout.css, responsive.css, menu_fix.css).
   Being last + !important makes it the final word on phones, so no other file
   can re-open the menu. Desktop (>768px) is untouched.

   STATE A collapsed (every fresh page load): only the hamburger shows; the
           9-item menu and all submenus are hidden; the page content is visible.
   STATE B menu open: tap hamburger -> the 9 items list out.
   STATE C drilled in: tap a section -> the title header, hamburger and the
           other 8 items hide; only that submenu shows, led by a [<- Back] btn.
   Navigating a submenu link loads the next page in STATE A.
   ============================================================================= */
@media (max-width: 768px) {

    /* Hamburger visible in STATE A + STATE B */
    .site-header .mobile-menu-toggle {
        display: block !important;
        position: absolute !important;
        top: 1rem !important;
        right: 1rem !important;
        z-index: 1002 !important;
    }

    /* STATE A default: the whole menu is hidden */
    .site-header .nav-menu {
        display: none !important;
        flex-direction: column !important;
        width: 100% !important;
    }
    /* STATE B: hamburger opened (JS adds .active) */
    .site-header .nav-menu.active {
        display: flex !important;
    }

    .site-header .nav-menu > li {
        flex: none !important;
        width: 100% !important;
        border-bottom: 1px solid #e0e0e0;
    }
    .site-header .nav-link {
        padding: 0.95rem 1.1rem;
        font-size: 1.05rem;
        text-align: left;
    }
    .site-header .nav-dropdown > .nav-link::after {
        content: "\203A";
        float: right;
        font-size: 1.3rem;
        line-height: 1;
        opacity: 0.55;
    }

    /* Submenus: neutralise the desktop hover/visibility model and keep them
       hidden until their section is opened by a tap (.submenu-open via JS). */
    .site-header .nav-dropdown > .dropdown-menu {
        display: none !important;
        visibility: visible !important;   /* cancel desktop visibility:hidden */
        opacity: 1 !important;
        transition: none !important;
        position: static !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        width: 100% !important;
        min-width: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #ffffff !important;
        border: none !important;
        box-shadow: none !important;
        transform: none !important;
        border-radius: 0 !important;
        overflow: visible !important;
        z-index: auto !important;
    }
    /* Hover must NOT reveal submenus on touch */
    .site-header .nav-dropdown:hover > .dropdown-menu {
        display: none !important;
        visibility: visible !important;
    }
    /* STATE C: the opened section reveals its submenu */
    .site-header .nav-dropdown.submenu-open > .dropdown-menu {
        display: block !important;
    }

    /* STATE C drill-down: hide EVERYTHING except the open submenu */
    body.submenu-active .site-header .header-top { display: none !important; }
    body.submenu-active .site-header .mobile-menu-toggle { display: none !important; }
    body.submenu-active .site-header .nav-menu > li:not(.submenu-open) { display: none !important; }
    body.submenu-active .site-header .nav-dropdown.submenu-open > .nav-link { display: none !important; }
    body.submenu-active .site-header .nav-dropdown.submenu-open > .nav-link::after { content: none !important; }

    /* Back button (JS injects it as the first child of the open submenu) */
    .site-header .dropdown-back {
        display: block !important;
        padding: 1rem 1.25rem;
        font-size: 1.1rem;
        font-weight: 700;
        color: #ffffff;
        background: var(--color-primary, #2980b9);
        cursor: pointer;
        user-select: none;
        border: none;
    }

    /* Submenu links: full-width, easy tap targets */
    .site-header .dropdown-menu a {
        display: block !important;
        padding: 1.1rem 1.25rem !important;
        padding-left: 1.25rem !important;
        font-size: 1.1rem;
        border-bottom: 1px solid #e0e0e0;
        background: transparent;
        white-space: normal;
    }
}

/* Desktop safety: the injected Back button never shows above 768px */
@media (min-width: 769px) {
    .dropdown-back { display: none !important; }
}
