/* ============================================================
   Grouped mega menu — appended to PrimeLife/style.css
   Selectors are scoped to .mega-menu-grouped so they don't
   affect other menu items still using the flat layout.
   ============================================================ */

/* Row layout — even columns separated by hairline dividers */
.mega-menu-grouped .panel-menu .mega-menu-grouped__row {
    align-items: stretch;
    margin: 0;
}

.mega-menu-grouped__col {
    padding: 0 1.75rem !important;
    border-right: 1px solid #E5E7EB;
}

.mega-menu-grouped__col:last-child {
    border-right: none;
}

/* Column eyebrow (Men's Health / Mental Health / etc.) */
.mega-menu-grouped__eyebrow {
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--theme-secondary-color, #0F2E0F);
    margin-bottom: 1rem;
    text-align: left;
}

/* ───── Intro column (first column) ───── */
.mega-menu-grouped__intro-desc {
    color: var(--text-color, #6B7280);
    font-size: 0.9rem;
    line-height: 1.55;
    margin-bottom: 1.5rem;
    text-align: left;
}

.mega-menu-grouped__view-all {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    justify-self: start;
    margin-right: auto;
    gap: 4px;
    color: var(--theme-primary-color, #2D8543);
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    transition: gap 0.15s ease;
}

.mega-menu-grouped__view-all:hover {
    text-decoration: underline;
    gap: 8px;
}

/* ───── Category columns — child items ───── */
.mega-menu-grouped__item {
    display: block;
    text-decoration: none;
    color: inherit;
    margin-bottom: 1.25rem;
    transition: opacity 0.15s ease;
}

.mega-menu-grouped__item:last-child {
    margin-bottom: 0;
}

.mega-menu-grouped__item:hover {
    text-decoration: none;
    opacity: 0.85;
}

.mega-menu-grouped__item:hover .mega-menu-grouped__title {
    color: var(--theme-primary-color, #2D8543);
}

/* Item layout — icon + (title + description) */
.mega-menu-grouped__item .menu_item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    text-align: left;
}

.mega-menu-grouped__item-text {
    flex: 1 1 auto;
    min-width: 0;
}

.mega-menu-grouped__title {
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: #595959;
    line-height: 1.2;
    margin-bottom: 0.2rem !important;
    transition: color 0.15s ease;
}
#menu-main-menu li ul.panel-menu ul.row>li:hover p {
    color: var(--theme-menu-content-color) !important;
}

.mega-menu-grouped__desc {
    font-size: 0.8rem;
    color: var(--text-color, #6B7280);
    line-height: 1.45;
}

/* Icon container — flat (no pill background) so the SVG colour shows through */
.mega-menu-grouped__item .menu_icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    height: auto;
    background-color: transparent;
    color: var(--theme-primary-color, #2D8543);
    font-size: 1.4rem;
    line-height: 1;
}

.mega-menu-grouped__item .menu_icon i {
    color: var(--theme-primary-color, #2D8543);
}

.mega-menu-grouped__item .menu_icon svg,
.mega-menu-grouped__item .menu_icon img {
    width: 24px;
    height: 24px;
    fill: var(--theme-primary-color, #2D8543);
}

.mega-menu-grouped__item .menu_icon--placeholder {
    background-color: transparent;
    width: 0;
    height: 0;
    margin-right: 0;
}

/* ───── Responsive ───── */
@media (max-width: 991.98px) {
    .mega-menu-grouped__col {
        padding: 0 !important;
        border-right: none;
        border-bottom: 1px solid #E5E7EB;
    }

    .mega-menu-grouped__col:last-child {
        border-bottom: none;
    }

    .mega-menu-grouped__col.mega-menu-grouped__intro {
        display:  none;
    }
    .mega-menu-grouped__eyebrow {
        display: none !important;
    }
}




/* === Icon overrides — flat (no pill), inline SVG/img next to the title === */

/* Container — strip the rounded square + background entirely */
.mega-menu-grouped .menu_icon,
.mega-menu-grouped__item .menu_icon {
    flex-shrink: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: auto !important;
    height: auto !important;
    border-radius: 0 !important;
    background-color: transparent !important;
    color: var(--theme-primary-color, #2D8543) !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Constrain SVG / image size — overrides any parent-theme rule or
   inline width/height attributes on the SVG itself */
.mega-menu-grouped .menu_icon svg,
.mega-menu-grouped .menu_icon img,
.mega-menu-grouped__item .menu_icon svg,
.mega-menu-grouped__item .menu_icon img {
    width: 24px !important;
    height: 24px !important;
    max-width: 24px !important;
    max-height: 24px !important;
    display: block;
}

.mega-menu-grouped .menu_icon svg path,
.mega-menu-grouped .menu_icon svg circle,
.mega-menu-grouped .menu_icon svg rect {
    fill: var(--theme-primary-color, #2D8543);
}

/* Kill the green underline that the parent theme is adding under .menu_item h4 */
.mega-menu-grouped .menu_item h4,
.mega-menu-grouped__title {
    border-bottom: none !important;
    padding-bottom: 0 !important;
    margin-bottom: 0.2rem !important;
    text-decoration: none !important;
}

.mega-menu-grouped .menu_item h4::after,
.mega-menu-grouped__title::after {
    content: none !important;
    display: none !important;
}

/* Tighter row spacing inside columns */
.mega-menu-grouped__item {
    margin-bottom: 1rem !important;
}

.mega-menu-grouped__item:last-child {
    margin-bottom: 0 !important;
}

/* Item text alignment — title aligned to the icon's vertical centre */
.mega-menu-grouped__item .menu_item {
    align-items: flex-start !important;
}

/* Description sits below the title, slightly muted */
.mega-menu-grouped__desc {
    color: var(--text-color, #6B7280) !important;
    font-size: 0.8rem !important;
    line-height: 1.45 !important;
    margin-top: 0.15rem !important;
}


/* ============================================================
   Panel container — full-width, rounded, soft shadow
   Scoped to .mega-menu-grouped so the flat layout is unaffected.
   ============================================================ */
@media (min-width: 992px) {

    /* Panel spans the full width of the nav and detaches slightly */
    .mega-menu-grouped > ul.panel-menu {
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        top: calc(100% + 0.5rem) !important;
        background: #fff !important;
        border: 1px solid #E5E7EB !important;
        border-radius: 16px !important;
        box-shadow: 0 12px 40px rgba(15, 46, 15, 0.08) !important;
        padding: 3.5rem 4rem !important;
        overflow: hidden;
    }

    /* Defeat Bootstrap .container's max-width so the columns
       use the panel's full inner width */
    .mega-menu-grouped > ul.panel-menu > li.container {
        max-width: 100% !important;
        width: 100% !important;
        padding-left: 1.5rem !important;
        padding-right: 1.5rem !important;
    }
}

/* ============================================================
   Icon overrides (round 2) — small + green, no parent caps
   ============================================================ */

/* Parent theme has .panel-menu .menu_icon { max-width: 2rem; font-size: 2rem }
   and .panel-menu .menu_icon img { max-height: 4rem; width: 100% } — both win
   over our earlier rules. Defeat them here. */
.mega-menu-grouped .panel-menu .menu_icon,
.mega-menu-grouped .menu_icon,
.mega-menu-grouped__item .menu_icon {
    max-width: none !important;
    max-height: none !important;
    font-size: 1rem !important;
    line-height: 1 !important;
}

/* Hard-cap the actual visual — SVG / IMG / inline-SVG inside the icon span */
.mega-menu-grouped .panel-menu .menu_icon svg,
.mega-menu-grouped .panel-menu .menu_icon img,
.mega-menu-grouped .menu_icon svg,
.mega-menu-grouped .menu_icon img,
.mega-menu-grouped__item .menu_icon svg,
.mega-menu-grouped__item .menu_icon img {
    width: 22px !important;
    height: 22px !important;
    max-width: 22px !important;
    max-height: 22px !important;
    min-width: 22px !important;
    min-height: 22px !important;
    display: block !important;
}

/* Recolour every paint-bearing node inside the inline SVG to theme green.
   Skip nodes that explicitly opt out with fill="none" / stroke="none". */
.mega-menu-grouped .menu_icon svg,
.mega-menu-grouped .menu_icon svg path,
.mega-menu-grouped .menu_icon svg circle,
.mega-menu-grouped .menu_icon svg rect,
.mega-menu-grouped .menu_icon svg polygon,
.mega-menu-grouped .menu_icon svg ellipse,
.mega-menu-grouped .menu_icon svg g {
    color: var(--theme-primary-color, #2D8543) !important;
}

.mega-menu-grouped .menu_icon svg [fill]:not([fill="none"]),
.mega-menu-grouped .menu_icon svg path:not([fill="none"]),
.mega-menu-grouped .menu_icon svg circle:not([fill="none"]),
.mega-menu-grouped .menu_icon svg rect:not([fill="none"]),
.mega-menu-grouped .menu_icon svg polygon:not([fill="none"]),
.mega-menu-grouped .menu_icon svg ellipse:not([fill="none"]),
.mega-menu-grouped .menu_icon svg g:not([fill="none"]) {
    fill: var(--theme-primary-color, #2D8543) !important;
}

.mega-menu-grouped .menu_icon svg [stroke]:not([stroke="none"]) {
    stroke: var(--theme-primary-color, #2D8543) !important;
}

/* ============================================================
   Suppress parent theme's green underline bar between h4 + p
   ============================================================ */
.mega-menu-grouped .panel-menu h4:has(+ p):after,
.mega-menu-grouped__title:has(+ p):after,
.mega-menu-grouped__title::after {
    content: none !important;
    display: none !important;
    background: none !important;
    height: 0 !important;
    width: 0 !important;
    margin: 0 !important;
}


@media (min-width: 992px) {

    /* ── Reanchor the panel to .container-xl instead of .navbar-header ── */

    /* 1. Promote .container-xl to be a positioning context. Safe — nothing
          in the page currently relies on it being static. */
    #mainNavbar > .container-xl.d-flex.align-items-center {
        position: relative !important;
    }

    /* 2. When a grouped panel is hovered / focused / explicitly open, drop
          .navbar-header's position:relative so the absolute .panel-menu walks
          past it up to .container-xl. The search overlay only uses
          .navbar-header as an anchor when *it* is open (.is-active), and
          the user can't have search open and a mega menu open at the same
          time, so this is safe. */
    /* #mainNavbar > .container-xl:has(.mega-menu-grouped:hover) .navbar-header.position-relative,
    #mainNavbar > .container-xl:has(.mega-menu-grouped:focus-within) .navbar-header.position-relative,
    #mainNavbar > .container-xl:has(.mega-menu-grouped .panel-menu.open) .navbar-header.position-relative {
        position: static !important;
    } */
}

@media (min-width: 992px) {
    /* Keep container-xl as the positioning context for the mega panel at all times.
       This prevents the panel snapping to the narrower .navbar-header on close. */
    #mainNavbar > .container-xl.d-flex.align-items-center {
        position: relative !important;
    }

    #mainNavbar > .container-xl:has(.mega-menu-grouped) .navbar-header.position-relative {
        position: static !important;
    }
}

/* ============================================================
   Intro column — force "All Conditions →" link to the left
   ============================================================ */

/* Left-align the whole intro column's content (text + inline-flex link).
   Escalated selector beats any parent-theme centering on the panel <li>. */
.mega-menu-grouped .panel-menu .mega-menu-grouped__intro {
    text-align: left !important;
    align-items: flex-start !important;   /* in case the col is a flex container */
}

/* Belt-and-suspenders on the link itself — wins regardless of whether the
   column ends up as a block, flex, or grid container. */
.mega-menu-grouped .panel-menu .mega-menu-grouped__view-all,
.mega-menu-grouped__view-all {
    align-self: flex-start !important;
    justify-self: start !important;
    margin-right: auto !important;
    margin-left: 0 !important;
}


/* ============================================================
   < 1440px (but still desktop-ish) — cramp panel paddings so
   the 4 columns stay side-by-side. Without this, the 3.5rem/4rem
   panel padding plus column padding pushes col 4 onto a new row.
   Lower bound 992px so we don't fight with the mobile rules below.
   ============================================================ */
@media (min-width: 992px) and (max-width: 1439.98px) {

    /* Smaller outer panel breathing room */
    .mega-menu-grouped > ul.panel-menu {
        padding: 1.75rem 2rem !important;
    }

    /* Tighter inner Bootstrap .container padding */
    .mega-menu-grouped > ul.panel-menu > li.container {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }

    /* Tighter per-column gutter (was 1.75rem each side) */
    .mega-menu-grouped__col {
        padding: 0 1rem !important;
    }

    /* Trim intro copy so the column doesn't dominate */
    .mega-menu-grouped__intro-desc {
        font-size: 0.85rem;
        margin-bottom: 1rem;
    }

    .mega-menu-grouped__eyebrow {
        margin-bottom: 0.75rem;
    }

    /* Slightly tighter item spacing */
    .mega-menu-grouped__item {
        margin-bottom: 0.875rem !important;
    }
}


/* ============================================================
   Mobile (< 992px) — strip the absolute-positioned desktop
   panel chrome and let the grouped menu sit inline inside
   the parent theme's collapsible drawer.
   ============================================================ */
@media (max-width: 991.98px) {

    /* Strip the floating-card look — no border, no shadow, no rounded
       corners, no absolute positioning. The drawer is the container now. */
    .mega-menu-grouped > ul.panel-menu {
        position: relative !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        background: transparent !important;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        padding: 0.5rem 0 !important;
        overflow: visible !important;
    }

    .mega-menu-grouped > ul.panel-menu > li.container {
        max-width: 100% !important;
        width: 100% !important;
        padding: 0 !important;
    }

    /* Each ACF column becomes a full-width section, separated by a thin
       divider line. (The earlier @media block above set padding & border-bottom
       — these rules tighten typography to suit narrow widths.) */
    .mega-menu-grouped__col {
        padding: 1rem 1.25rem !important;
        border-right: none !important;
        border-bottom: 1px solid #E5E7EB !important;
    }

    .mega-menu-grouped__col:last-child {
        border-bottom: none !important;
    }

    /* Section header style for the eyebrow */
    .mega-menu-grouped__eyebrow {
        font-size: 0.7rem;
        margin-bottom: 0.75rem;
    }

    /* Intro column copy + CTA */
    .mega-menu-grouped__intro-desc {
        font-size: 0.875rem;
        margin-bottom: 0.875rem;
    }

    .mega-menu-grouped__view-all {
        font-size: 0.875rem;
    }

    /* Items — slightly bigger touch target, comfortable spacing */
    .mega-menu-grouped__item {
        margin-bottom: 0.875rem !important;
        padding: 0.25rem 0;
    }

    .mega-menu-grouped__item:last-child {
        margin-bottom: 0 !important;
    }

    .mega-menu-grouped__item .menu_item {
        gap: 0.625rem !important;
        align-items: center !important;
    }

    .mega-menu-grouped__title {
        font-size: 0.875rem;
    }

    .mega-menu-grouped__desc {
        font-size: 0.75rem !important;
    }

    /* Slightly smaller icons on mobile so they sit nicely next to titles */
    .mega-menu-grouped .menu_icon svg,
    .mega-menu-grouped .menu_icon img,
    .mega-menu-grouped__item .menu_icon svg,
    .mega-menu-grouped__item .menu_icon img {
        width: 20px !important;
        height: 20px !important;
        max-width: 20px !important;
        max-height: 20px !important;
        min-width: 20px !important;
        min-height: 20px !important;
    }
}


/* ============================================================
   Mobile (< 992px) — list-style overrides
   Renders the panel as a clean vertical list with bold serif
   section headings instead of cards with icons and descriptions.
   ============================================================ */
@media (max-width: 991.98px) {

    /* Hide visual chrome that doesn't suit a narrow list view */
    .mega-menu-grouped__item .menu_icon,
    .mega-menu-grouped .panel-menu .menu_icon {
        display: none !important;
    }

    .mega-menu-grouped__desc,
    .mega-menu-grouped__intro-desc,
    .mega-menu-grouped__view-all {
        display: none !important;
    }

    /* No more column dividers — the whole thing flows as one list */
    .mega-menu-grouped__col {
        border-bottom: none !important;
        padding: 0 1rem !important;
    }

    /* The intro column collapses to just its eyebrow ("WHAT WE TREAT" style) */
    .mega-menu-grouped__intro {
        padding-top: 0.5rem !important;
        padding-bottom: 0.25rem !important;
    }

    .mega-menu-grouped__intro .mega-menu-grouped__eyebrow {
        font-size: 0.7rem;
        letter-spacing: 0.12em;
        font-weight: 600;
        color: #9CA3AF;
        text-transform: uppercase;
        margin-bottom: 0.5rem;
    }

    /* Group columns get bold serif section headings, mixed case
       (case is preserved because the walker no longer calls strtoupper). */
    .mega-menu-grouped__group {
        padding: 0!important;
    }

    .mega-menu-grouped__group .mega-menu-grouped__eyebrow {
        text-transform: none !important;
        letter-spacing: 0 !important;
        font-family: Georgia, "Times New Roman", "Source Serif Pro", serif;
        font-size: 1.1rem;
        font-weight: 700;
        color: #111827;
        margin-bottom: 0.75rem;
    }

    /* Items become plain text rows — no uppercase, regular weight, gray.
       Indented slightly under the section heading to mirror the reference. */
    .mega-menu-grouped__item {
        margin-bottom: 0 !important;
        padding: 10px 15px 10px 35px !important;
    }

    .mega-menu-grouped__item .menu_item {
        gap: 0 !important;
        align-items: center !important;
    }

    .mega-menu-grouped__title {
        font-weight: 400 !important;
        text-transform: none !important;
        letter-spacing: 0 !important;
        line-height: 1.4 !important;
        margin: 0 !important;
    }

    /* Don't recolour the title on hover — keep the calm list look */
    .mega-menu-grouped__item:hover .mega-menu-grouped__title {
        color: #111827 !important;
    }

    .site-header #navbar > ul .menu-item-has-children .panel-menu {
        padding: 0 !important;
    }


}

@media (min-width: 1024px) and (max-width: 1440px) {
    .site-header #navbar #menu-main-menu li {
        margin-right: 0 !important;
    }
}

@media (min-width: 992px) {
    #mainNavbar > .container-xl.mega-is-closing .navbar-header.position-relative {
        position: static !important;
    }
}