/* Library courses: syllabus, lesson navigation, math, step-through figures
   and live SQL (docs/decisions/0017, 0018, 0019). Only house-style's tokens
   from main.css; the look is the site's terminal look (0007): monospace,
   dashed rules, the success green as the one accent. */

/* ---- courses ---- */

.lib-group { font-size: 0.875rem; font-weight: 400; color: var(--muted-foreground); margin: 2.5rem 0 0; text-transform: lowercase; }
.lib-group::before { content: "# "; }
.lesson-no { margin: 0 0 0.25rem; font-size: 0.875rem; color: var(--success); }
.syllabus-part { font-size: 1rem; margin: 1.75rem 0 0.25rem; }
.syllabus-part::before { content: "### "; color: var(--muted-foreground); }
.syllabus .planned > span:last-child { color: var(--muted-foreground); }
.syllabus .status { font-size: 0.8rem; color: var(--muted-foreground); }
.syllabus .current a { font-weight: 700; text-decoration: none; }
.syllabus .current a::before { content: "> "; color: var(--success); }

.course-nav {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 3rem;
  padding-top: 1rem; border-top: 1px dashed var(--border);
}
.course-nav a { display: block; text-decoration: none; }
.course-nav a span { display: block; font-size: 0.875rem; color: var(--muted-foreground); }
.course-nav a:hover { text-decoration: underline; }
.course-nav .next { text-align: right; grid-column: 2; }

/* ---- math (MathML, drawn by the browser) ---- */

math { font-size: 1.1em; }
.math-display { margin: 0 0 1rem; overflow-x: auto; overflow-y: hidden; padding: 0.25rem 0; }
.math-display math { display: block math; }

/* ---- step-through figures ---- */

.steps { border: 1px solid var(--border); border-radius: 4px; padding: 1rem; }
/* On a wide screen a figure may be wider than the 46rem text column, up to
   58rem, centred on it, so drawings ~880 units wide keep their text size. */
@media (min-width: 62rem) {
  .steps { width: 58rem; box-sizing: border-box; margin-left: 50%; transform: translateX(-50%); }
}
.steps:focus { outline: none; }
.steps-stage { overflow-x: auto; min-height: 4rem; }
.steps-stage svg { display: block; max-width: 100%; height: auto; margin: 0 auto; font-family: var(--mono); }
.steps-fallback { color: var(--muted-foreground); font-size: 0.875rem; margin: 0; }
.steps-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem;
  margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px dashed var(--border);
}
.steps-bar input[type="range"] { flex: 1 1 8rem; accent-color: var(--success); }
.steps-count { font-size: 0.875rem; color: var(--muted-foreground); min-width: 3.5rem; text-align: right; }
.steps-caption { margin: 0.75rem 0 0; min-height: 3em; }
.steps figcaption { border-top: 1px dashed var(--border); padding-top: 0.5rem; }

.steps button, .sql-bar button {
  font: inherit; font-size: 0.875rem; color: var(--foreground); background: var(--muted);
  border: 1px solid var(--border); border-radius: 3px; padding: 0.2rem 0.6rem; cursor: pointer;
}
.steps button:hover:not(:disabled), .sql-bar button:hover:not(:disabled) { border-color: var(--foreground); }
.steps button:disabled, .sql-bar button:disabled { color: var(--muted-foreground); cursor: default; }
.steps-play { min-width: 4.5rem; }

/* Shared pieces widgets draw with, so each widget stays small. A "cell" is
   a box of text; .on marks what the current step is about, .new what it
   just added, .gone what it removed. */
.w-row { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: stretch; margin: 0.35rem 0; }
.w-label { font-size: 0.875rem; color: var(--muted-foreground); margin: 0.6rem 0 0.2rem; }
.w-cell {
  border: 1px solid var(--border); border-radius: 3px; padding: 0.15rem 0.45rem;
  background: var(--background); white-space: pre; font-size: 0.875rem;
}
.w-cell.on { border-color: var(--success); box-shadow: inset 0 0 0 1px var(--success); }
.w-cell.new { background: var(--warning-soft); }
.w-cell.gone { color: var(--muted-foreground); text-decoration: line-through; border-style: dashed; }
.w-table { border-collapse: collapse; font-size: 0.875rem; margin: 0.25rem 0 0.5rem; }
.w-table th, .w-table td { border: 1px solid var(--border); padding: 0.15rem 0.5rem; text-align: left; white-space: pre; }
.w-table th { color: var(--muted-foreground); font-weight: 400; }
.w-table tr.on td { box-shadow: inset 0 0 0 1px var(--success); }
.w-table tr.new td { background: var(--warning-soft); }
.w-table tr.gone td { color: var(--muted-foreground); text-decoration: line-through; }
.w-svg-line { stroke: var(--border); }
.w-svg-on { stroke: var(--success); fill: none; }
/* Sizes in SVG units. A widget drawn wider than the text column shows at
   full size because the figure widens (.steps below); on a narrow screen it
   scrolls sideways rather than shrinking its text under the floor (0007). */
.w-svg-text { fill: var(--foreground); font-size: 13px; }
.w-svg-muted { fill: var(--muted-foreground); font-size: 12px; }

.w-svg-box { fill: var(--background); stroke: var(--border); }
.w-svg-box.on { stroke: var(--success); stroke-width: 2; }
.w-svg-box.new { fill: var(--warning-soft); }

/* ---- live SQL ---- */

.sql { margin: 0 0 1.25rem; border: 1px solid var(--border); border-radius: 4px; }
.sql .sql-src pre, .sql pre { margin: 0; border: 0; border-radius: 0; }
.sql-edit {
  display: block; width: 100%; box-sizing: border-box; margin: 0; padding: 0.9rem 1rem;
  font-family: var(--mono); font-size: 0.875rem; line-height: 1.5; resize: vertical;
  color: var(--foreground); background: var(--muted); border: 0; border-bottom: 1px solid var(--border);
}
.sql-edit:focus { outline: 2px solid var(--foreground); outline-offset: -2px; }
.sql-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem;
  padding: 0.4rem 1rem; border-top: 1px dashed var(--border); border-bottom: 1px dashed var(--border);
}
.sql-status { font-size: 0.8rem; color: var(--muted-foreground); }
.sql-out pre.sql-result { background: var(--background); font-size: 0.875rem; }
.sql-out pre.sql-error { color: var(--foreground); background: var(--warning-soft); }

/* ---- answers (layouts/_shortcodes/answer.html) ---- */

.answer { margin: 0 0 1rem; border: 1px dashed var(--border); border-radius: 4px; padding: 0.4rem 1rem; }
.answer summary { cursor: pointer; color: var(--muted-foreground); font-size: 0.875rem; }
.answer summary::before { content: "$ cat "; color: var(--success); }
.answer[open] summary { margin-bottom: 0.5rem; }
