/* ==========================================================================
   Limicole Translator — Language Switcher
   Customizable via CSS variables: override them in your theme to restyle
   without touching the plugin.
   ========================================================================== */

:root {
    --lmc-switcher-color: inherit;              /* text color, inherits menu color */
    --lmc-switcher-hover: rgba(0, 0, 0, 0.06);  /* hover background */
    --lmc-switcher-radius: 10px;                /* corner radius */
    --lmc-switcher-bg: #ffffff;                 /* dropdown background */
    --lmc-switcher-border: rgba(0, 0, 0, 0.08); /* dropdown border */
    --lmc-switcher-shadow: 0 10px 30px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
    --lmc-switcher-active: #f0f4ff;             /* current language row */
    --lmc-switcher-accent: #2b5fd9;             /* accent (active check, focus ring) */
    --lmc-switcher-font-size: 0.95rem;
}

/* ---------- Container ---------- */
.mm-lang-switcher {
    position: relative;
    display: inline-flex !important;
    align-items: center;
    font-size: var(--lmc-switcher-font-size);
    vertical-align: middle;
    line-height: 1;
}

/* ---------- Current language button (pill) ---------- */
.mm-lang-current {
    display: inline-flex;
    align-items: center;
    gap: 0.45em;

    margin: 0;
    padding: 0.45em 0.8em;
    font: inherit;
    line-height: 1;
    cursor: pointer;

    color: var(--lmc-switcher-color);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--lmc-switcher-radius);
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.mm-lang-current:hover {
    background: var(--lmc-switcher-hover);
}

.mm-lang-current:focus-visible {
    outline: 2px solid var(--lmc-switcher-accent);
    outline-offset: 2px;
}

/* Chevron indicator */
.mm-lang-current::after {
    content: "";
    width: 0.5em;
    height: 0.5em;
    margin-left: 0.15em;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg) translateY(-15%);
    transition: transform 0.18s ease;
    opacity: 0.6;
}

.mm-lang-switcher.is-open .mm-lang-current::after {
    transform: rotate(225deg) translateY(-15%);
}

/* ---------- Dropdown ---------- */
.mm-lang-list {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);

    list-style: none;
    margin: 0;
    padding: 6px;

    min-width: 11rem;
    background: var(--lmc-switcher-bg);
    border: 1px solid var(--lmc-switcher-border);
    border-radius: var(--lmc-switcher-radius);
    box-shadow: var(--lmc-switcher-shadow);

    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-6px) scale(0.98);
    transform-origin: top right;
    transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s;
    z-index: 9999;
    display: block !important;
}

.mm-lang-switcher.is-open .mm-lang-list {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.mm-lang-list li {
    margin: 0;
    padding: 0;
    list-style: none;
}

/* ---------- Language option row ---------- */
.mm-lang-option {
    display: flex;
    align-items: center;
    gap: 0.55em;

    padding: 0.55em 0.75em;
    border-radius: calc(var(--lmc-switcher-radius) - 4px);
    text-decoration: none !important;
    color: #1f2937;
    font-size: 0.92em;
    white-space: nowrap;
    transition: background-color 0.12s ease;
}

.mm-lang-option:hover {
    background-color: var(--lmc-switcher-hover);
    color: #111827;
}

.mm-lang-option:focus-visible {
    outline: 2px solid var(--lmc-switcher-accent);
    outline-offset: -2px;
}

/* Current language row: tinted + check mark */
.mm-lang-option.is-active {
    background: var(--lmc-switcher-active);
    font-weight: 600;
}

.mm-lang-option.is-active::after {
    content: "✓";
    margin-left: auto;
    padding-left: 0.75em;
    color: var(--lmc-switcher-accent);
    font-weight: 700;
}

/* ---------- Flag + code + label ---------- */
.mm-lang-icon {
    display: inline-block !important;
    min-width: 1.25em;
    flex-shrink: 0;
    line-height: 1;
    font-style: normal;
    font-size: 1.15em;
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", sans-serif;
    unicode-bidi: bidi-override;
    direction: ltr;
}

/* Flags come from PHP as emoji; never generate content from CSS
   (the old attr(data-lang) fallback duplicated "RU" as text) */
.mm-lang-icon::before,
.mm-lang-icon::after,
.mm-lang-option::before,
.mm-lang-icon-has-flag::before,
.mm-lang-icon-has-flag::after {
    content: none !important;
}

.mm-lang-code {
    font-size: 0.78em;
    font-weight: 700;
    letter-spacing: 0.05em;
    opacity: 0.65;
    text-transform: uppercase;
}

.mm-lang-label {
    line-height: 1.2;
}

/* ==========================================================================
   Alternative styles: list & inline (legacy markup kept for compatibility)
   ========================================================================== */

.ml-lang-switcher {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.ml-lang-switcher li {
    margin: 0;
    list-style: none;
}

.ml-lang-switcher a {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    padding: 0.4em 0.75em;
    border: 1px solid var(--lmc-switcher-border);
    border-radius: 999px;
    text-decoration: none;
    font-size: 0.9em;
    color: inherit;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.ml-lang-switcher a:hover {
    background: var(--lmc-switcher-hover);
}

.ml-lang-switcher .current-lang a {
    background: var(--lmc-switcher-active);
    border-color: var(--lmc-switcher-accent);
    font-weight: 600;
}

.ml-lang-icon {
    font-style: normal;
    line-height: 1;
}

.ml-lang-code {
    font-size: 0.78em;
    font-weight: 700;
    letter-spacing: 0.05em;
    opacity: 0.65;
    text-transform: uppercase;
}

/* Inline style */
.ml-lang-switcher-inline {
    position: relative;
    display: inline-block;
}

.ml-lang-switcher-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    background: none;
    border: none;
    padding: 0.3em 0.5em;
    font: inherit;
    cursor: pointer;
    color: inherit;
    border-radius: 6px;
}

.ml-lang-switcher-trigger:hover {
    background: var(--lmc-switcher-hover);
}

.ml-lang-arrow {
    font-size: 0.6em;
    opacity: 0.6;
}

.ml-lang-switcher-inline .ml-lang-switcher-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    margin: 0;
    padding: 6px;
    min-width: 10rem;
    list-style: none;
    background: var(--lmc-switcher-bg);
    border: 1px solid var(--lmc-switcher-border);
    border-radius: var(--lmc-switcher-radius);
    box-shadow: var(--lmc-switcher-shadow);
    z-index: 9999;
}

.ml-lang-switcher-inline.is-open .ml-lang-switcher-dropdown {
    display: block;
}

.ml-lang-switcher-dropdown li {
    margin: 0;
    list-style: none;
}

.ml-lang-switcher-dropdown a {
    display: flex;
    align-items: center;
    gap: 0.5em;
    padding: 0.5em 0.7em;
    border-radius: 6px;
    text-decoration: none;
    color: #1f2937;
    font-size: 0.9em;
}

.ml-lang-switcher-dropdown a:hover {
    background: var(--lmc-switcher-hover);
}

.ml-lang-switcher-dropdown .current-lang a {
    background: var(--lmc-switcher-active);
    font-weight: 600;
}

/* ==========================================================================
   Menu integration (Elementor / classic themes)
   ========================================================================== */

.menu-item-lang-switcher,
li.menu-item-lang-switcher {
    display: inline-flex !important;
    align-items: center !important;
    vertical-align: middle !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    list-style: none !important;
    line-height: inherit !important;
    min-height: 0 !important;
}

.elementor-nav-menu .menu-item-lang-switcher,
nav .menu-item-lang-switcher,
ul .menu-item-lang-switcher {
    display: inline-flex !important;
    align-items: center !important;
    flex-shrink: 0;
}

.menu-item-lang-switcher .mm-lang-switcher {
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

.menu-item-lang-switcher .mm-lang-current {
    color: inherit !important;
    font-size: inherit !important;
    font-family: inherit !important;
    line-height: inherit !important;
    white-space: nowrap;
}

.mm-lang-switcher-in-menu {
    display: inline-flex !important;
    align-items: center !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
}

/* ---------- Dark mode ---------- */
@media (prefers-color-scheme: dark) {
    .mm-lang-list,
    .ml-lang-switcher-inline .ml-lang-switcher-dropdown {
        --lmc-switcher-bg: #1f2430;
        --lmc-switcher-border: rgba(255, 255, 255, 0.1);
        --lmc-switcher-active: rgba(90, 130, 255, 0.18);
    }

    .mm-lang-list .mm-lang-option,
    .ml-lang-switcher-dropdown a {
        color: #e5e7eb;
    }

    .mm-lang-list .mm-lang-option:hover,
    .ml-lang-switcher-dropdown a:hover {
        background: rgba(255, 255, 255, 0.08);
        color: #ffffff;
    }
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .mm-lang-switcher {
        font-size: 0.9rem;
    }

    .mm-lang-list {
        right: auto;
        left: 0;
        transform-origin: top left;
    }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    .mm-lang-list,
    .mm-lang-current::after,
    .mm-lang-option {
        transition: none;
    }
}


/* The switcher is not a dropdown menu item: suppress theme-injected toggles
   and submenus that some themes add to any menu item they consider a parent. */
.menu-item-lang-switcher > .sub-menu,
.menu-item-lang-switcher > ul.sub-menu,
.menu-item-lang-switcher > .ast-menu-toggle,
.menu-item-lang-switcher > .dropdown-menu-toggle,
.menu-item-lang-switcher > .menu-item-toggle,
.menu-item-lang-switcher > button[class*="toggle"] {
  display: none !important;
}


/* The switcher item holds a button, not a link, so it does not inherit the
   row height the theme gives to menu links. Where the menu is a flex row it
   can stretch; the exact height is matched by frontend.js, which reads the
   line-height of a neighbouring link rather than assuming a number. */
li.menu-item-lang-switcher {
    align-self: stretch;
}

li.menu-item-lang-switcher > .mm-lang-switcher,
li.menu-item-lang-switcher > .ai-multilang-switcher {
    display: inline-flex;
    align-items: center;
    height: 100%;
}
