.site-header__nav-item--mega {
    position: static;
}

.site-header__nav-item--compact {
    position: relative;
}

.site-header__nav-item--custom {
    position: static;
}

.site-header__nav-link--has-menu::after {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-left: 9px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    content: "";
    transform: translateY(-2px) rotate(45deg);
}

/* Keep every navigation trigger above the wide invisible hover bridge. */
.site-header__nav-link--has-menu {
    position: relative;
    z-index: 21;
}

.mega-menu {
    position: absolute;
    left: 50%;
    top: calc(100% - 26px);
    z-index: 20;
    width: min(1400px, calc(100% - 60px));
    padding-top: 0;
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(6px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

/* Keep the pointer inside the open menu while it crosses the visual gap below the trigger. */
.mega-menu::before {
    position: absolute;
    right: 0;
    bottom: 100%;
    left: 0;
    height: 28px;
    content: "";
}

.site-header__nav-item--mega.is-menu-open .mega-menu {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.site-header__nav-item--mega.is-menu-open > .site-header__nav-link--has-menu {
    color: var(--mc-color-blue);
}

.mega-menu__inner {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0;
    max-height: none;
    padding: 10px 0;
    overflow: hidden;
    border-radius: 8px;
    background: #f6f6f6;
    box-shadow: none;
}

.mega-menu--compact {
    left: auto;
    right: 0;
    top: calc(100% + 27px);
    width: min(350px, calc(100vw - 48px));
    transform: translateY(8px);
}

.site-header__nav-item--compact.is-menu-open .mega-menu {
    transform: translateY(0);
}

.mega-menu--compact .mega-menu__inner {
    display: block;
    max-height: none;
    padding: 10px 0;
}

.mega-menu--compact .mega-menu__column + .mega-menu__column {
    margin-top: 24px;
}

.mega-menu--custom {
    left: auto;
    right: max(30px, calc((100% - 1400px) / 2));
    top: calc(100% - 26px);
    width: min(700px, calc(100vw - 60px));
    transform: translateY(6px);
}

.site-header__nav-item--compact.is-menu-open .mega-menu--custom {
    transform: translateY(0);
}

.mega-menu--custom .mega-menu__inner {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0;
    max-height: none;
    min-height: 0;
    padding: 10px 0;
    border-radius: 8px;
    background: #f6f6f6;
    box-shadow: none;
}

.mega-menu--custom .mega-menu__column + .mega-menu__column {
    margin-top: 0;
}

.mega-menu--custom .mega-menu__title {
    margin-bottom: 0;
    padding: 13px 34px;
    color: #777;
    font-size: 16px;
    font-weight: 600;
    line-height: 27.68px;
    text-transform: none;
}

.mega-menu--custom .mega-menu__column:nth-child(3) .mega-menu__title {
    color: #333333;
}

.mega-menu--custom .mega-menu__list {
    row-gap: 0;
}

.mega-menu--custom .mega-menu__list a {
    display: flex;
    min-height: 33.9px;
    padding: 2px 31px;
    color: #333333;
    font-size: 16px;
    font-weight: 400;
    line-height: 29.92px;
}

.mega-menu__title {
    min-height: 59.2px;
    margin: 0;
    padding: 13px 34px;
    color: #3a3a3a;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0;
    line-height: 27.68px;
    text-transform: uppercase;
}

.mega-menu__list {
    display: grid;
    row-gap: 0;
    margin: 0;
    padding: 0;
    list-style: none;
}

.mega-menu__list li {
    display: block;
}

.mega-menu__list a {
    display: flex;
    align-items: center;
    gap: 7px;
    width: 100%;
    min-height: 33.9px;
    padding: 2px 31px;
    border-radius: 0;
    color: #101820;
    font-size: 16px;
    font-weight: 400;
    line-height: 29.92px;
    text-decoration: none;
    transition: color 0.18s ease;
}

.mega-menu__list a br {
    display: none;
}

.mega-menu__list a span:last-child {
    min-width: 0;
}

.mega-menu__list a:hover,
.mega-menu__list a:focus,
.mega-menu__list a.is-current,
.mega-menu__list a[aria-current="page"] {
    color: var(--mc-color-blue);
}

.mega-menu__list a:focus-visible,
.site-header__nav-link:focus-visible {
    outline: 2px solid var(--mc-color-blue);
    outline-offset: 4px;
}

.mega-menu__icon {
    position: relative;
    display: inline-flex;
    flex: 0 0 24px;
    width: 24px;
    height: 24px;
    color: #303236;
    opacity: 0.84;
    transition: color 0.18s ease, opacity 0.18s ease;
}

.mega-menu__icon--image {
    display: block;
    max-width: 24px;
    object-fit: contain;
    object-position: center;
}

.mega-menu__icon::after {
    position: absolute;
    inset: 0;
    background-color: currentColor;
    content: "";
    mask: var(--mega-icon, url("data:image/svg+xml,%3Csvg viewBox='0 0 24 22' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 12.2C4.9 7 8.8 4 13.5 4c4.2 0 6.8 2.4 7.5 6.1M4 12.2c3.8-.5 7.4.2 10.4 2.2 1.8 1.2 4.1 1.4 6.1.6M7.2 9.1c.8 1.9.7 3.9-.3 5.8M2.6 16.2c5.7-1.6 11.6-1.2 17.6 1.2' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")) center / contain no-repeat;
    -webkit-mask: var(--mega-icon, url("data:image/svg+xml,%3Csvg viewBox='0 0 24 22' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 12.2C4.9 7 8.8 4 13.5 4c4.2 0 6.8 2.4 7.5 6.1M4 12.2c3.8-.5 7.4.2 10.4 2.2 1.8 1.2 4.1 1.4 6.1.6M7.2 9.1c.8 1.9.7 3.9-.3 5.8M2.6 16.2c5.7-1.6 11.6-1.2 17.6 1.2' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")) center / contain no-repeat;
}

.mega-menu__icon::before {
    content: none;
}

.mega-menu__list a:hover .mega-menu__icon,
.mega-menu__list a:focus .mega-menu__icon,
.mega-menu__list a.is-current .mega-menu__icon,
.mega-menu__list a[aria-current="page"] .mega-menu__icon {
    color: #3f7ad9;
    opacity: 1;
}

.mega-menu--products .mega-menu__column:nth-child(2) .mega-menu__icon::after {
    --mega-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 22' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 13.5C5.2 9.9 8.1 8 12.1 8c4.1 0 6.9 1.9 7.9 5.5M5.5 13.3c4.2 1.8 8.4 1.8 12.8 0M7.2 16.2c3.4 1.1 6.8 1.1 10.2 0M9.1 8.5 8.5 6.2M15.2 8.5l.6-2.3' fill='none' stroke='black' stroke-width='1.55' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.mega-menu--products .mega-menu__column:nth-child(3) .mega-menu__icon::after {
    --mega-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 22' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6.2 10.5C6.6 6.8 9 4.7 12 4.7s5.4 2.1 5.8 5.8v5.1c-3.4 1.3-8.2 1.3-11.6 0v-5.1ZM6.4 11.5c3.5 1.3 7.7 1.3 11.2 0M8.2 15.8V19M15.8 15.8V19M9 8.7c2-.7 4-.7 6 0' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.mega-menu--products .mega-menu__column:nth-child(4) .mega-menu__icon::after {
    --mega-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 22' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M8 5.5h8l2.5 3.1-2 8.4c-2.9 1-6.1 1-9 0l-2-8.4L8 5.5ZM8.5 5.7c1.6 2 5.4 2 7 0M5.8 8.7h12.4M9.2 10.8v4.8M12 10.8v5.2M14.8 10.8v4.8' fill='none' stroke='black' stroke-width='1.45' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.mega-menu__icon--arrow {
    flex-basis: 18px;
    width: 18px;
    height: 18px;
    border: 1.5px solid currentColor;
    border-radius: 50%;
}

.mega-menu__icon--arrow::before {
    display: none;
}

.mega-menu__icon--arrow::after {
    inset: auto;
    left: 5px;
    top: 4px;
    width: 5px;
    height: 5px;
    background: transparent;
    border: 0;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    border-radius: 0;
    mask: none;
    -webkit-mask: none;
    transform: rotate(-45deg);
}

@media (min-width: 1201px) and (max-width: 1279px) {
    .mega-menu {
        top: calc(100% - 8px);
        width: min(900px, calc(100vw - 44px));
    }

    .mega-menu__inner {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 28px 42px;
        max-height: none;
        padding: 26px;
    }

    /* Keep the Products panel in the legacy four-column desktop layout. */
    .mega-menu--products {
        width: min(1400px, calc(100vw - 44px));
    }

    .mega-menu--products .mega-menu__inner {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 0;
        padding: 10px 0;
    }

    .mega-menu--compact {
        width: min(340px, calc(100vw - 44px));
    }

    .mega-menu--custom {
        left: 50%;
        width: min(860px, calc(100vw - 44px));
    }

    .mega-menu--custom .mega-menu__inner {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 34px;
        min-height: auto;
        padding: 34px 30px;
    }

    .mega-menu--custom .mega-menu__title {
        margin-bottom: 20px;
        font-size: 19px;
    }

    .mega-menu--custom .mega-menu__list {
        row-gap: 14px;
    }

    .mega-menu--custom .mega-menu__list a {
        font-size: 17px;
    }

    .mega-menu__list a {
        font-size: 16px;
        line-height: 1.45;
    }
}

/* Match the legacy site's restrained compact dropdowns on desktop. */
@media (min-width: 1201px) {
    /* Collections is a short category list, so keep it as compact as the legacy menu. */
    .mega-menu--collections {
        left: 50%;
        right: auto;
        top: calc(100% + 15px);
        width: max-content;
        min-width: 184px;
        max-width: min(240px, calc(100vw - 48px));
        transform: translateX(-50%) translateY(8px);
    }

    .site-header__nav-item--compact.is-menu-open .mega-menu--collections {
        transform: translateX(-50%) translateY(0);
    }

    .mega-menu--collections .mega-menu__inner {
        padding: 1.5px 0;
        border-radius: 8px;
        background: #f6f6f6;
        box-shadow: none;
    }

    .mega-menu--collections .mega-menu__title {
        position: absolute;
        width: 1px;
        height: 1px;
        margin: -1px;
        padding: 0;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .mega-menu--collections .mega-menu__list a {
        gap: 0;
        min-height: 33.9px;
        padding: 2px 18px;
        color: #333333;
        font-size: 16px;
        line-height: 29.92px;
        white-space: nowrap;
    }

    .mega-menu--collections .mega-menu__icon {
        display: none;
    }

    .mega-menu--collections > p:empty {
        display: none;
        margin: 0;
    }

    .mega-menu--about {
        top: calc(100% + 15px);
        width: 184px;
    }

    .mega-menu--about .mega-menu__inner {
        padding: 1.5px 0;
        border-radius: 8px;
        background: #f6f6f6;
        box-shadow: none;
    }

    .mega-menu--about .mega-menu__title {
        position: absolute;
        width: 1px;
        height: 1px;
        margin: -1px;
        padding: 0;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .mega-menu--about .mega-menu__list a {
        gap: 0;
        min-height: 33.9px;
        padding: 2px 31px;
        color: #333333;
        font-size: 16px;
        line-height: 29.92px;
    }

    .mega-menu--about .mega-menu__icon {
        display: none;
    }

    /* WordPress can insert an empty paragraph after the generated menu block. */
    .mega-menu--about > p:empty {
        display: none;
        margin: 0;
    }
}

@media (max-width: 1200px) {
    .site-header__nav-item--mega {
        width: 100%;
    }

    .mega-menu {
        display: none;
    }

    .site-header__nav-item--mega.is-menu-open > .mega-menu {
        position: static;
        display: block;
        width: 100%;
        padding-top: 8px;
        opacity: 1;
        pointer-events: auto;
        transform: none;
    }

    .mega-menu--compact {
        width: 100%;
    }

    .mega-menu--custom {
        left: auto;
        top: auto;
        width: 100%;
        transform: none;
    }

    .mega-menu__inner {
        grid-template-columns: 1fr;
        gap: 24px;
        padding: 24px 18px;
        border-radius: 6px;
        box-shadow: none;
    }

    .mega-menu--custom .mega-menu__inner {
        grid-template-columns: 1fr;
        gap: 24px;
        min-height: auto;
        padding: 24px 18px;
    }

    .mega-menu--custom .mega-menu__title {
        margin-bottom: 14px;
        font-size: 18px;
    }

    .mega-menu--custom .mega-menu__list {
        row-gap: 11px;
    }

    .mega-menu--custom .mega-menu__list a {
        font-size: 15px;
    }

    .mega-menu__title {
        margin-bottom: 14px;
        font-size: 18px;
        text-align: left;
    }

    .mega-menu__list {
        gap: 11px;
    }

    .mega-menu__list a {
        grid-template-columns: 28px minmax(0, 1fr);
        font-size: 15px;
        text-align: left;
    }
}
