/* ============================================================
   TinyTrivia Design System v3.0
   Orbitron (display) + Chakra Petch (body/UI)
   Dark-first, light via [data-theme="light"]
   ============================================================ */

/* ─── CSS Custom Properties ─── */
:root {
    /* Accent palette - same in both themes */
    --accent: #FF6B35;
    --accent-hover: #E55A28;
    --accent-secondary: #E63946;
    --accent-gradient: linear-gradient(135deg, #FF6B35, #E63946);
    --accent-glow: rgba(255, 107, 53, 0.25);
    --xp-color: #F5A623;
    --success: #22C55E;
    --error: #EF4444;
    --info: #6366F1;
    --warning: #F59E0B;

    /* Host colors */
    --host-sarcastic: #EF4444;
    --host-neutral: #6366F1;
    --host-positive: #F59E0B;
    --host-roaster: #EF4444;
    --host-professor: #6366F1;
    --host-cheerleader: #F59E0B;
    --host-viking: #92400E;

    /* Mastery */
    --mastery-bronze: #CD7F32;
    --mastery-silver: #C0C0C0;
    --mastery-gold: #FFD700;
    --mastery-platinum: #E5E4E2;

    /* Rarity */
    --rarity-common: #9E9E9E;
    --rarity-rare: #2196F3;
    --rarity-epic: #9C27B0;
    --rarity-legendary: #FFD700;

    /* XP */
    --xp-primary: #7C3AED;
    --xp-dark: #5B21B6;

    /* Radii */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 14px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    /* Dark theme (default) */
    --bg: #0F0F13;
    --bg-secondary: #16161D;
    --bg-card: rgba(255, 255, 255, 0.03);
    --bg-card-hover: rgba(255, 255, 255, 0.06);
    --bg-elevated: rgba(255, 255, 255, 0.05);
    --bg-header: rgba(15, 15, 19, 0.85);
    --border: rgba(255, 255, 255, 0.06);
    --border-medium: rgba(255, 255, 255, 0.12);
    --text: #E8E6E3;
    --text-secondary: #999;
    --text-muted: #666;
    --glow-warm: rgba(255, 107, 53, 0.08);
    --glow-warm-strong: rgba(255, 107, 53, 0.15);
    --glow-cool: rgba(99, 102, 241, 0.06);
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-btn: 0 4px 24px rgba(255, 107, 53, 0.3);
    --danger: #D63031;
    /* Aliases used by arena/game pages */
    --card-bg: #1a1a2e;
    --text-primary: #fff;
    --sidebar-bg: #0f0f1a;
    --sidebar-width: 260px;
}

/* ─── Light Theme ─── */
[data-theme="light"] {
    --bg: #F5F3F0;
    --bg-secondary: #FFFFFF;
    --bg-card: rgba(0, 0, 0, 0.02);
    --bg-card-hover: rgba(0, 0, 0, 0.05);
    --bg-elevated: rgba(0, 0, 0, 0.04);
    --bg-header: rgba(245, 243, 240, 0.9);
    --border: rgba(0, 0, 0, 0.06);
    --border-medium: rgba(0, 0, 0, 0.12);
    --text: #1A1A2E;
    --text-secondary: #666;
    --text-muted: #999;
    --glow-warm: rgba(255, 107, 53, 0.06);
    --glow-warm-strong: rgba(255, 107, 53, 0.12);
    --glow-cool: rgba(99, 102, 241, 0.04);
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-btn: 0 4px 24px rgba(255, 107, 53, 0.2);
    /* Aliases */
    --card-bg: #FFFFFF;
    --text-primary: #1A1A2E;
    --sidebar-bg: #FFFFFF;
}

/* ─── Base Reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    font-family: 'Chakra Petch', 'Rajdhani', sans-serif;
    font-weight: 400;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }

/* ─── Ambient Background (dark only) ─── */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background:
        radial-gradient(circle at 10% 20%, rgba(239, 68, 68, 0.07) 0%, transparent 50%),
        radial-gradient(circle at 90% 80%, rgba(99, 102, 241, 0.05) 0%, transparent 50%),
        radial-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 100% 100%, 100% 100%, 32px 32px;
}
[data-theme="light"] body::before {
    background:
        radial-gradient(circle at 10% 20%, rgba(255, 107, 53, 0.04) 0%, transparent 50%),
        radial-gradient(rgba(0, 0, 0, 0.015) 1px, transparent 1px);
    background-size: 100% 100%, 32px 32px;
}

/* ─── Typography Helpers ─── */
.font-display { font-family: 'Orbitron', sans-serif; }
.font-body { font-family: 'Chakra Petch', 'Rajdhani', sans-serif; }
.section-label {
    font-family: 'Orbitron', sans-serif;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 16px;
}

/* ─── Card Base ─── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: border-color 0.2s, background 0.2s;
}
.card:hover { border-color: var(--border-medium); }

/* ─── Button Styles ─── */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--accent-gradient);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    padding: 12px 32px;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 2px;
    box-shadow: var(--shadow-btn);
    transition: transform 0.15s, box-shadow 0.15s;
    cursor: pointer;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 32px rgba(255, 107, 53, 0.4); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 24px;
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.15s;
    cursor: pointer;
}
.btn-secondary:hover { border-color: var(--border-medium); background: var(--bg-card-hover); }

/* Toggle button (for settings) */
.btn-toggle {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 600;
    font-size: 13px;
    transition: all 0.15s;
    cursor: pointer;
}
.btn-toggle.active,
.btn-toggle[aria-pressed="true"] {
    background: rgba(255, 107, 53, 0.2);
    border-color: rgba(255, 107, 53, 0.4);
    color: var(--accent);
}

/* ─── Theme Toggle Button ─── */
.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s;
    padding: 0;
    flex-shrink: 0;
    line-height: 1;
    color: var(--text-secondary);
}
.theme-toggle:hover {
    border-color: var(--accent);
    transform: scale(1.1);
}

/* ─── XP Pill Badge ─── */
.xp-pill {
    background: var(--accent-gradient);
    border-radius: var(--radius-full);
    padding: 4px 14px;
    font-family: 'Orbitron', sans-serif;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

/* ─── Progress Bar ─── */
.progress-track {
    width: 100%;
    height: 8px;
    background: var(--bg-elevated);
    border-radius: 4px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 4px;
    transition: width 0.4s ease;
}

/* ─── Toast Notifications ─── */
.toast-container { position: fixed; top: 80px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
    background: var(--bg-secondary);
    border: 1px solid var(--border-medium);
    color: var(--text);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(40px); } }

/* ─── Loading ─── */
.loading-screen { display: flex; align-items: center; justify-content: center; min-height: 40vh; }
.loading-dots { display: flex; gap: 6px; }
.loading-dots span {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--accent);
    animation: dotBounce 1.2s infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 0.15s; }
.loading-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes dotBounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.3; } 30% { transform: translateY(-8px); opacity: 1; } }

/* ─── Spinner ─── */
.spinner {
    width: 32px; height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Level-up / Celebration Overlay ─── */
.levelup-overlay {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(15, 15, 19, 0.92);
    display: flex; align-items: center; justify-content: center; flex-direction: column;
    animation: fadeIn 0.3s ease;
}
[data-theme="light"] .levelup-overlay { background: rgba(255, 255, 255, 0.92); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ─── Modal ─── */
.modal-overlay {
    position: fixed; inset: 0; z-index: 150;
    background: rgba(0, 0, 0, 0.6);
    display: flex; align-items: center; justify-content: center;
    animation: fadeIn 0.2s;
}
[data-theme="light"] .modal-overlay { background: rgba(0, 0, 0, 0.4); }
.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-xl);
    padding: 32px;
    max-width: 480px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

/* ─── Responsive Container ─── */
.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }

/* ─── Misc ─── */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }

/* ─── Form Inputs ─── */
.form-input,
.comp-input,
.comp-select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: 'Chakra Petch', sans-serif;
    font-size: 14px;
    transition: border-color 0.2s;
}
.form-input:focus,
.comp-input:focus,
.comp-select:focus {
    outline: none;
    border-color: var(--accent);
}
