.site-header-shell {
    position: sticky;
    z-index: 1000;
    top: 0;
    width: 100%;
}

.site-header {
    position: relative;
    z-index: 100;
    background-color: var(--color-white);

    &.is-menu-open {
        .mobile-menu {
            pointer-events: auto;
        }
    }
}

body.mobile-menu-open {
    overflow: hidden;
}

.topbar {
    display: none;
    background-color: var(--color-lightblue);

    > .wrapper {
        display: flex;
        align-items: center;
        justify-content: space-between;
        max-width: 1440px;
        margin-inline: auto;
        padding-block: 0.5rem;
        padding-inline: 2rem;

        .spacer {
            flex: 1;
        }

        .topbar-menu {
            display: flex;
            align-items: center;
            gap: 2rem;
            margin: 0;
            padding: 0;
            list-style: none;
            color: var(--color-darkblue);
            font-size: 0.875rem;
            font-weight: 500;
            letter-spacing: -0.0175rem;

            a {
                color: inherit;

                &:hover,
                &:focus-visible {
                    text-decoration: underline;
                }
            }

            > .menu-item-has-children {
                position: relative;

                > .sub-menu {
                    position: absolute;
                    z-index: 100;
                    top: 100%;
                    left: 0;
                    height: 0;
                    min-width: 12rem;
                    margin: 0;
                    overflow: hidden;
                    padding: 0.75rem;
                    list-style: none;
                    background-color: var(--color-white);
                    box-shadow: 0 0.75rem 2rem rgb(9 17 41 / 14%);
                    opacity: 0;
                    visibility: hidden;
                    pointer-events: none;
                }
            }
        }
    }

    @media (min-width: 768px) {
        display: block;
    }
}

.desktop-menu {
    position: relative;
    background-color: var(--color-white);

    > .wrapper {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 2rem;
        max-width: 1440px;
        margin-inline: auto;
        padding: 1rem 2.5rem;

        > nav {
            display: none;

            @media (min-width: 768px) {
                display: block;
            }
        }

        > .menu-toggle {
            flex: 0 0 auto;

            @media (min-width: 768px) {
                display: none;
            }
        }
    }
}

.site-header__logo {
    display: block;
    min-width: 0;
}

.site-header__logo-image {
    width: clamp(10rem, 22vw, 15rem);
    height: auto;
}

.header-menu {
    margin: 0;
    padding: 0;
    list-style: none;
}

.header-menu--desktop {
    display: flex;
    align-items: center;
    gap: clamp(1rem, 2.25vw, 2rem);

    > .menu-item {
        display: flex;
        align-items: center;
        &:last-of-type {
            a {
                background-color: var(--color-ctablue);
                font-family: var(--font-worksans);
                color: var(--color-white);
                font-weight: 500;
                font-size: 1rem;
                letter-spacing: -2%;
                line-height: 1;
                border-radius: 8px;
                padding-block: 1rem;
                padding-inline: 1.5rem;
                transition: 0.15s;
                &:hover {
                    background-color: var(--color-darkblue);
                    transition: 0.15s;
                }
            }
        }
    }

    .menu-item__link,
    .menu-item__label,
    .header-menu__submenu-toggle {
        color: var(--color-darkblue);
        font-size: 1rem;
        font-weight: 500;
        line-height: 1.5;
    }

    .menu-item__link,
    .header-menu__submenu-toggle {
        &:hover,
        &:focus-visible {
            color: var(--color-ctablue);
        }
    }

    > .menu-item > .sub-menu {
        position: absolute;
        z-index: 10;
        top: 100%;
        right: 2rem;
        left: 2rem;
        display: grid;
        height: 0;
        grid-template-columns: repeat(auto-fit, minmax(min(8.5rem, 100%), 1fr));
        gap: 1rem;
        max-width: 1440px;
        margin-inline: auto;
        overflow: hidden;
        padding: 1.5rem;
        list-style: none;
        border-top: 1px solid rgb(9 17 41 / 10%);
        background-color: var(--color-white);
        box-shadow: 0 1rem 2rem rgb(9 17 41 / 12%);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;

        .menu-item__link {
            position: relative;
            isolation: isolate;
            display: grid;
            overflow: hidden;
            background-color: var(--color-darkblue);
            color: var(--color-white);
            border-radius: 4px;

            &::before {
                position: absolute;
                z-index: 1;
                inset: 0;
                background: linear-gradient(
                    180deg,
                    rgba(9, 17, 41, 0) 50%,
                    rgba(9, 17, 41, 0.5) 100%
                );
                content: "";
                pointer-events: none;
            }

            &:hover,
            &:focus-visible {
                color: var(--color-white);

                .menu-item__image {
                    transform: scale(1.03);
                }
            }

            &:focus-visible {
                outline: 2px solid var(--color-ctablue);
                outline-offset: 2px;
            }
        }

        .menu-item__image {
            grid-area: 1 / 1;
            width: 100%;
            height: 105px;
            object-fit: cover;
            transition: transform 200ms ease;
        }

        .menu-item__text {
            position: absolute;
            z-index: 2;
            right: 0.5rem;
            bottom: 0.5rem;
            left: 0.5rem;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 0.5rem;
            color: var(--color-white);
            font-family: var(--font-lora);
            font-size: 1rem;
            font-weight: 400;
            line-height: 1.2;

            &::after {
                flex: 0 0 0.875rem;
                width: 0.875rem;
                height: 0.875rem;
                background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14' fill='none'%3E%3Cpath d='M9.22664 6.27587L6.16631 3.21554L6.97304 2.40881L11.4106 6.8464L6.97304 11.284L6.16631 10.4773L9.22664 7.41693H2.28214V6.27587H9.22664Z' fill='white'/%3E%3C/svg%3E");
                background-position: center;
                background-repeat: no-repeat;
                background-size: contain;
                content: "";
            }
        }
    }
}

.header-menu__submenu-toggle {
    display: inline-flex;
    align-items: center;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;

    &::after {
        width: 0.5rem;
        height: 0.5rem;
        border-right: 2px solid currentColor;
        border-bottom: 2px solid currentColor;
        content: "";
        transform: translateY(-0.125rem) rotate(45deg);
        transition: transform 150ms ease;
    }

    &[aria-expanded="true"]::after {
        transform: translateY(0.125rem) rotate(225deg);
    }

    &.header-menu__submenu-toggle--icon-only {
        padding: 0.5rem;
    }
}

.header-menu--desktop,
.topbar-menu {
    .header-menu__submenu-toggle {
        &::after {
            flex: 0 0 1.5rem;
            width: 1.5rem;
            height: 1.5rem;
            border: 0;
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M12 14L8 10H16L12 14Z' fill='%23091129'/%3E%3C/svg%3E");
            background-position: center;
            background-repeat: no-repeat;
            background-size: contain;
            transform: none;
        }

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

[data-submenu-toggle] + .sub-menu {
    margin-block: 0;
}

.mobile-menu {
    position: fixed;
    z-index: 2;
    inset: 0;
    height: 100dvh;
    overflow: hidden;
    overscroll-behavior: contain;
    background-color: var(--color-white);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    > .wrapper {
        height: 100%;
        overflow-y: auto;
        padding: 1rem 2rem 3rem;
    }

    .site-header__mobile-logo {
        display: block;
        width: fit-content;
        padding-block: 0.25rem;
    }

    .site-header__mobile-logo-image {
        width: auto;
        height: 3rem;
    }

    nav {
        position: relative;
        min-height: calc(100dvh - 7rem);
        margin-top: 2rem;
        overflow: hidden;
    }

    @media (min-width: 768px) {
        display: none;
    }
}

.header-menu--mobile {
    position: relative;
    display: grid;
    align-content: start;
    min-height: 100%;
    gap: 0.5rem;

    .menu-item {
        list-style: none;

        > .menu-item__link,
        > .menu-item__label,
        > .header-menu__submenu-toggle {
            display: flex;
            align-items: center;
            min-height: 3.5rem;
            width: 100%;
            padding: 0;
            color: var(--color-blue);
            font-family: var(--font-lora);
            font-size: 2rem;
            font-weight: 400;
            line-height: 1.25;
            text-align: left;
        }

        > .header-menu__submenu-toggle {
            justify-content: space-between;

            &::after,
            &[aria-expanded="true"]::after {
                transform: translateX(-0.125rem) rotate(-45deg);
            }
        }
    }

    .sub-menu {
        position: absolute;
        z-index: 2;
        inset: 0;
        display: grid;
        align-content: start;
        min-height: 100%;
        gap: 0.5rem;
        margin: 0;
        padding: 0 0 3rem;
        list-style: none;
        background-color: var(--color-white);
        visibility: hidden;
        pointer-events: none;

        .mobile-menu__submenu-header {
            min-height: 3.5rem;
        }
    }

    .mobile-menu__back {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        min-height: 3.5rem;
        width: 100%;
        padding: 0;
        border: 0;
        background: transparent;
        color: var(--color-darkblue);
        font-family: var(--font-lora);
        font-size: 2rem;
        font-weight: 400;
        line-height: 1.25;
        text-align: left;

        &::before {
            flex: 0 0 0.5rem;
            width: 0.5rem;
            height: 0.5rem;
            border-bottom: 2px solid currentColor;
            border-left: 2px solid currentColor;
            content: "";
            transform: translateX(0.125rem) rotate(45deg);
        }

        &:focus-visible {
            border-radius: 0.25rem;
            outline: 2px solid var(--color-ctablue);
            outline-offset: 2px;
        }
    }
}

.menu-toggle {
    position: relative;
    z-index: 3;
    display: grid;
    min-width: 3rem;
    min-height: 3rem;
    padding: 0;
    place-items: center;
    border: 0;
    background: transparent;
    color: var(--color-darkblue);

    &:focus-visible {
        border-radius: 0.25rem;
        outline: 2px solid var(--color-ctablue);
        outline-offset: 2px;
    }
}

.menu-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.menu-icon--close {
    opacity: 0;
    visibility: hidden;
}

@media (min-width: 1024px) {
    .desktop-menu {
        > .wrapper {
            padding-block: 1.25rem;
        }
    }
}
