/* theme.css — AssessmentHub shared design tokens ("Calm Academic",
   livened up per user tuning — this file should live at
   src/styles/theme.css; all pages link it from there. */

/* Used by the symbol palette's super/subscript buttons (x², x₂, and the
   individual pre-made ⁰¹²³.../₀₁₂₃... buttons). A plain <sup>/<sub> tag's
   default vertical-align:super/sub does NOT work inside a flex container
   (button labels use display:flex; align-items:center to center their
   content) — flexbox ignores vertical-align on its items entirely, which
   is why an earlier attempt at this rendered both identically flat.
   position:relative + top DOES still work on a flex item, so that's used
   here instead. */
.script-sup { font-size: 0.7em; position: relative; top: -0.5em; }
.script-sub { font-size: 0.7em; position: relative; top: 0.4em; }

:root {
    /* Primary accent — muted slate blue, used for buttons, links, focus states */
    --primary: #6c8ebd;
    --primary-dark: #4a6b9c;
    --primary-light: #eff6ff;

    /* Semantic colours — softened, not alarm-toned */
    --success: #659683;
    --success-bg: #EAF4EE;
    --success-border: #86b2a1;

    --warning: #D09345;
    --warning-bg: #FBF3E4;
    --warning-border: #E3B66A;

    --danger: #CC6A58;
    --danger-bg: #FBEEEC;
    --danger-border: #D47F70;

    /* Neutrals */
    --bg: #F4F6FA;
    --card-bg: #FFFFFF;
    --text: #2F3439;
    --subtext: #707780;
    --border: #E0DED8;

    /* Shared shape/shadow tokens */
    --radius: 14px;
    --radius-sm: 8px;
    --card-shadow: 0 6px 20px rgba(30, 30, 30, 0.05);

    /* Mode accents — Test and Practice share the same design system but
       keep a distinct top-of-card colour so students can tell at a glance
       which mode they're in (this existed before as hardcoded teal vs
       amber; now it's two tokens within the same palette family instead
       of two competing colour schemes). */
    --test-accent: #7A9BC8;      /* same as --primary */
    --test-accent-dark: #587BB0;
    --practice-accent: #6FA89C;  /* muted teal-green, distinct from primary blue */
    --practice-accent-dark: #55897E;
    --practice-accent-light: #EAF4F1;
}

/* Selected-answer highlight for MCQ/True-False — CSS-only via :has(),
   supported in all current major browsers. Falls back to no highlight
   (not broken, just less visually clear) on very old browsers. */
.mcq-option:has(input:checked) {
    background: var(--primary-light);
    border-color: var(--primary);
}

/* MathQuill field container (math_input short-answer questions, see
   QuestionCard.js/shared-ui.js's initMathFields) — matches the plain
   input/textarea border+radius+focus convention every page already
   defines for itself, since MathQuill mounts into a <div>, not a real
   <input>, so it inherits none of those per-page rules automatically.
   :focus-within, not :focus — the actual focus target is MathQuill's own
   internal hidden <textarea>, not this outer div. */
.math-field-input {
    padding: 11px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    box-sizing: border-box;
    font-size: 1.15rem;
    min-height: 44px;
    background: var(--card-bg);
    cursor: text;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.math-field-input:focus-within {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 6px rgba(91, 127, 166, 0.2);
}

/* Font size/family preferences — applied by window.UI.applyPreferences()
   (shared-ui.js) via CSS custom properties set on <html>. Any element that
   should respect the student's chosen text size/font must use these
   variables rather than a fixed value. Existing pages weren't written with
   these in mind, so this only takes effect where var(--pref-...) is
   explicitly used going forward — it does not retroactively resize
   everything on every page automatically. */
:root {
    --pref-font-scale: 1;
    --pref-font-family: inherit;
}

/* Dark Mode and High Contrast — applied via body.dark-mode / body.high-contrast,
   toggled by window.UI.applyPreferences(). Defined ONCE here so every page
   that links theme.css (dashboard.html, take-test.html, practice.html,
   settings.html, results.html, etc.) gets identical, consistent styling —
   no per-page duplication, no risk of one page's version drifting from
   another's. Deliberately avoids pure black/white extremes (see
   shared-ui.js comment) — halation/glare risk for many readers.
   High Contrast is defined AFTER Dark Mode so that when both are active
   together, High Contrast's stronger values win. */
body.dark-mode {
    --bg: #16181a;
    --card-bg: #22262b;
    --text: #f5f5f5;
    --subtext: #d5dade;
    --border: #4a5158;
    --primary-light: #2a3644;
    --primary: #8bb8ec;
    --primary-dark: #a8ccf5;
    --success: #a8e6c4;
    --success-bg: #1f5a3e;
    --danger: #ffb3a3;
    --danger-bg: #6b3229;
    --warning: #f7d59f;
    --warning-bg: #5c4726;
} 
body.dark-mode,
body.dark-mode .card,
body.dark-mode .hero,
body.dark-mode .recent-card {
    background: var(--bg);
    color: var(--text);
}

body.high-contrast {
    --bg: #121212;
    --card-bg: #1c1c1c;
    --text: #f5f0e6;
    --subtext: #d8cfc0;
    --border: #f5f0e6;
    --primary-light: #262626;
    /* Real visibility bug: --primary/--primary-dark were never overridden
       here, so anything using them (e.g. dashboard.html's "Your Curriculum"
       ribbon border) fell back to the light-mode value (#4a6b9c), which
       reads as barely-there against this mode's near-black background —
       same bug class as the *-bg tokens fixed above. Brightened to match
       dark mode's own already-correct values. */
    --primary: #8bb8ec;
    --primary-dark: #a8ccf5;
    /* Semantic *-bg tokens were never overridden here — they stayed at
       their light-mode pastel values (e.g. --warning-bg: #FBF3E4), which
       are nearly the same pale tone as --text above (#f5f0e6), making text
       on any of these surfaces (e.g. the Study Priority / Feedback
       collapsible headers on dashboard.html) invisible. Dark mode already
       solved this same problem for its own palette; mirrored here. */
    --success-bg: #1a4a30;
    --success-border: #4ade80;
    --warning-bg: #4a3712;
    --warning-border: #f0b429;
    --danger-bg: #5c1f16;
    --danger-border: #ff6b52;
}
body.high-contrast,
body.high-contrast .card,
body.high-contrast .hero,
body.high-contrast .recent-card {
    background: var(--bg);
    color: var(--text);
    border-color: var(--border);
}
body.high-contrast .card,
body.high-contrast .recent-card,
body.high-contrast .hero {
    border-width: 2px;
    border-style: solid;
}

/* Question header bar and symbol/utility buttons use light-mode-only
   accent tokens (--primary-light, --practice-accent-light, --subtext)
   that were never designed to shift with contrast mode — override them
   directly here so they don't stay stuck light/washed-out against a dark
   page. Covers take-test.html and practice.html's shared question-header
   and toggle-btn classes without touching either page individually. */
body.high-contrast .question-header {
    background-color: #2a2a2a !important;
    color: var(--text) !important;
    border-bottom-color: var(--border) !important;
}
body.high-contrast .toggle-btn,
body.high-contrast .hint-btn {
    background: #2a2a2a !important;
    color: var(--text) !important;
    border: 2px solid var(--border) !important;
}

/* Display Mode pill button on the dashboard hero — needs explicit
   visible styling under both modes since it borrows .streak-pill's base
   look, which alone isn't guaranteed to contrast against a dark hero. */
body.dark-mode .streak-pill[onclick] {
    background: #2f3338 !important;
    color: var(--text) !important;
    border-color: #4a4f55 !important;
}
body.high-contrast .streak-pill[onclick] {
    background: #262626 !important;
    color: var(--text) !important;
    border-color: var(--text) !important;
}