/* ============================================================
   TrainTanmay shared theme — matches the Design Technology app
   (drafting-office surfaces, Barlow Semi Condensed / IBM Plex type,
   Auto · Light · Dark · Salmon themes, OpenDyslexic toggle).
   ESAT brand colour: yellow. Loaded last so it wins over style.css
   and neon.css.
   --color-primary is used for TEXT (links, active nav) so on light
   themes it is a deep gold that passes contrast; solid fills use
   --brand-fill (true yellow) with dark ink.
   ============================================================ */

:root {
  --font-display: 'Barlow Semi Condensed', 'Arial Narrow', Arial, sans-serif;
  --font-body: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, Menlo, Consolas, monospace;
}

:root[data-theme='light'] {
  --color-bg: #f7f6f1;
  --color-surface: #ffffff;
  --color-surface-2: #ffffff;
  --color-surface-offset: #f0eee6;
  --color-surface-offset-2: #e6e3d7;
  --color-divider: #e2ded0;
  --color-border: #cfc9b6;
  --color-text: #1c1a12;
  --color-text-muted: #5f5a4a;
  --color-text-faint: #9a9482;
  --color-text-inverse: #1d1600;
  --color-primary: #855700;
  --color-primary-hover: #6b4600;
  --color-primary-soft: #fff1bf;
  --brand-fill: #ffc917;
  --brand-fill-hover: #ffd84d;
  --brand-ink: #1d1600;
  --color-violet: #5a3fb3;
  --color-violet-soft: #ebe5f8;
  --color-success: #1f7a50;
  --color-success-soft: #ddf1e6;
  --color-error: #b23a33;
  --color-error-soft: #f8e1df;
  --color-warning: #a3540f;
  --color-warning-soft: #f9e6d3;
  --color-chart-1: #d9a400;
  --color-chart-2: #1f5fbf;
  --color-chart-3: #c2413a;
  --color-chart-4: #5a3fb3;
  --grid-line: rgba(133, 87, 0, 0.07);
  --shadow-sm: 0 1px 2px rgba(28, 26, 18, 0.06);
  --shadow-md: 0 1px 2px rgba(28, 26, 18, 0.06), 0 6px 20px rgba(28, 26, 18, 0.06);
  --shadow-lg: 0 16px 40px rgba(28, 26, 18, 0.12);
  color-scheme: light;
}

:root[data-theme='dark'] {
  --color-bg: #12110c;
  --color-surface: #1b1a13;
  --color-surface-2: #222017;
  --color-surface-offset: #26241a;
  --color-surface-offset-2: #312e21;
  --color-divider: #34311f;
  --color-border: #474230;
  --color-text: #f3efe0;
  --color-text-muted: #bdb69e;
  --color-text-faint: #847d66;
  --color-text-inverse: #1d1600;
  --color-primary: #ffd23f;
  --color-primary-hover: #ffe17a;
  --color-primary-soft: #3a3110;
  --brand-fill: #ffd23f;
  --brand-fill-hover: #ffe17a;
  --brand-ink: #1d1600;
  --color-violet: #b9a3ff;
  --color-violet-soft: #2a2440;
  --color-success: #5fd39b;
  --color-success-soft: #14301f;
  --color-error: #f58a82;
  --color-error-soft: #3a1d1a;
  --color-warning: #f0a356;
  --color-warning-soft: #3a2a18;
  --color-chart-1: #ffd23f;
  --color-chart-2: #5b9cff;
  --color-chart-3: #f58a82;
  --color-chart-4: #b9a3ff;
  --grid-line: rgba(255, 210, 63, 0.05);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

:root[data-theme='salmon'] {
  --color-bg: #f6e4da;
  --color-surface: #fcf3ee;
  --color-surface-2: #fdf7f3;
  --color-surface-offset: #f1dccf;
  --color-surface-offset-2: #e9cfbf;
  --color-divider: #e3c6b6;
  --color-border: #d2a991;
  --color-text: #2b1d17;
  --color-text-muted: #6b4e40;
  --color-text-faint: #a08272;
  --color-text-inverse: #1d1600;
  --color-primary: #7a4c00;
  --color-primary-hover: #5f3b00;
  --color-primary-soft: #f8e2b0;
  --brand-fill: #f6bd16;
  --brand-fill-hover: #ffcc3d;
  --brand-ink: #1d1600;
  --color-violet: #5a3fb3;
  --color-violet-soft: #ead9e6;
  --color-success: #2c7a4e;
  --color-success-soft: #e2ecd9;
  --color-error: #a8382f;
  --color-error-soft: #f4d2cb;
  --color-warning: #9a5a14;
  --color-warning-soft: #f5e2c4;
  --color-chart-1: #c98f00;
  --color-chart-2: #1d4f99;
  --color-chart-3: #a8382f;
  --color-chart-4: #5a3fb3;
  --grid-line: rgba(122, 76, 0, 0.06);
  --shadow-sm: 0 1px 2px rgba(60, 30, 15, 0.06);
  --shadow-md: 0 1px 2px rgba(60, 30, 15, 0.06), 0 6px 20px rgba(60, 30, 15, 0.07);
  --shadow-lg: 0 16px 40px rgba(60, 30, 15, 0.12);
  --question-filter: none;
  --question-blend: normal;
  color-scheme: light;
}

/* ---------- drafting-office base ---------- */
body {
  font-family: var(--font-body);
  background-color: var(--color-bg);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 24px 24px;
  background-attachment: fixed;
}
h1, h2, h3, h4 {
  font-family: var(--font-display);
  letter-spacing: 0.01em;
  line-height: 1.15;
}
h1 { font-weight: 800; }
h2, h3 { font-weight: 700; }

.topbar {
  background: color-mix(in srgb, var(--color-surface) 92%, transparent);
  border-bottom: 1px solid var(--color-divider);
}
.brand { font-family: var(--font-display); font-weight: 800; letter-spacing: 0.01em; }
.brand > span { font-size: 1.3rem; line-height: 1; }
.brand small {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-top: 3px;
}
.brand svg { width: 38px; height: 38px; }
/* same mark as the D&T app (big T + small t), in ESAT yellow */
.brand .logo-tile { fill: var(--brand-fill); }
.brand .logo-T { fill: var(--brand-ink); }
.brand .logo-t { fill: #9a6200; }

.nav a[aria-current='page'] {
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-weight: 600;
}

/* ---------- yellow fills with dark ink ---------- */
.btn-primary,
.chip[aria-pressed='true'],
.opt[aria-pressed='true'],
.seg-i input:checked + span,
.pa-c.is-sel {
  background: var(--brand-fill);
  border-color: var(--brand-fill);
  color: var(--brand-ink);
}
.btn-primary:hover {
  background: var(--brand-fill-hover);
  border-color: var(--brand-fill-hover);
  color: var(--brand-ink);
}
.switch input:checked,
.meter > span,
.hl1,
.pace-dot[data-stage='work'] {
  background: var(--brand-fill);
  border-color: var(--brand-fill);
}
.learn-btn[aria-pressed='true'] .tick { color: #fff; }
[data-theme='dark'] .learn-btn[aria-pressed='true'] .tick { color: var(--brand-ink); }

/* top-bar controls copied from the D&T app */
.tb-controls { display: flex; gap: 8px; align-items: center; flex: none; }
.theme-select {
  height: 36px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  padding: 0 8px;
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
}
.icon-btn { cursor: pointer; color: var(--color-text-muted); background: var(--color-surface); }
.icon-btn:hover { color: var(--color-text); }
.dysbtn { font-weight: 700; font-size: 0.95rem; width: auto; min-width: 38px; padding: 0 8px; }
.dysbtn[aria-pressed='true'] {
  background: var(--brand-fill);
  color: var(--brand-ink);
  border-color: var(--brand-fill);
}
.app-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  background: var(--color-surface);
  white-space: nowrap;
}
.app-switch:hover { color: var(--color-text); border-color: var(--color-primary); text-decoration: none; }
@media (max-width: 720px) {
  .app-switch .lbl { display: none; }
}

/* ---------- dyslexia-friendly font (same as D&T app) ---------- */
@font-face {
  font-family: 'OpenDyslexic';
  src: url(../fonts/opendyslexic-latin-400-normal.woff2) format('woff2');
  font-weight: 400 500;
  font-display: swap;
}
@font-face {
  font-family: 'OpenDyslexic';
  src: url(../fonts/opendyslexic-latin-700-normal.woff2) format('woff2');
  font-weight: 600 900;
  font-display: swap;
}
html.dys {
  --font-display: 'OpenDyslexic', sans-serif;
  --font-body: 'OpenDyslexic', sans-serif;
}
html.dys body,
html.dys button,
html.dys input,
html.dys select,
html.dys textarea {
  font-family: 'OpenDyslexic', sans-serif;
}
html.dys body { line-height: 1.65; font-size: 84%; }
html.dys .nav a,
html.dys .brand { font-family: 'IBM Plex Sans', system-ui, sans-serif; }
html.dys h1 { font-size: clamp(1.5rem, 3.6vw, 2.2rem); }
html.dys h1, html.dys h2, html.dys h3, html.dys h4 { letter-spacing: 0; line-height: 1.3; }

/* ---------- home hero (matches the D&T app's hero) ---------- */
.hero {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1.05fr;
  min-height: 340px;
  border: 1px solid var(--color-divider);
  border-radius: 16px;
  background: var(--color-surface);
  overflow: hidden;
  margin-bottom: var(--space-6);
  box-shadow: var(--shadow-md);
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
}
.hero-text {
  position: relative;
  padding: 34px 30px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
}
.hero-text p { margin: 0; max-width: 52ch; color: var(--color-text-muted); }
.hero .eyebrow {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.hero .pun {
  font-size: clamp(1.8rem, 3.8vw, 2.7rem);
  font-weight: 800;
  min-height: 2.3em;
  cursor: pointer;
  margin: 0;
}
.typing::after {
  content: '';
  display: inline-block;
  width: 0.08em;
  height: 0.9em;
  background: var(--brand-fill);
  margin-left: 0.06em;
  vertical-align: -0.05em;
  animation: tt-blink 1s steps(1) infinite;
}
@keyframes tt-blink { 50% { opacity: 0; } }
.hero-play {
  position: relative;
  min-height: 300px;
  border-left: 1px solid var(--color-divider);
  cursor: crosshair;
  touch-action: none;
}
.hero-play canvas { position: absolute; inset: 0; display: block; }
.hero-hint {
  position: absolute;
  top: 12px;
  right: 14px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  background: color-mix(in srgb, var(--color-surface) 80%, transparent);
  padding: 2px 8px;
  border-radius: 6px;
  pointer-events: none;
}
.hero-readout {
  position: absolute;
  top: 36px;
  right: 14px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px 10px;
  max-width: 70%;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--color-text-muted);
  pointer-events: none;
}
@media (min-width: 861px) { .hero-hint .hs { display: none; } }
.hero-readout b { color: var(--color-text); font-weight: 600; }
.hero-readout .hits b { background: var(--brand-fill); color: var(--brand-ink); padding: 0 5px; border-radius: 4px; }
.titleblock {
  position: absolute;
  left: 44px;
  top: 12px;
  display: grid;
  grid-template-columns: auto auto;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  pointer-events: none;
}
.titleblock span { padding: 3px 8px; border-right: 1px solid var(--color-divider); }
.titleblock span:nth-child(2n) { border-right: 0; }
.titleblock span:nth-child(-n + 2) { border-bottom: 1px solid var(--color-divider); }
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; }
  .hero-play { order: -1; min-height: 250px; border-left: 0; border-bottom: 1px solid var(--color-divider); }
  .hero-text { padding: 22px 18px; }
  .titleblock { display: none; }
  .hero-hint { left: 40px; right: 10px; text-align: left; }
  .hero-hint .hl { display: none; }
  .hero-readout { top: 34px; left: 40px; right: 10px; justify-content: flex-start; max-width: none; font-size: 0.66rem; }
}

/* rise-in motion, same as the D&T home */
@keyframes tt-rise { from { opacity: 0; transform: translateY(22px) scale(0.985); } to { opacity: 1; transform: none; } }
.hero-text > *, .hero-play, #view > .grid > *, #view > .card {
  animation: tt-rise 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.hero-text > *:nth-child(1) { animation-delay: 0.05s; }
.hero-text > *:nth-child(2) { animation-delay: 0.15s; }
.hero-text > *:nth-child(3) { animation-delay: 0.25s; }
.hero-text > *:nth-child(4) { animation-delay: 0.35s; }
.hero-play { animation-delay: 0.2s; animation-duration: 1.1s; }
#view > .grid > *:nth-child(1) { animation-delay: 0.4s; }
#view > .grid > *:nth-child(2) { animation-delay: 0.48s; }
#view > .grid > *:nth-child(3) { animation-delay: 0.56s; }
#view > .grid > *:nth-child(4) { animation-delay: 0.64s; }
.stat, .card { transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.25s ease, border-color 0.2s; }
a.card:hover, button.card:hover, .stat:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
@media (prefers-reduced-motion: reduce) {
  .hero-text > *, .hero-play, #view > .grid > *, #view > .card { animation: none !important; }
  .typing::after { animation: none; }
  .stat, .card { transition: none; }
  a.card:hover, button.card:hover, .stat:hover { transform: none; }
}
