@screen lg {
    .c-site-header--filled .c-main-menu__link {
        @apply text-primary-500;

        &:hover,
        &:active,
        &:focus,
        &:focus-within {
            @apply text-primary-500;
        }
    }
}

.c-main-menu {
    margin-top: 0;
    padding: 0;
    order: 5;

    @media screen and (max-width: map-get($breakpoints, 'lg') - 1px) {
        display: none;
        position: fixed;
        flex-direction: column;
        justify-content: flex-start;
        overflow-y: scroll;
        padding: 0 1rem;
        width: 100%;
        height: 100vh;
        top: 0;
        right: 0;
        left: 0;
        background-color: theme('colors.primary.500');
        z-index: 1;

        &.is-target,
        &:target {
            display: flex;
            opacity: 1;
        }
    }

    @screen lg {
        display: flex;
    }
}

.c-main-menu__item {
    border-bottom: 1px solid theme('colors.primary.400');
    display: block;
    height: 100%;
    margin-bottom: .5rem;
    margin-top: 0;
    padding-bottom: .5rem;
    padding-top: 0;
    position: relative;

    @media screen and (max-width: map-get($breakpoints, 'lg') - 1px) {
        height: auto;
        margin-bottom: 2rem;
        padding-bottom: 2rem;
    }

    &:first-child {
        &:last-child {
            border: 0;
        }

        @media screen and (max-width: map-get($breakpoints, 'lg') - 1px) {
            margin-top: 12rem;
        }
    }

    @screen lg {
        align-items: center;
        border: 0;
        display: flex;
        margin-bottom: 0;
        padding-bottom: 0;

        &::before {
            box-sizing: inherit;
            content: '';
            position: absolute;
            left: 1.25rem;
            border-bottom: 2px solid theme('colors.primary.500');
            width: 0;
            height: 100%;
            transition: width .5s ease-out;
        }

        &:hover,
        &:focus-within {
            &::before {
                width: calc(60%-2rem);
            }
        }
    }
}

.c-main-menu__item-divider {
    align-items: center;
    display: flex;
    justify-content: space-between;
}

.c-main-menu--is-uppercase .c-main-menu__link {
    text-transform: uppercase;

    @screen lg {
        padding: 1rem 1.25rem;
    }
}

.c-main-menu__link {
    @apply relative font-bold text-white no-underline antialiased;
    position: relative;
    font-size: 1rem;
    text-decoration: none;
    transition: $transition-time;

    @media screen and (max-width: map-get($breakpoints, 'lg') - 1px) {
        font-size: 1.625rem;
    }

    &:hover,
    &:active,
    &:focus {
        @apply text-primary-200;
    }

    &.is-active {
        @apply text-primary-600;
    }

    @screen lg {
        @apply flex items-center h-full p-4;
    }

    .has-overlay & {
        color: white;

        &:hover,
        &:active,
        &:focus {
            color: theme('colors.primary.200');
        }
    }
}

.c-main-menu__submenu-toggle {
    @apply text-white rounded-full h-8 w-8 flex items-center justify-center;
    transition: $transition-time;

    &:hover,
    &:focus {
        @apply text-primary-200;
    }

    @screen lg {
        display: none;
    }
}

.c-main-menu__submenu-toggle-icon {
    @apply text-2xl;
    transition: $transition-time;
    top: 0;

    [aria-expanded=true] & {
        transform: rotate(180deg);
    }
}

.c-main-submenu {
    margin: 0;
    padding: .5rem 1rem;

    @media screen and (max-width: map-get($breakpoints, 'lg') - 1px) {
        display: none;

        &.is-target,
        &:target {
            display: block;
        }
    }

    @screen lg {
        @apply shadow-lg;
        visibility: hidden;
        opacity: 0;
        position: absolute;
        top: 100%;
        left: 0;
        width: 17rem;
        background-color: #fff;
        z-index: 1;
        transition: $transition-time;

        .c-main-menu__item:last-child &,
        .c-main-menu__item:last-child & {
            left: auto;
            right: 0;
        }

        .c-main-menu__item:hover &,
        .c-main-menu__item:focus-within & {
            visibility: visible;
            opacity: 1;
        }
    }
}

.c-main-submenu__link {
    @apply py-2 px-0 text-gray-900 no-underline block;
    transition: $transition-time;

    &:hover,
    &:focus {
        .c-main-menu__item:hover &,
        .c-main-menu__item.hover & {
            @apply text-primary-300;
        }
    }

    @screen lg {
        @apply text-secondary-800;

        &:hover,
        &:focus {
            .c-main-menu__item:hover &,
            .c-main-menu__item.hover & {
                @apply text-primary-500;
            }
        }
    }

    @media screen and (max-width: map-get($breakpoints, 'lg') - 1px) {
        color: theme('colors.white');
        font-size: 1rem;
    }
}
