/* ============================================================
   lang-switcher.css — 語系切換下拉選單樣式
   
   設計風格：延續 Cyber Tarot 的暗色主題
   - 深色背景 + 金色強調色
   - 半透明毛玻璃效果
   - 流暢的動畫過渡
   ============================================================ */

/* === 容器定位 === */
.lang-switcher {
    position: fixed;
    z-index: 8000; /* 低於 loading overlay 和 question dialog，高於一般 UI */
    pointer-events: auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    /* 關鍵：限制寬度為內容寬度，避免 block 元素橫跨整個螢幕寬度擋住觸控 */
    width: fit-content;
    touch-action: manipulation; /* 避免干擾手機觸控手勢 */
}

/* 位置變體 */
.lang-switcher--top-right {
    top: 12px;
    right: 12px;
}

.lang-switcher--top-left {
    top: 12px;
    left: 12px;
}

.lang-switcher--bottom-right {
    bottom: 12px;
    right: 12px;
}

.lang-switcher--bottom-left {
    bottom: 12px;
    left: 12px;
}

/* === 切換按鈕 === */
.lang-switcher__toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 25px;
    color: #d4af37;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    outline: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.lang-switcher__toggle:hover {
    background: rgba(0, 0, 0, 0.85);
    border-color: rgba(212, 175, 55, 0.6);
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.15);
}

.lang-switcher__toggle.active {
    background: rgba(0, 0, 0, 0.9);
    border-color: #d4af37;
}

/* 地區代碼文字（TW / US） */
.lang-switcher__code {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #d4af37;
    background: rgba(212, 175, 55, 0.15);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 4px;
    padding: 1px 5px;
    line-height: 1.3;
    font-family: 'Consolas', 'Monaco', monospace;
}

.lang-switcher__label {
    color: rgba(255, 255, 255, 0.9);
    font-size: 13px;
}

.lang-switcher__arrow {
    font-size: 10px;
    color: rgba(212, 175, 55, 0.6);
    transition: transform 0.2s ease;
    margin-left: 2px;
}

.lang-switcher__toggle.active .lang-switcher__arrow {
    transform: rotate(180deg);
}

/* === 下拉選單 === */
.lang-switcher__dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 160px;
    background: rgba(15, 15, 15, 0.95);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 12px;
    padding: 6px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6),
                0 0 20px rgba(212, 175, 55, 0.05);
    
    /* 隱藏 + 動畫 */
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.95);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

/* 左側定位時，下拉選單靠左 */
.lang-switcher--top-left .lang-switcher__dropdown,
.lang-switcher--bottom-left .lang-switcher__dropdown {
    right: auto;
    left: 0;
}

/* 底部定位時，下拉選單在上方展開 */
.lang-switcher--bottom-right .lang-switcher__dropdown,
.lang-switcher--bottom-left .lang-switcher__dropdown {
    top: auto;
    bottom: calc(100% + 6px);
    transform: translateY(8px) scale(0.95);
}

.lang-switcher__dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* === 選項按鈕 === */
.lang-switcher__option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 14px;
    text-align: left;
    outline: none;
}

.lang-switcher__option:hover:not(.active) {
    background: rgba(212, 175, 55, 0.12);
    color: #fff;
}

.lang-switcher__option.active {
    background: rgba(212, 175, 55, 0.15);
    color: #d4af37;
    cursor: default;
}

/* 選項中的地區代碼 */
.lang-switcher__option-code {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #d4af37;
    background: rgba(212, 175, 55, 0.12);
    border: 1px solid rgba(212, 175, 55, 0.25);
    border-radius: 4px;
    padding: 2px 6px;
    line-height: 1.3;
    font-family: 'Consolas', 'Monaco', monospace;
    min-width: 26px;
    text-align: center;
}

.lang-switcher__option-label {
    flex: 1;
}

.lang-switcher__check {
    color: #d4af37;
    font-size: 14px;
    font-weight: bold;
}

/* === 響應式：小螢幕適配 === */
@media (max-width: 480px) {
    .lang-switcher {
        font-size: 12px;
    }

    .lang-switcher__toggle {
        padding: 6px 10px;
        font-size: 12px;
        gap: 4px;
    }

    .lang-switcher__code {
        font-size: 10px;
        padding: 1px 4px;
    }

    .lang-switcher__label {
        font-size: 12px;
    }

    .lang-switcher__dropdown {
        min-width: 140px;
    }

    .lang-switcher__option {
        padding: 8px 12px;
        font-size: 13px;
    }
}

/* === 入場動畫 === */
@keyframes lang-switcher-fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.lang-switcher {
    animation: lang-switcher-fadeIn 0.3s ease-out;
}
