/* ============================================================
   U&S Nutrition — Premium Mega Menu
   Based on approved prototype design.
   ============================================================ */

/* ---- Container & Positioning ---- */

.nasa-mega-menu-container {
    width: 100%;
    z-index: 100;
}

/* CRITICAL: Override theme's .nasa-hide-for-mobile which sets display:none
   on ALL screen sizes (both style-large.css AND style-mobile.css have this rule).
   The mega menu is only for desktop; mobile is handled by @media below. */
.nasa-mega-menu-container.nasa-hide-for-mobile {
    display: block !important;
}

/* ---- Dropdown Panel ---- */

.nasa-mega-menu-wrap {
    position: absolute;
    /* Position relative to #masthead (which has position:relative) instead of
       this container, so the dropdown aligns properly below the nav bar.
       The mega-menu-container sits right after the nav row in the DOM,
       so top:0 would start below the row. Using #masthead as containing
       block with top:100% ensures it starts at the bottom of #masthead. */
    top: 100%;
    left: 50%;
    width: 70%;
    z-index: 999;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.04);
    border-top: none;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.06), 0 20px 60px rgba(0, 0, 0, 0.04);
    border-radius: 0 0 16px 16px;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(8px);
    transition: opacity 300ms ease-out, transform 300ms ease-out, visibility 300ms ease-out;
    pointer-events: none;
    /* Prevent body { overflow-x: hidden } from clipping the mega menu */
    overflow-y: auto;
    overflow-x: visible;
}

.nasa-mega-menu-wrap.nasa-mm-active {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

/* ---- Inner Container ---- */

.nasa-mm-inner {
    width: 100%;
    margin-inline: auto;
    padding: 28px 32px 24px;
}

/* ---- CSS Grid (dynamic columns from WooCommerce) ---- */

.nasa-mm-grid {
    display: grid;
    grid-template-columns: var(--nasa-mm-grid, repeat(4, 1fr));
    gap: 32px;
    align-items: start;
}

/* ---- Column ---- */

.nasa-mm-col {
    min-width: 0;
}

/* ---- Parent Category Heading ---- */

.nasa-mm-parent {
    margin: 0 0 12px;
    padding: 0 0 10px;
    color: #1a1a1a;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    border-bottom: 2px solid transparent;
    display: inline-block;
    transition: border-color 250ms ease-out;
}

.nasa-mm-parent a {
    color: inherit;
    text-decoration: none;
    display: inline-block;
    transition: color 250ms ease-out;
}

.nasa-mm-col:hover .nasa-mm-parent {
    border-bottom-color: #1a1a1a;
}

/* ---- Child Category List ---- */

.nasa-mm-children {
    list-style: none;
    margin: 0;
    padding: 0;
}

.nasa-mm-child-item {
    margin: 0;
    padding: 0;
}

.nasa-mm-child-item a {
    display: inline-block;
    padding: 4px 0;
    color: #555;
    text-decoration: none;
    line-height: 1.5;
    position: relative;
    transition: color 250ms ease-out, transform 250ms ease-out;
}

.nasa-mm-child-item a::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 3px;
    width: 0;
    height: 1px;
    background: #1a1a1a;
    transition: width 250ms ease-out;
}

.nasa-mm-child-item a:hover {
    color: #1a1a1a;
    transform: translateX(3px);
}

.nasa-mm-child-item a:hover::after {
    width: 100%;
}

/* ============================================================
   RESPONSIVE BREAKPOINTS
   ============================================================ */

/* ---- Large Desktop (≥1440px) ---- */
@media (min-width: 1440px) {
    .nasa-mm-inner {
        max-width: 1320px;
    }

    .nasa-mm-grid {
        gap: 48px;
    }
}

/* ---- Desktop (1200–1439px) ---- */
@media (max-width: 1439px) {
    .nasa-mm-inner {
        max-width: 1200px;
    }

    .nasa-mm-grid {
        gap: 40px;
    }
}

/* ---- Laptop (992–1199px) ---- */
@media (max-width: 1199px) {
    .nasa-mega-menu-wrap {
        width: 85%;
    }

    .nasa-mm-inner {
        max-width: calc(100% - 48px);
        padding: 24px 24px 20px;
    }

    .nasa-mm-grid {
        gap: 28px;
    }
}

/* ---- Tablet & below (<768px) — Hide Mega Menu ----
 * NOTE: Must match theme's hamburger toggle breakpoint (767px).
 * If mega menu hid earlier (991px), there was a 768-991px gap
 * where NEITHER mega menu NOR hamburger worked. */
@media (max-width: 767px) {
    .nasa-mega-menu-wrap {
        display: none !important;
    }
}

/* 6-7 categories: tighter spacing */
.nasa-mm-grid--compact {
    gap: 24px;
}

/* 8+ categories: tighter gap for wrapped rows */
.nasa-mm-grid--many {
    gap: 20px;
}

/* Override mobile menu: show accordion arrows for injected WooCommerce categories */
#mobile-navigation li .nasa-has-items-child {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    margin-left: auto;
    margin-right: 4px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 200ms, transform 250ms ease;
    position: relative;
    z-index: 3;
}

#mobile-navigation li .nasa-has-items-child:hover {
    background: #f0f0f0;
}

#mobile-navigation li .nasa-has-items-child svg {
    transition: transform 250ms ease;
    width: 12px;
    height: 12px;
}

#mobile-navigation li.active > a > .nasa-has-items-child svg {
    transform: rotate(180deg);
}

/* Mobile: nested category indentation */
#mobile-navigation .nav-dropdown-mobile > .sub-menu > li > a {
    padding-left: 36px !important;
    font-weight: 600;
}

#mobile-navigation .nav-dropdown-mobile .sub-menu li .nav-dropdown-mobile .sub-menu li a {
    padding-left: 52px !important;
    font-weight: 400;
    color: #555;
}

/* Mobile: dropdown background & state */
#mobile-navigation .nav-dropdown-mobile {
    background: #fafafa;
    border-top: 1px solid #f0f0f0;
    border-bottom: 1px solid #f0f0f0;
    display: none;
}

#mobile-navigation li.active > .nav-dropdown-mobile {
    display: block;
}

/* ---- Desktop Mega Menu: Column Dividers ---- */
.nasa-mm-col + .nasa-mm-col {
    border-left: 1px solid #f0f0f0;
    padding-left: 32px;
}

@media (min-width: 1440px) {
    .nasa-mm-col + .nasa-mm-col {
        padding-left: 48px;
    }
}

@media (max-width: 1439px) {
    .nasa-mm-col + .nasa-mm-col {
        padding-left: 40px;
    }
}

@media (max-width: 1199px) {
    .nasa-mm-col + .nasa-mm-col {
        padding-left: 28px;
    }
}

/* ---- Mobile Menu: Fix Arrow Alignment ----
 * The .nasa-title-menu must be flex so that margin-left: auto 
 * on the arrow span pushes it to the right edge. */
#mobile-navigation .nasa-title-menu {
    display: flex !important;
    align-items: center;
    width: 100%;
}

/* Arrow: override margin-right to 0, let margin-left:auto do the push */
#mobile-navigation li .nasa-has-items-child {
    margin-left: auto;
    margin-right: 0;
}
