/* ============================================================
   QuizLab — soft UI (neumorphic) design system.

   Depth comes from layered shadows; STATE never does. Every
   interactive surface also carries a border, an icon, or a label,
   because neumorphic shadow separation is ~1.2:1 and cannot be
   relied on to communicate meaning.

   Text contrast is verified in both themes (WCAG AA, 4.5:1+).
   ============================================================ */

:root {
  /* ---- Light: soft neutral ground, raised cards ---- */
  --bg:             #e4e9f2;
  --surface:        #eef2f8;
  --surface-raised: #f2f6fc;
  --surface-sunk:   #e0e5ee;
  --surface-hi:     #d9e0ea;

  --border:         #d2d9e4;
  --border-hi:      #bcc6d6;

  --text:           #16202f;   /* 15.9:1 on surface */
  --text-2:         #354052;   /* 9.4:1  */
  --text-muted:     #5a6478;   /*  5.6:1 */
  --text-on-hi:     #596377;   /*  4.6:1 on --surface-hi, for .pill-mute */
  --text-dim:       #5c667a;   /*  4.6:1 on --surface-sunk, the darkest
                                    surface it sits on. The old #626c80 was
                                    4.8:1 against --surface but only 4.18:1 on
                                    --surface-sunk and 4.34:1 on --bg, so muted
                                    text and input placeholders failed AA in the
                                    light theme. */

  --accent:         #235ccc;   /*  4.6:1 on --surface-hi, 5.0:1 on --bg.
                                    #2c65cf cleared AA on --surface only; links
                                    on the page background sat at 4.45:1. */
  --accent-2:       #7c4ddb;
  --accent-on:      #ffffff;
  --accent-soft:    rgba(35, 92, 204, 0.10);   /* tracks --accent #235ccc */

  --correct:        #14742f;   /*  5.2:1 on --surface (was #15803d, 4.46:1) */
  --correct-bg:     rgba(21, 128, 61, 0.10);
  --wrong:          #be123c;
  --wrong-bg:       rgba(190, 18, 60, 0.10);
  --gold:           #96590a;   /*  5.0:1 on --surface (was #a16207, 4.38:1) */
  --gold-bg:        rgba(161, 98, 7, 0.12);

  /* Neumorphic light source: top-left */
  --sh-dark:        rgba(163, 177, 198, 0.55);
  --sh-light:       rgba(255, 255, 255, 0.92);

  --shadow-raised:  -5px -5px 12px var(--sh-light), 5px 5px 14px var(--sh-dark);
  --shadow-soft:    -3px -3px 7px var(--sh-light), 3px 3px 8px var(--sh-dark);
  --shadow-sunk:    inset -3px -3px 7px var(--sh-light), inset 3px 3px 8px var(--sh-dark);
  --shadow-press:   inset -2px -2px 5px var(--sh-light), inset 3px 3px 7px var(--sh-dark);

  --radius:         14px;
  --radius-sm:      10px;
  --radius-lg:      22px;
  --radius-pill:    999px;

  --press:          150ms;
  --ease:           cubic-bezier(0.2, 0, 0.2, 1);

  --sidebar-w:      236px;

  color-scheme: light;
}

/* ---- Dark: same shapes, real contrast ---- */
:root[data-theme="dark"] {
  --bg:             #1c1f26;
  --surface:        #23272f;
  --surface-raised: #272b33;
  --surface-sunk:   #1e2128;
  --surface-hi:     #2f343e;

  --border:         #343a45;
  --border-hi:      #454c5a;

  --text:           #f2f5fa;   /* 13.0:1 on surface-raised */
  --text-2:         #dde3ec;   /* 11.0:1 */
  --text-muted:     #a8b2c1;   /*  6.6:1 */
  --text-dim:       #8b95a5;   /*  4.7:1 */
  --text-on-hi:     #96a0b0;   /*  4.7:1 on --surface-hi (#2f343e) */

  --accent:         #7aa7f0;   /*  5.8:1 */
  --accent-2:       #b39af5;
  --accent-on:      #10141b;
  --accent-soft:    rgba(122, 167, 240, 0.14);

  --correct:        #4ade80;
  --correct-bg:     rgba(74, 222, 128, 0.13);
  --wrong:          #fb7185;
  --wrong-bg:       rgba(251, 113, 133, 0.13);
  --gold:           #fbbf24;
  --gold-bg:        rgba(251, 191, 36, 0.14);

  --sh-dark:        rgba(0, 0, 0, 0.55);
  --sh-light:       rgba(255, 255, 255, 0.045);

  color-scheme: dark;
}

/* Honour the OS when the user has not chosen. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:             #1c1f26;
    --surface:        #23272f;
    --surface-raised: #272b33;
    --surface-sunk:   #1e2128;
    --surface-hi:     #2f343e;
    --border:         #343a45;
    --border-hi:      #454c5a;
    --text:           #f2f5fa;
    --text-2:         #dde3ec;
    --text-muted:     #a8b2c1;
    --text-dim:       #8b95a5;
    --text-on-hi:     #96a0b0;
    --accent:         #7aa7f0;
    --accent-2:       #b39af5;
    --accent-on:      #10141b;
    --accent-soft:    rgba(122, 167, 240, 0.14);
    --correct:        #4ade80;
    --correct-bg:     rgba(74, 222, 128, 0.13);
    --wrong:          #fb7185;
    --wrong-bg:       rgba(251, 113, 133, 0.13);
    --gold:           #fbbf24;
    --gold-bg:        rgba(251, 191, 36, 0.14);
    --sh-dark:        rgba(0, 0, 0, 0.55);
    --sh-light:       rgba(255, 255, 255, 0.045);
    color-scheme: dark;
  }
}

/* ============================================================
   Legacy token bridge (v1/v2 -> v3)

   style.css and dashboard.css referenced --magenta/--violet/--surface-2/
   --bg-deep, which were declared ONCE under a plain :root in style.css with
   no light-theme override. In light mode they resolved to near-black
   (#17171a, #060607) and painted dark surfaces onto a light page — this was
   the original "CSS not loading" report.

   Aliasing them onto the live token set means any rule we have not yet
   ported still lands in-theme instead of out of it. These are a safety net,
   not an API: new code uses the v3 tokens directly.
   ============================================================ */

:root {
  --violet:      var(--accent-2);
  --violet-hi:   var(--accent-2);
  --magenta:     var(--accent);
  --magenta-hi:  var(--accent);
  --surface-2:   var(--surface-hi);
  --bg-deep:     var(--bg);
  --r-sm:        var(--radius-sm);
  --ease-out:    var(--ease);
  --ease-bounce: var(--ease);
}

/* ============================================================
   Base
   ============================================================ */

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; min-height: 100%; }

body {
  background: var(--bg);
  color: var(--text-2);
  font-family: "Outfit", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 15.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background 200ms var(--ease), color 200ms var(--ease);
}

h1, h2, h3, h4 {
  margin: 0;
  color: var(--text);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

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

button { font-family: inherit; }

/* Every clickable thing says so. */
a, button, .nav-link, .tag, .demo-btn, .option, .mode-card,
.quiz-card, [role="button"] { cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ============================================================
   Soft surfaces
   ============================================================ */

.card {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 20px 22px;
}
.card-tight { padding: 14px 16px; }

.soft-raised { box-shadow: var(--shadow-raised); }
.soft-sunk   { box-shadow: var(--shadow-sunk); }

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;                 /* touch target */
  padding: 11px 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface-raised);
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 600;
  box-shadow: var(--shadow-soft);
  transition: transform var(--press) var(--ease),
              box-shadow var(--press) var(--ease),
              background var(--press) var(--ease);
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { box-shadow: var(--shadow-press); transform: translateY(0); }

.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-on);
}
.btn-primary:hover { filter: brightness(1.06); }

.btn-ghost {
  background: transparent;
  box-shadow: none;
  color: var(--text-muted);
}
.btn-ghost:hover { background: var(--surface); color: var(--text); }

/* ============================================================
   Quiz options — the A/B/C/D pills from the reference
   ============================================================ */

.options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 22px;
}

.option {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 62px;
  padding: 14px 20px;
  text-align: left;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text);
  font-size: 0.97rem;
  font-weight: 600;
  box-shadow: var(--shadow-raised);
  transition: transform var(--press) var(--ease),
              box-shadow var(--press) var(--ease),
              border-color var(--press) var(--ease);
}
.option:hover:not(:disabled) { transform: translateY(-2px); }
.option:active:not(:disabled) { box-shadow: var(--shadow-press); transform: translateY(0); }
.option:disabled { cursor: default; }

.option-key {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: var(--radius-pill);
  background: var(--surface-sunk);
  box-shadow: var(--shadow-press);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 800;
}

/* State carries a border + colour + (in markup) an icon — never shadow alone. */
.option.selected  { border-color: var(--accent);  box-shadow: var(--shadow-press); }
.option.is-correct {
  border-color: var(--correct);
  background: var(--correct-bg);
  color: var(--correct);
  box-shadow: var(--shadow-soft);
}
.option.is-correct .option-key { background: var(--correct); color: #fff; box-shadow: none; }
.option.is-wrong {
  border-color: var(--wrong);
  background: var(--wrong-bg);
  color: var(--wrong);
  box-shadow: var(--shadow-press);
}
.option.is-wrong .option-key { background: var(--wrong); color: #fff; box-shadow: none; }

@media (max-width: 640px) {
  .options { grid-template-columns: minmax(0, 1fr); }
}

/* ============================================================
   Inputs
   ============================================================ */

.input, .select, .textarea {
  width: 100%;
  min-height: 44px;
  padding: 11px 15px;
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-press);
  color: var(--text);
  font-family: inherit;
  font-size: 0.93rem;
}
.input::placeholder, .textarea::placeholder { color: var(--text-dim); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: var(--shadow-press), 0 0 0 3px var(--accent-soft);
}

.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 15px; }
.field label { font-size: 0.83rem; font-weight: 600; color: var(--text-muted); }
.hint { font-size: 0.78rem; color: var(--text-dim); margin: 0; }

/* ============================================================
   Chips / pills — compact labels stay on one line
   ============================================================ */

.tag, .pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 13px;
  border-radius: var(--radius-pill);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  color: var(--text-muted);
  font-size: 0.79rem;
  font-weight: 600;
  white-space: nowrap;
  min-width: 0;
}
.tag.active { background: var(--accent); border-color: transparent; color: var(--accent-on); }
.pill-good { background: var(--correct-bg); border-color: transparent; color: var(--correct); }
.pill-mid  { background: var(--gold-bg);    border-color: transparent; color: var(--gold); }
.pill-low  { background: var(--wrong-bg);   border-color: transparent; color: var(--wrong); }
.pill-info { background: var(--accent-soft);border-color: transparent; color: var(--accent); }
.pill-mute { background: var(--surface-hi); color: var(--text-on-hi); box-shadow: none; }

/* ============================================================
   Utility
   ============================================================ */

.muted { color: var(--text-muted); }
.dim   { color: var(--text-dim); }
.text-c { text-align: center; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 22px; }
.mt-0 { margin-top: 0; }

.media { display: flex; align-items: center; gap: 12px; }
.media-body { flex: 1; min-width: 0; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.stack { display: flex; flex-direction: column; gap: 14px; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.hidden { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .btn:hover, .option:hover, .mode-card:hover { transform: none; }
}
