/* Language flag selector — glassmorphism, responsive, on blue header */
.lang-selector {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    width: fit-content;
    max-width: 100%;
    margin: -3rem auto 1rem;
    padding: 0.315rem;
    border-radius: 9999px;
    /* Glassmorphism on primary (blue) background — more structured */
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.06));
    backdrop-filter: blur(10px) saturate(140%);
    -webkit-backdrop-filter: blur(10px) saturate(140%);
    border: 1px solid rgba(255, 255, 255, 0.35);
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    overflow: hidden;
}

html.dark .lang-selector {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04));
    border: 1px solid rgba(255, 255, 255, 0.22);
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.lang-pill {
    display: flex;
    align-items: center;
    gap: 0.36rem;
    padding: 0.27rem 0.63rem;
    border-radius: 9999px;
    text-decoration: none;
    font-size: 0.72rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.92);
    white-space: nowrap;
    transition: background 0.2s ease, box-shadow 0.2s ease;
    flex: 0 0 auto;
}

.lang-pill:hover {
    background: rgba(255, 255, 255, 0.2);
}

.lang-pill-current {
    background: rgba(255, 255, 255, 0.22);
    box-shadow: 0 0 0 1.35px rgba(255, 255, 255, 0.55);
    pointer-events: none;
    cursor: default;
}

html.dark .lang-pill-current {
    background: rgba(255, 255, 255, 0.14);
    box-shadow: 0 0 0 1.35px rgba(255, 255, 255, 0.45);
}

/* Flag icon — fixed size, never shrinks (prevents CLS) */
.lang-flag {
    flex: 0 0 auto;
    width: 20px;
    height: 15px; /* 4:3 ratio */
    display: inline-flex;
    align-items: center;
    overflow: hidden;
}

.lang-flag svg {
    width: 20px;
    height: 15px;
    display: block;
    object-fit: cover;
    border-radius: 2px;
}

/* Label — shrinks to 0 when space runs out, hiding flags-only */
.lang-label {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* When container is too narrow, labels collapse — flags remain */
@media (max-width: 432px) {
    .lang-selector:has(.lang-pill:nth-child(3)) .lang-label {
        max-width: 0;
        opacity: 0;
        padding: 0;
        margin: 0;
    }
}

/* For 2 languages on narrow screens, keep labels if they fit */
@media (max-width: 342px) {
    .lang-label {
        max-width: 0;
        opacity: 0;
        padding: 0;
        margin: 0;
    }
}
