/* ==========================================================================
   TheoLearn — design tokens
   Deliberately the same palette and type as theoungureanu.com so the two
   sites read as siblings. Dark only, as the portfolio is: there is no light
   theme to maintain and no toggle to get wrong.
   ========================================================================== */

:root {
    --color-bg: #09090b;
    --color-bg-gradient: linear-gradient(135deg, #09090b 0%, #0f0f12 50%, #09090b 100%);
    --color-surface: #111114;
    --color-surface-elevated: #18181b;
    --color-surface-hover: #1f1f23;

    --color-border: rgba(255, 255, 255, .06);
    --color-border-strong: rgba(255, 255, 255, .12);

    --color-text: #fafafa;
    --color-text-secondary: rgba(255, 255, 255, .65);
    --color-text-muted: rgba(255, 255, 255, .4);

    --color-accent: #00d4aa;
    --color-accent-hover: #00e8bc;
    --color-accent-muted: #00b894;
    --color-accent-subtle: rgba(0, 212, 170, .08);
    --color-accent-glow: rgba(0, 212, 170, .25);

    --color-purple: #a855f7;
    --color-blue: #3b82f6;
    --color-orange: #f97316;
    --color-red: #ef4444;
    --color-green: #22c55e;

    --font-display: 'Outfit', system-ui, sans-serif;
    --font-body: 'Space Grotesk', system-ui, sans-serif;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --transition-fast: 150ms cubic-bezier(.4, 0, .2, 1);
    --transition-base: 300ms cubic-bezier(.4, 0, .2, 1);

    --shadow-md: 0 4px 16px rgba(0, 0, 0, .3);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .4);
    --shadow-glow: 0 0 24px var(--color-accent-glow);

    --sidebar-width: 240px;
    --content-max-width: 1100px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    background: var(--color-bg);
    background-image: var(--color-bg-gradient);
    background-attachment: fixed;
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); }
h2 { font-size: clamp(1.35rem, 3vw, 1.75rem); }
h3 { font-size: 1.15rem; }
p  { margin: 0 0 1rem; }

a { color: var(--color-accent); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--color-accent-hover); }

/* -------------------------------------------------------------------------- boot */

.boot { display: grid; place-items: center; min-height: 100vh; }

.boot-spinner,
.spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--color-border-strong);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 700ms linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
    .boot-spinner, .spinner { animation-duration: 2s; }
    * { transition-duration: .01ms !important; }
}

/* -------------------------------------------------------------------------- shell */

.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: .35rem;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 1.5rem;
    display: block;
}

.brand span { color: var(--color-accent); }

.nav-link {
    display: block;
    padding: .6rem .85rem;
    border-radius: var(--radius-sm);
    color: var(--color-text-secondary);
    font-size: .95rem;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.nav-link:hover { background: var(--color-surface-hover); color: var(--color-text); }

.nav-link.active {
    background: var(--color-accent-subtle);
    color: var(--color-accent);
    font-weight: 500;
}

.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: .35rem; }

.main { flex: 1; min-width: 0; padding: 2rem clamp(1rem, 4vw, 3rem) 4rem; }
.container { max-width: var(--content-max-width); margin: 0 auto; }

@media (max-width: 820px) {
    .shell { flex-direction: column; }
    .sidebar {
        width: 100%; height: auto; position: static;
        flex-direction: row; flex-wrap: wrap; align-items: center;
        gap: .5rem; padding: .85rem 1rem;
    }
    .brand { margin: 0 auto 0 0; }
    .sidebar-footer { margin: 0; flex-direction: row; }
    .nav-link { padding: .45rem .7rem; font-size: .875rem; }
    .main { padding: 1.25rem 1rem 3rem; }
}

/* -------------------------------------------------------------------------- cards */

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: border-color var(--transition-base), transform var(--transition-base);
}

.card + .card { margin-top: 1rem; }
.card-interactive:hover { border-color: var(--color-border-strong); transform: translateY(-2px); }

.card-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem;
}

.card-title { font-family: var(--font-display); font-weight: 600; font-size: 1.1rem; margin: 0; }
.card-meta { color: var(--color-text-muted); font-size: .85rem; }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

/* -------------------------------------------------------------------------- stats */

.stat {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1.15rem 1.25rem;
}

.stat-value { font-family: var(--font-display); font-size: 2rem; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--color-text-muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; }

/* -------------------------------------------------------------------------- buttons */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    padding: .65rem 1.25rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-family: var(--font-body); font-size: .95rem; font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--color-accent); color: #04120f; }
.btn-primary:hover:not(:disabled) { background: var(--color-accent-hover); box-shadow: var(--shadow-glow); color: #04120f; }

.btn-outline { background: transparent; border-color: var(--color-border-strong); color: var(--color-text); }
.btn-outline:hover:not(:disabled) { background: var(--color-surface-hover); color: var(--color-text); }

.btn-ghost { background: transparent; color: var(--color-text-secondary); padding: .5rem .75rem; }
.btn-ghost:hover:not(:disabled) { color: var(--color-text); background: var(--color-surface-hover); }

.btn-danger { background: transparent; border-color: var(--color-red); color: var(--color-red); }
.btn-sm { padding: .4rem .8rem; font-size: .85rem; }
.btn-row { display: flex; gap: .65rem; flex-wrap: wrap; align-items: center; }

/* -------------------------------------------------------------------------- forms */

.form-group { margin-bottom: 1rem; }

.form-label {
    display: block; margin-bottom: .35rem;
    font-size: .85rem; font-weight: 500; color: var(--color-text-secondary);
}

.form-input, .form-textarea, .form-select {
    width: 100%;
    padding: .65rem .85rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: .95rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-accent-subtle);
}

.form-textarea { resize: vertical; min-height: 100px; font-family: ui-monospace, 'Cascadia Code', monospace; font-size: .85rem; }
.form-checkbox { display: flex; align-items: center; gap: .5rem; cursor: pointer; }
.form-checkbox input { width: 18px; height: 18px; accent-color: var(--color-accent); cursor: pointer; }
.form-row { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

/* -------------------------------------------------------------------------- test runner */

.test-shell { max-width: 760px; margin: 0 auto; }

.test-header {
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem;
}

.progress-track { height: 6px; background: var(--color-surface-elevated); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--color-accent); transition: width var(--transition-base); }

.question-stem { font-family: var(--font-display); font-size: 1.2rem; font-weight: 500; margin-bottom: 1.25rem; }

.option {
    display: flex; align-items: flex-start; gap: .75rem;
    padding: .9rem 1rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-bottom: .6rem;
}

.option:hover { border-color: var(--color-accent-muted); background: var(--color-surface-hover); }
.option.selected { border-color: var(--color-accent); background: var(--color-accent-subtle); }
.option input { margin-top: .25rem; accent-color: var(--color-accent); width: 18px; height: 18px; cursor: pointer; }
.option-text { flex: 1; }

/* Dots let a student see at a glance what they have skipped. */
.question-dots { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: 1.5rem; }

.dot {
    width: 30px; height: 30px;
    border-radius: 50%;
    border: 1px solid var(--color-border-strong);
    background: transparent;
    color: var(--color-text-muted);
    font-size: .8rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.dot:hover { border-color: var(--color-accent-muted); color: var(--color-text); }
.dot.answered { border-color: var(--color-accent-muted); color: var(--color-accent); }
.dot.current { background: var(--color-accent); border-color: var(--color-accent); color: #04120f; font-weight: 600; }

/* -------------------------------------------------------------------------- results */

.score-hero { text-align: center; padding: 2rem 1rem; }
.score-value { font-family: var(--font-display); font-size: clamp(3rem, 12vw, 4.5rem); font-weight: 700; line-height: 1; }
.score-band { text-transform: uppercase; letter-spacing: .1em; font-size: .8rem; color: var(--color-text-muted); }

.band-excellent { color: var(--color-accent); }
.band-good { color: var(--color-green); }
.band-fair { color: var(--color-blue); }
.band-weak { color: var(--color-orange); }
.band-poor { color: var(--color-red); }

.answer-block { border-left: 3px solid var(--color-border-strong); padding-left: 1rem; margin: .75rem 0; }
.answer-block.correct { border-left-color: var(--color-green); }
.answer-block.incorrect { border-left-color: var(--color-red); }
.answer-block.pending { border-left-color: var(--color-orange); }
.answer-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--color-text-muted); }

/* -------------------------------------------------------------------------- mastery bars */

.mastery-row { display: grid; grid-template-columns: 1fr 120px 60px; gap: .75rem; align-items: center; padding: .6rem 0; border-bottom: 1px solid var(--color-border); }
.mastery-row:last-child { border-bottom: none; }
.mastery-track { height: 8px; background: var(--color-surface-elevated); border-radius: 999px; overflow: hidden; }
.mastery-fill { height: 100%; border-radius: 999px; transition: width var(--transition-base); }
.mastery-value { text-align: right; font-size: .85rem; color: var(--color-text-secondary); font-variant-numeric: tabular-nums; }

@media (max-width: 520px) {
    .mastery-row { grid-template-columns: 1fr 80px 48px; font-size: .875rem; }
}

/* -------------------------------------------------------------------------- misc */

.badge {
    display: inline-block;
    padding: .2rem .6rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 500;
    border: 1px solid var(--color-border-strong);
    color: var(--color-text-secondary);
}

.badge-accent { border-color: var(--color-accent-muted); color: var(--color-accent); background: var(--color-accent-subtle); }
.badge-warn { border-color: var(--color-orange); color: var(--color-orange); }
.badge-danger { border-color: var(--color-red); color: var(--color-red); }

.alert { padding: .85rem 1rem; border-radius: var(--radius-sm); border: 1px solid; margin-bottom: 1rem; font-size: .9rem; }
.alert-error { border-color: var(--color-red); background: rgba(239, 68, 68, .08); color: #fca5a5; }
.alert-info { border-color: var(--color-accent-muted); background: var(--color-accent-subtle); color: var(--color-accent); }
.alert-warn { border-color: var(--color-orange); background: rgba(249, 115, 22, .08); color: #fdba74; }

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--color-text-muted); }
.muted { color: var(--color-text-muted); }
.secondary { color: var(--color-text-secondary); }
.center { text-align: center; }
.mono { font-family: ui-monospace, 'Cascadia Code', monospace; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

.loading-block { display: flex; align-items: center; justify-content: center; gap: .75rem; padding: 3rem 1rem; color: var(--color-text-muted); }

.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--color-border-strong); color: var(--color-text-muted); font-weight: 500; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
.table td { padding: .7rem .5rem; border-bottom: 1px solid var(--color-border); }
.table-wrap { overflow-x: auto; }

/* -------------------------------------------------------------------------- Romanian mark */

/* The 1-10 nota sits beside the percentage. A percentage means little to a Romanian parent;
   the nota is what they actually read, so it is styled to be findable without competing with
   the headline figure. */

.grade-chip {
    display: inline-block;
    margin-left: .5rem;
    padding: .1rem .5rem;
    border-radius: 999px;
    font-family: var(--font-body);
    font-size: .78em;
    font-weight: 600;
    vertical-align: middle;
    border: 1px solid;
    letter-spacing: .01em;
}

.grade-pass {
    color: var(--color-accent);
    border-color: var(--color-accent-muted);
    background: var(--color-accent-subtle);
}

/* Below 5 is a fail, and should be unmistakable at a glance. */
.grade-fail {
    color: #fca5a5;
    border-color: var(--color-red);
    background: rgba(239, 68, 68, .08);
}

/* -------------------------------------------------------------------------- maths */

/* KaTeX inherits colour, so it picks up the dark theme without overrides. These rules only
   stop it fighting the surrounding layout. */

.math-text { display: inline; }

.katex {
    font-size: 1.05em;      /* KaTeX runs slightly small against Space Grotesk */
    line-height: 1.4;
}

/* A wide displayed equation must scroll inside its own box rather than widening the page. */
.katex-display {
    margin: .75em 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: .25em;
}

/* Malformed TeX renders as red source text rather than blanking the question — see math.js. */
.katex-error {
    color: var(--color-red) !important;
    font-family: ui-monospace, 'Cascadia Code', monospace;
    font-size: .9em;
}

/* Options are clickable rows; stray text selection inside the maths makes them feel broken. */
.option .katex { user-select: none; }

/* -------------------------------------------------------------------------- blazor error */

#blazor-error-ui {
    display: none;
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;
    background: #7f1d1d; color: #fff;
    padding: .75rem 1.25rem;
    box-shadow: var(--shadow-lg);
}

#blazor-error-ui .reload { color: #fff; text-decoration: underline; margin-left: .75rem; }
