/**
 * 多语言切换组件样式 - 优化版 V2
 * 采用现代玻璃态设计 + 流畅动画
 */

/* ==================== 导航栏语言切换按钮 ==================== */
.language-switch-btn {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    position: relative;
    font-family: var(--font-primary);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.header.scrolled .language-switch-btn {
    background: var(--white);
}

.language-switch-btn:hover {
    opacity: 0.8;
}

.language-switch-btn:active {
    transform: scale(0.98);
}

.language-switch-btn:focus {
    outline: none;
    border: none;
}

.language-switch-btn:focus-visible {
    outline: none;
    border: none;
}

.lang-code {
    color: #A0A6B5;
    transition: color 0.3s ease;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
}

.lang-code.active {
    color: #464B5A;
    font-weight: 600;
}

.lang-divider {
    color: #E8EAEF;
    margin: 0 4px;
    font-weight: 300;
    user-select: none;
}

/* 确保在透明导航栏状态下文字也清晰可见 */
.header:not(.scrolled) .language-switch-btn .lang-code {
    color: rgba(160, 166, 181, 0.9);
}

.header:not(.scrolled) .language-switch-btn .lang-code.active {
    color: rgba(70, 75, 90, 0.95);
}

.header:not(.scrolled) .language-switch-btn .lang-divider {
    color: rgba(232, 234, 239, 0.8);
}

/* ==================== 语言选择弹窗 ==================== */
.language-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.language-modal.active {
    opacity: 1;
    visibility: visible;
}

/* 弹窗主体 - 玻璃态设计 */
.language-modal-content {
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.95) 0%, 
        rgba(255, 255, 255, 0.98) 100%
    );
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border-radius: 32px;
    padding: 48px;
    max-width: 560px;
    width: 90%;
    box-shadow: 
        0 24px 48px rgba(0, 0, 0, 0.2),
        0 0 0 1px rgba(255, 255, 255, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    transform: scale(0.8) translateY(30px);
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    text-align: center;
    position: relative;
    overflow: hidden;
}

/* 背景装饰渐变 */
.language-modal-content::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(
        circle at 30% 20%,
        rgba(40, 50, 180, 0.08) 0%,
        transparent 50%
    ),
    radial-gradient(
        circle at 70% 80%,
        rgba(255, 184, 0, 0.08) 0%,
        transparent 50%
    );
    pointer-events: none;
    z-index: 0;
}

.language-modal.active .language-modal-content {
    transform: scale(1) translateY(0);
}

/* ==================== 弹窗头部 ==================== */
.language-modal-header {
    margin-bottom: 40px;
    position: relative;
    z-index: 1;
}

.language-modal-title {
    font-size: 2.25rem;
    background: linear-gradient(135deg, var(--primary-blue) 0%, #4A54D1 50%, var(--primary-gold) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 12px;
    font-weight: 800;
    letter-spacing: -0.02em;
    animation: titleFade 0.8s ease-out 0.2s both;
}

@keyframes titleFade {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.language-modal-subtitle {
    font-size: 1rem;
    color: #64748b;
    font-weight: 500;
    animation: titleFade 0.8s ease-out 0.3s both;
}

/* ==================== 语言选项 ==================== */
.language-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 32px;
    position: relative;
    z-index: 1;
}

.language-option {
    padding: 36px 24px;
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.8) 0%, 
        rgba(248, 250, 252, 0.8) 100%
    );
    border: 2px solid rgba(226, 232, 240, 0.8);
    border-radius: 24px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* 悬停背景效果 */
.language-option::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, 
        rgba(40, 50, 180, 0.08) 0%, 
        rgba(255, 184, 0, 0.08) 100%
    );
    opacity: 0;
    transition: opacity 0.4s ease;
    z-index: 0;
}

.language-option:hover::before {
    opacity: 1;
}

/* 悬停状态 */
.language-option:hover {
    transform: translateY(-8px) scale(1.02);
    border-color: var(--primary-blue);
    box-shadow: 
        0 20px 40px rgba(40, 50, 180, 0.15),
        0 0 0 3px rgba(40, 50, 180, 0.1);
}

.language-option:active {
    transform: translateY(-4px) scale(1);
}

.language-option-content {
    position: relative;
    z-index: 1;
}

/* 国旗图标 */
.language-flag-large {
    font-size: 5rem;
    margin-bottom: 16px;
    display: block;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.1));
    animation: float 4s ease-in-out infinite;
    transition: transform 0.4s ease;
}

.language-option:hover .language-flag-large {
    transform: scale(1.1) rotate(5deg);
    animation-play-state: paused;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    25% {
        transform: translateY(-8px) rotate(2deg);
    }
    75% {
        transform: translateY(-4px) rotate(-2deg);
    }
}

/* 语言名称 */
.language-name {
    font-size: 1.625rem;
    font-weight: 700;
    color: var(--primary-navy);
    margin-bottom: 8px;
    letter-spacing: -0.01em;
    transition: color 0.3s ease;
}

.language-option:hover .language-name {
    color: var(--primary-blue);
}

.language-name-en {
    font-size: 0.938rem;
    color: #94a3b8;
    font-weight: 500;
}

/* 交错动画 */
.language-option:nth-child(1) {
    animation: slideInLeft 0.6s ease-out 0.4s both;
}

.language-option:nth-child(2) {
    animation: slideInRight 0.6s ease-out 0.5s both;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* 第二张卡片延迟动画 */
.language-option:nth-child(2) .language-flag-large {
    animation-delay: 0.5s;
}

/* ==================== 点击波纹效果 ==================== */
.language-option::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(40, 50, 180, 0.4) 0%, transparent 70%);
    transform: translate(-50%, -50%);
    opacity: 0;
    pointer-events: none;
}

.language-option:active::after {
    animation: ripple 0.6s ease-out;
}

@keyframes ripple {
    0% {
        width: 0;
        height: 0;
        opacity: 1;
    }
    100% {
        width: 300px;
        height: 300px;
        opacity: 0;
    }
}

/* ==================== 底部提示 ==================== */
.language-modal-footer {
    font-size: 0.875rem;
    color: #94a3b8;
    margin-top: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
    z-index: 1;
    animation: titleFade 0.8s ease-out 0.6s both;
}

.language-modal-footer::before {
    content: '💡';
    font-size: 1rem;
}

/* ==================== 响应式设计 ==================== */

/* 1200px 断点 */
@media (max-width: 1200px) {
    .language-switch-btn {
        padding: 8px 14px;
        font-size: 0.813rem;
        gap: 6px;
    }
    
    .lang-flag {
        font-size: 1.125rem;
    }
}

/* 平板适配 */
@media (max-width: 768px) {
    .language-switch-btn {
        padding: 10px;
        gap: 0;
    }

    .lang-text {
        display: none;
    }

    .lang-flag {
        font-size: 1.375rem;
    }

    .language-modal-content {
        padding: 36px 24px;
        width: 92%;
        border-radius: 24px;
    }

    .language-modal-title {
        font-size: 1.75rem;
    }

    .language-modal-subtitle {
        font-size: 0.938rem;
    }

    .language-options {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .language-option {
        padding: 32px 20px;
    }

    .language-flag-large {
        font-size: 4rem;
    }

    .language-name {
        font-size: 1.5rem;
    }

    /* 修改动画为统一方向 */
    .language-option:nth-child(1),
    .language-option:nth-child(2) {
        animation: slideUp 0.6s ease-out both;
    }

    .language-option:nth-child(2) {
        animation-delay: 0.5s;
    }

    @keyframes slideUp {
        from {
            opacity: 0;
            transform: translateY(30px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}

/* 小手机适配 */
@media (max-width: 480px) {
    .language-modal-content {
        padding: 28px 20px;
        width: 94%;
        border-radius: 20px;
    }

    .language-modal-header {
        margin-bottom: 32px;
    }

    .language-modal-title {
        font-size: 1.5rem;
    }

    .language-modal-subtitle {
        font-size: 0.875rem;
    }

    .language-option {
        padding: 28px 16px;
        border-radius: 20px;
    }

    .language-flag-large {
        font-size: 3.5rem;
        margin-bottom: 12px;
    }

    .language-name {
        font-size: 1.375rem;
    }

    .language-name-en {
        font-size: 0.875rem;
    }

    .language-modal-footer {
        font-size: 0.813rem;
        margin-top: 20px;
    }
}

/* ==================== 可访问性增强 ==================== */

/* 键盘焦点样式 */
.language-option:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 
        0 0 0 4px rgba(40, 50, 180, 0.2),
        0 8px 24px rgba(40, 50, 180, 0.15);
}

.language-switch-btn:focus {
    outline: none;
    box-shadow: none;
}

.language-switch-btn:focus-visible {
    outline: none;
    box-shadow: none;
}

/* 减少动画（尊重用户偏好） */
@media (prefers-reduced-motion: reduce) {
    .language-modal-content,
    .language-option,
    .language-flag-large,
    .language-switch-btn,
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==================== 加载状态 ==================== */
.language-modal.loading .language-modal-content {
    pointer-events: none;
}

.language-modal.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--primary-gold);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: spin 0.8s linear infinite;
    z-index: 10001;
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* ==================== 高对比度支持 ==================== */
@media (prefers-contrast: high) {
    .language-modal-content {
        background: white;
        border: 3px solid black;
    }

    .language-option {
        background: white;
        border: 2px solid black;
    }

    .language-option:hover {
        background: #f0f0f0;
    }
}
