/* ============================================================
   WikiAnomaly — Wikimedia Codex Design System
   ============================================================ */

/* --- Design Tokens (Codex) --- */
:root {
    /* Colors */
    --color-base: #202122;
    --color-subtle: #54595d;
    --color-placeholder: #72777d;
    --color-inverted: #ffffff;
    --color-progressive: #3366cc;
    --color-progressive-hover: #2a4b8d;
    --color-progressive-active: #1a3366;
    --color-destructive: #d73333;
    --color-destructive-hover: #b32424;
    --color-success: #14866d;
    --color-success-subtle: #d5fdf4;
    --color-warning: #edab00;
    --color-notice: #54595d;
    --color-error-subtle: #fee7e6;

    --bg-base: #f8f9fa;
    --bg-surface: #ffffff;
    --bg-surface-hover: #eaecf0;

    --border-base: #a2a9b1;
    --border-subtle: #c8ccd1;
    --border-progressive: #3366cc;

    /* Spacing (8px grid) */
    --space-25: 2px;
    --space-50: 4px;
    --space-75: 6px;
    --space-100: 8px;
    --space-150: 12px;
    --space-200: 16px;
    --space-300: 24px;
    --space-400: 32px;
    --space-500: 40px;
    --space-600: 48px;

    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-size-small: 0.8125rem;
    --font-size-medium: 0.875rem;
    --font-size-base: 1rem;
    --font-size-large: 1.125rem;
    --font-size-x-large: 1.375rem;
    --font-size-xx-large: 1.75rem;
    --font-size-xxx-large: 2.25rem;
    --font-weight-normal: 400;
    --font-weight-bold: 700;
    --line-height-base: 1.6;

    /* Border radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-pill: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.08);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
    --shadow-xl: 0 8px 32px rgba(0,0,0,0.15);

    /* Transitions */
    --transition-fast: 100ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 350ms ease;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    color: var(--color-base);
    background: var(--bg-base);
    line-height: var(--line-height-base);
    min-height: 100vh;
    overflow-x: hidden;
}

/* --- Animated Background --- */
.bg-pattern {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background:
        radial-gradient(circle at 20% 80%, rgba(51,102,204,0.06) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(20,134,109,0.06) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(215,51,51,0.03) 0%, transparent 70%);
    z-index: 0;
    pointer-events: none;
}

/* --- Container --- */
.container {
    max-width: 640px;
    margin: 0 auto;
    padding: var(--space-200);
    position: relative;
    z-index: 1;
}

/* --- Header Bar --- */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-150) var(--space-200);
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--space-300);
    border: 1px solid var(--border-subtle);
}

.header-logo {
    display: flex;
    align-items: center;
    gap: var(--space-100);
    font-size: var(--font-size-large);
    font-weight: var(--font-weight-bold);
    color: var(--color-progressive);
    text-decoration: none;
}

.header-logo .logo-icon {
    font-size: 1.5rem;
}

.header-stats {
    display: flex;
    align-items: center;
    gap: var(--space-200);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: var(--space-50);
    font-size: var(--font-size-medium);
    font-weight: var(--font-weight-bold);
}

.stat-item .stat-icon { font-size: 1.1rem; }

.lives .heart { color: var(--color-destructive); transition: var(--transition-base); }
.lives .heart.lost { opacity: 0.2; transform: scale(0.8); }
.streak-val { color: var(--color-warning); }
.score-val { color: var(--color-progressive); }

/* --- Screens --- */
.screen {
    display: none;
    animation: fadeIn 0.3s ease;
}

.screen.active {
    display: block;
}

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

/* --- Start Screen --- */
.start-screen {
    text-align: center;
    padding: var(--space-500) var(--space-200);
}

.game-title {
    font-size: var(--font-size-xxx-large);
    font-weight: var(--font-weight-bold);
    color: var(--color-progressive);
    margin-bottom: var(--space-100);
    letter-spacing: -0.02em;
}

.game-title .title-icon {
    display: block;
    font-size: 3.5rem;
    margin-bottom: var(--space-150);
}

.game-subtitle {
    font-size: var(--font-size-large);
    color: var(--color-subtle);
    margin-bottom: var(--space-400);
    max-width: 460px;
    margin-left: auto;
    margin-right: auto;
}

.rules-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-300);
    margin-bottom: var(--space-400);
    text-align: left;
    box-shadow: var(--shadow-sm);
}

.rules-card h3 {
    font-size: var(--font-size-base);
    color: var(--color-progressive);
    margin-bottom: var(--space-150);
    display: flex;
    align-items: center;
    gap: var(--space-100);
}

.rules-card ul {
    list-style: none;
    padding: 0;
}

.rules-card li {
    padding: var(--space-75) 0;
    font-size: var(--font-size-medium);
    color: var(--color-subtle);
    display: flex;
    align-items: flex-start;
    gap: var(--space-100);
    line-height: 1.5;
}

.rules-card li .rule-icon {
    flex-shrink: 0;
    font-size: 1rem;
    margin-top: 1px;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-100);
    padding: var(--space-150) var(--space-400);
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-bold);
    border: none;
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
    user-select: none;
}

.btn-primary {
    background: var(--color-progressive);
    color: var(--color-inverted);
    box-shadow: var(--shadow-md), 0 0 0 0 rgba(51,102,204,0.3);
    min-width: 200px;
    padding: var(--space-200) var(--space-500);
    font-size: var(--font-size-large);
}

.btn-primary:hover {
    background: var(--color-progressive-hover);
    box-shadow: var(--shadow-lg), 0 0 0 4px rgba(51,102,204,0.15);
    transform: translateY(-1px);
}

.btn-primary:active {
    background: var(--color-progressive-active);
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-surface);
    color: var(--color-progressive);
    border: 1px solid var(--border-progressive);
    padding: var(--space-150) var(--space-300);
}

.btn-secondary:hover {
    background: rgba(51,102,204,0.05);
}

/* --- Game Screen --- */
.entity-card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: var(--space-300);
    text-align: center;
    margin-bottom: var(--space-200);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.entity-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--color-progressive), var(--color-success));
}

.entity-name {
    font-size: var(--font-size-xx-large);
    font-weight: var(--font-weight-bold);
    color: var(--color-base);
    margin-bottom: var(--space-50);
}

.entity-description {
    font-size: var(--font-size-medium);
    color: var(--color-subtle);
}

.entity-link {
    display: inline-block;
    margin-top: var(--space-100);
    font-size: var(--font-size-small);
    color: var(--color-progressive);
    text-decoration: none;
    opacity: 0.7;
}

.entity-link:hover { opacity: 1; text-decoration: underline; }

/* --- Timer --- */
.timer-bar-container {
    margin-bottom: var(--space-200);
}

.timer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-75);
}

.timer-label {
    font-size: var(--font-size-small);
    color: var(--color-subtle);
    font-weight: var(--font-weight-bold);
}

.timer-value {
    font-size: var(--font-size-medium);
    font-weight: var(--font-weight-bold);
    color: var(--color-base);
    min-width: 32px;
    text-align: right;
}

.timer-value.urgent { color: var(--color-destructive); }

.timer-track {
    width: 100%;
    height: 6px;
    background: var(--bg-surface-hover);
    border-radius: var(--radius-pill);
    overflow: hidden;
}

.timer-fill {
    height: 100%;
    background: var(--color-progressive);
    border-radius: var(--radius-pill);
    transition: width 1s linear, background-color 0.5s ease;
    width: 100%;
}

.timer-fill.warning { background: var(--color-warning); }
.timer-fill.danger  { background: var(--color-destructive); }

/* --- Prompt --- */
.prompt {
    font-size: var(--font-size-medium);
    color: var(--color-subtle);
    text-align: center;
    margin-bottom: var(--space-200);
    font-weight: var(--font-weight-bold);
}

.prompt .prompt-icon { margin-right: var(--space-50); }

/* --- Fact Cards --- */
.facts-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-150);
}

.fact-card {
    background: var(--bg-surface);
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-200);
    cursor: pointer;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    gap: var(--space-200);
    user-select: none;
    position: relative;
    overflow: hidden;
}

.fact-card:hover:not(.disabled) {
    border-color: var(--color-progressive);
    box-shadow: var(--shadow-md), 0 0 0 2px rgba(51,102,204,0.1);
    transform: translateY(-2px);
}

.fact-card:active:not(.disabled) {
    transform: translateY(0);
}

.fact-card.disabled {
    cursor: default;
    pointer-events: none;
}

.fact-card.correct {
    border-color: var(--color-success);
    background: var(--color-success-subtle);
    box-shadow: 0 0 0 2px rgba(20,134,109,0.15);
}

.fact-card.wrong {
    border-color: var(--color-destructive);
    background: var(--color-error-subtle);
    box-shadow: 0 0 0 2px rgba(215,51,51,0.15);
}

.fact-card.reveal-fake {
    border-color: var(--color-success);
    background: var(--color-success-subtle);
    animation: pulse-green 0.6s ease;
}

@keyframes pulse-green {
    0%, 100% { box-shadow: 0 0 0 2px rgba(20,134,109,0.15); }
    50%      { box-shadow: 0 0 0 6px rgba(20,134,109,0.25); }
}

.fact-icon {
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-base);
    border-radius: var(--radius-md);
    flex-shrink: 0;
}

.fact-content {
    flex: 1;
    text-align: left;
}

.fact-property {
    font-size: var(--font-size-small);
    color: var(--color-subtle);
    font-weight: var(--font-weight-bold);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: var(--space-25);
}

.fact-value {
    font-size: var(--font-size-base);
    color: var(--color-base);
    font-weight: var(--font-weight-bold);
}

.fact-badge {
    position: absolute;
    right: var(--space-150);
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.3rem;
    opacity: 0;
    transition: opacity var(--transition-base);
}

.fact-card.correct .fact-badge,
.fact-card.wrong .fact-badge,
.fact-card.reveal-fake .fact-badge {
    opacity: 1;
}

/* --- Loading --- */
.loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(248,249,250,0.85);
    z-index: 100;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: var(--space-200);
    backdrop-filter: blur(4px);
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-subtle);
    border-top-color: var(--color-progressive);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-text {
    font-size: var(--font-size-medium);
    color: var(--color-subtle);
    font-weight: var(--font-weight-bold);
}

/* --- Combo Toast --- */
.combo-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    font-size: var(--font-size-xxx-large);
    font-weight: var(--font-weight-bold);
    color: var(--color-progressive);
    pointer-events: none;
    z-index: 200;
    text-shadow: 0 2px 12px rgba(51,102,204,0.3);
    opacity: 0;
    transition: none;
}

.combo-toast.show {
    animation: comboPopup 0.8s ease forwards;
}

@keyframes comboPopup {
    0%   { transform: translate(-50%, -50%) scale(0); opacity: 0; }
    30%  { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
    70%  { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    100% { transform: translate(-50%, -70%) scale(0.8); opacity: 0; }
}

/* --- Points Toast --- */
.points-toast {
    position: fixed;
    top: 30%;
    left: 50%;
    transform: translateX(-50%);
    font-size: var(--font-size-xx-large);
    font-weight: var(--font-weight-bold);
    color: var(--color-success);
    pointer-events: none;
    z-index: 200;
    opacity: 0;
}

.points-toast.show {
    animation: pointsFloat 1s ease forwards;
}

@keyframes pointsFloat {
    0%   { opacity: 0; transform: translateX(-50%) translateY(0); }
    30%  { opacity: 1; }
    100% { opacity: 0; transform: translateX(-50%) translateY(-60px); }
}

/* --- Game Over Screen --- */
.gameover-screen {
    text-align: center;
    padding: var(--space-400) var(--space-200);
}

.gameover-title {
    font-size: var(--font-size-xxx-large);
    font-weight: var(--font-weight-bold);
    color: var(--color-base);
    margin-bottom: var(--space-100);
}

.gameover-subtitle {
    font-size: var(--font-size-base);
    color: var(--color-subtle);
    margin-bottom: var(--space-400);
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-150);
    margin-bottom: var(--space-400);
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-200);
    box-shadow: var(--shadow-sm);
}

.stat-card-value {
    font-size: var(--font-size-xx-large);
    font-weight: var(--font-weight-bold);
    color: var(--color-progressive);
}

.stat-card-label {
    font-size: var(--font-size-small);
    color: var(--color-subtle);
    margin-top: var(--space-50);
}

.gameover-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--space-150);
    align-items: center;
}

/* --- Wrong Shake --- */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%      { transform: translateX(-8px); }
    40%      { transform: translateX(8px); }
    60%      { transform: translateX(-6px); }
    80%      { transform: translateX(6px); }
}

.shake { animation: shake 0.4s ease; }

/* --- Footer --- */
.footer {
    text-align: center;
    padding: var(--space-300) 0;
    font-size: var(--font-size-small);
    color: var(--color-placeholder);
}

.footer a {
    color: var(--color-progressive);
    text-decoration: none;
}

.footer a:hover { text-decoration: underline; }

/* --- Round Counter --- */
.round-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-50);
    background: var(--bg-surface-hover);
    padding: var(--space-50) var(--space-150);
    border-radius: var(--radius-pill);
    font-size: var(--font-size-small);
    font-weight: var(--font-weight-bold);
    color: var(--color-subtle);
    margin-bottom: var(--space-200);
}

/* --- Responsive --- */
@media (max-width: 480px) {
    .container { padding: var(--space-150); }
    .game-title { font-size: var(--font-size-xx-large); }
    .entity-name { font-size: var(--font-size-x-large); }
    .header { padding: var(--space-100) var(--space-150); }
    .header-stats { gap: var(--space-150); }
    .stat-item { font-size: var(--font-size-small); }
    .fact-card { padding: var(--space-150); }
    .btn-primary { min-width: 160px; padding: var(--space-150) var(--space-300); }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: var(--space-100); }
}
