
.mg-header__category-dropdown--hierarchy {
    width: min(340px, 92vw);
    max-width: none;
    overflow: visible;
}

.mg-header-cat-hierarchy__parents,
.mg-header-cat-hierarchy__children ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.mg-header-cat-hierarchy__parent {
    position: relative;
}

.mg-header-cat-hierarchy__row {
    display: flex;
    align-items: stretch;
    min-width: 0;
}

.mg-header__category-dropdown .mg-header-cat-hierarchy__parent-link {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: .65rem .75rem;
    overflow-wrap: anywhere;
}

.mg-header-cat-hierarchy__toggle {
    flex: 0 0 44px;
    min-width: 44px;
    min-height: 44px;
    border: 0;
    border-left: 1px solid rgba(15,33,59,.08);
    border-radius: 0;
    background: transparent;
    color: #9D1C66;
    cursor: pointer;
    font: inherit;
    font-size: 1.15rem;
}

.mg-header-cat-hierarchy__children {
    background: #fff;
    z-index: 10050;
}

.mg-header-cat-hierarchy__children a {
    min-height: 44px;
    display: flex !important;
    align-items: center;
    padding: .65rem .8rem !important;
    white-space: normal;
    overflow-wrap: anywhere;
}

.mg-header-cat-hierarchy__toggle:focus-visible {
    outline: 3px solid currentColor;
    outline-offset: -3px;
}

/* Wide desktop: child categories use a viewport-clamped fixed flyout. */
@media (min-width: 1024px) {
    .mg-header-cat-hierarchy__children {
        position: fixed;
        width: min(330px, calc(100vw - 24px));
        max-width: calc(100vw - 24px);
        max-height: min(72vh, 620px);
        overflow-y: auto;
        overflow-x: hidden;
        padding: .45rem;
        border: 1px solid rgba(15,33,59,.12);
        border-radius: 8px;
        box-shadow: 0 12px 28px rgba(15,33,59,.14);
    }
}

/* Tablet/mobile and narrow desktop: always load children inline. */
@media (max-width: 1023px) {
    .mg-header__category-dropdown--hierarchy {
        width: min(100%, 92vw);
        overflow-y: auto;
        overflow-x: hidden;
        max-height: 78vh;
    }

    .mg-header-cat-hierarchy__children {
        position: static !important;
        left: auto !important;
        top: auto !important;
        width: 100%;
        max-width: 100%;
        max-height: 46vh;
        overflow-y: auto;
        overflow-x: hidden;
        padding-left: 12px;
        border-top: 1px solid rgba(15,33,59,.08);
        box-shadow: none;
    }
}


/* v0.8.22 — inline child-panel width/containment hotfix.
 * Keep the working v0.8.21 hierarchy and JS unchanged.
 * At <=1023px the child panel must remain inside the dropdown's content box.
 */
@media (max-width: 1023px) {
    .mg-header__category-dropdown--hierarchy,
    .mg-header-cat-hierarchy__parents,
    .mg-header-cat-hierarchy__parent,
    .mg-header-cat-hierarchy__row,
    .mg-header-cat-hierarchy__children,
    .mg-header-cat-hierarchy__children ul,
    .mg-header-cat-hierarchy__children li {
        box-sizing: border-box;
        max-width: 100%;
    }

    .mg-header__category-dropdown--hierarchy {
        width: min(92vw, 420px);
        max-width: calc(100vw - 16px);
        overflow-x: hidden;
    }

    .mg-header-cat-hierarchy__parents {
        width: 100%;
        overflow-x: hidden;
    }

    .mg-header-cat-hierarchy__parent,
    .mg-header-cat-hierarchy__row {
        width: 100%;
        min-width: 0;
    }

    .mg-header-cat-hierarchy__parent-link {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .mg-header-cat-hierarchy__children {
        width: auto !important;
        max-width: 100% !important;
        margin: 0 0 0 12px;
        padding: 0 !important;
        border-left: 1px solid rgba(15,33,59,.08);
        overflow-x: hidden !important;
    }

    .mg-header-cat-hierarchy__children ul {
        width: 100%;
        max-width: 100%;
    }

    .mg-header-cat-hierarchy__children a {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        padding-left: 12px !important;
        padding-right: 10px !important;
        overflow-wrap: anywhere;
        white-space: normal;
    }
}


/* v0.8.23 — mobile header hierarchy integration */
.mg-header__mobile-category-hierarchy,
.mg-header__mobile-category-hierarchy [data-mg-header-cat-hierarchy],
.mg-header__mobile-category-hierarchy .mg-header-cat-hierarchy__parents,
.mg-header__mobile-category-hierarchy .mg-header-cat-hierarchy__parent,
.mg-header__mobile-category-hierarchy .mg-header-cat-hierarchy__row {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.mg-header__mobile-category-hierarchy .mg-header-cat-hierarchy__parent {
    border-top: 1px solid rgba(15,33,59,.08);
}

.mg-header__mobile-category-hierarchy .mg-header-cat-hierarchy__parent-link {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 10px 4px;
    color: inherit;
    text-decoration: none;
    white-space: normal;
    overflow-wrap: anywhere;
}

.mg-header__mobile-category-hierarchy .mg-header-cat-hierarchy__toggle {
    min-width: 44px;
    min-height: 44px;
    flex: 0 0 44px;
}

.mg-header__mobile-category-hierarchy .mg-header-cat-hierarchy__children {
    position: static !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    width: auto !important;
    max-width: 100% !important;
    margin: 0 0 0 12px;
    padding: 0 !important;
    border-left: 1px solid rgba(15,33,59,.08);
    border-top: 0;
    box-shadow: none;
    overflow-x: hidden !important;
}

.mg-header__mobile-category-hierarchy .mg-header-cat-hierarchy__children ul,
.mg-header__mobile-category-hierarchy .mg-header-cat-hierarchy__children li {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.mg-header__mobile-category-hierarchy .mg-header-cat-hierarchy__children a {
    min-height: 44px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 10px 10px 10px 12px !important;
    white-space: normal;
    overflow-wrap: anywhere;
}

.mg-header__mobile-category-all {
    border-top: 1px solid rgba(15,33,59,.12);
    margin-top: 4px;
    padding-top: 4px;
}

.mg-header__mobile-category-all a {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 10px 4px;
    font-weight: 700;
    text-decoration: none;
}


/* v0.8.25 — mobile child visibility recovery.
 * Explicit branch open state prevents legacy header CSS/JS from leaving
 * child panels visually hidden after the toggle is activated.
 */
.mg-header-cat-hierarchy__parent > .mg-header-cat-hierarchy__children {
    display: none;
}

.mg-header-cat-hierarchy__parent.is-open > .mg-header-cat-hierarchy__children {
    display: block !important;
}

@media (max-width: 1023px) {
    .mg-header__mobile-category-hierarchy .mg-header-cat-hierarchy__parent.is-open
        > .mg-header-cat-hierarchy__children {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        height: auto !important;
        max-height: 46vh;
    }
}


/* v0.8.26 — mobile child panel right-edge containment hotfix.
 * The visible child panel was correctly opening, but its 12px left indent
 * combined with full width caused the right edge to be clipped.
 */
@media (max-width: 1023px) {
    .mg-header__mobile-category-hierarchy .mg-header-cat-hierarchy__children {
        box-sizing: border-box;
        margin-left: 12px !important;
        margin-right: 0 !important;
        width: calc(100% - 12px) !important;
        max-width: calc(100% - 12px) !important;
        min-width: 0 !important;
        padding: 0 !important;
        overflow-x: hidden !important;
    }

    .mg-header__mobile-category-hierarchy .mg-header-cat-hierarchy__children > ul,
    .mg-header__mobile-category-hierarchy .mg-header-cat-hierarchy__children > ul > li,
    .mg-header__mobile-category-hierarchy .mg-header-cat-hierarchy__children > ul > li > a {
        box-sizing: border-box;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }

    .mg-header__mobile-category-hierarchy .mg-header-cat-hierarchy__children > ul > li > a {
        padding-left: 10px !important;
        padding-right: 10px !important;
        white-space: normal !important;
        overflow-wrap: anywhere;
        word-break: normal;
    }
}
