/* ═══════════════════════════════════════════════════════════════════════════
   Classroom Sims v2 — Design Tokens + Base Styles
   Spec: ENGINEERING-SPEC.md § 1–3
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── 1. Design Tokens ──────────────────────────────────────────────────── */

:root {
  /* ink */
  --ink:          oklch(0.24 0.012 80);   /* #34302A */
  --ink-hover:    oklch(0.14 0.012 80);   /* #1D1A16 */
  --ink-2:        oklch(0.52 0.015 80);   /* #7C7469 */
  --ink-3:        oklch(0.68 0.015 80);   /* #A9A196 */
  --ink-4:        oklch(0.66 0.015 80);   /* #A29A8F */
  --ink-raised:   oklch(0.30 0.012 80);   /* #423D36 */
  --ink-border:   oklch(0.38 0.012 80);   /* #554F46 */
  --ink-border-2: oklch(0.42 0.012 80);   /* #5F584E */
  --ink-ghost:    oklch(0.45 0.012 80);   /* #675F55 */

  /* paper */
  --paper:        oklch(0.975 0.008 85);  /* #FAF9F5 */
  --paper-hi:     oklch(0.99 0.006 85);   /* #FDFCF9 */
  --paper-sunk:   oklch(0.955 0.010 85);  /* #F4F2EC */
  --shell:        oklch(0.93 0.008 85);   /* #EAE7E0 */
  --line:         oklch(0.90 0.012 85);   /* #E2DED5 */
  --line-strong:  oklch(0.88 0.012 85);   /* #DBD7CD */

  /* accents — semantic, never decorative */
  --blue:         oklch(0.48 0.13 262);   /* #3A5BC7 */
  --blue-wash:    oklch(0.965 0.02 262);  /* #F4F5FD */
  --blue-line:    oklch(0.90 0.04 262);   /* #DDE1F6 */
  --clay:         oklch(0.58 0.14 45);    /* #B96A3C */
  --clay-wash:    oklch(0.965 0.035 45);  /* #FCF2EB */
  --clay-live:    oklch(0.58 0.17 25);    /* #C55B48 */
  --green:        oklch(0.50 0.11 155);   /* #2E7757 */
  --green-wash:   oklch(0.965 0.03 155);  /* #EDF7F1 */
  --amber:        oklch(0.82 0.10 75);    /* #E8C286 */

  /* motion tokens */
  --t-tap: 120ms ease;
  --t-state: 160ms ease;
  --t-enter: 400ms ease;
  --t-progress: 500ms cubic-bezier(0.2, 0.8, 0.3, 1);
  --t-bar: 800ms cubic-bezier(0.2, 0.8, 0.3, 1);

  /* heatmap — four discrete bands (ANNOTATIONS § 7.4) */
  --heat-1-bg: oklch(0.90 0.075 45);   /* under 40% */
  --heat-1-fg: oklch(0.38 0.11 40);
  --heat-2-bg: oklch(0.945 0.045 55);  /* 40–55% */
  --heat-2-fg: oklch(0.45 0.09 50);
  --heat-3-bg: oklch(0.955 0.035 145); /* 55–68% */
  --heat-3-fg: oklch(0.40 0.08 155);
  --heat-4-bg: oklch(0.90 0.075 155);  /* over 68% */
  --heat-4-fg: oklch(0.32 0.09 155);

  /* spacing */
  --gutter: clamp(18px, 4cqi, 56px);
  --section-gap: clamp(30px, 5cqi, 70px);
}

/* ── 2. Fonts ──────────────────────────────────────────────────────────── */

/* Instrument Serif — display (always loaded) */
@font-face {
  font-family: 'Instrument Serif';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/fonts/instrument-serif-latin-400.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Instrument Serif';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url(/fonts/instrument-serif-latin-400-italic.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* IBM Plex Sans — UI (variable weight, always loaded) */
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url(/fonts/plex-sans-latin-400.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* IBM Plex Mono — codes, data, labels (per-weight, always loaded) */
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/fonts/plex-mono-latin-400.woff2) format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(/fonts/plex-mono-latin-500.woff2) format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(/fonts/plex-mono-latin-600.woff2) format('woff2');
}

/* ── Indic script subsets — loaded per-language ────────────────────────── */

/* Devanagari (Hindi, Marathi) */
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/fonts/plex-sans-devanagari-devanagari-400.woff2) format('woff2');
  unicode-range: U+0900-097F, U+1CD0-1CF9, U+200C-200D, U+20A8, U+20B9, U+20F0, U+25CC, U+A830-A839, U+A8E0-A8FF, U+11B00-11B09;
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(/fonts/plex-sans-devanagari-devanagari-500.woff2) format('woff2');
  unicode-range: U+0900-097F, U+1CD0-1CF9, U+200C-200D, U+20A8, U+20B9, U+20F0, U+25CC, U+A830-A839, U+A8E0-A8FF, U+11B00-11B09;
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(/fonts/plex-sans-devanagari-devanagari-600.woff2) format('woff2');
  unicode-range: U+0900-097F, U+1CD0-1CF9, U+200C-200D, U+20A8, U+20B9, U+20F0, U+25CC, U+A830-A839, U+A8E0-A8FF, U+11B00-11B09;
}

/* Tamil — Noto Sans Tamil (fallback for IBM Plex which lacks Tamil) */
@font-face {
  font-family: 'Noto Sans Tamil';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url(/fonts/noto-sans-tamil.woff2) format('woff2');
  unicode-range: U+0B82-0BFA, U+200C-200D, U+20B9, U+25CC;
}

/* Telugu — Noto Sans Telugu */
@font-face {
  font-family: 'Noto Sans Telugu';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url(/fonts/noto-sans-telugu.woff2) format('woff2');
  unicode-range: U+0C00-0C7F, U+1CDA, U+200C-200D, U+25CC;
}

/* Bengali — Noto Sans Bengali */
@font-face {
  font-family: 'Noto Sans Bengali';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url(/fonts/noto-sans-bengali.woff2) format('woff2');
  unicode-range: U+0951-0952, U+0964-0965, U+0980-09FE, U+1CD0, U+1CD2, U+1CD5-1CD6, U+1CD8, U+1CE1, U+1CEA, U+1CED, U+1CF2, U+1CF5-1CF7, U+200C-200D, U+20B9, U+25CC;
}

/* ── 3. Base Reset ─────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 15px;
  line-height: 1.5;
}

/* Language-specific font stacks */
:lang(hi) body, :lang(mr) body { font-family: 'IBM Plex Sans', system-ui, sans-serif; }
:lang(ta) body { font-family: 'Noto Sans Tamil', 'IBM Plex Sans', system-ui, sans-serif; }
:lang(te) body { font-family: 'Noto Sans Telugu', 'IBM Plex Sans', system-ui, sans-serif; }
:lang(bn) body { font-family: 'Noto Sans Bengali', 'IBM Plex Sans', system-ui, sans-serif; }

/* Remove letter-spacing on mono eyebrows for non-Latin scripts */
:lang(hi) .eyebrow, :lang(ta) .eyebrow, :lang(te) .eyebrow,
:lang(bn) .eyebrow, :lang(mr) .eyebrow { letter-spacing: 0 !important; }

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
::selection { background: oklch(0.90 0.06 85); }
input, button, select, textarea { font: inherit; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4, h5, h6 { margin: 0; }
p { margin: 0; }

/* ── 4. Motion ─────────────────────────────────────────────────────────── */

@keyframes csRise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes csPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition-duration: 1ms !important;
  }
}

/* ── 5. Typography Classes ─────────────────────────────────────────────── */

.display-xl {
  font-family: 'Instrument Serif', Georgia, serif;
  font-weight: 400;
  font-size: clamp(34px, 7.2cqi, 78px);
  line-height: 1.02;
  letter-spacing: -0.022em;
  text-wrap: balance;
}
.display-l {
  font-family: 'Instrument Serif', Georgia, serif;
  font-weight: 400;
  font-size: clamp(30px, 5.6cqi, 66px);
  line-height: 1.04;
  letter-spacing: -0.022em;
  text-wrap: balance;
}
.display-m {
  font-family: 'Instrument Serif', Georgia, serif;
  font-weight: 400;
  font-size: clamp(24px, 3.4cqi, 40px);
  line-height: 1.08;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
.question-text {
  font-family: 'Instrument Serif', Georgia, serif;
  font-weight: 400;
  font-size: clamp(26px, 3.6cqi, 40px);
  line-height: 1.12;
  letter-spacing: -0.018em;
  text-wrap: balance;
}
.diagnosis {
  font-family: 'Instrument Serif', Georgia, serif;
  font-weight: 400;
  font-size: clamp(19px, 2.2cqi, 26px);
  line-height: 1.28;
  letter-spacing: -0.012em;
}
.quote {
  font-family: 'Instrument Serif', Georgia, serif;
  font-style: italic;
  font-weight: 400;
  font-size: clamp(18px, 2.1cqi, 24px);
  line-height: 1.4;
}
.stat-value {
  font-family: 'Instrument Serif', Georgia, serif;
  font-weight: 400;
  font-size: clamp(32px, 4.2cqi, 54px);
  line-height: 1;
  letter-spacing: -0.025em;
}
.body-l {
  font-size: clamp(15px, 1.5cqi, 20px);
  line-height: 1.5;
}
.eyebrow {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  line-height: 1;
}
.mono {
  font-family: 'IBM Plex Mono', monospace;
}
.join-code {
  font-family: 'IBM Plex Mono', monospace;
  font-size: clamp(20px, 2.4cqi, 28px);
  font-weight: 600;
  letter-spacing: 0.16em;
  line-height: 1;
}
.board-code {
  font-family: 'IBM Plex Mono', monospace;
  font-size: clamp(30px, 4.6cqi, 52px);
  font-weight: 600;
  letter-spacing: 0.14em;
  line-height: 1;
}

/* Editorial emphasis — serif italic inline swap */
em.ed, .editorial-em {
  font-family: 'Instrument Serif', Georgia, serif;
  font-style: italic;
  color: var(--ink);
  font-size: 1.12em;
}

.text-pretty { text-wrap: pretty; }
.text-balance { text-wrap: balance; }

/* ── 6. Component Classes ──────────────────────────────────────────────── */

/* Header */
.site-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 20;
}
.logo-mark {
  width: 26px; height: 26px;
  border-radius: 7px;
  background: var(--ink);
  color: var(--paper);
  display: grid;
  place-items: center;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 600;
}
.logo-wordmark {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

/* Pill buttons (country/language switcher) */
.pill {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-2);
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 5px 11px;
  cursor: pointer;
  letter-spacing: 0.03em;
  transition: border-color var(--t-state), color var(--t-state);
  min-width: 52px;
  text-align: center;
}
.pill:hover { border-color: var(--ink); color: var(--ink); }

/* Buttons */
.btn-primary {
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--paper);
  background: var(--ink);
  border: none;
  border-radius: 9px;
  padding: 12px 22px;
  cursor: pointer;
  transition: transform var(--t-tap), background var(--t-state);
  text-decoration: none;
  display: inline-block;
}
.btn-primary:hover { background: var(--ink-hover); text-decoration: none; color: var(--paper); }
.btn-primary:active { transform: scale(0.97); }

.btn-ghost {
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 12px 20px;
  cursor: pointer;
  transition: border-color var(--t-state);
  text-decoration: none;
  display: inline-block;
}
.btn-ghost:hover { border-color: var(--ink); text-decoration: none; }

.btn-on-dark {
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--ink);
  background: var(--paper);
  border: none;
  border-radius: 9px;
  padding: 12px 22px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.btn-on-dark:hover { text-decoration: none; }

.btn-ghost-dark {
  font-family: inherit;
  font-size: 14.5px;
  color: oklch(0.90 0.008 85);
  background: transparent;
  border: 1px solid var(--ink-ghost);
  border-radius: 9px;
  padding: 12px 18px;
  cursor: pointer;
  transition: border-color var(--t-state);
  text-decoration: none;
  display: inline-block;
}
.btn-ghost-dark:hover { border-color: oklch(0.75 0.012 85); text-decoration: none; }

/* Eyebrow badge */
.eyebrow-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--blue);
  background: var(--blue-wash);
  border: 1px solid var(--blue-line);
  border-radius: 999px;
  padding: 6px 13px;
}
.eyebrow-badge .dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--blue);
}

/* Chips */
.chip {
  font-family: inherit;
  font-size: 13px;
  color: var(--ink-2);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  transition: all var(--t-state);
}
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip[aria-checked="true"], .chip.selected {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

/* Hairline containers (gap-as-divider pattern) */
.hairline-stack {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.hairline-stack > * { background: var(--paper-hi); }

.hairline-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  background: var(--line);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--line);
  padding: clamp(22px, 3cqi, 34px) clamp(20px, 4cqi, 56px);
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  font-size: 12.5px;
  color: var(--ink-3);
}
.site-footer a { color: var(--ink-3); }
.site-footer .copy { margin-right: auto; }

/* Live dot */
.live-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--clay-live);
  animation: csPulse 1.8s ease-in-out infinite;
}

/* Misconception bar */
.misc-bar-track {
  height: 7px;
  border-radius: 4px;
  background: var(--line);
  overflow: hidden;
}
.misc-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width var(--t-bar);
}
.misc-bar-fill.clay { background: var(--clay); }
.misc-bar-fill.green { background: var(--green); }

/* Dark-ground misconception bars (Home) */
.misc-bar-track-dark {
  height: 6px;
  border-radius: 3px;
  background: var(--ink-border);
  overflow: hidden;
}

/* Seat grid */
.seat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  gap: 6px;
}
.seat {
  aspect-ratio: 1;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
}
.seat.understood { background: var(--green-wash); color: var(--green); border: 1px solid var(--green); }
.seat.primary { background: var(--clay-wash); color: var(--clay); border: 1px solid var(--clay); }
.seat.other { background: var(--blue-wash); color: var(--blue); border: 1px solid var(--blue); }
.seat.pending { background: transparent; border: 1px dashed var(--line-strong); color: var(--ink-3); }

/* Option rows (Practice) */
.option-row {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 15px 16px;
  cursor: pointer;
  transition: all var(--t-state);
  background: var(--paper);
  min-height: 50px;
}
.option-row:hover { border-color: var(--ink); }
.option-key {
  width: 24px; height: 24px;
  border-radius: 6px;
  background: var(--paper-sunk);
  color: var(--ink-2);
  display: grid;
  place-items: center;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  flex-shrink: 0;
  transition: all var(--t-state);
}
.option-text {
  flex: 1;
  font-size: 15.5px;
  line-height: 1.4;
}
.option-mark {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--ink-3);
}

/* Revealed states */
.option-row.correct {
  background: var(--green-wash);
  border-color: var(--green);
  cursor: default;
}
.option-row.correct .option-key {
  background: var(--green);
  color: var(--paper);
}
.option-row.chosen-wrong {
  background: var(--clay-wash);
  border-color: var(--clay);
  cursor: default;
}
.option-row.chosen-wrong .option-key {
  background: var(--clay);
  color: var(--paper);
}
.option-row.revealed {
  cursor: default;
}
.option-row.revealed .option-text {
  color: var(--ink-4);
}

/* Verdict block */
.verdict-block {
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  animation: csRise 0.35s ease both;
}
.verdict-label {
  padding: 12px 20px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--paper);
}
.verdict-label.correct { background: var(--green); }
.verdict-label.wrong { background: var(--clay); }
.verdict-body { padding: 20px; background: var(--paper-hi); }

/* Reteach card */
.reteach-card {
  border: 1px dashed var(--blue-line);
  background: var(--blue-wash);
  border-radius: 13px;
  padding: 18px 20px;
}

/* Class tiles (Home) */
.class-tile {
  text-align: left;
  font-family: inherit;
  background: var(--paper-hi);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 14px 13px;
  cursor: pointer;
  transition: border-color var(--t-state), transform var(--t-state), background var(--t-state);
  text-decoration: none;
  display: block;
  color: inherit;
}
.class-tile:hover {
  border-color: var(--blue);
  background: var(--blue-wash);
  transform: translateY(-2px);
  text-decoration: none;
}
.class-tile .num {
  display: block;
  font-family: 'Instrument Serif', Georgia, serif;
  font-size: 26px;
  line-height: 1;
  color: var(--ink);
  margin-bottom: 6px;
}
.class-tile .subj {
  display: block;
  font-size: 11px;
  line-height: 1.3;
  color: var(--ink-3);
}

/* ── 7. Utility Classes ────────────────────────────────────────────────── */

.container { container-type: inline-size; }
.ink { color: var(--ink); }
.ink-2 { color: var(--ink-2); }
.ink-3 { color: var(--ink-3); }
.ink-4 { color: var(--ink-4); }
.bg-paper { background: var(--paper); }
.bg-paper-hi { background: var(--paper-hi); }
.bg-paper-sunk { background: var(--paper-sunk); }
.bg-ink { background: var(--ink); color: var(--paper); }
