/* ============================================================
   Shared course stylesheet
   Used by every lesson and reference document in this workspace.
   ============================================================ */

:root {
  --paper: #fcfbf8;
  --ink: #20242c;
  --muted: #626b78;
  --faint: #8b93a0;
  --rule: #ddd7cb;
  --accent: #12556b;
  --accent-soft: #eaf2f3;
  --warm: #a4492a;
  --warm-soft: #f8ede8;
  --ok: #2f6b4f;
  --ok-soft: #edf6f0;
  --bad: #a33b32;
  --bad-soft: #fbefed;
  --code-bg: #f4f1e9;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", ui-monospace, Menlo, Consolas, "Liberation Mono", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 18px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  line-height: 1.56;
  text-rendering: optimizeLegibility;
}

.page {
  max-width: 46rem;
  margin: 0 auto;
  padding: 3.5rem 1.5rem 6rem;
}

/* ---------- Header ---------- */

.lesson-header {
  border-bottom: 1px solid var(--rule);
  padding-bottom: 1.75rem;
  margin-bottom: 2.5rem;
}

.eyebrow {
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

h1 {
  font-family: var(--serif);
  font-size: clamp(2.1rem, 5vw, 3rem);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.02em;
  margin: 0.55rem 0 0.8rem;
}

.deck {
  font-size: 1.14rem;
  color: var(--muted);
  max-width: 38rem;
  margin: 0;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.4rem;
  margin-top: 1.35rem;
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--faint);
}

.meta strong {
  color: var(--muted);
  font-weight: 600;
}

/* ---------- Prose ---------- */

h2 {
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
  margin: 3.1rem 0 0.75rem;
}

h3 {
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 2.1rem 0 0.5rem;
}

p {
  margin: 0 0 1rem;
}

ul,
ol {
  margin: 0 0 1.1rem;
  padding-left: 1.35rem;
}

li {
  margin-bottom: 0.4rem;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--warm);
}

strong {
  font-weight: 650;
}

em {
  font-style: italic;
}

hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 2.5rem 0;
}

/* ---------- Callouts ---------- */

.callout {
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  padding: 1rem 1.15rem;
  margin: 1.5rem 0;
  border-radius: 0 5px 5px 0;
}

.callout p:last-child,
.callout ul:last-child,
.callout ol:last-child {
  margin-bottom: 0;
}

.callout--warm {
  background: var(--warm-soft);
  border-left-color: var(--warm);
}

.callout--plain {
  background: #f7f4ec;
  border-left-color: var(--rule);
}

.callout-label {
  display: block;
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.4rem;
}

.callout--warm .callout-label {
  color: var(--warm);
}

/* ---------- Code ---------- */

code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: rgba(18, 85, 107, 0.07);
  padding: 0.08em 0.3em;
  border-radius: 3px;
}

pre,
pre.code {
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.65;
  background: var(--code-bg);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 1rem 1.15rem;
  overflow-x: auto;
  margin: 0 0 1.1rem;
  tab-size: 4;
}

pre code {
  background: none;
  padding: 0;
  font-size: inherit;
  border-radius: 0;
}

figure {
  margin: 1.5rem 0;
}

figcaption {
  font-family: var(--sans);
  font-size: 0.75rem;
  color: var(--faint);
  margin-top: 0.5rem;
}

.file-tab {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  background: var(--code-bg);
  border: 1px solid var(--rule);
  border-bottom: 0;
  border-radius: 5px 5px 0 0;
  padding: 0.35rem 0.7rem;
  margin-bottom: -1px;
  position: relative;
  z-index: 1;
}

.file-tab + pre {
  border-top-left-radius: 0;
}

/* Minimal syntax colours, applied with spans. */
.kw { color: var(--accent); font-weight: 600; }
.ty { color: #7a4b8c; }
.st { color: #4f6b35; }
.cm { color: var(--faint); font-style: italic; }
.fn { color: var(--warm); }
.nu { color: #8a5a1f; }

/* ---------- Annotated code ---------- */

.annotations {
  list-style: none;
  padding: 0;
  margin: 1rem 0 1.5rem;
  counter-reset: note;
}

.annotations li {
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-top: 1px solid var(--rule);
  font-size: 0.94rem;
}

.annotations li:last-child {
  border-bottom: 1px solid var(--rule);
}

.annotations .n {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 50%;
  width: 1.55rem;
  height: 1.55rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.1rem;
}

/* ---------- Tables ---------- */

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0 1.5rem;
  font-family: var(--sans);
  font-size: 0.84rem;
  line-height: 1.45;
}

th {
  text-align: left;
  font-weight: 650;
  color: var(--muted);
  border-bottom: 2px solid var(--rule);
  padding: 0.5rem 0.6rem;
  vertical-align: bottom;
}

td {
  border-bottom: 1px solid var(--rule);
  padding: 0.55rem 0.6rem;
  vertical-align: top;
}

td code,
th code {
  white-space: nowrap;
}

/* ---------- Exercise steps ---------- */

.steps {
  counter-reset: step;
  list-style: none;
  padding: 0;
  margin: 1.25rem 0;
}

.steps > li {
  counter-increment: step;
  position: relative;
  padding-left: 2.4rem;
  margin-bottom: 0.9rem;
}

.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0.05rem;
  width: 1.6rem;
  height: 1.6rem;
  border: 1px solid var(--accent);
  border-radius: 50%;
  color: var(--accent);
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 650;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Quiz ---------- */

.quiz {
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: #fff;
  padding: 1.35rem;
  margin: 1.5rem 0;
}

.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.25rem;
}

.quiz-title {
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.quiz-score {
  font-family: var(--sans);
  font-size: 0.76rem;
  color: var(--faint);
}

.quiz-q {
  padding: 1.35rem 0 0.4rem;
  margin-top: 1.1rem;
  border-top: 1px solid var(--rule);
}

.quiz-header + .quiz-q {
  border-top: 0;
  margin-top: 0;
}

.q-text {
  font-family: var(--sans);
  font-size: 0.94rem;
  font-weight: 600;
  line-height: 1.45;
  margin: 0 0 0.85rem;
}

.q-options {
  display: grid;
  gap: 0.45rem;
}

.q-option {
  appearance: none;
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  width: 100%;
  text-align: left;
  font-family: var(--sans);
  font-size: 0.86rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 5px;
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}

.q-option:hover:not(:disabled) {
  border-color: var(--accent);
  background: #f3f8f8;
}

.q-option:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.q-option:disabled {
  cursor: default;
  opacity: 0.9;
}

.q-option .key {
  flex: none;
  width: 1.35rem;
  height: 1.35rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.q-option.is-correct {
  border-color: var(--ok);
  background: var(--ok-soft);
}

.q-option.is-correct .key {
  border-color: var(--ok);
  color: var(--ok);
}

.q-option.is-wrong {
  border-color: var(--bad);
  background: var(--bad-soft);
}

.q-option.is-wrong .key {
  border-color: var(--bad);
  color: var(--bad);
}

.q-feedback {
  font-family: var(--sans);
  font-size: 0.82rem;
  margin: 0.65rem 0 0;
}

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

.q-explain {
  font-size: 0.9rem;
  color: var(--muted);
  border-left: 2px solid var(--rule);
  padding-left: 0.8rem;
  margin: 0.55rem 0 0;
}

.quiz-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
}

.quiz-reset {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--accent);
  background: none;
  border: 1px solid var(--rule);
  border-radius: 5px;
  padding: 0.4rem 0.7rem;
  cursor: pointer;
}

.quiz-reset:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.quiz-hint {
  font-family: var(--sans);
  font-size: 0.74rem;
  color: var(--faint);
}

/* ---------- Primary source card ---------- */

.source-card {
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 1.15rem 1.25rem;
  background: #fff;
  margin: 1.25rem 0;
}

.source-card .kicker {
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--warm);
}

.source-card h3 {
  margin: 0.25rem 0 0.4rem;
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-transform: none;
  color: var(--ink);
}

.source-card p {
  font-size: 0.92rem;
  color: var(--muted);
  margin: 0;
}

/* ---------- Footer nav ---------- */

.lesson-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  border-top: 1px solid var(--rule);
  margin-top: 3.5rem;
  padding-top: 1.25rem;
  font-family: var(--sans);
  font-size: 0.82rem;
}

.lesson-nav a {
  text-decoration: none;
}

.lesson-nav .next {
  text-align: right;
}

.ask-teacher {
  margin-top: 2.5rem;
  padding: 1rem 1.15rem;
  border: 1px dashed var(--rule);
  border-radius: 6px;
  font-size: 0.92rem;
  color: var(--muted);
}

.ask-teacher strong {
  color: var(--ink);
}

/* ---------- Index page ---------- */

.lesson-list {
  list-style: none;
  padding: 0;
  margin: 1.25rem 0 2rem;
  border-top: 1px solid var(--rule);
}

.lesson-list li {
  display: grid;
  grid-template-columns: 2.7rem 1fr auto;
  gap: 0.9rem;
  align-items: start;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--rule);
}

.lesson-list .num {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--faint);
  padding-top: 0.22rem;
}

.lesson-list a {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.94rem;
  text-decoration: none;
}

.lesson-list p {
  margin: 0.15rem 0 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.status {
  font-family: var(--sans);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 99px;
  padding: 0.2rem 0.55rem;
  white-space: nowrap;
}

.status--done { color: var(--ok); background: var(--ok-soft); }
.status--current { color: var(--warm); background: var(--warm-soft); }
.status--ready { color: var(--accent); background: var(--accent-soft); }
.status--lookup { color: var(--muted); background: #f2efe8; }

.doc-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  font-family: var(--sans);
  font-size: 0.84rem;
}

.doc-links a {
  color: var(--accent);
  text-decoration: none;
}

.doc-links a:hover {
  text-decoration: underline;
}

/* ---------- Reference documents ---------- */

.ref-header {
  margin-bottom: 2rem;
}

.ref-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.ref-card {
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: #fff;
  padding: 1rem 1.1rem;
}

.ref-card h3 {
  margin-top: 0;
}

.ref-card p:last-child,
.ref-card ul:last-child {
  margin-bottom: 0;
}

.anatomy {
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.8;
  background: var(--code-bg);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 1rem 1.15rem;
  overflow-x: auto;
}

.anatomy .arrow {
  color: var(--warm);
}

.anatomy .ann {
  color: var(--faint);
  font-family: var(--sans);
  font-size: 0.7rem;
}

.tag {
  display: inline-block;
  font-family: var(--sans);
  font-size: 0.66rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 3px;
  padding: 0.15rem 0.4rem;
  vertical-align: middle;
}

/* ---------- Print ---------- */

@media print {
  html { font-size: 10.5pt; }
  body { background: #fff; }
  .page { max-width: none; padding: 0; }
  .lesson-nav,
  .quiz-reset,
  .quiz-hint,
  .no-print { display: none; }
  a { color: inherit; text-decoration: none; }
  pre,
  .quiz,
  .callout,
  .source-card,
  table { break-inside: avoid; }
  h2, h3 { break-after: avoid; }
}
