.multi-menu-mega {
    list-style-type: none;
    margin: 0;
    padding: 0;
    position: relative;
    z-index: 10;

    button {
        background-color: transparent;
        border: 0 none;
        margin: 0;
        padding: 0;
        box-shadow: none;
    }

    /* Desktop Styles */

    @media (min-width: 600px) {
        .menu-toggle-container,
        .menu-mega-container-close-container {
            display: none;
        }

        .arrow-toggle {
            display: none;
        }

        ul {
            margin: 0;
            padding: 0;
            list-style-type: none;
        }

        .menu-mega-container-inner {
            display: flex;
            flex-wrap: wrap;
            justify-content: flex-end;
            position: relative;
            
            .menu-item {
                &.menu-item-depth-0 {
                    margin-left: 30px;
                    position: relative;

                    &:first-child {
                        margin-left: 0;
                    }

                    .menu-clickable {
                        font-size: 1.125rem;
                        position: relative;

                        &.has-children {
                            padding-right: 25px;
                            z-index: 1;

                            .arrow-toggle {
                                display: block;
                                position: absolute;
                                right: 0;
                                top: calc(50% - 10px);
                                width: 20px;
                                height: 20px;
                                pointer-events: none;
                            }
                        }
                    }

                    .submenu-outer-wrapper {
                        display: none;
                    }
                }
            }

            .mega-menu-tray {
                display: none;

                &.menu-open {
                    display: block;
                    position: absolute;
                    right: 0;
                    top: 25px;
                    padding: 30px;
                    padding-top: 35px;
                    width: 100%;
                    min-width: 800px;

                    .submenu-outer-wrapper.depth-1 {
                        display: none;
                    }

                    .submenu-inner-wrapper {
                        .submenu-list {
                            display: grid;
                            grid-template-columns: repeat(3, 1fr);
                            gap: 30px; /* 30px spacing between rows and columns */

                            .menu-item {
                                display: block;

                                .menu-item-description {
                                    font-weight: normal;
                                    margin-top: .75rem;
                                }

                                .featured-image-wrapper {
                                    margin-bottom: 15px;
                                }

                                .item-title {
                                    font-size: 1.125rem;
                                    line-height: 1.25;
                                    margin-bottom: 0;
                                }
                            }
                        }
                    }
                }
            }
        }        
    }

    /* Mobile Styles */

    @media (max-width: 600px) {

        .menu-mega-container {
            position: fixed;
            top: 0;
            bottom: 0;
            right: -100%;
            width: 100%;
            border-left: 1px solid transparent;
            transition: right 0.5s ease-in-out;
            height: 100dvh;
            overflow: scroll;

            &.open {
                right: 0;
            }

            .menu-mega-container-close-container {
                margin-top: 30px;
                margin-left: 30px;
                margin-right: 30px;
                z-index: 1;
                position: relative;

                .js-multi-menu-mega-toggle-close {
                    margin-left: auto;
                    margin-right: 0;
                    display: flex;
                    flex-wrap: wrap;
                    align-items: center;
                    justify-content: flex-end;
                    cursor: pointer;
                    z-index: 9;

                    .button-text {
                        font-weight: bold;
                        text-transform: uppercase;
                        display: block;
                        margin-right: 6px;
                    }

                    .button-icon {
                        width: 50px;
                        display: block;
                    }
                }
            }

            .mega-menu-tray { 
                display: none !important;
            }
        }

        .menu-toggle-container {
            .js-multi-menu-mega-toggle-open {
                display: flex;
                flex-wrap: wrap;
                align-items: center;
                justify-content: flex-end;
                margin-left: auto;
                margin-right: 0;
                cursor: pointer;

                .button-text {
                    display: block;
                    margin-right: 6px;
                    font-weight: bold;
                    text-transform: uppercase;
                }

                .button-icon {
                    width: 50px;
                    display: block;
                }
            }
        }

        .menu-mega-container-inner {
            padding: 0;
            margin-top: 50px;
            margin-left: 30px;
            margin-right: 30px;
            margin-bottom: 30px;
            list-style-type: none;

            @media (min-width: 600px) {
                margin-bottom: 60px;
            }
            
            li {
                margin: 0;
                padding: 0;
            }

            .menu-item {
                position: relative;
                margin-top: 5px;

                &:first-child {
                    margin-top: 0;
                }

                @media (max-width: 600px) {

                    .submenu-list {
                        align-self: end;
                        min-height: 0;
                        transition: visibility 1s;
                        visibility: hidden;
                    }

                    .submenu-inner-wrapper {
                        display: grid;
                        grid-template-rows: 0fr;
                        overflow: hidden;
                        transition: grid-template-rows 1s;
        
                        .submenu-list {
                            margin: 0;
                            padding: 0;
                            list-style-type: none;
        
                            li {
                                margin-left: 30px;
        
                                &:first-child {
                                    margin-top: 10px;
                                }
        
                                &:last-child {
                                    margin-bottom: 10px;
                                }
                            }
                        }
                    }
        
                    .submenu-inner-wrapper.expanded {
                        grid-template-rows: 1fr;
        
                        .submenu-list {
                            visibility: visible;
                        }
                    }

                    .menu-clickable {
                        display: block;
                        width: 100%;
                        margin: 0;
                        padding: 0;
                        text-align: left;
                        position: relative;
                        cursor: pointer;
                        padding-right: 40px !important;

                        .arrow-toggle {
                            position: absolute;
                            width: 26px;
                            right: 0;
                            top: 0;
                            cursor: pointer;
                            overflow: hidden;

                            svg {
                                transition: all 1s;
                            }
                        }

                        .arrow-toggle.rotate {
                            svg {
                                transform: rotate(180deg);
                            }
                        }

                        .is-button {
                            .arrow-toggle {
                                pointer-events: none;
                            }
                        }
                    }

                    .menu-item-description {
                        display: none;
                    }

                    .featured-image-wrapper {
                        display: none;
                    }
                }
            }
        }
    }

    /* Class modifiers for specific menu behavior on desktop sizes */

    &.no-featured-images {
        @media (min-width: 600px) {
            .mega-menu-tray.menu-open {
                .submenu-inner-wrapper .submenu-list .menu-item {
                    .featured-image-wrapper {
                        display: none;
                    }
                }
            }
        }
    }

    &.four-columns {
        @media (min-width: 600px) {
            .mega-menu-tray.menu-open {
                .submenu-inner-wrapper .submenu-list {
                    grid-template-columns: repeat(4, 1fr);
                }
            }
        }
    }

    &.two-columns {
        @media (min-width: 600px) {
            .mega-menu-tray.menu-open {
                .submenu-inner-wrapper .submenu-list {
                    grid-template-columns: repeat(2, 1fr);
                }
            }
        }
    }
}

/* Lock scrolling on the body while the menu is open */

body.mm-lock {
    overflow: hidden;
    height: 100dvh;
}