:root {
    --cpx-overlay-bg: rgba(255, 255, 255, 0.45);
    --cpx-overlay-blur: 6px;
    --cpx-modal-bg: #ffffff;
    --cpx-modal-radius: 16px;
    --cpx-modal-shadow: 0 20px 45px rgba(0, 0, 0, 0.18);
    --cpx-gap: 5px 16px;
    --cpx-grid-columns: 3;
    --cpx-flag-size: 22px;
    --cpx-modal-max-width: 640px;
    --cpx-modal-padding: 20px;
    --cpx-text-color: #111;

    /* animatie */
    --cpx-modal-ease: cubic-bezier(.2, .7, .2, 1);
    --cpx-modal-dur: .22s;
}

.lang-switcher {
    position: relative;
    display: inline-block;
}

@media screen and (min-width: 1024px) {
    .lang-switcher {
        margin-top: 10px;
    }
}

/* Trigger */
.lang-switcher__current {
    /* Reset elementor button styling */
    border: none !important;

    display: inline-flex;
    align-items: center;
    gap: 6px;

    position: relative;
    /* layout */
    height: 1.5rem !important;
    padding: 0 !important;
    /* box-model */
    background: transparent !important;
    cursor: pointer;

    color: inherit;
    /* visual */
}

.lang-switcher__current img {
    display: block;
    height: 1.5rem;
    width: 1.5rem;

    object-fit: contain;
    /* visual */
    object-position: center;
}

.lang-switcher__label {
    font-size: 0.95rem;
    line-height: 1.2;
}

/* Overlay (fade blijft hetzelfde) */
.lang-switcher__overlay {
    position: fixed;
    inset: 0;
    backdrop-filter: blur(var(--cpx-overlay-blur));
    -webkit-backdrop-filter: blur(var(--cpx-overlay-blur));
    background-color: var(--cpx-overlay-bg);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--cpx-modal-dur) var(--cpx-modal-ease);
    z-index: 9998;
}

/* Modal: scaleY + fade */
.lang-switcher__modal {
    position: fixed;
    left: 50%;
    top: 50%;

    font-family: var(--e-global-typography-text-font-family);
    font-weight: var(--e-global-typography-text-font-weight);

    max-width: var(--cpx-modal-max-width);
    width: calc(100vw - 40px);

    /* let het lijken alsof hij van boven openklapt */
    transform-origin: top center;
    transform: translate(-50%, -50%) scaleY(0.82);
    opacity: 0;

    background-color: var(--cpx-modal-bg);
    border-radius: var(--cpx-modal-radius);
    box-shadow: var(--cpx-modal-shadow);
    color: var(--cpx-text-color);

    pointer-events: none;
    will-change: transform, opacity;
    transition:
        transform var(--cpx-modal-dur) var(--cpx-modal-ease),
        opacity var(--cpx-modal-dur) var(--cpx-modal-ease);
    z-index: 9999;
}

/* Open state — vanuit body class */
body.cpx-lang-switcher-open .lang-switcher__overlay {
    opacity: 1;
    pointer-events: auto;
}

body.cpx-lang-switcher-open .lang-switcher__modal {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scaleY(1);
}

/* Reduced motion: spring direct open/ dicht */
@media (prefers-reduced-motion: reduce) {

    .lang-switcher__overlay,
    .lang-switcher__modal {
        transition: none;
    }

    .lang-switcher__modal {
        transform: translate(-50%, -50%) scaleY(1);
        opacity: 1;
    }
}

.lang-switcher__modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: var(--cpx-modal-padding);
    /* box-model */
    border-bottom: 1px solid rgba(0, 0, 0, .06);
    /* visual */
}

.lang-switcher__modal__title {
    font-size: 1.1rem;
    margin: 0;
    /* box-model */
}

.lang-switcher__modal__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 27px !important;
    height: auto;
    border: none !important;
    padding: 0 !important;
    background: transparent !important;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;

    img {
        width: 100%;
        height: auto;
    }
}

/* Grid */
.lang-switcher__grid {
    display: grid;
    grid-template-columns: repeat(var(--cpx-grid-columns), minmax(0, 1fr));
    gap: var(--cpx-gap);

    padding: var(--cpx-modal-padding);
    /* box-model */
}

.lang-switcher__item {
    display: inline-flex;
    align-items: center;
    gap: 10px;

    text-decoration: none;
    padding: 10px 12px;
    /* box-model */
    border-radius: 12px;

    color: var(--e-global-color-text) !important;
    /* visual */
    background: #fff;
    box-shadow: 0 1px 0 rgba(0, 0, 0, .04);

    transition: transform .12s ease, box-shadow .12s ease;
    /* transitions */
}

.lang-switcher__item:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, .08);
}

.lang-switcher__item__flag {
    width: var(--cpx-flag-size);
    height: var(--cpx-flag-size);
    object-fit: contain;
    object-position: center;
    border-radius: 999px;
    border: 1px solid #f2f2f2;
}

.lang-switcher__item__label {
    font-size: 0.95rem;
    line-height: 1.2;
}

/* Open state (via body class voor scroll lock + states) */
body.cpx-lang-switcher-open .lang-switcher__overlay {
    opacity: 1;
    pointer-events: auto;
}

body.cpx-lang-switcher-open .lang-switcher__modal {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}

/* Kleine schermen: 2 kolommen */
@media (max-width: 480px) {
    .lang-switcher__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}