/* Shared stylesheet for the RL → GRPO course.
   Tufte-inspired: serif body, generous margins, restrained color. */

:root {
  --bg: #fbfaf7;
  --ink: #1a1a1a;
  --muted: #6b6b6b;
  --rule: #d9d6cf;
  --accent: #8a1538;     /* deep crimson, used sparingly */
  --accent-soft: #f4e8ec;
  --code-bg: #f3f1ec;
  --green: #2e6b3e;
  --amber: #8a6d1f;
}

* { box-sizing: border-box; }

html { font-size: 17px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

article {
  max-width: 680px;
  margin: 0 auto;
  padding: 3rem 1.5rem 6rem;
}

header.lesson-head {
  border-bottom: 1px solid var(--rule);
  padding-bottom: 1.5rem;
  margin-bottom: 2rem;
}
header.lesson-head .kicker {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
header.lesson-head h1 {
  font-size: 1.7rem;
  line-height: 1.25;
  margin: 0 0 0.5rem;
  font-weight: 600;
}
header.lesson-head .meta {
  color: var(--muted);
  font-size: 0.85rem;
}

h2 {
  font-size: 1.25rem;
  margin: 2.2rem 0 0.8rem;
  font-weight: 600;
}
h3 {
  font-size: 1.05rem;
  margin: 1.6rem 0 0.5rem;
  font-weight: 600;
}

p { margin: 0.8rem 0; }

a { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--accent-soft); }
a:hover { border-bottom-color: var(--accent); }

code, pre {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.86rem;
}
code { background: var(--code-bg); padding: 0.1em 0.35em; border-radius: 3px; }
pre {
  background: var(--code-bg);
  padding: 0.9rem 1rem;
  border-radius: 5px;
  overflow-x: auto;
  line-height: 1.5;
}
pre code { background: none; padding: 0; }

blockquote {
  margin: 1.4rem 0;
  padding: 0.5rem 0 0.5rem 1.2rem;
  border-left: 3px solid var(--accent);
  color: #444;
  font-style: italic;
}

/* Margin note (Tufte-style aside) */
aside.margin {
  float: right;
  width: 160px;
  margin: 0.2rem -200px 0 1rem;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
  font-style: italic;
}

/* Diagram / figure */
figure {
  margin: 1.6rem 0;
  text-align: center;
}
figure svg { max-width: 100%; height: auto; }
figure svg .node { cursor: pointer; transition: opacity 0.15s; }
figure svg .node:hover circle { fill: var(--accent-soft); }
figcaption {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.4rem;
  text-align: center;
}

/* Key term */
.kw {
  border-bottom: 1.5px dotted var(--accent);
  cursor: help;
}

/* Callout box */
.callout {
  border: 1px solid var(--rule);
  border-left: 4px solid var(--accent);
  background: #fff;
  padding: 0.9rem 1.1rem;
  margin: 1.4rem 0;
  border-radius: 0 4px 4px 0;
}
.callout.win { border-left-color: var(--green); }
.callout.tip { border-left-color: var(--amber); }

/* Mapping table (term -> meaning), reused across lessons */
table.map {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.92rem;
}
table.map td {
  border-bottom: 1px solid var(--rule);
  padding: 0.55rem 0.4rem;
  vertical-align: top;
}
table.map td:first-child {
  width: 7rem;
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}

/* Reusable sliders + readout (lesson 3, 5, ...) */
.sliders label { display: block; margin: 0.4rem 0; font-size: 0.9rem; }
.sliders input[type=range] { width: 200px; vertical-align: middle; margin: 0 0.5rem; }
.sliders span { font-family: ui-monospace, "SF Mono", Menlo, monospace; color: var(--accent); }
.readout { font-size: 0.9rem; margin: 0.6rem 0 1rem; font-family: ui-monospace, monospace; background: var(--code-bg); padding: 0.6rem 0.8rem; border-radius: 4px; line-height: 1.6; }

/* Reusable code/console/symbol-map components (shared across lessons) */
table.symmap { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: 0.9rem; }
table.symmap th { text-align: left; color: var(--muted); border-bottom: 1px solid var(--rule); padding: 0.4rem; }
table.symmap td { border-bottom: 1px solid var(--rule); padding: 0.5rem 0.4rem; }
pre.code-block { background: #1e1e1e; color: #f1f1f1; padding: 1rem 1.1rem; border-radius: 6px; overflow-x: auto; font-size: 0.82rem; line-height: 1.55; }
pre.code-block code { background: none; color: inherit; padding: 0; }
p.run-cmd { font-size: 0.85rem; color: var(--muted); }
pre.console { background: #111; color: #d6ffd6; padding: 0.9rem 1rem; border-radius: 6px; font-size: 0.84rem; line-height: 1.55; overflow-x: auto; white-space: pre; }
.muted-small { color: var(--muted); font-size: 0.82rem; margin-top: -0.3rem; }

/* Boxed "hero formula" — the one thing to remember */
.formula-box {
  background: #fff;
  border: 1px solid var(--rule);
  border-left: 4px solid var(--accent);
  padding: 1rem 1.2rem;
  margin: 1.2rem 0;
  border-radius: 0 5px 5px 0;
  text-align: center;
}
.formula-box .tag { font-family: ui-monospace, monospace; font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }

/* Step badges for derivations */
.step { display: inline-block; width: 1.6rem; height: 1.6rem; line-height: 1.6rem; text-align: center; border-radius: 50%; background: var(--accent); color: #fff; font-family: ui-monospace, monospace; font-size: 0.8rem; margin-right: 0.5rem; vertical-align: middle; }

/* Training line chart (lesson 4+) */
.train-wrap { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-start; }
.train-wrap svg { background: var(--code-bg); border-radius: 5px; }
.chart-legend { font-size: 0.82rem; line-height: 1.7; }
.chart-legend .sw { display: inline-block; width: 0.9rem; height: 0.9rem; border-radius: 2px; vertical-align: middle; margin-right: 0.3rem; }
button.train-btn { font-family: inherit; font-size: 0.9rem; padding: 0.5rem 1rem; background: var(--accent); color: #fff; border: none; border-radius: 4px; cursor: pointer; }
button.train-btn:hover { opacity: 0.9; }

/* Quiz */
.quiz {
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 1.2rem 1.3rem 0.4rem;
  margin: 2rem 0;
  background: #fff;
}
.quiz h3 { margin-top: 0; }
.quiz .q-options { display: flex; flex-direction: column; gap: 0.55rem; margin: 0.9rem 0 1.1rem; }
.quiz button.opt {
  text-align: left;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.4;
  padding: 0.6rem 0.9rem;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 5px;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.12s;
}
.quiz button.opt:hover { border-color: var(--accent); }
.quiz button.opt.correct { background: #eaf3ec; border-color: var(--green); color: var(--green); }
.quiz button.opt.wrong { background: #f7ecec; border-color: #b03b3b; color: #b03b3b; }
.quiz .feedback {
  font-size: 0.86rem;
  color: var(--muted);
  margin: 0.2rem 0 0.9rem;
  min-height: 1.2rem;
}

/* Footer */
footer.lesson-foot {
  margin-top: 3rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--rule);
  font-size: 0.85rem;
  color: var(--muted);
}
footer.lesson-foot .next {
  display: inline-block;
  margin-top: 0.6rem;
  padding: 0.5rem 0.95rem;
  background: var(--accent);
  color: #fff;
  border-radius: 4px;
  border: none;
}
footer.lesson-foot .next:hover { opacity: 0.9; }

@media (max-width: 720px) {
  aside.margin { float: none; width: auto; margin: 0.8rem 0; display: block; }
}
