/* shared/common.css - Common styles across all MathsMastery apps */

:root {
    --font-display: 'Fredoka', sans-serif;
    --font-ui: 'Nunito', system-ui, sans-serif;
    --color-primary: #3b82f6;
    --color-primary-hover: #2563eb;
    --color-success: #10b981;
    --color-error: #ef4444;
    --color-bg: #f3f4f6;
    --color-surface: #ffffff;
    --color-text: #1f2937;
    --color-text-muted: #6b7280;
    --radius-pill: 9999px;
    --radius-card: 1.25rem;
    --radius-card-sm: 0.875rem;
    --radius-btn: 0.625rem;
    --radius-chip: 0.5rem;
    --shadow-card: 0 1px 3px rgba(0,0,0,0.07), 0 4px 12px rgba(0,0,0,0.08);
    /* Whiteboard/blackboard tokens (match landing page) */
    --chalk-bg: #f0eff2;
    --chalk-surface: #ffffff;
    --chalk-heading: #1e1c2a;
    --chalk-body: #6b6475;
    /* Per-app connector line colour; overridden in each app's CSS */
    --app-accent: #94a3b8;
}

body {
    font-family: var(--font-ui);
    background-color: var(--chalk-bg);
}

h1, h2, h3, h4, .level-section-title {
    font-family: var(--font-display);
}

.card {
    background-color: var(--chalk-surface);
    border-radius: var(--radius-card);
    border: 1px solid rgba(0, 0, 0, 0.06);
    padding: 2rem;
    box-shadow: var(--shadow-card);
    transition: all 0.3s ease-in-out;
    width: 95%;
    max-width: 700px;
}

.btn {
    display: inline-block;
    font-weight: 600;
    font-size: 0.9375rem;
    padding: 0.75rem 1.625rem;
    border-radius: var(--radius-btn);
    transition: all 0.2s ease;
    cursor: pointer;
    text-align: center;
    border: none;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--color-primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: #f8fafc;
    color: #64748b;
    border: 1px solid #e2e8f0;
}

.btn-secondary:hover {
    background: #f1f5f9;
    color: #475569;
}

.question-text {
    font-weight: 700;
    color: var(--chalk-heading);
    letter-spacing: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.feedback {
    font-weight: 600;
    min-height: 5rem;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.feedback-correct { color: #10b981; }
.feedback-incorrect { color: #ef4444; }

/* Ensure math renderers (KaTeX, MathQuill) inherit feedback colour */
.feedback .mq-root-block,
.feedback .mq-math-mode {
    color: inherit;
}

.level-section-title {
    text-align: left;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--chalk-heading);
    margin-top: 2rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 3px solid var(--app-accent);
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
}

.level-btn {
    border: 2px solid #e5e7eb;
    border-radius: 1rem;
    padding: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 120px;
}
.level-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.level-title {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    text-align: center;
    line-height: 1.2;
}
.best-time {
    font-size: 0.75rem;
    font-weight: 500;
    margin-top: 0.5rem;
}

/* Rating color system */
.rating-queen { background: linear-gradient(135deg, #fef7f0, #f9a8d4); color: #9d174d; border-color: #f472b6; }
.rating-true-mastery { background: linear-gradient(135deg, #fef7f0, #f9a8d4); color: #9d174d; border-color: #f472b6; }
.rating-mastery { background: linear-gradient(135deg, #fefbeb, #fbbf24); color: #a16207; border-color: #f59e0b; }
.rating-expert { background: linear-gradient(135deg, #ecfdf5, #34d399); color: #065f46; border-color: #34d399; }
.rating-developing { background: linear-gradient(135deg, #dcfce7, #4ade80); color: #047857; border-color: #6ee7b7; }
.rating-beginner { background: linear-gradient(135deg, #f8fafc, #94a3b8); color: #1e293b; border-color: #94a3b8; }
.rating-none { background: #f3f4f6; color: #374151; }

#confetti-canvas {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 9999;
}

/* Keyboard Key Display */
.dcg {
    padding: 3px 5px;
    border: 1px solid #bbb;
    border-radius: 3px;
    white-space: nowrap;
    line-height: 2em;
    margin: 0 1px;
}

.level-btn.current {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    animation: pulse-current 2s ease-in-out infinite;
}

@keyframes pulse-current {
    0%, 100% {
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(59, 130, 246, 0.3);
    }
}

/* Mastery Progress Bars */
.mastery-progress-label {
    font-size: 0.875rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.mastery-progress-stats {
    font-size: 0.75rem;
    color: #6b7280;
}

.mastery-progress-bar {
    height: 16px;
    background-color: #f3f4f6;
    border-radius: 8px;
    overflow: hidden;
}

.mastery-progress-fill {
    height: 100%;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    transition: width 0.5s ease-in-out;
}

/* Settings screen title */
#settings-screen h1 {
    letter-spacing: -0.025em;
}

/* Game screen streak/timer chips */
div:has(> #streak-counter),
div:has(> #timer) {
    background: rgba(59, 130, 246, 0.07);
    border: 1px solid rgba(59, 130, 246, 0.15);
    border-radius: 999px;
    padding: 0.375rem 0.875rem;
    font-size: 0.875rem;
}

/* Quit confirmation toast */
.quit-toast {
    position: fixed;
    transform: translateX(-50%);
    background: var(--color-primary);
    color: white;
    padding: 0.6rem 1.4rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: 1rem;
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.quit-toast.visible {
    opacity: 1;
}


/* ============================
   Success screen redesign
   ============================ */

.success-header {
    display: flex; align-items: center; gap: 1.25rem;
    margin-bottom: 1.25rem; text-align: left;
}
.success-icon-circle {
    width: 72px; height: 72px; min-width: 72px;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    background: #d1fae5; border: 3px solid rgba(255,255,255,0.8);
    box-shadow: 0 0 0 4px rgba(16,185,129,0.2);
}
.success-icon-emoji { font-size: 2rem; line-height: 1; }

.success-icon-circle.rating-beginner   { background: #f1f5f9; box-shadow: 0 0 0 4px rgba(148,163,184,0.2); }
.success-icon-circle.rating-developing { background: #dbeafe; box-shadow: 0 0 0 4px rgba(96,165,250,0.2); }
.success-icon-circle.rating-expert     { background: #d1fae5; box-shadow: 0 0 0 4px rgba(16,185,129,0.2); }
.success-icon-circle.rating-mastery    { background: #fef3c7; box-shadow: 0 0 0 4px rgba(245,158,11,0.2); }
.success-icon-circle.rating-queen      { background: #fce7f3; box-shadow: 0 0 0 4px rgba(236,72,153,0.2); }

.success-challenge-label { font-size: 1rem; font-weight: 600; color: #10b981; margin-bottom: 0.1rem; }
.success-rating-name { font-size: 2rem; font-weight: 800; color: #111827; line-height: 1.15; }
.success-level-name { font-size: 0.875rem; color: #6b7280; margin-top: 0.1rem; }

.success-time-card {
    background: #f0fdf4; border-radius: 0.875rem; padding: 1rem 1.25rem;
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; margin-bottom: 1.25rem; text-align: left;
}
.success-time-label {
    font-size: 0.65rem; font-weight: 700; letter-spacing: 0.1em;
    color: #6b7280; text-transform: uppercase; margin-bottom: 0.25rem;
    text-align: left;
}
.success-time-row { display: flex; align-items: center; gap: 0.625rem; flex-wrap: wrap; }
.success-time-value {
    font-size: 2.5rem; font-weight: 800; color: #3b82f6;
    font-variant-numeric: tabular-nums; line-height: 1;
}
.success-new-best {
    background: white; border: 1.5px solid #e5e7eb; border-radius: 999px;
    padding: 0.2rem 0.75rem; font-size: 0.78rem; font-weight: 600;
    color: #374151; white-space: nowrap;
}
.success-time-right { text-align: right; flex-shrink: 0; }
.success-prev-label { font-size: 0.7rem; color: #9ca3af; margin-bottom: 0.125rem; }
.success-prev-time { font-size: 1rem; font-weight: 600; color: #6b7280; font-variant-numeric: tabular-nums; }

.success-timeline { display: flex; align-items: flex-start; margin-bottom: 1.25rem; }
.success-timeline-item { display: flex; flex-direction: column; align-items: center; flex: 1; }
.success-timeline-connector {
    flex: 1; height: 2px; background: #d1d5db;
    align-self: center; margin-bottom: 1.75rem;
}
.success-timeline-connector.achieved { background: #10b981; }
.success-timeline-node {
    width: 40px; height: 40px; border-radius: 50%;
    background: #e5e7eb; border: 2px solid #d1d5db;
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem; position: relative; z-index: 1;
}
.success-timeline-item.achieved .success-timeline-node {
    background: var(--chalk-surface); border-color: #10b981; border-width: 2.5px;
}
.success-timeline-item.current .success-timeline-node {
    width: 48px; height: 48px; font-size: 1.2rem;
    background: var(--chalk-surface); border-color: #10b981; border-width: 3px;
    box-shadow: 0 0 0 4px rgba(16,185,129,0.2);
}
.success-timeline-label {
    font-size: 0.75rem; font-weight: 500; color: #9ca3af;
    margin-top: 0.375rem; text-align: center; line-height: 1.2;
}
.success-timeline-item.achieved .success-timeline-label,
.success-timeline-item.current .success-timeline-label { color: #6b7280; }
.success-timeline-item.current .success-timeline-label { font-weight: 700; color: #111827; }

.success-rating-hint {
    background: #fffbeb; border: 1px solid #fde68a; border-radius: 0.75rem;
    padding: 0.75rem 1rem; display: flex; align-items: center;
    gap: 0.75rem; margin-bottom: 1.25rem; font-size: 0.875rem; color: #374151; line-height: 1.4;
}
.success-hint-icon { font-size: 1.25rem; flex-shrink: 0; }
.success-hint-time { font-weight: 700; color: #d97706; }
.success-hint-rating { font-weight: 700; color: #b45309; }

.success-actions { display: flex; flex-direction: column; align-items: center; gap: 0.625rem; }
.success-actions .btn-primary { width: 100%; }
.success-back-btn {
    display: flex; align-items: center; gap: 0.375rem;
    color: #6b7280; font-size: 0.8rem; font-weight: 500; cursor: pointer;
    background: none; border: none; padding: 0.25rem 0.5rem; border-radius: var(--radius-btn);
    transition: color 0.15s;
}
.success-back-btn:hover { color: #374151; }

#success-screen { max-width: 700px; }
