/**
 * Products mega-menu dropdown (development-only, logged-in users).
 * Self-contained dark panel — works over both the light and .page-dark header.
 * Type scale / spacing emulated from the "Option 2" comp.
 */

/* Parent <li> that owns the panel (WP already sets position:relative on it). */
.nav-mega-parent {
    position: relative;
}

/* Panel — hidden until the parent item is hovered/focused.
   Anchored left so it opens rightward from the Products button. */
.nav-mega {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: min(900px, 94vw);
    background-color: var(--color-black);
    color: var(--color-white);
    box-shadow: 0 30px 70px -20px rgba(0, 0, 0, 0.7);
    border-top: 3px solid var(--color-grass);
    z-index: 200;
}

.nav-mega-parent:hover .nav-mega,
.nav-mega-parent:focus-within .nav-mega {
    display: block;
}

.nav-mega__inner {
    padding: 28px 32px 32px;
}

/* Header row: "OUR PRODUCTS" + "VIEW ALL PRODUCTS →" */
.nav-mega__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 20px;
}

.nav-mega__title {
    font-family: lato;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 1.05rem;
    color: var(--color-white);
}

/* High-specificity selector needed to beat the theme's #menu-main-nav li a rule. */
.nav-mega__viewall,
.primary-menu ul#menu-main-nav .nav-mega__viewall,
.primary-menu ul#menu-main-nav .nav-mega__viewall:hover {
    font-family: lato;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.85rem; /* smaller than the .nav-mega__title heading (1.05rem) */
    letter-spacing: 1.2px;
    color: var(--color-lightning);
    text-decoration: none;
    white-space: nowrap;
    margin: 0;
}

.primary-menu ul#menu-main-nav .nav-mega__viewall:hover {
    opacity: 0.8;
}

/* Two columns: fixed list | preview */
.nav-mega__body {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 28px;
    align-items: stretch;
}

.nav-mega__list {
    list-style: none;
    margin: 0;
    padding: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-mega__item {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Override the inherited primary-nav link styling for panel rows. */
.nav-mega__item a,
.primary-menu ul#menu-main-nav .nav-mega__item a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0;
    padding: 10px 4px;
    font-family: lato;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: none;
    letter-spacing: 0;
    line-height: 1.2;
    color: rgba(242, 244, 239, 0.75);
    text-decoration: none;
    transition: color 0.15s ease;
}

.nav-mega__arrow {
    opacity: 0;
    color: var(--color-lightning);
    font-weight: 700;
    transition: opacity 0.15s ease;
}

.nav-mega__item.is-active a,
.nav-mega__item a:hover,
.primary-menu ul#menu-main-nav .nav-mega__item.is-active a,
.primary-menu ul#menu-main-nav .nav-mega__item a:hover {
    color: var(--color-lightning);
}

.nav-mega__item.is-active .nav-mega__arrow,
.nav-mega__item a:hover .nav-mega__arrow {
    opacity: 1;
}

/* Preview column — stretches to the list's height. */
.nav-mega__previews {
    position: relative;
    min-height: 320px;
    border-radius: 6px;
    overflow: hidden;
    background-color: #141414;
}

.nav-mega__preview {
    display: none;
    position: absolute;
    inset: 0;
}

.nav-mega__preview.is-active {
    display: block;
}

.nav-mega__preview-img,
.nav-mega__img {
    width: 100%;
    height: 100%;
}

.nav-mega__img {
    object-fit: cover;
    display: block;
}

/* Caption overlaid on the bottom-left of the image. */
.nav-mega__caption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 40px 20px 16px;
    background: linear-gradient(transparent, rgba(12, 13, 11, 0.92));
}

.nav-mega__name {
    font-family: lato;
    font-weight: 800;
    font-size: 1.25rem;
    line-height: 1.1;
    color: var(--color-white);
}

.nav-mega__spec {
    font-family: lato;
    font-size: 0.78rem;
    color: rgba(242, 244, 239, 0.6);
}

/* ---- Responsive: this theme swaps to the burger menu at <=1670px (that's
   where header.css hides .menu and shows #menu-toggle), so the panel must go to
   its stacked mobile layout at the same breakpoint — otherwise the desktop
   absolutely-positioned panel shoots off the right edge of the mobile menu. */
@media screen and (max-width: 1670px) {
    /* Let the open mobile menu scroll internally instead of getting stuck
       behind the fixed header while the page scrolls behind it. */
    .primary-menu ul#menu-main-nav.active {
        max-height: calc(100vh - 120px);
        max-height: calc(100dvh - 120px);
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    /* Menu text white on the dark mobile menu. The panel's product names keep
       their gray via a more specific rule, so only the nav items change. */
    .primary-menu ul#menu-main-nav li a {
        color: var(--color-white);
    }

    .nav-mega {
        display: none;
        position: relative;
        top: 0;
        left: auto;
        width: 100%;
        box-shadow: none;
        border-top: 0;
    }

    /* On touch, open/close by tapping Products (toggles .is-open via JS)
       rather than hover/focus, which don't reliably clear on mobile. */
    .nav-mega-parent:hover .nav-mega,
    .nav-mega-parent:focus-within .nav-mega {
        display: none;
    }
    .nav-mega-parent.is-open .nav-mega {
        display: block;
    }

    .nav-mega__inner {
        padding: 10px 14px 16px;
    }

    .nav-mega__head {
        padding-bottom: 8px;
    }

    .nav-mega__title {
        font-size: 0.95rem;
    }

    .nav-mega__body {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .nav-mega__previews {
        display: none;
    }

    /* No preview column on mobile, so don't auto-highlight the first item. */
    .nav-mega__item.is-active a,
    .primary-menu ul#menu-main-nav .nav-mega__item.is-active a {
        color: rgba(242, 244, 239, 0.75);
    }

    .nav-mega__item.is-active .nav-mega__arrow {
        opacity: 0;
    }
}
