/* Language switcher — rounded flag tiles (navbar) */

.lang-switcher {
    position: relative;
    display: flex;
    align-items: center;
    margin-left: 8px;
    flex-shrink: 0;
    z-index: 1400;
}

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

.lang-switcher__toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    overflow: hidden;
    pointer-events: auto;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.lang-switcher__toggle:hover,
.lang-switcher__toggle[aria-expanded='true'] {
    border-color: rgba(51, 184, 184, 0.55);
    background: rgba(0, 153, 153, 0.15);
    box-shadow: 0 0 0 1px rgba(51, 184, 184, 0.2);
}

.lang-switcher__toggle img,
.lang-switcher__option img {
    width: 28px;
    height: 19px;
    object-fit: cover;
    border-radius: 4px;
    display: block;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.15);
}

.lang-switcher__menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 168px;
    padding: 6px;
    margin: 0;
    list-style: none;
    border-radius: 12px;
    background: rgba(12, 28, 38, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(16px);
    z-index: 1401;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-6px);
    transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
}

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

.lang-switcher__option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #d8e5f1;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
}

.lang-switcher__option img {
    width: 28px;
    height: 19px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.lang-switcher__option:hover {
    background: rgba(255, 255, 255, 0.08);
}

.lang-switcher__option.is-active {
    background: rgba(0, 153, 153, 0.22);
    color: #9be6ff;
}

.lang-switcher__option .lang-native {
    font-weight: 700;
}

.lang-switcher__option .lang-en-name {
    font-size: 12px;
    font-weight: 500;
    color: #97aec2;
    margin-left: auto;
}

@media (max-width: 768px) {
    .nav-container .lang-switcher {
        order: 0;
        flex-shrink: 0;
        margin-left: auto;
        margin-right: 8px;
        position: relative;
        z-index: 1400;
    }

    .lang-switcher__menu {
        position: fixed;
        top: calc(var(--navbar-height, 64px) + env(safe-area-inset-top, 0px) + 6px);
        right: 12px;
        left: auto;
        min-width: min(200px, calc(100vw - 24px));
        z-index: 1500;
    }

    .nav-container:has(.lang-switcher) .logo {
        max-width: calc(100% - 96px);
    }

}

/* Fallback when :has() unsupported — layout-fix also sets logo width */
@supports not selector(:has(*)) {
    @media (max-width: 768px) {
        .nav-container .logo {
            max-width: calc(100% - 96px);
        }
    }
}

/* Chinese hero: tight 3-line stack (no <br> — avoids double line breaks) */
html[lang="zh-Hans"] .hero h1 {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2em;
    line-height: 1.05;
    letter-spacing: 0.02em;
}

html[lang="zh-Hans"] .hero h1 .hero-title-zh-lead,
html[lang="zh-Hans"] .hero h1 > .gradient,
html[lang="zh-Hans"] .hero h1 .hero-title-brand {
    display: block;
    margin: 0;
}

@media (min-width: 1025px) {
    html[lang="zh-Hans"] .hero h1 {
        font-size: clamp(42px, 4.1vw, 58px);
        gap: 0.14em;
        max-width: 9em;
        margin-bottom: 24px;
    }

    html[lang="zh-Hans"] .hero h1 .hero-title-zh-lead {
        font-size: 0.68em;
        font-weight: 700;
        color: var(--text-soft);
        -webkit-text-fill-color: var(--text-soft);
        letter-spacing: 0.1em;
        line-height: 1.1;
    }

    html[lang="zh-Hans"] .hero h1 > .gradient {
        line-height: 1.05;
    }

    html[lang="zh-Hans"] .hero h1 .hero-title-brand {
        font-size: 0.5em;
        font-weight: 600;
        letter-spacing: 0.18em;
        color: var(--muted);
        -webkit-text-fill-color: var(--muted);
        line-height: 1.1;
    }
}

@media (max-width: 1024px) {
    html[lang="zh-Hans"] .hero h1 {
        font-size: clamp(30px, 7.5vw, 40px);
        align-items: center;
        text-align: center;
        gap: 0.18em;
        margin-left: auto;
        margin-right: auto;
        max-width: 100%;
    }

    html[lang="zh-Hans"] .hero h1 .hero-title-zh-lead {
        font-size: 0.88em;
        letter-spacing: 0.06em;
    }

    html[lang="zh-Hans"] .hero h1 .hero-title-brand {
        font-size: 0.58em;
        letter-spacing: 0.1em;
        color: var(--text-soft);
        -webkit-text-fill-color: var(--text-soft);
    }
}
