/*
 * Mountain Diary — the language switcher (Site\Header\LanguageSwitcher, with
 * language-switcher.js): on a computer the flag button in the header with its drop-down list, on
 * a phone the language item in the slide menu, which replaces it there. The button's square is the
 * header's (header-layout.css); the colours come from the design tokens. Printed after the theme's
 * styles.
 */

/* === Desktop: the flag button and its drop-down list === */
.md-lang-switcher {
    position: relative;
    display: flex;
    align-items: center;
    margin-right: 6px;
    z-index: 1000;
}

/* Only the flag shows; !important keeps the theme's button styles off it. */
.md-lang-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    background: none !important;
    border: 0 !important;
    border-radius: var(--md-radius-sm);
    cursor: pointer;
}

.md-lang-btn .md-lang-flag {
    display: block;
    width: 22px;
    height: 16px;
    border-radius: 2px;
    box-shadow: 0 0 2px var(--md-hairline);
    transition: transform 0.15s;
}

.md-lang-btn:hover .md-lang-flag {
    transform: scale(1.1);
}

/* The drop-down list, in the tone of the header's other menus */
.md-lang-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: -20px;
    min-width: 180px;
    padding: 4px 0;
    background: var(--md-dropdown);
    border: 1px solid var(--md-border);
    border-radius: var(--md-radius);
    box-shadow: var(--md-shadow);
    overflow: hidden;
    display: none;
    z-index: 9999;
}

.md-lang-dropdown.md-show {
    display: block;
}

.md-lang-dropdown .md-lang-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    font-size: 15px;
    font-weight: 500;
    color: var(--md-text);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s;
}

.md-lang-dropdown .md-lang-item:hover {
    background: var(--md-hover-tint);
}

.md-lang-dropdown .md-lang-item.md-active {
    background: var(--md-hover-tint);
    font-weight: 600;
}

.md-lang-dropdown .md-lang-item img {
    width: 20px;
    height: 14px;
    border-radius: 2px;
    object-fit: cover;
    box-shadow: 0 0 1px var(--md-hairline);
    flex-shrink: 0;
}

/* === Mobile: the language item in the slide menu === */

/* On phones the item in the menu replaces the switcher of the header. */
@media (width <= 768px) {
    .md-lang-switcher {
        display: none !important;
    }
}

/* The theme adds a sub-menu toggle to the item, which has its own. */
.md-mobile-lang-item > .dropdown-toggle {
    display: none !important;
}

.md-mobile-lang-toggle,
.md-mobile-lang-link {
    display: flex !important;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.md-mobile-lang-flag {
    width: 20px;
    height: 14px;
    border-radius: 2px;
    flex-shrink: 0;
    box-shadow: 0 0 2px var(--md-hairline);
}

.md-mobile-lang-link .md-mobile-lang-flag {
    width: 18px;
    height: 13px;
    box-shadow: 0 0 1px var(--md-hairline);
}
