/**
 * Polyglot — Language Switcher Styles
 *
 * Minimal, un-opinionated CSS. Designed to inherit theme styles.
 */

/* === List Switcher === */
.polyglot-switcher {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5em;
}

.polyglot-switcher li {
    margin: 0;
    padding: 0;
}

.polyglot-switcher a {
    display: inline-flex;
    align-items: center;
    gap: 0.35em;
    text-decoration: none;
    padding: 0.25em 0.5em;
    border-radius: 3px;
    font-size: 0.9em;
    transition: background-color 0.2s ease;
}

.polyglot-switcher a:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.polyglot-switcher .active a {
    font-weight: 600;
}

.polyglot-switcher .polyglot-flag {
    display: inline-block;
    width: 1.2em;
    height: 0.9em;
    border-radius: 2px;
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
}

/* === Dropdown Switcher === */
.polyglot-switcher-dropdown {
    position: relative;
    display: inline-block;
}

.polyglot-switcher-dropdown select {
    padding: 0.35em 2em 0.35em 0.5em;
    border: 1px solid #ccc;
    border-radius: 3px;
    background: #fff;
    font-size: 0.9em;
    cursor: pointer;
    appearance: auto;
}

/* === Vertical List (for widgets/sidebars) === */
.polyglot-switcher--vertical {
    flex-direction: column;
    gap: 0.25em;
}

.polyglot-switcher--vertical a {
    display: flex;
    width: 100%;
    padding: 0.4em 0.6em;
}

/* === Flags Only === */
/* render() emits polyglot-switcher--flags with __flag/__name spans; the
   --flags-only / .polyglot-lang-name names are kept for custom classes. */
.polyglot-switcher--flags a,
.polyglot-switcher--flags-only a {
    padding: 0.2em;
}

.polyglot-switcher--flags .polyglot-switcher__name,
.polyglot-switcher--flags-only .polyglot-switcher__name,
.polyglot-switcher--flags-only .polyglot-lang-name {
    display: none;
}

.polyglot-switcher--flags .polyglot-switcher__flag,
.polyglot-switcher--flags-only .polyglot-switcher__flag {
    font-size: 1.3em;
    line-height: 1;
}

.polyglot-switcher--flags-only .polyglot-flag {
    width: 1.6em;
    height: 1.2em;
}

/* === Custom Dropdown === */
.polyglot-switcher--dropdown {
    position: relative;
    display: inline-block;
}

.polyglot-dd-trigger {
    background: none !important;
    border: none !important;
    padding: 0 !important;
    cursor: pointer;
    font: inherit;
    color: inherit;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px;
}

.polyglot-dd-panel {
    position: absolute;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    z-index: 99999;
    overflow: hidden;
}

.polyglot-dd-item {
    display: flex;
    align-items: center;
    gap: 6px;
    text-decoration: none !important;
    color: #1d2327 !important;
    transition: background .1s;
    white-space: nowrap;
}

.polyglot-dd-item:hover {
    background: #f0f5ff !important;
}

/* === Inline items inside nav menus === */
/* The anchor is a flex row so the flag emoji (an inline <img> once wp-emoji runs)
   sits on the same axis as the other menu titles instead of the text baseline. */
.menu-item-polyglot-lang > .w-nav-anchor {
    display: inline-flex;
    align-items: center;
    gap: 0.35em;
}

.w-nav .menu-item-polyglot-lang > .w-nav-anchor {
    display: flex;
}

.menu-item-polyglot-lang .w-nav-title {
    display: inline-flex;
    align-items: center;
    gap: 0.35em;
}

.menu-item-polyglot-lang .polyglot-switcher__flag img.emoji {
    vertical-align: middle;
}

/* === Dropdown inside nav menus (Impreza, etc.) === */
.menu-item-polyglot-lang {
    position: relative !important;
}

/* Centre the trigger by making the <li> a flex box: a percentage height on the
   button never resolves inside an inline-flex wrapper without an explicit height.
   The wrapper stretches to the item height (so the panel opens under the header)
   and centres the button itself; the theme's tall line-height on the menu item
   (88px in Impreza 9) must not build a line box around the button. */
.w-nav-list .menu-item-polyglot-lang.polyglot-desktop-only {
    display: flex;
    align-items: center;
    align-self: stretch;
}

.menu-item-polyglot-lang .polyglot-switcher--dropdown {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.w-nav-list .menu-item-polyglot-lang.polyglot-desktop-only > .polyglot-switcher--dropdown {
    display: flex !important;
    align-items: center;
    align-self: stretch;
    height: auto !important;
    line-height: 1;
}

.menu-item-polyglot-lang .polyglot-dd-trigger {
    line-height: 1 !important;
    height: auto !important;
    align-self: center;
    vertical-align: middle;
    padding: 0 20px !important;
}

/* Override Impreza/theme nav styles */
.w-nav-list .menu-item-polyglot-lang,
.menu-item-polyglot-lang {
    overflow: visible !important;
}

.w-nav-list .menu-item-polyglot-lang .polyglot-dd-panel,
.menu-item-polyglot-lang .polyglot-dd-panel {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 0;
}

.w-nav-list .menu-item-polyglot-lang .polyglot-dd-trigger,
.menu-item-polyglot-lang .polyglot-dd-trigger {
    display: inline-flex !important;
    align-items: center !important;
    background: none !important;
    border: none !important;
    color: inherit !important;
    font-size: inherit !important;
    font-family: inherit !important;
}

/* Force compact padding on dropdown items inside nav menus */
.menu-item-polyglot-lang .polyglot-dd-item,
.w-nav-list .polyglot-dd-item,
.polyglot-dd-panel .polyglot-dd-item {
    padding: 8px 16px !important;
    margin: 0 !important;
    line-height: 1.4 !important;
    font-size: 14px !important;
}

.polyglot-dd-panel {
    padding: 4px 0 !important;
}

/* Ensure the noscript fallback doesn't show when JS is active */
.polyglot-switcher--dropdown noscript {
    display: none;
}

/* === Floating Switcher === */
.polyglot-floating-switcher {
    display: flex;
    align-items: center;
    justify-content: center;
}

.polyglot-floating-switcher .polyglot-switcher {
    margin: 0; padding: 0; list-style: none;
    display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
}

.polyglot-floating-switcher .polyglot-switcher__flag {
    font-size: 20px; cursor: pointer; transition: transform .15s;
}

.polyglot-floating-switcher .polyglot-switcher__flag:hover { transform: scale(1.2); }
.polyglot-floating-switcher .polyglot-switcher__item.active .polyglot-switcher__flag { opacity: .5; }
.polyglot-floating-switcher a { text-decoration: none; }
.polyglot-floating-switcher .polyglot-switcher__name { font-size: 13px; }

/* Dropdown inside floating bubble */
.polyglot-floating-switcher .polyglot-switcher--dropdown {
    display: flex !important;
    align-items: center !important;
}

.polyglot-floating-switcher .polyglot-dd-trigger {
    padding: 0 !important;
    margin: 0 !important;
    line-height: 1 !important;
}

/* Panel centered relative to the trigger */
.polyglot-floating-switcher .polyglot-dd-panel {
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%);
}

/* === Mobile/Desktop toggle for menu language items === */
/* Desktop: show dropdown <li>, hide individual mobile <li>s. The Impreza rules
   below outrank the theme's own .w-nav-item declarations, so only one of the
   two <li>s is ever visible. */
.polyglot-mobile-only,
.w-nav:not(.type_mobile) .w-nav-list .menu-item.polyglot-mobile-only {
    display: none !important;
}

/* Mobile (Impreza): hide dropdown, show individual items as native menu entries */
.w-nav.type_mobile .w-nav-list .menu-item.polyglot-desktop-only {
    display: none !important;
}

.w-nav.type_mobile .w-nav-list .menu-item.polyglot-mobile-only {
    display: block !important;
}

/* Mobile dropdown arrow */
.polyglot-mobile-arrow {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg) translateY(-2px);
    opacity: .5;
    transition: transform .2s;
    margin-left: 6px;
    vertical-align: middle;
}

.polyglot-mobile-only.opened .polyglot-mobile-arrow {
    transform: rotate(-135deg) translateY(-2px);
}

/* === Padding customization via CSS variables === */
.polyglot-floating-switcher {
    padding: var(--polyglot-float-padding, 10px 14px);
}

.polyglot-dd-trigger {
    padding: var(--polyglot-trigger-padding, 0) !important;
}

.polyglot-dd-item {
    padding: var(--polyglot-item-padding, 8px 14px) !important;
}

.polyglot-dd-panel {
    border-radius: var(--polyglot-panel-radius, 10px);
}

/* === RTL Support === */
[dir="rtl"] .polyglot-switcher {
    direction: rtl;
}
