/* Sprachauswahl als Dropdown (Theme-Override von partials/langswitcher.html.twig).
   Basis-Optik: helle Pille für hellen Untergrund.
   --floating: fixiert in der unteren rechten Ecke des Viewports (Standard).
   --on-dark:  Variante für dunklen Untergrund, z.B. im Seitenfluss des Footers. */

.langswitcher-dropdown {
    position: relative;
    display: inline-block;
    max-width: 100%;
}

.langswitcher-dropdown--floating {
    position: fixed;
    right: 20px;
    bottom: 20px;
    /* unter Magnific Popup (1042) und Tingle-Modals (1100), über dem Seiteninhalt */
    z-index: 1000;
}

.langswitcher-dropdown__toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 8px 14px;
    background: #FFF;
    border: 1px solid rgba(49, 57, 139, 0.18);
    border-radius: 8px;
    color: #31398B;
    font-family: inherit;
    font-size: 16px;
    font-weight: 500;
    line-height: 24px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.langswitcher-dropdown__toggle:hover,
.langswitcher-dropdown__toggle[aria-expanded="true"] {
    background: #F1F3FA;
    border-color: rgba(49, 57, 139, 0.4);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
}

.langswitcher-dropdown__toggle:focus-visible {
    outline: 2px solid #31398B;
    outline-offset: 2px;
}

.langswitcher-dropdown__caret {
    width: 0;
    height: 0;
    margin-left: 2px;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid currentColor;
    transition: transform 0.15s ease;
}

.langswitcher-dropdown__toggle[aria-expanded="true"] .langswitcher-dropdown__caret {
    transform: rotate(180deg);
}

.langswitcher-dropdown__flag {
    flex: 0 0 auto;
    width: 22px;
    height: 16px;
    border-radius: 2px;
    object-fit: cover;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
}

/* Menü klappt nach oben und rechtsbündig auf, damit es in der Ecke im Viewport bleibt.
   Für Platzierungen mit Platz nach unten: Klasse langswitcher-dropdown--down setzen. */
.langswitcher-dropdown__menu {
    position: absolute;
    z-index: 1;
    right: 0;
    bottom: calc(100% + 8px);
    min-width: 100%;
    margin: 0;
    padding: 6px;
    list-style: none;
    background: #FFF;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
}

.langswitcher-dropdown--down .langswitcher-dropdown__menu {
    top: calc(100% + 8px);
    bottom: auto;
    transform: translateY(-4px);
}

.langswitcher-dropdown.is-open .langswitcher-dropdown__menu,
.langswitcher-dropdown:focus-within .langswitcher-dropdown__menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.langswitcher-dropdown__menu li {
    list-style: none;
    margin: 0;
}

/* Höhere Spezifität, damit generische Link-Regeln (z.B. im Footer) nicht greifen */
.footer .row-custom a.langswitcher-dropdown__item,
a.langswitcher-dropdown__item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    margin: 0;
    padding: 8px 12px;
    border-radius: 4px;
    color: #31398B;
    font-size: 16px;
    line-height: 24px;
    font-weight: 400;
    text-decoration: none;
    white-space: nowrap;
}

.footer .row-custom a.langswitcher-dropdown__item:hover,
a.langswitcher-dropdown__item:hover,
.footer .row-custom a.langswitcher-dropdown__item:focus-visible,
a.langswitcher-dropdown__item:focus-visible {
    background: #F1F3FA;
    text-decoration: none;
}

.footer .row-custom a.langswitcher-dropdown__item.active,
a.langswitcher-dropdown__item.active {
    background: #F1F3FA;
    font-weight: 600;
    text-decoration: none;
}

/* Variante für dunklen Untergrund (Footer & Co.) */
.langswitcher-dropdown--on-dark .langswitcher-dropdown__toggle {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 8px;
    color: #FFF;
    box-shadow: none;
}

.langswitcher-dropdown--on-dark .langswitcher-dropdown__toggle:hover,
.langswitcher-dropdown--on-dark .langswitcher-dropdown__toggle[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.18);
    border-color: #FFF;
    box-shadow: none;
}

.langswitcher-dropdown--on-dark .langswitcher-dropdown__toggle:focus-visible {
    outline-color: #FFF;
}

.langswitcher-dropdown--on-dark .langswitcher-dropdown__menu {
    right: auto;
    left: 0;
}

@media (max-width: 981px) {
    .langswitcher-dropdown--floating {
        right: 12px;
        bottom: 12px;
    }

    .langswitcher-dropdown__menu {
        min-width: 180px;
    }
}

@media print {
    .langswitcher-dropdown--floating {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .langswitcher-dropdown__toggle,
    .langswitcher-dropdown__caret,
    .langswitcher-dropdown__menu {
        transition: none;
    }
}
