/* Beacon site design system — tokens per Global Constraints (shared.md).
   Ported from the demo's validated palette (demo/public/style.css);
   this file is the authoritative site-wide stylesheet going forward. */

:root {
  --bg: #111418;
  --fg: #E7EAEE;
  --accent: #5B8DEF;
  --track: #22272e;
  --muted: #8b95a3;
  --border: #262b33;
  --danger: #e0616b;
  --warn: #d9a441;
  /* palette-validated status + mark colors (read on dark AND light) */
  --ok-status: #2E9E6B;
  --amber-status: #C47F17;
  --mark-correct: #5B8DEF;
  --mark-incorrect: #E5484D;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f7f8fa;
    --fg: #14171c;
    --accent: #5B8DEF;
    --track: #e3e6eb;
    --muted: #5b6472;
    --border: #dde1e7;
    --danger: #b4232e;
    --warn: #8a5f10;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.55;
}

body {
  min-height: 100vh;
}

main {
  max-width: 880px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

h1, h2, h3 {
  line-height: 1.2;
  font-weight: 600;
}

a {
  color: var(--accent);
}

.mono, code, pre, .fact-json, .wire-console {
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
}

.accent { color: var(--accent); }

.muted { color: var(--muted); }

.card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  background: color-mix(in srgb, var(--track) 35%, transparent);
}

.btn {
  display: inline-block;
  padding: 0.7rem 1.4rem;
  border-radius: 8px;
  background: var(--accent);
  color: #0b0e12;
  text-decoration: none;
  font-weight: 600;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
}

.btn:hover { opacity: 0.9; }

.btn.secondary {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border);
}

.links {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 2rem 0;
}

pre {
  background: color-mix(in srgb, var(--track) 55%, transparent);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  overflow-x: auto;
  font-size: 0.85rem;
}

/* mastery bars — single accent-on-neutral, per dataviz pass */
.mastery-row {
  display: grid;
  grid-template-columns: 140px 1fr 60px;
  align-items: center;
  gap: 0.75rem;
  margin: 0.6rem 0;
}

.mastery-track {
  height: 10px;
  border-radius: 6px;
  background: var(--track);
  overflow: hidden;
}

.mastery-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 6px;
  transition: width 0.5s ease;
  width: 0%;
}

.mastery-value {
  font-family: ui-monospace, monospace;
  text-align: right;
  color: var(--muted);
  font-size: 0.85rem;
}

/* counters row */
.counters {
  display: flex;
  gap: 2rem;
  margin: 1rem 0 2rem;
}

.counter {
  text-align: center;
}

.counter .n {
  font-size: 1.6rem;
  font-weight: 700;
  font-family: ui-monospace, monospace;
}

.counter .label {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* fact feed / wire console */
.fact-feed {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.fact-row {
  display: grid;
  grid-template-columns: 90px 1fr 90px;
  gap: 0.75rem;
  padding: 0.5rem 0.9rem;
  border-bottom: 1px solid var(--border);
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
  align-items: center;
}

.fact-row:last-child { border-bottom: none; }

.verb-tag {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border: 1px solid var(--border);
  color: var(--accent);
  width: fit-content;
}

.fact-detail {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.disclaimer {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.8rem;
}

/* course page interactions */
.interaction {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0;
}

.interaction.locked { opacity: 0.45; pointer-events: none; }

.choices {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 1rem 0;
}

.choice-btn {
  text-align: left;
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  font-size: 0.95rem;
}

.choice-btn:hover { border-color: var(--accent); }
.choice-btn.correct { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, transparent); }
.choice-btn.wrong { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent); }

.feedback {
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

.feedback.ok { color: var(--accent); }
.feedback.bad { color: var(--danger); }

.wire-console {
  margin-top: 2.5rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: color-mix(in srgb, var(--track) 55%, transparent);
}

.wire-console h2 {
  margin: 0;
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

.wire-console-body {
  max-height: 360px;
  overflow-y: auto;
  padding: 0.5rem 1.25rem 1rem;
}

.fact-json {
  font-size: 0.78rem;
  white-space: pre-wrap;
  word-break: break-word;
  border-bottom: 1px dashed var(--border);
  padding: 0.6rem 0;
}

.fact-json:last-child { border-bottom: none; }

input[type="text"], input[type="number"] {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--fg);
  padding: 0.5rem 0.7rem;
  font-size: 0.95rem;
  font-family: inherit;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.status-pill {
  display: inline-block;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.status-pill.live { color: var(--accent); border-color: var(--accent); }

/* status chips: icon + word + color — never color alone.
   complete = ok-status, active = accent, abandoned = amber-status. */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4ch;
  padding: 0.12rem 0.6rem;
  border-radius: 999px;
  border: 1px solid currentColor;
  font-size: 0.75rem;
  white-space: nowrap;
  background: color-mix(in srgb, currentColor 10%, transparent);
}

/* status + struggle chips share the palette: complete/fluent = ok-status,
   active/effortful = accent, abandoned/struggling = amber-status. */
.chip.complete, .chip.fluent { color: var(--ok-status); }
.chip.active, .chip.effortful { color: var(--accent); }
.chip.abandoned, .chip.struggling { color: var(--amber-status); }

/* sessions table */
.sessions-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.sessions-table th {
  text-align: left;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border);
}

.sessions-table td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
}

.sessions-table tr:last-child td { border-bottom: none; }

/* per-item latency / correctness small multiples */
.item-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1rem;
}

.item-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
}

.item-card h4 {
  margin: 0 0 0.75rem;
  font-family: ui-monospace, monospace;
  font-weight: 600;
  font-size: 0.82rem;
}

.chart-legend {
  display: flex;
  gap: 1.25rem;
  font-size: 0.78rem;
  color: var(--fg);
  margin: 0 0 0.75rem;
}

.legend-dot { font-size: 0.9em; }
.legend-dot.correct { color: var(--mark-correct); }
.legend-dot.incorrect { color: var(--mark-incorrect); }

/* inline SVG latency small-multiple (charts.js renderLatencySvg) — bar fill
   (locked correct/incorrect marks) and label ink color are set INLINE on the
   <path>/<text> elements, and the geometry lives in the SVG path data itself,
   so there are deliberately no .bars/.bar/.bar-label CSS rules here to drift
   out of sync. This just sizes/positions the element. */
.latency-svg {
  display: block;
  max-width: 100%;
  margin-top: 0.25rem;
}

.item-trend {
  margin: 0.6rem 0 0;
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  color: var(--muted);
}

/* struggle panel */
.struggle-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.struggle-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.struggle-row .item-id {
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
  min-width: 170px;
}

.struggle-row .reason {
  color: var(--muted);
  font-size: 0.8rem;
}

/* /debug wire-lint report — severity coded by border color (never color
   alone: each line also prints its [error]/[warn]/[ok] status word). */
.lint-report {
  margin-top: 1rem;
}

.lint-line {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  margin: 0.5rem 0;
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
}

.lint-line.error { border-color: var(--danger); }
.lint-line.warn { border-color: var(--warn); }
.lint-line.ok { border-color: var(--border); }
