/* themes.css — the speller's color themes (SPEC §5.3 S7), loaded LAST on every student page (/student/*). Each block
   redefines the color tokens of app.css :root for <html data-theme="…"> (ids: public/js/shared/themes.js; set before
   the first paint by js/lib/theme-boot.js, then synced from /api/me by js/lib/theme.js). Parent and coordinator
   pages don't load this file: they keep app.css's brand colors. The flash canvases read --flash-* (lib/flash.js).
   tests/unit/themes.test.mjs checks that every block defines the same tokens as app.css :root, that the "auto" dark
   copy equals "dark", and the WCAG AA contrast of the text/background pairs (body text ≥ 4.5:1, borders ≥ 3:1,
   flashed words ≥ 7:1). Change a color here, then run the unit tests and `npm.cmd run screens:themes`. */

/* ---------- Light (also "Match my device" on a light device): warm paper, dark green ink, no pure white ---------- */
[data-theme="light"], [data-theme="auto"] {
  --forest: #1f4a3a; --forest-2: #2b6450; --pine: #173a2d; --ink: #1d2a24; --muted: #56645d;
  --cream: #f8f3e8; --cream-2: #efe7d6; --sage: #e8f0e9; --mint: #ddece2;
  --sun: #f4b740; --sun-deep: #c98f17; --sun-soft: #fbebc4;
  --berry: #d4573b; --berry-ink: #ad3c23;
  --card: #fffcf5; --line: #e2d9c5; --line-strong: #75867c;
  --on-forest: #fffcf5; --forest-deep: #173a2d; --on-sun: #173a2d; --btn-edge: transparent;
  --sage-line: #cfdfd3; --mint-line: #bed8c6; --sun-line: #eccf8a; --sun-ink: #664705; --berry-soft: #f9e0d8; --berry-line: #ebbbab;
  --ring: rgba(31, 74, 58, .25); --hover: rgba(255, 252, 245, .75);
  --scrim: rgba(23, 58, 45, .55);
  --flash-bg: #f8f3e8; --flash-ink: #173a2d; --flash-card-bg: #fffcf5; --flash-card-ink: #173a2d;
  --tile-shadow: 0 3px 0 rgba(23, 58, 45, .16);
  color-scheme: light;
}

/* ---------- Dark: deep green-gray (not black), off-white text (not white), muted accents ---------- */
[data-theme="dark"] {
  --forest: #8fcdb0; --forest-2: #7ebd9e; --pine: #cfe4d8; --ink: #dde6e1; --muted: #a5b3ac;
  --cream: #1a2421; --cream-2: #151e1b; --sage: #22342d; --mint: #1f3b30;
  --sun: #e0b35c; --sun-deep: #9c7a35; --sun-soft: #3a3120;
  --berry: #de7c64; --berry-ink: #f0a693;
  --card: #222d2a; --line: #35443f; --line-strong: #7f938b;
  --on-forest: #10201a; --forest-deep: #5a917a; --on-sun: #1f1a0e; --btn-edge: transparent;
  --sage-line: #3a5046; --mint-line: #426a57; --sun-line: #5f502d; --sun-ink: #efd393; --berry-soft: #3c2622; --berry-line: #6c3c32;
  --ring: rgba(143, 205, 176, .35); --hover: rgba(255, 255, 255, .06);
  --scrim: rgba(0, 0, 0, .62);
  --flash-bg: #1a2421; --flash-ink: #eef4f0; --flash-card-bg: #222d2a; --flash-card-ink: #eef4f0;
  --tile-shadow: 0 3px 0 rgba(0, 0, 0, .35);
  color-scheme: dark;
}

/* "Match my device" on a dark device: an exact copy of the Dark block (the unit test keeps them equal). */
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    --forest: #8fcdb0; --forest-2: #7ebd9e; --pine: #cfe4d8; --ink: #dde6e1; --muted: #a5b3ac;
    --cream: #1a2421; --cream-2: #151e1b; --sage: #22342d; --mint: #1f3b30;
    --sun: #e0b35c; --sun-deep: #9c7a35; --sun-soft: #3a3120;
    --berry: #de7c64; --berry-ink: #f0a693;
    --card: #222d2a; --line: #35443f; --line-strong: #7f938b;
    --on-forest: #10201a; --forest-deep: #5a917a; --on-sun: #1f1a0e; --btn-edge: transparent;
    --sage-line: #3a5046; --mint-line: #426a57; --sun-line: #5f502d; --sun-ink: #efd393; --berry-soft: #3c2622; --berry-line: #6c3c32;
    --ring: rgba(143, 205, 176, .35); --hover: rgba(255, 255, 255, .06);
    --scrim: rgba(0, 0, 0, .62);
    --flash-bg: #1a2421; --flash-ink: #eef4f0; --flash-card-bg: #222d2a; --flash-card-ink: #eef4f0;
    --tile-shadow: 0 3px 0 rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

/* ---------- Sepia: soft tan reading paper, brown ink, olive greens (long study sessions) ---------- */
[data-theme="sepia"] {
  --forest: #3f5530; --forest-2: #4f6136; --pine: #33402a; --ink: #3a2e20; --muted: #65553f;
  --cream: #f1e7d0; --cream-2: #e8dcc0; --sage: #e9e3c9; --mint: #e2e4c6;
  --sun: #e3ac4c; --sun-deep: #ad7f2a; --sun-soft: #f3dfae;
  --berry: #b85c3c; --berry-ink: #93391d;
  --card: #f8f0dd; --line: #dccdab; --line-strong: #8a7a5c;
  --on-forest: #f8f0dd; --forest-deep: #2a3a1f; --on-sun: #2e2414; --btn-edge: transparent;
  --sage-line: #d3cba8; --mint-line: #c9cc9f; --sun-line: #dcc185; --sun-ink: #573d09; --berry-soft: #f2d7c5; --berry-line: #dfb49c;
  --ring: rgba(63, 85, 48, .25); --hover: rgba(255, 250, 238, .6);
  --scrim: rgba(52, 38, 20, .5);
  --flash-bg: #f1e7d0; --flash-ink: #2a2116; --flash-card-bg: #f8f0dd; --flash-card-ink: #2a2116;
  --tile-shadow: 0 3px 0 rgba(74, 56, 30, .18);
  color-scheme: light;
}

/* ---------- High contrast (low vision): black on white, dark borders, outlined buttons, ≥ 7:1 text ---------- */
[data-theme="contrast"] {
  --forest: #00552f; --forest-2: #0a5c38; --pine: #00331f; --ink: #000000; --muted: #333333;
  --cream: #ffffff; --cream-2: #f0f0f0; --sage: #eef5f0; --mint: #dcefe2;
  --sun: #ffc533; --sun-deep: #000000; --sun-soft: #fff1c7;
  --berry: #b3261e; --berry-ink: #8f1d12;
  --card: #ffffff; --line: #595959; --line-strong: #000000;
  --on-forest: #ffffff; --forest-deep: #000000; --on-sun: #000000; --btn-edge: #000000;
  --sage-line: #1c4a33; --mint-line: #0b5d33; --sun-line: #7a5300; --sun-ink: #4d3500; --berry-soft: #fde3dc; --berry-line: #9b2a12;
  --ring: rgba(0, 85, 47, .35); --hover: #f0f0f0;
  --scrim: rgba(0, 0, 0, .72);
  --flash-bg: #ffffff; --flash-ink: #000000; --flash-card-bg: #ffffff; --flash-card-ink: #000000;
  --tile-shadow: 0 3px 0 #000000;
  color-scheme: light;
}

/* ---------- Settings → Theme (pages/student-settings.js): big radio cards, each with a small preview ---------- */
.theme-choices { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.theme-card { display: flex; align-items: center; gap: 12px; min-height: 68px; padding: 10px 14px; border: 2px solid var(--line-strong);
  border-radius: var(--r); background: var(--card); cursor: pointer; }
.theme-card:hover { border-color: var(--forest); }
.theme-card:has(input:checked) { border-color: var(--forest); box-shadow: inset 0 0 0 2px var(--forest); }
.theme-card input { flex: none; width: 22px; height: 22px; margin: 0; accent-color: var(--forest); }
.theme-text { display: flex; flex-direction: column; line-height: 1.3; }
.theme-name { font-weight: 800; color: var(--pine); }
.theme-note { font-size: .88rem; font-weight: 600; color: var(--muted); }
/* Each half of the preview carries its own data-theme, so it shows THAT theme's colors whatever the page uses. */
.theme-swatch { flex: none; display: flex; width: 64px; height: 46px; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 10px;
  forced-color-adjust: none; }
.swatch-half { flex: 1; display: flex; flex-direction: column; gap: 4px; padding: 7px 6px; background: var(--cream); }
.sw-ink, .sw-muted, .sw-sun { display: block; height: 5px; border-radius: 3px; background: var(--ink); }
.sw-muted { width: 70%; background: var(--muted); }
.sw-sun { width: 22px; height: 9px; margin-top: auto; background: var(--sun); }

/* Keyboard focus on checkboxes and radios (these cards, voices, How many?): the full --forest ring (≥ 3:1 on the page
   in every theme, unit-tested), not the soft --ring glow app.css gives every focused input. */
input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible { outline: 3px solid var(--forest); outline-offset: 2px; }
