/* Rust from the Contract Up — track stylesheet.
 * Inherits the C++/Go sheet (which itself inherits the shared RL sheet) so all
 * of .callout / .topic-grid / .principle-grid / .two-col / .widget / .kpi-grid /
 * .toc-card / .prompt-list / footer.lesson-nav are already defined.
 * Everything below is Rust-track-only and additive.
 */
@import "../../cpp/lessons/style.css";

:root {
  /* One visual language for ownership across every widget in the track. */
  --own:      #334155;   /* an owner (the one name that frees)            */
  --shared:   #2563eb;   /* a shared borrow  &T  (many readers)           */
  --excl:     #d97706;   /* an exclusive borrow  &mut T  (one writer)     */
  --moved:    #94a3b8;   /* a name that has been moved out of             */
  --live:     #7c3aed;   /* a live range / region                         */
  --err:      #dc2626;   /* the compiler said no                          */
  --good:     #16a34a;   /* the compiler said yes                         */
}

/* ── Compiler-verdict badge on a code block ─────────────────────────────
 * The badge is generated from ONE attribute, data-rs, and that same attribute
 * is what tools/validate_rust_lessons.py feeds to rustc — so the label you read
 * is the label the compiler produced, not one an author typed.
 *   data-rs="ok"          compiles cleanly
 *   data-rs="E0502"       rejected with exactly that error code
 *   data-rs="E0499,E0502" rejected with exactly that set of codes
 *   data-rs="panic"       compiles; panics when run
 *   data-rs="skip"        not Rust (C++/Go/pseudo) — needs data-lang or data-why
 */
pre[data-rs] { position: relative; padding-top: 34px; }
pre[data-rs]::before {
  position: absolute; top: 8px; right: 12px;
  font-family: var(--mono); font-size: 11px; line-height: 1;
  padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text-mute);
  content: attr(data-rs);
}
pre[data-rs="ok"]::before      { content: "\2713  compiles"; color: #166534; background: #dcfce7; border-color: #86efac; }
pre[data-rs="panic"]::before   { content: "\2713  compiles \00b7  panics at run time"; color: #92400e; background: #fef3c7; border-color: #fcd34d; }
pre[data-rs^="E"]::before      { content: "\2717  rejected \00b7  error[" attr(data-rs) "]"; color: #991b1b; background: #fee2e2; border-color: #fca5a5; }
pre[data-rs="error"]::before   { content: "\2717  rejected"; color: #991b1b; background: #fee2e2; border-color: #fca5a5; }
pre[data-rs="skip"]::before    { content: attr(data-lang); color: var(--text-mute); background: var(--bg-soft); }
pre[data-rs="skip"]:not([data-lang])::before { content: "not Rust"; }

/* The compiler's own words, quoted from a real run (validated against rustc). */
pre.diag {
  background: #1f2430; color: #e5e7eb; border-color: #1f2430;
  font-size: 12.5px; border-left: 4px solid var(--err);
}
pre.diag code { color: inherit; }

/* Program output the lesson claims (validated by running the binary). */
pre.out { background: var(--bg-elev); border-style: dashed; font-size: 13px; }
pre.out::before { content: "output"; display: block; font: 10px var(--mono);
  text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim); margin-bottom: 4px; }

/* ── The derivation table: problem inherited → one move → problem created ── */
table.derive td:nth-child(1), table.derive th:nth-child(1) { width: 6%; font-family: var(--mono); color: var(--text-dim); }
table.derive td:nth-child(2) { width: 30%; }
table.derive td:nth-child(3) { width: 34%; font-weight: 600; }
table.derive td:nth-child(4) { width: 30%; color: var(--text-mute); }
table.derive tr.part td { background: var(--bg-soft); font-family: var(--mono); font-size: 12px;
  letter-spacing: .06em; text-transform: uppercase; color: var(--text-mute); }

/* ── Three-language comparison: C++ trusts · Go constrains · Rust verifies ── */
table.cmp3 th:nth-child(2), table.cmp3 td:nth-child(2) { background: rgba(37, 99, 235, .05); }
table.cmp3 th:nth-child(3), table.cmp3 td:nth-child(3) { background: rgba(22, 163, 74, .05); }
table.cmp3 th:nth-child(4), table.cmp3 td:nth-child(4) { background: rgba(217, 119, 6, .06); }

/* ── Road-not-taken and honest-limit call-outs ───────────────────────── */
.callout.road { border-left-color: var(--live); }
.callout.road .label::before { content: "\21aa  "; }
.callout.limit { border-left-color: var(--warn); }
.callout.limit .label::before { content: "\26a0  "; }

/* ── Ownership vocabulary chips, used in prose and inside widgets ───────── */
.chip.own    { color: var(--own);    border-color: var(--own); }
.chip.shared { color: var(--shared); border-color: var(--shared); }
.chip.excl   { color: var(--excl);   border-color: var(--excl); }
.chip.moved  { color: var(--moved);  border-color: var(--moved); text-decoration: line-through; }
.chip.err    { color: var(--err);    border-color: var(--err); }
.chip.good   { color: var(--good);   border-color: var(--good); }

/* Widgets in this track are canvas-first (EPUB-capturable) with a text readout. */
.rs-canvas {
  width: 100%; height: 300px; display: block;
  background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px;
}
.rs-canvas.tall { height: 380px; }
.rs-canvas.short { height: 220px; }
.widget .readout {
  font-family: var(--mono); font-size: 13px; line-height: 1.5;
  background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; margin: 8px 0; min-height: 2.6em; white-space: pre-wrap;
}
.widget .readout.ok  { border-left: 4px solid var(--good); }
.widget .readout.err { border-left: 4px solid var(--err); }
.widget select { font-family: var(--mono); font-size: 13px; padding: 5px 8px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); }
.widget button.toggle-on { background: var(--accent); color: #fff; border-color: var(--accent); }

@media (max-width: 720px) {
  table.derive td:nth-child(n), table.derive th:nth-child(n) { width: auto; }
  .rs-canvas { height: 260px; }
}
