/* =========================================================
   英语学习平台 - 统一移动端优先样式表 (Mobile-First CSS)
   ========================================================= */
@import "mastery.css";
@import "quiz.css";
@import "modal.css";

:root {
    --primary: #4f46e5;
    --primary-light: #818cf8;
    --primary-dark: #3730a3;
    --primary-bg: #eef2ff;
    
    --success: #10b981;
    --success-bg: #ecfdf5;
    --success-border: #34d399;
    
    --danger: #ef4444;
    --danger-bg: #fef2f2;
    --danger-border: #f87171;
    
    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    
    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    
    --card-bg: #ffffff;
    --page-bg: #f8fafc;
    --border-color: #e2e8f0;
    
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 8px 20px rgba(79, 70, 229, 0.08);
    --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background-color: var(--page-bg);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
}

/* ================= 主容器 (手机100%，PC/平板居中卡片视窗) ================= */
.app-container {
    width: 100%;
    max-width: 520px;
    min-height: 100vh;
    min-height: 100dvh;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    padding: clamp(8px, 1.2vh, 12px) clamp(10px, 3vw, 16px) max(clamp(10px, 1.4vh, 16px), env(safe-area-inset-bottom));
    box-shadow: var(--shadow-md);
    position: relative;
}

@media (min-width: 480px) {
    .app-container {
        padding: 16px 18px max(24px, env(safe-area-inset-bottom));
    }
}

@media (min-width: 540px) {
    body {
        padding: 24px 0;
        background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    }
    .app-container {
        min-height: calc(100vh - 48px);
        border-radius: var(--radius-lg);
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08);
    }
}

/* ================= 头部导航与状态栏 ================= */
.quiz-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: clamp(6px, 1vh, 8px);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--page-bg);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 18px;
    font-weight: 700;
    transition: all 0.2s ease;
}

.back-btn:active {
    transform: scale(0.92);
    background: #e2e8f0;
}

.header-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
}

.score-badge, .points-badge {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    color: #b45309;
    border: 1.5px solid #fcd34d;
    font-size: 0.88rem;
    font-weight: 800;
    padding: 3px 10px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.15);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
}

.coin-icon {
    font-size: 1rem;
    line-height: 1;
    display: inline-block;
}

.points-badge.coin-pulse {
    animation: coinPulse 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes coinPulse {
    0% { transform: scale(1); box-shadow: 0 2px 6px rgba(245, 158, 11, 0.15); }
    40% { transform: scale(1.28); box-shadow: 0 0 16px rgba(245, 158, 11, 0.5); background: #fef08a; }
    100% { transform: scale(1); box-shadow: 0 2px 6px rgba(245, 158, 11, 0.15); }
}

.floating-coin-pill {
    background: linear-gradient(135deg, #fef08a 0%, #f59e0b 100%);
    color: #78350f;
    font-weight: 800;
    font-size: 0.95rem;
    padding: 5px 12px;
    border-radius: 20px;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.45);
    border: 1.5px solid #ffffff;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

@media (max-width: 414px) {
    .quiz-header { gap: 4px; }
    .header-title { font-size: 0.95rem; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .exit-quiz-btn { padding: 4px 8px; font-size: 0.78rem; white-space: nowrap; }
    .points-badge, .score-badge { padding: 2px 7px; font-size: 0.8rem; }
}

/* ================= 筛选与进度控制区 ================= */
.filter-bar {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.filter-select {
    flex: 1;
    min-width: 0;
    padding: 8px 12px;
    font-size: 0.88rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background-color: var(--page-bg);
    color: var(--text-main);
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
}

/* 顶部自主退出胶囊按钮 */
.exit-quiz-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: 20px;
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.exit-quiz-btn:active {
    background: #e2e8f0;
    transform: scale(0.96);
}

/* 实时学情状态条 (防折行，手机端单行优雅显示) */
.live-stats-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 10px 0 6px;
    padding: 5px 12px;
    background: #f8fafc;
    border-radius: 20px;
    border: 1px solid #e2e8f0;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
}

.live-stat-item {
    white-space: nowrap;
    flex-shrink: 0;
}

.live-stat-item strong {
    color: var(--text-main);
    font-weight: 800;
}

.live-stat-divider {
    color: #cbd5e1;
    flex-shrink: 0;
}

/* ================= 题目卡片、选项、拼写与弹窗样式已模块化抽离至 quiz.css ================= */

/* ================= 统一骨架屏与加载指示器 ================= */
.loading-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 0;
    color: var(--text-muted);
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 12px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
