/* ============================================================================
   RheumWave — DESIGN TOKENS + BASE
   ----------------------------------------------------------------------------
   Every page loads this first. It holds the colour palette, the light/dark
   switch, and the handful of base rules that apply site-wide.

   This block used to be copy-pasted into index.html, cases.html, quizzes.html
   and rheumwave-case.css. Four copies meant four places to edit and four
   chances to miss one. Change a colour here and the whole site moves.

   Load order on every page:
       rheumwave-theme.css      (this file)
       rheumwave-chrome.css     (header + footer — not on quizzes.html)
       page-specific styles
   ========================================================================== */

:root {
  --navy:          #1E3A5F;
  --navy-mid:      #2A4F7A;
  --teal:          #3B6EA5;
  --teal-light:    #E8EEF5;
  --bg:            #F5F2ED;
  --surface:       #FDFCFA;
  --surface-2:     #EEE9E2;
  --ink:           #1C1917;
  --ink-2:         #57534E;
  --ink-3:         #A8A29E;
  --border:        rgba(28,25,23,0.1);
  --border-strong: rgba(28,25,23,0.18);
  --shadow:        0 4px 18px rgba(30,58,95,0.10);
  --shadow-lg:     0 10px 36px rgba(30,58,95,0.16);
  --success:       #1A4731;
  --success-light: #E6F2EC;
  --radius:        10px;

  /* Sticky header height. Used by the scroll-margin rule below so in-page
     anchors don't land underneath the header. Kept in sync with the padding
     in rheumwave-chrome.css — if you change one, change the other. */
  --header-h:      74px;

  /* The one blue that is lighter than the header, used for hero bands. */
  --hero-mid:      #35619B;
}

[data-theme="dark"] {
  --bg:            #0f172a;
  --surface:       #1e293b;
  --surface-2:     #162035;
  --ink:           #f1f5f9;
  --ink-2:         #94a3b8;
  --ink-3:         #475569;
  --border:        rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.14);
  --shadow:        0 4px 18px rgba(0,0,0,0.30);
  --shadow-lg:     0 10px 36px rgba(0,0,0,0.45);
  --teal-light:    #1a2e45;
  --success-light: #0a2218;
}

/* A readable blue on dark backgrounds. Headings that use --navy in light mode
   are unreadable on a dark background, so they switch to this instead. */
[data-theme="dark"] { --heading: #7bb3d4; }
:root { --heading: var(--navy); }

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

body {
  margin: 0;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  transition: background .3s, color .3s;
}

a { color: inherit; }

/* The header is sticky, so anything jumped to via a #link would land
   behind it. This stops the scroll just below the header instead. */
[id] { scroll-margin-top: calc(var(--header-h) + 22px); }

/* Glide to anchors rather than snapping — but only for people who
   haven't asked their system to reduce motion. */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; border-radius: 4px; }
[data-theme="dark"] :focus-visible { outline-color: #7bb3d4; }

/* ── SHARED TYPE ──────────────────────────────────────────────────────────
   The two roles the site uses everywhere: a serif for anything that names
   something, and Inter for everything else. */
.rw-serif { font-family: 'Source Serif 4', serif; letter-spacing: -0.01em; }

/* ── PAGE TITLE (quizzes, resources, disclaimer, any plain page) ────────── */
.page-title {
  font-family: 'Source Serif 4', serif;
  font-size: clamp(1.8rem, 3.4vw, 2.2rem);
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--heading);
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.page-intro {
  color: var(--ink-2);
  font-size: .95rem;
  margin: 0 0 26px;
  max-width: 64ch;
  line-height: 1.65;
}
.page-label {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--teal);
  margin: 0 0 12px;
}
[data-theme="dark"] .page-label { color: #7bb3d4; }

/* ── SHARED CARD ──────────────────────────────────────────────────────────
   The case library, the quiz list and the homepage all show the same kind of
   card, so the card lives here rather than in three stylesheets. */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform .15s, box-shadow .15s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

/* Not built yet: visible as a roadmap, but nothing to click, so nobody
   lands on a page that isn't there. */
.card.locked { opacity: .55; box-shadow: none; border-style: dashed; }
.card.locked:hover { transform: none; box-shadow: none; }

.card-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 5px; gap: 8px; }
.card h3 {
  margin: 0;
  font-family: 'Source Serif 4', serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--heading);
  letter-spacing: -0.01em;
}
.card .meta { font-size: .8rem; color: var(--ink-3); margin-bottom: 12px; }
.card .attempts-line { font-size: .78rem; color: var(--ink-3); margin-top: 2px; }
.card .actions { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 7px; }

.attempts-history { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.attempt-pill {
  font-size: .72rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--surface-2);
  color: var(--ink-3);
  border: 1px solid var(--border);
}

/* ── SCORE BADGE ────────────────────────────────────────────────────────── */
.score-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .72rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
  background: var(--surface-2);
  color: var(--ink-3);
}
.score-badge.low  { background: #fef3c7; color: #92400e; }
.score-badge.mid  { background: #dbeafe; color: #1e40af; }
.score-badge.high { background: var(--success-light); color: var(--success); }
[data-theme="dark"] .score-badge      { background: #1e293b; color: #64748b; }
[data-theme="dark"] .score-badge.low  { background: #2d1f06; color: #fbbf24; }
[data-theme="dark"] .score-badge.mid  { background: #1a2d47; color: #7bb3d4; }
[data-theme="dark"] .score-badge.high { background: #0d2b1d; color: #4ade80; }

/* ── BUTTONS ────────────────────────────────────────────────────────────── */
.btn {
  background: var(--navy);
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 7px;
  font-size: .85rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: opacity .2s, transform .15s;
}
.btn:hover { opacity: .88; transform: translateY(-1px); }
.btn.secondary { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--border-strong); }
[data-theme="dark"] .btn { background: var(--teal); }
[data-theme="dark"] .btn.secondary { background: var(--surface-2); color: var(--ink); }

/* ── SESSION BANNER (cases + quizzes) ───────────────────────────────────── */
#sessionBanner {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: var(--success-light);
  border: 1px solid rgba(26,71,49,0.18);
  border-radius: 9px;
  padding: 10px 16px;
  margin-bottom: 22px;
  font-size: .85rem;
}
#sessionBanner.visible { display: flex; }
#sessionBanner .left { display: flex; align-items: center; gap: 8px; color: var(--success); font-weight: 500; }
[data-theme="dark"] #sessionBanner { border-color: rgba(74,222,128,0.22); }
[data-theme="dark"] #sessionBanner .left { color: #4ade80; }
#sessionBanner button {
  background: none; border: none; font-size: .78rem; color: var(--ink-3);
  cursor: pointer; text-decoration: underline; font-family: inherit; white-space: nowrap;
}
#sessionBanner button:hover { color: var(--ink-2); }

/* ── SYNC TOAST ─────────────────────────────────────────────────────────── */
#syncStatus {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); font-size: .8rem;
  padding: 7px 18px; border-radius: 20px; box-shadow: 0 4px 16px rgba(0,0,0,.2);
  opacity: 0; transition: opacity .3s; pointer-events: none; z-index: 300; white-space: nowrap;
}
#syncStatus.show { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .btn:hover, .card:hover { transform: none; }
}
