/* ============================================================
   Neural Forge — Shared theme
   Used by: index.html, setup.html, _template/module.html, tools/*
   ============================================================ */

:root {
  --bg:#0a0a0f;       --bg2:#10101a;   --panel:#15151f;   --panel2:#1b1b27;
  --ink:#e8e7ef;      --ink-soft:#9a98ad;   --rule:#272735;
  --accent:#ffb547;   --accent2:#7c5cff;    --accent3:#26d6a8;
  --danger:#ff5a6e;   --locked:#444056;

  --mono:'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --serif:'Fraunces', Georgia, serif;
  --sans:'Inter', system-ui, -apple-system, sans-serif;
}

[data-flavor="hacker"]        { --accent:#26d6a8; --accent2:#1adfa1; }
[data-flavor="mathematician"] { --accent:#7c5cff; --accent2:#a487ff; }
[data-flavor="linguist"]      { --accent:#ffb547; --accent2:#ffd17a; }
[data-flavor="artist"]        { --accent:#ff5e9d; --accent2:#ff9dc0; }
[data-flavor="scientist"]     { --accent:#52b6ff; --accent2:#a3d4ff; }
[data-flavor="builder"]       { --accent:#ff8a3c; --accent2:#ffb27a; }

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans); min-height: 100%;
}
body {
  background:
    radial-gradient(ellipse at top left, rgba(124,92,255,0.10), transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(255,181,71,0.08), transparent 50%),
    var(--bg);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, kbd, samp { font-family: var(--mono); }

/* ---------- top header (shared shell) ---------- */
header.forge-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; border-bottom: 1px solid var(--rule);
  backdrop-filter: blur(6px); position: sticky; top: 0; z-index: 50;
  background: rgba(10,10,15,0.78);
}
.forge-brand { display: flex; align-items: center; gap: 12px; }
.forge-brand-mark {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: grid; place-items: center; font-family: var(--serif);
  font-weight: 800; color: #0a0a0f; font-size: 17px;
}
.forge-brand-name { font-family: var(--serif); font-weight: 500; font-size: 19px; letter-spacing: 0.4px; }
.forge-nav { display: flex; align-items: center; gap: 20px; font-size: 13px; color: var(--ink-soft); }
.forge-nav a { color: var(--ink-soft); }
.forge-nav a:hover { color: var(--accent); text-decoration: none; }
.forge-nav a.active { color: var(--accent); }

main.forge-main { max-width: 1180px; margin: 0 auto; padding: 28px 28px 80px; }

/* ---------- typography ---------- */
h1.forge-title {
  font-family: var(--serif); font-weight: 300; font-size: 48px;
  line-height: 1.05; letter-spacing: -1px; margin: 12px 0 16px;
}
h1.forge-title em {
  font-style: italic; font-weight: 500;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
h2.forge-section {
  font-family: var(--serif); font-weight: 500; font-size: 26px;
  margin: 44px 0 16px; display: flex; align-items: baseline; gap: 12px;
}
h2.forge-section .num {
  font-family: var(--mono); font-size: 12px; color: var(--accent);
  border: 1px solid var(--accent); border-radius: 6px; padding: 2px 8px; letter-spacing: 1px;
}
.forge-lede { color: var(--ink-soft); font-size: 16px; line-height: 1.6; max-width: 720px; }

/* ---------- panel & card primitives ---------- */
.forge-panel {
  background: var(--panel); border: 1px solid var(--rule); border-radius: 12px;
  padding: 20px;
}
.forge-panel.accent { border-color: rgba(255,181,71,0.25); }
.forge-callout {
  background: linear-gradient(135deg, rgba(124,92,255,0.06), rgba(255,181,71,0.04));
  border: 1px solid var(--rule); border-radius: 12px; padding: 18px 22px;
  font-size: 14px; color: var(--ink-soft);
}
.forge-callout strong { color: var(--ink); }

/* Numerical stability variant — used in code-lab modules where floating-point
   subtleties (overflow, fsum drift, softmax exponentials) deserve a callout.
   Added run 3 of the rigor audit. */
.forge-callout.stability {
  background: linear-gradient(135deg, rgba(38,214,168,0.06), rgba(124,92,255,0.04));
  border-left: 3px solid var(--accent3);
  border-radius: 0 12px 12px 0;
}
.forge-callout.stability strong { color: var(--accent3); }
.forge-callout.stability code {
  font-family: var(--mono); font-size: 12px;
  background: var(--bg2); color: var(--accent); padding: 1px 5px; border-radius: 4px;
}

/* "What changes if we drop assumption X?" alternative-history variant
   (D21, run 6 of the rigor audit).  Used in modules where a design choice
   could plausibly have gone another way — Pre-LN vs Post-LN, cosine sim
   vs cosine distance, ReLU vs GELU, etc.  Rigor = knowing why each choice
   was made; alternatives illuminate the choice.  Distinct visual register
   from .stability so a student can see at a glance whether they're in
   "here be NaNs" territory or "here be design-space" territory. */
.forge-callout.alternative {
  background: linear-gradient(135deg, rgba(124,92,255,0.08), rgba(38,214,168,0.04));
  border-left: 3px dashed var(--accent2);
  border-radius: 0 12px 12px 0;
}
.forge-callout.alternative strong { color: var(--accent2); }
.forge-callout.alternative code {
  font-family: var(--mono); font-size: 12px;
  background: var(--bg2); color: var(--accent2); padding: 1px 5px; border-radius: 4px;
}

/* Pre-test panel (D6, run 6) — soft-graded warm-up at module entry.
   Three short questions, live-graded, persisted to
   localStorage.forge.pretest.m{NN}.  See FRAMEWORK §11 (Pre-test
   convention) for the schema and authoring guidance.  Visual register
   sits between the regular .forge-callout and a checkpoint: clearly an
   ungraded probe, not a stage gate. */
.forge-pretest {
  background: linear-gradient(135deg, rgba(124,92,255,0.05), rgba(82,182,255,0.04));
  border: 1px solid var(--rule); border-left: 3px solid var(--accent2);
  border-radius: 0 12px 12px 0; padding: 16px 22px; margin: 14px 0 24px;
}
.forge-pretest > p.pretest-lede {
  margin: 0 0 12px; color: var(--ink-soft); font-size: 13px;
}
.forge-pretest [data-pq] {
  margin: 10px 0; padding: 10px 12px; border-radius: 8px;
  background: rgba(10,10,15,0.35);
}
.forge-pretest [data-pq] .pq-question {
  font-size: 14px; margin: 0 0 6px; color: var(--ink);
}
.forge-pretest [data-pq] input {
  background: var(--bg2); border: 1px solid var(--rule); color: var(--ink);
  padding: 6px 10px; border-radius: 6px; font-family: var(--mono);
  font-size: 13px; width: 180px; margin-right: 8px;
}
.forge-pretest [data-pq] .pq-status {
  font-family: var(--mono); font-size: 12px; color: var(--ink-soft);
}
.forge-pretest [data-pq].correct .pq-status { color: var(--accent3); }
.forge-pretest [data-pq].wrong   .pq-status { color: var(--danger); }
.forge-pretest [data-pq] .pq-hint {
  margin: 6px 0 0; color: var(--ink-soft); font-size: 12px;
  font-style: italic; display: none;
}
.forge-pretest [data-pq].wrong .pq-hint { display: block; }

/* ============================================================
   "What you can now prove" closing checklist (D23, run 2)
   AND References list (D9, run 2; link taxonomy D39, run 5).
   Lifted into theme.css in run 5 of course-worker-rigor.md so the
   template's restored prove-list/refs blocks render correctly
   without requiring page-local CSS — the coder run-2 repair lost
   the template's inline copies, and a future module copying the
   template would have inherited an unstyled list.
   ============================================================ */
ul.prove-list { list-style: none; padding-left: 0; margin: 14px 0 24px; }
ul.prove-list li {
  margin: 8px 0; padding: 10px 14px; background: var(--panel);
  border-left: 3px solid var(--accent3); border-radius: 0 8px 8px 0;
  font-size: 14px; cursor: pointer; user-select: none;
}
ul.prove-list li.checked {
  border-left-color: var(--accent); background: rgba(255,181,71,0.06);
  text-decoration: line-through; color: var(--ink-soft);
}
ul.prove-list li .box {
  display: inline-block; width: 14px; height: 14px; margin-right: 10px;
  border: 1.5px solid var(--ink-soft); border-radius: 3px; vertical-align: -2px;
}
ul.prove-list li.checked .box {
  background: var(--accent); border-color: var(--accent); position: relative;
}
ul.prove-list li.checked .box::after {
  content: '✓'; position: absolute; top: -3px; left: 1px; color: #0a0a0f;
  font-family: var(--mono); font-size: 12px; font-weight: 700;
}

ul.refs { list-style: none; padding-left: 0; margin: 8px 0 28px; }
ul.refs li {
  margin: 6px 0; padding: 8px 10px; font-size: 14px; line-height: 1.5;
  border-bottom: 1px dashed var(--rule);
}
ul.refs .tag {
  display: inline-block; font-family: var(--mono); font-size: 10px;
  letter-spacing: 1.5px; padding: 2px 6px; border-radius: 4px; margin-right: 8px;
  background: var(--bg2); color: var(--accent2);
}
ul.refs .tag.intro    { color: var(--accent3); }
ul.refs .tag.standard { color: var(--accent);  }
ul.refs .tag.advanced { color: var(--danger);  }
/* Stable-link affordance — every reference SHOULD carry a DOI / arXiv /
   ISBN / canonical playlist URL.  Underline on hover only, so the list
   stays scannable. */
ul.refs a { color: var(--accent); text-decoration: none; border-bottom: 1px dotted var(--rule); }
ul.refs a:hover { text-decoration: none; border-bottom-color: var(--accent); }

/* ---------- buttons ---------- */
.forge-btn {
  padding: 10px 18px; border-radius: 8px; border: none; cursor: pointer;
  font-family: var(--sans); font-weight: 500; font-size: 13px;
  background: var(--accent); color: #0a0a0f; transition: filter .15s;
}
.forge-btn:hover { filter: brightness(1.1); }
.forge-btn.secondary { background: transparent; color: var(--ink); border: 1px solid var(--rule); }
.forge-btn.secondary:hover { border-color: var(--accent); color: var(--accent); }
.forge-btn.ghost { background: transparent; color: var(--ink-soft); }
.forge-btn.ghost:hover { color: var(--accent); }

/* Disabled state (E45 — worker-coder.md run 17).  Applies to any
   .forge-btn with the DOM `disabled` attribute — most notably the
   Run button during E44's busy-guard window, but also covers any
   future button that goes inert during a long-running operation.
   Suppresses the :hover brightness shift so a disabled button looks
   unmistakably inert (no false-affordance on hover). */
.forge-btn:disabled,
.forge-btn[disabled] {
  cursor: not-allowed; opacity: 0.55; filter: none;
}
.forge-btn:disabled:hover,
.forge-btn[disabled]:hover { filter: none; }

/* In-flight pulse on the Run button (E45) — pairs with E44's
   _runGuarded() in assets/runtime.js, which sets data-running="1"
   on .run for the duration of the run and removes the attribute
   in finally.  The pulse is intentionally subtle: the label change
   to "\2026 Running" is the primary signal, this is peripheral-
   vision reinforcement so a student waiting through Pyodide's
   ~10 s first-time warmup SEES that the click landed without
   needing to read the label.  Animation runs only while the
   data-attribute is present, so the success / fail / partial /
   exception exits from _runGuarded() all cleanly stop it. */
@keyframes forge-run-pulse {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 0.85; }
}
.code-lab .run[data-running="1"] {
  animation: forge-run-pulse 1.4s ease-in-out infinite;
}

/* ============================================================
   <code-lab> custom element
   ============================================================ */
.code-lab {
  background: var(--panel); border: 1px solid var(--rule); border-radius: 12px;
  margin: 22px 0; overflow: hidden;
}
.code-lab__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--rule); background: var(--panel2);
}
.code-lab__title { font-weight: 500; font-size: 14px; }
.code-lab__title::before { content: '▸ '; color: var(--accent); }
.code-lab__tier {
  font-family: var(--mono); font-size: 10px; letter-spacing: 1.5px;
  color: var(--ink-soft); border: 1px solid var(--rule); padding: 2px 6px; border-radius: 4px;
}
.code-lab__langs {
  display: flex; gap: 4px; padding: 8px 12px; background: var(--bg2);
  border-bottom: 1px solid var(--rule); overflow-x: auto;
}
.code-lab__lang {
  font-family: var(--mono); font-size: 12px; padding: 6px 12px; border-radius: 6px;
  background: transparent; color: var(--ink-soft); border: 1px solid transparent;
  cursor: pointer; white-space: nowrap;
}
.code-lab__lang:hover:not(.disabled) { color: var(--ink); border-color: var(--rule); }
.code-lab__lang.active {
  color: var(--accent); border-color: var(--accent);
  background: linear-gradient(135deg, rgba(255,181,71,0.06), transparent);
}
.code-lab__lang.disabled { opacity: 0.35; cursor: not-allowed; }

.code-lab__editor {
  font-family: var(--mono); font-size: 13px; line-height: 1.55;
  padding: 18px; background: var(--bg); color: var(--ink);
  white-space: pre; tab-size: 4; min-height: 160px; max-height: 480px;
  overflow: auto; border: none; outline: none; width: 100%; resize: vertical;
}
.code-lab__foot {
  display: flex; align-items: center; gap: 10px; padding: 12px 18px;
  border-top: 1px solid var(--rule); background: var(--panel2);
}
.code-lab__output {
  font-family: var(--mono); font-size: 12px; padding: 14px 18px;
  background: #07070b; color: #a8e6c1; border-top: 1px solid var(--rule);
  white-space: pre-wrap; max-height: 240px; overflow: auto;
  display: none;
}
.code-lab__output.show { display: block; }
.code-lab__output.err { color: var(--danger); }

/* Test-reporter pill (E1, worker-coder.md run 1). Lives in the foot
   alongside the tier label. Flavor-aware via the existing CSS variables —
   pass uses --accent3 (the always-green "good" channel of the palette);
   fail uses --danger; partial uses --accent (warning amber, or whatever
   the active flavor maps "warn" to). Idle state is empty (no border, no
   chrome) so unrun labs don't look broken. */
.code-lab__pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.5px;
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid transparent; background: transparent; color: transparent;
  transition: background-color .15s, color .15s, border-color .15s;
  min-height: 22px;
  user-select: none;
}
.code-lab__pill[data-state="idle"]    { /* invisible until first run */ }
.code-lab__pill[data-state="pass"] {
  background: rgba(38, 214, 168, 0.10);
  color: var(--accent3); border-color: var(--accent3);
}
.code-lab__pill[data-state="fail"] {
  background: rgba(255, 90, 110, 0.10);
  color: var(--danger); border-color: var(--danger);
}
.code-lab__pill[data-state="partial"] {
  background: rgba(255, 181, 71, 0.10);
  color: var(--accent); border-color: var(--accent);
}
/* Tier chip is now an <a> — strip default link styling so it still looks
   like the original badge but is keyboard-focusable + opens setup.html#tiers
   in a new tab. */
.code-lab__tier { text-decoration: none; cursor: help; }
.code-lab__tier:hover { color: var(--accent); border-color: var(--accent); }

/* <objectives> slot (E13, worker-coder.md run 2). Small panel between the
   lab head and the language tabs explaining what the lab is teaching.
   Flavor-aware via existing variables. The em-dash prefix mirrors the
   prove-list visual rhythm so module-level prove + lab-level objectives
   feel like the same family. */
.code-lab__objectives {
  font-size: 12px; line-height: 1.55; color: var(--ink-soft);
  padding: 10px 18px; background: var(--bg2);
  border-bottom: 1px solid var(--rule);
  white-space: pre-wrap;
}
.code-lab__objectives::before {
  content: '⌖ objectives'; display: block;
  font-family: var(--mono); font-size: 10px; letter-spacing: 1.5px;
  color: var(--accent3); margin-bottom: 4px;
}

/* E21 (coder run 7): per-flavor <objectives> glyph variants.  The
   crosshair above stays the default; each recognised flavor swaps in a
   glyph that matches the side-quest flavor's voice.  Colors continue
   to come from --accent3 so the panel stays consistent across flavors
   while the prefix carries flavor identity into the lab. */
[data-flavor="hacker"]        .code-lab__objectives::before { content: '> objectives'; }
[data-flavor="mathematician"] .code-lab__objectives::before { content: '∀ objectives'; }
[data-flavor="linguist"]      .code-lab__objectives::before { content: '§ objectives'; }
[data-flavor="artist"]        .code-lab__objectives::before { content: '✦ objectives'; }
[data-flavor="scientist"]     .code-lab__objectives::before { content: '⚗ objectives'; }
[data-flavor="builder"]       .code-lab__objectives::before { content: '▣ objectives'; }

/* "? ask tutor" button rendered inside fail/partial pills (E15). Keeps
   the pill's color scheme; click forwards the lab's snippet + error to
   the tutor sidebar. Hidden when no tutor is loaded. */
.code-lab__ask-tutor {
  margin-left: 8px; padding: 0 8px; border-radius: 999px;
  border: 1px solid currentColor; background: transparent; color: inherit;
  font: inherit; font-size: 10px; letter-spacing: 0.5px; cursor: pointer;
  line-height: 1.6;
}
.code-lab__ask-tutor:hover { filter: brightness(1.2); }
.code-lab__ask-tutor:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* ============================================================
   AI Tutor sidebar
   ============================================================ */
.tutor-fab {
  position: fixed; bottom: 28px; right: 28px; z-index: 60;
  width: 54px; height: 54px; border-radius: 27px; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #0a0a0f; font-size: 22px; font-weight: 700;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.05);
  transition: transform .15s;
}
.tutor-fab:hover { transform: scale(1.06); }
.tutor-fab.open { transform: rotate(45deg); }

.tutor-panel {
  position: fixed; top: 0; right: 0; height: 100vh; width: 380px;
  background: var(--panel); border-left: 1px solid var(--rule); z-index: 55;
  transform: translateX(100%); transition: transform .25s ease;
  display: flex; flex-direction: column;
}
.tutor-panel.show { transform: translateX(0); }
.tutor-head {
  padding: 16px 18px; border-bottom: 1px solid var(--rule);
  display: flex; align-items: center; justify-content: space-between;
}
.tutor-head h4 { margin: 0; font-family: var(--serif); font-weight: 500; font-size: 16px; }
.tutor-head .ctx { font-family: var(--mono); font-size: 10px; color: var(--accent); letter-spacing: 1px; }
.tutor-body {
  flex: 1; overflow-y: auto; padding: 16px; display: flex;
  flex-direction: column; gap: 10px;
}
.tutor-msg {
  padding: 10px 12px; border-radius: 10px; font-size: 13px; line-height: 1.45;
  max-width: 92%;
}
.tutor-msg.user { align-self: flex-end; background: var(--accent); color: #0a0a0f; }
.tutor-msg.bot  { align-self: flex-start; background: var(--panel2); color: var(--ink); border: 1px solid var(--rule); }
.tutor-msg.sys  { align-self: center; font-size: 11px; color: var(--ink-soft); font-style: italic; }
.tutor-input {
  border-top: 1px solid var(--rule); padding: 12px; display: flex; gap: 8px;
}
.tutor-input input {
  flex: 1; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--rule);
  background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 13px;
}
.tutor-input input:focus { outline: none; border-color: var(--accent); }

/* ============================================================
   Forge Gate
   ============================================================ */
.forge-gate {
  background: linear-gradient(135deg, rgba(124,92,255,0.10), rgba(255,181,71,0.06));
  border: 1px solid var(--rule); border-radius: 14px; padding: 28px;
  margin-top: 36px;
}
.forge-gate h3 {
  font-family: var(--serif); font-weight: 500; font-size: 22px; margin: 0 0 8px;
}
.forge-gate .prompt { color: var(--ink-soft); font-size: 14px; margin-bottom: 14px; }
.forge-gate input {
  width: 100%; padding: 12px 14px; border-radius: 8px; border: 1px solid var(--rule);
  background: var(--bg); color: var(--ink); font-family: var(--mono); font-size: 14px;
}
.forge-gate input:focus { outline: none; border-color: var(--accent); }
.forge-gate .row { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.forge-gate .status { font-family: var(--mono); font-size: 12px; min-height: 18px; }
.forge-gate .status.ok { color: var(--accent3); }
.forge-gate .status.bad { color: var(--danger); }

/* ============================================================
   Math (KaTeX overrides)
   ============================================================ */
.katex { font-size: 1.05em; }
.katex-display { margin: 18px 0; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 880px) {
  .tutor-panel { width: 100vw; }
  h1.forge-title { font-size: 36px; }
  main.forge-main { padding: 18px 16px 60px; }
}

/* end of theme.css — sentinel for scripts/check-tails.mjs */
