/*
 * Shared stylesheet for the "LLMs & Open Source" teaching workspace.
 * Tufte-inspired: readable serif body, generous margins, restrained palette,
 * print-friendly. Every lesson and reference doc links this file so the course
 * reads as one consistent whole.
 */

:root {
  --ink: #1a1a17;
  --ink-soft: #4a463e;
  --paper: #fdfcf9;
  --rule: #e3ddcf;
  --accent: #9a3b1b;      /* terracotta — links, emphasis */
  --accent-soft: #f3e4dc;
  --teal: #1f5e57;        /* secondary accent */
  --gold: #b8862f;
  --code-bg: #f4f1e8;
  --max: 46rem;
}

* { box-sizing: border-box; }

html { font-size: 18px; }

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

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 3.5rem 1.4rem 6rem;
}

/* ---- Masthead ---- */
.masthead {
  border-bottom: 2px solid var(--ink);
  padding-bottom: 0.8rem;
  margin-bottom: 2.4rem;
}
.kicker {
  font-family: ui-sans-serif, "Helvetica Neue", Arial, sans-serif;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.4rem;
}
.masthead h1 {
  font-size: 2.1rem;
  line-height: 1.12;
  margin: 0 0 0.5rem;
  font-weight: 600;
}
.masthead .meta {
  font-family: ui-sans-serif, "Helvetica Neue", Arial, sans-serif;
  font-size: 0.78rem;
  color: var(--ink-soft);
}

/* ---- Typography ---- */
h2 {
  font-size: 1.4rem;
  margin: 2.6rem 0 0.8rem;
  font-weight: 600;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.3rem;
}
h3 { font-size: 1.12rem; margin: 1.8rem 0 0.5rem; font-weight: 600; }
p { margin: 0.7rem 0; }
a { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--accent-soft); }
a:hover { border-bottom-color: var(--accent); }
strong { font-weight: 650; }
em { color: var(--ink-soft); }
small { font-size: 0.8rem; color: var(--ink-soft); }

/* ---- Lede ---- */
.lede {
  font-size: 1.18rem;
  line-height: 1.5;
  color: var(--ink-soft);
  margin: 0 0 1.5rem;
}

/* ---- Mission banner ---- */
.mission {
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  padding: 0.9rem 1.2rem;
  margin: 1.6rem 0;
  font-size: 0.95rem;
}
.mission b { color: var(--accent); }

/* ---- Callouts ---- */
.callout {
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 1rem 1.2rem;
  margin: 1.4rem 0;
  background: #fff;
}
.callout.key { border-left: 4px solid var(--teal); }
.callout.warn { border-left: 4px solid var(--gold); background: #fdf8ec; }
.callout .label {
  font-family: ui-sans-serif, "Helvetica Neue", Arial, sans-serif;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--teal);
  display: block;
  margin-bottom: 0.3rem;
}
.callout.warn .label { color: var(--gold); }

/* ---- Cost / control ladder ---- */
.ladder { margin: 1.6rem 0; counter-reset: rung; }
.rung {
  display: grid;
  grid-template-columns: 2.4rem 1fr;
  gap: 0.9rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0.85rem 1rem;
  margin-bottom: 0.6rem;
  background: #fff;
  align-items: start;
}
.rung .num {
  counter-increment: rung;
  font-family: ui-sans-serif, sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
  background: var(--teal);
  border-radius: 50%;
  width: 2rem; height: 2rem;
  display: flex; align-items: center; justify-content: center;
}
.rung:nth-child(1) .num { background: #2f7d6f; }
.rung:nth-child(2) .num { background: #4a8a5c; }
.rung:nth-child(3) .num { background: #b8862f; }
.rung:nth-child(4) .num { background: var(--accent); }
.rung h4 { margin: 0 0 0.2rem; font-size: 1.02rem; }
.rung .who { font-size: 0.85rem; color: var(--ink-soft); }
.rung .price {
  font-family: ui-sans-serif, sans-serif;
  font-size: 0.8rem;
  color: var(--teal);
  font-weight: 600;
}

/* ---- Tables ---- */
table { border-collapse: collapse; width: 100%; margin: 1.4rem 0; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
th {
  font-family: ui-sans-serif, sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  border-bottom: 2px solid var(--ink);
}
tbody tr:hover { background: #fffdf6; }
td code { font-size: 0.82rem; }

/* ---- Code ---- */
code {
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  background: var(--code-bg);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.86em;
}
pre {
  background: var(--code-bg);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 1rem;
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.5;
}
pre code { background: none; padding: 0; }

/* ---- Citations ---- */
.cite { font-size: 0.74rem; vertical-align: super; color: var(--accent); }
.sources { font-size: 0.82rem; color: var(--ink-soft); }
.sources ol { padding-left: 1.2rem; }
.sources li { margin: 0.3rem 0; }

/* ---- Quiz widget ---- */
.quiz {
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 1.2rem 1.4rem;
  margin: 1.6rem 0;
}
.quiz h3 { margin-top: 0; }
.q { margin: 1.2rem 0; }
.q-stem { font-weight: 600; margin-bottom: 0.5rem; }
.opt {
  display: block;
  border: 1px solid var(--rule);
  border-radius: 5px;
  padding: 0.5rem 0.8rem;
  margin: 0.35rem 0;
  cursor: pointer;
  font-size: 0.92rem;
  background: var(--paper);
  transition: background 0.12s;
}
.opt:hover { background: var(--accent-soft); }
.opt.correct { background: #e6f2ec; border-color: var(--teal); }
.opt.wrong { background: #fbe9e3; border-color: var(--accent); }
.opt input { margin-right: 0.5rem; }
.feedback {
  font-size: 0.88rem;
  margin-top: 0.5rem;
  padding: 0.6rem 0.8rem;
  border-radius: 5px;
  display: none;
}
.feedback.show { display: block; }
.feedback.right { background: #e6f2ec; color: var(--teal); }
.feedback.miss { background: #fbe9e3; color: var(--accent); }

/* ---- Footer nav ---- */
.lesson-footer {
  margin-top: 3rem;
  border-top: 2px solid var(--ink);
  padding-top: 1.2rem;
  font-size: 0.9rem;
}
.next-step {
  background: var(--teal);
  color: #fff;
  padding: 1rem 1.2rem;
  border-radius: 6px;
  margin: 1.6rem 0;
}
.next-step a { color: #fff; border-bottom-color: rgba(255,255,255,0.5); }
.ask-teacher {
  font-style: italic;
  color: var(--ink-soft);
  border-left: 3px solid var(--gold);
  padding-left: 0.9rem;
  margin: 1.6rem 0;
}

/* ---- Glossary ---- */
.term { margin: 1.1rem 0; padding-bottom: 0.9rem; border-bottom: 1px dotted var(--rule); }
.term dt { font-weight: 650; font-size: 1.05rem; color: var(--ink); }
.term dd { margin: 0.3rem 0 0; color: var(--ink-soft); font-size: 0.92rem; }

/* ---- Print ---- */
@media print {
  body { background: #fff; }
  .wrap { max-width: 100%; padding: 0; }
  .opt:hover, tbody tr:hover { background: none; }
  a { color: var(--ink); border: none; }
  .next-step { background: none; color: var(--ink); border: 1px solid var(--ink); }
  .quiz, .callout { break-inside: avoid; }
}

@media (max-width: 600px) {
  html { font-size: 16px; }
  .masthead h1 { font-size: 1.7rem; }
}
