/* ============================================================================
 *  i18n-anim.css — 液态玻璃语言切换器 + 失焦/对焦文字切换动效
 * ============================================================================
 *  文字动效 (Task 3 微调):
 *    - 位移缩减至 4px, 离场加速到 0.2s
 *    - blur(5px) 主导, 营造"失焦再对焦"感, 弱化上下移动
 *  切换器 (Task 2 液态玻璃):
 *    - backdrop-filter: blur(12px) saturate(180%)
 *    - 半透明背景 rgba(255,255,255,0.1), 极细微白边框, 流畅阴影过渡
 *    - 胶囊触发 + 弹出菜单 (纯手写, 无原生 select)
 *  移动端 (Task 4):
 *    - 触控目标 ≥44px, 靠边贴合, 弹出菜单右对齐不溢出
 *    - 点击唤醒 (不依赖 hover)
 * ========================================================================== */

/* ---------- 文字切换动效: 失焦 -> 对焦 ---------- */
@keyframes i18n-text-leave {
    from { opacity: 1; filter: blur(0); transform: translateY(0); }
    to   { opacity: 0; filter: blur(5px); transform: translateY(-4px); }
}
@keyframes i18n-text-enter {
    from { opacity: 0; filter: blur(5px); transform: translateY(4px); }
    to   { opacity: 1; filter: blur(0); transform: translateY(0); }
}

body.i18n-leaving [data-i18n-auto],
body.i18n-leaving [data-i18n-auto-html] {
    will-change: opacity, filter, transform;
    animation: i18n-text-leave 0.2s cubic-bezier(0.4, 0, 0.2, 1) both;
}
body.i18n-entering [data-i18n-auto],
body.i18n-entering [data-i18n-auto-html] {
    will-change: opacity, filter, transform;
    animation: i18n-text-enter 0.34s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@media (prefers-reduced-motion: reduce) {
    body.i18n-leaving [data-i18n-auto], body.i18n-leaving [data-i18n-auto-html],
    body.i18n-entering [data-i18n-auto], body.i18n-entering [data-i18n-auto-html] {
        animation: none !important;
        will-change: auto;
    }
}

/* ==========================================================================
 *  液态玻璃语言切换器
 * ========================================================================== */
.i18n-switcher {
    position: fixed;
    z-index: 9999;
    right: 20px;
    bottom: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Inter, sans-serif;
    -webkit-tap-highlight-color: transparent;
    opacity: 0;
    transform: translateY(10px) scale(0.94);
    transition:
        opacity 0.55s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.55s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}
.i18n-switcher.i18n-ready {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* 触发胶囊 — 液态玻璃 */
.i18n-trigger {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 44px;
    padding: 0 16px 0 18px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    box-shadow:
        0 8px 28px rgba(0, 0, 0, 0.10),
        0 2px 8px rgba(0, 0, 0, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.45),
        inset 0 -1px 0 rgba(0, 0, 0, 0.03);
    color: rgba(0, 0, 0, 0.82);
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    white-space: nowrap;
    transition:
        box-shadow 0.3s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
        background 0.3s ease,
        border-color 0.3s ease;
}
.i18n-trigger:hover {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.35);
    box-shadow:
        0 12px 36px rgba(0, 0, 0, 0.14),
        0 4px 12px rgba(0, 0, 0, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.55);
    transform: translateY(-1px);
}
.i18n-trigger:active {
    transform: translateY(0) scale(0.98);
}
.i18n-switcher.is-open .i18n-trigger {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.4);
}

.i18n-trigger__name { line-height: 1; }

/* 雪佛龙箭头 (纯 CSS) */
.i18n-trigger__chev {
    width: 8px;
    height: 8px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg) translate(-1px, -1px);
    opacity: 0.5;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}
.i18n-switcher.is-open .i18n-trigger__chev {
    transform: rotate(-135deg) translate(-1px, -1px);
    opacity: 0.85;
}

/* 弹出菜单 — 液态玻璃 */
.i18n-popup {
    position: absolute;
    right: 0;
    bottom: calc(100% + 10px);
    min-width: 184px;
    padding: 6px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    box-shadow:
        0 16px 48px rgba(0, 0, 0, 0.16),
        0 4px 16px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.45);
    opacity: 0;
    transform: translateY(6px) scale(0.98);
    transform-origin: bottom right;
    pointer-events: none;
    transition:
        opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}
.i18n-switcher.is-open .i18n-popup {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* 选项 — 触控目标 ≥44px */
.i18n-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 44px;
    padding: 10px 14px;
    border: none;
    background: transparent;
    border-radius: 12px;
    color: rgba(0, 0, 0, 0.78);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    width: 100%;
    text-align: left;
    transition: background 0.2s ease, color 0.2s ease;
}
.i18n-option:hover { background: rgba(0, 0, 0, 0.05); }
.i18n-option:active { background: rgba(0, 0, 0, 0.08); }
.i18n-option__name { line-height: 1; }
.i18n-option__right {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.i18n-option__code {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: rgba(0, 0, 0, 0.32);
}
.i18n-option__check {
    width: 14px;
    height: 14px;
    opacity: 0;
    color: #000;
    flex-shrink: 0;
}
.i18n-option.is-active {
    background: rgba(0, 0, 0, 0.06);
    color: rgba(0, 0, 0, 0.92);
}
.i18n-option.is-active .i18n-option__code { color: rgba(0, 0, 0, 0.5); }
.i18n-option.is-active .i18n-option__check { opacity: 0.75; }

/* 切换进行中: 禁用并降透明 */
.i18n-switcher.is-switching {
    pointer-events: none;
    opacity: 0.7;
}

/* ---------- 移动端适配 (Task 4) ---------- */
@media (max-width: 640px) {
    .i18n-switcher {
        right: 12px;
        bottom: 12px;
    }
    .i18n-trigger {
        height: 44px;            /* 触控目标达标 */
        padding: 0 14px 0 16px;
        font-size: 0.75rem;
    }
    .i18n-popup {
        min-width: 168px;
        /* 右对齐 + 限宽, 杜绝横向溢出 */
        max-width: calc(100vw - 24px);
    }
    .i18n-option {
        min-height: 44px;        /* 触控目标达标 */
        padding: 11px 14px;
        font-size: 0.8125rem;
    }
}
