:root {
    --cpx-language-switcher-flag-size: 26px;
    --cpx-language-switcher-hit-area: 34px;
    --cpx-language-switcher-gap: 7px;
    --cpx-language-switcher-dropdown-gap: 6px;
    --cpx-language-switcher-background-color: #ffffff;
    --cpx-language-switcher-border-color: rgba(0, 0, 0, 0.1);
    --cpx-language-switcher-caret-color: currentColor;
    --cpx-language-switcher-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
    --cpx-language-switcher-transition: 160ms ease;
}

.cpx_language_switcher {
    position: relative;
    z-index: 20;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    font-size: 0;
    line-height: 1;
}

.cpx_language_switcher .cpx_language_switcher__trigger,
.cpx_language_switcher .cpx_language_switcher__link {
    width: var(--cpx-language-switcher-hit-area);
    min-width: var(--cpx-language-switcher-hit-area);
    height: auto;
    min-height: var(--cpx-language-switcher-hit-area);
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    outline-offset: 3px;
    background: transparent;
    box-shadow: none;
    color: var(--cpx-language-switcher-caret-color);
    font: inherit;
    line-height: 1;
    text-decoration: none;
    transform: none;
    cursor: pointer;
    appearance: none;
}

.cpx_language_switcher .cpx_language_switcher__trigger {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--cpx-language-switcher-gap);

    margin-top: 15px; /* Offset top because of the caret */
}

.cpx_language_switcher .cpx_language_switcher__link {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--cpx-language-switcher-transition);
}

.cpx_language_switcher .cpx_language_switcher__trigger:hover,
.cpx_language_switcher .cpx_language_switcher__trigger:focus,
.cpx_language_switcher .cpx_language_switcher__link:hover,
.cpx_language_switcher .cpx_language_switcher__link:focus {
    border: 0;
    background: transparent;
    box-shadow: none;
    color: var(--cpx-language-switcher-caret-color);
    text-decoration: none;
    transform: none;
}

.cpx_language_switcher .cpx_language_switcher__link:hover,
.cpx_language_switcher .cpx_language_switcher__link:focus {
    transform: scale(1.1);
}

.cpx_language_switcher__flag {
    position: relative;
    display: block;
    overflow: hidden;
    width: var(--cpx-language-switcher-flag-size);
    height: var(--cpx-language-switcher-flag-size);
    flex: 0 0 var(--cpx-language-switcher-flag-size);
    border: 1px solid var(--cpx-language-switcher-border-color);
    border-radius: 50%;
    background-color: var(--cpx-language-switcher-background-color);
}

.cpx_language_switcher .cpx_language_switcher__flag__image {
    position: absolute;
    top: 0;
    left: 0;
    display: block;
    width: 100%;
    max-width: none;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    object-fit: cover;
}

.cpx_language_switcher__caret {
    display: block;
    width: 10px;
    height: 6px;
    flex: 0 0 auto;
    transition: transform var(--cpx-language-switcher-transition);
    color: #fff;
}

.cpx_language_switcher__dropdown {
    position: absolute;
    top: calc(100% + var(--cpx-language-switcher-dropdown-gap));
    left: 50%;
    visibility: hidden;
    width: calc(var(--cpx-language-switcher-hit-area) + 8px);
    padding: 4px;
    border: 1px solid var(--cpx-language-switcher-border-color);
    border-radius: 999px;
    background-color: var(--cpx-language-switcher-background-color);
    box-shadow: var(--cpx-language-switcher-shadow);
    opacity: 0;
    transform: translate(-50%, -6px);
    transition:
        opacity var(--cpx-language-switcher-transition),
        transform var(--cpx-language-switcher-transition),
        visibility var(--cpx-language-switcher-transition);
    pointer-events: none;
}

.cpx_language_switcher__dropdown::before {
    position: absolute;
    bottom: 100%;
    left: 0;
    width: 100%;
    height: var(--cpx-language-switcher-dropdown-gap);
    content: "";
}

.cpx_language_switcher__list {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    margin: 0;
    padding: 0;
    list-style: none;
}

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

.cpx_language_switcher__item::before,
.cpx_language_switcher__item::after {
    content: none;
}

.cpx_language_switcher.is_open .cpx_language_switcher__dropdown {
    visibility: visible;
    opacity: 1;
    transform: translate(-50%, 0);
    pointer-events: auto;
}

.cpx_language_switcher.is_open .cpx_language_switcher__caret {
    transform: rotate(180deg);
}

@media (hover: hover) and (pointer: fine) {
    .cpx_language_switcher:hover .cpx_language_switcher__dropdown {
        visibility: visible;
        opacity: 1;
        transform: translate(-50%, 0);
        pointer-events: auto;
    }

    .cpx_language_switcher:hover .cpx_language_switcher__caret {
        transform: rotate(180deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .cpx_language_switcher__caret,
    .cpx_language_switcher__dropdown {
        transition: none;
    }
}
