/* Lyceum: a blackboard down the left, paper on the right. */

@font-face {
  font-family: "Source Serif 4";
  src: url("vendor/fonts/source-serif-4-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Source Serif 4";
  src: url("vendor/fonts/source-serif-4-latin-wght-italic.woff2") format("woff2");
  font-weight: 200 900;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Archivo";
  src: url("vendor/fonts/archivo-latin-wdth-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("vendor/fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 800;
  font-display: swap;
}

:root {
  color-scheme: light;
  --board: #1e3a34;
  --board-deep: #172e29;
  --board-line: #2f5149;
  --chalk: #f1efe6;
  --chalk-dim: #a9bdb5;
  --chalk-mark: #f4d35e;

  --page: #f2f4f3;
  --paper: #ffffff;
  --plate: #ffffff;
  --wash: #f1f3f2;
  --ink: #1a1f1d;
  --ink-2: #5b6662;
  --rule: #dde3e0;
  --rule-strong: #b9c4bf;
  --action: #1e3a34;
  --action-ink: #ffffff;
  --link: #1d5c4d;
  --good: #0a7a1d;
  --good-wash: #e8f5ea;
  --bad: #b3261e;
  --bad-wash: #fbeceb;
  --note: #6a5200;
  --note-wash: #fbf4d9;

  --serif: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --sans: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --measure: 42rem;
  --wide: 52rem;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --board: #16211e;
  --board-deep: #111917;
  --board-line: #26342f;
  --page: #121413;
  --paper: #171a19;
  --plate: #191919;
  --wash: #212524;
  --ink: #ecefed;
  --ink-2: #9ba6a2;
  --rule: #2c3230;
  --rule-strong: #46504c;
  --action: #d9e6e0;
  --action-ink: #13201c;
  --link: #8fd3bd;
  --good: #53c556;
  --good-wash: #16291a;
  --bad: #f08a84;
  --bad-wash: #2e1918;
  --note: #f4d35e;
  --note-wash: #2a2614;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 17px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--serif);
  line-height: 1.65;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--link); text-underline-offset: 0.18em; }
:focus-visible { outline: 2px solid var(--chalk-mark); outline-offset: 2px; }
main :focus-visible { outline-color: var(--link); }

.skip { position: absolute; left: -999px; top: 0; background: var(--paper); padding: 0.5rem 1rem; z-index: 10; }
.skip:focus { left: 0; }

.shell { display: grid; grid-template-columns: 19rem minmax(0, 1fr); min-height: 100vh; }

/* ------------------------------------------------------------ the board */

.rail {
  background: var(--board);
  color: var(--chalk);
  font-family: var(--sans);
  font-size: 0.86rem;
  line-height: 1.35;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.rail a { color: inherit; text-decoration: none; }
.wordmark {
  display: block;
  padding: 1.5rem 1.4rem 1.1rem;
  font-size: 1.7rem;
  font-weight: 640;
  font-stretch: 118%;
  letter-spacing: -0.02em;
}
.rail-nav { padding: 0 0.7rem 0.9rem; border-bottom: 1px solid var(--board-line); }
.rail-nav a, .rail-lesson {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  padding: 0.42rem 0.7rem;
  border-radius: 4px;
}
.rail-nav a:hover, .rail-lesson:hover { background: var(--board-deep); }
.rail-nav a[aria-current="page"], .rail-lesson[aria-current="page"] {
  background: var(--board-deep);
  box-shadow: inset 3px 0 0 var(--chalk-mark);
}
.count {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  color: var(--board);
  background: var(--chalk-mark);
  border-radius: 99px;
  padding: 0 0.5em;
  font-weight: 600;
  font-size: 0.78rem;
}
.rail-course { padding: 1rem 0.7rem; flex: 1; }
.rail-course-title { padding: 0 0.7rem 0.3rem; font-weight: 640; font-stretch: 110%; font-size: 1rem; }
.rail-unit { margin-top: 0.9rem; }
.rail-unit-title { padding: 0 0.7rem 0.25rem; color: var(--chalk-dim); font-size: 0.78rem; }
.rail-lesson .tick { width: 0.9rem; flex: none; color: var(--chalk-mark); font-size: 0.8rem; }
.rail-lesson.todo .tick { color: var(--board-line); }
.rail-foot {
  margin-top: auto;
  padding: 0.8rem 0.9rem 1rem;
  border-top: 1px solid var(--board-line);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.rail-foot button {
  background: none;
  border: 1px solid var(--board-line);
  color: var(--chalk-dim);
  border-radius: 4px;
  padding: 0.3rem 0.6rem;
  font-size: 0.78rem;
  cursor: pointer;
}
.rail-foot button:hover { color: var(--chalk); border-color: var(--chalk-dim); }
.menu-button { display: none; }

/* ------------------------------------------------------------ the paper */

main { padding: 3.2rem clamp(1.2rem, 5vw, 4.5rem) 6rem; outline: none; }
.column { max-width: var(--measure); }
.column > .viz, .column > .exercise { max-width: none; width: min(var(--wide), 100%); }

.crumbs { font-family: var(--sans); font-size: 0.82rem; color: var(--ink-2); margin-bottom: 0.9rem; }
.crumbs a { color: inherit; }
h1, h2, h3, h4 { font-family: var(--sans); line-height: 1.15; letter-spacing: -0.012em; }
h1 { font-size: 2.55rem; font-weight: 660; font-stretch: 112%; margin: 0 0 0.6rem; letter-spacing: -0.028em; }
h2 { font-size: 1.45rem; font-weight: 640; font-stretch: 106%; margin: 2.8rem 0 0.7rem; }
h3 { font-size: 1.1rem; font-weight: 640; margin: 2rem 0 0.4rem; }
.lede { font-size: 1.15rem; color: var(--ink-2); margin: 0 0 0.4rem; max-width: 36rem; }
.meta { font-family: var(--sans); font-size: 0.82rem; color: var(--ink-2); margin-bottom: 2.4rem; }
p { margin: 0 0 1.05rem; }
.prose ul, .prose ol { padding-left: 1.4rem; margin: 0 0 1.05rem; }
.prose li { margin-bottom: 0.3rem; }
main table { border-collapse: collapse; margin: 1.2rem 0 1.5rem; font-family: var(--sans); font-size: 0.9rem; font-variant-numeric: tabular-nums; display: block; max-width: 100%; width: max-content; overflow-x: auto; }
main th, main td { padding: 0.4rem 0.9rem; border-bottom: 1px solid var(--rule); text-align: left; white-space: nowrap; }
main th { font-weight: 600; border-bottom-color: var(--rule-strong); }
code { font-family: var(--mono); font-size: 0.86em; background: var(--wash); padding: 0.08em 0.3em; border-radius: 3px; }
pre { background: var(--wash); padding: 0.9rem 1rem; border-radius: 4px; overflow-x: auto; font-size: 0.84rem; line-height: 1.5; }
pre code { background: none; padding: 0; font-size: inherit; }
div.math { margin: 1.1rem 0 1.3rem; overflow-x: auto; overflow-y: hidden; padding: 0.15rem 0; }
.katex { font-size: 1.06em; }

/* Definitions, theorems and the like: a ruled margin, the kind's name in sans. */
.admonition { margin: 1.5rem 0; padding: 0.1rem 0 0.1rem 1.1rem; border-left: 3px solid var(--board); }
:root[data-theme="dark"] .admonition { border-left-color: var(--link); }
.admonition-title { font-family: var(--sans); font-weight: 640; font-size: 0.95rem; margin-bottom: 0.3rem; }
.admonition > :last-child { margin-bottom: 0; }
.admonition.warning { border-left-color: var(--bad); }
.admonition.example { border-left-color: var(--rule-strong); }

/* ------------------------------------------------------------ buttons */

.btn {
  font-family: var(--sans);
  font-size: 0.86rem;
  font-weight: 560;
  border: 1px solid var(--rule-strong);
  background: var(--paper);
  color: var(--ink);
  border-radius: 4px;
  padding: 0.42rem 0.85rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  line-height: 1.3;
}
.btn:hover { border-color: var(--ink-2); }
.btn.primary { background: var(--action); color: var(--action-ink); border-color: var(--action); }
.btn.primary:hover { filter: brightness(1.15); }
.btn.quiet { border-color: transparent; background: none; color: var(--ink-2); padding-left: 0.4rem; padding-right: 0.4rem; }
.btn.quiet:hover { color: var(--ink); text-decoration: underline; }
.btn[disabled] { opacity: 0.55; cursor: default; }
.row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }

/* ------------------------------------------------------------ figures */

.viz, .exercise {
  margin: 2.2rem 0 2.4rem;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 6px;
}
.block-head {
  font-family: var(--sans);
  font-size: 0.86rem;
  padding: 0.65rem 1.1rem;
  border-bottom: 1px solid var(--rule);
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
}
.block-head .label { font-weight: 640; white-space: nowrap; }
.block-head .title { color: var(--ink-2); }
.block-head .state { margin-left: auto; white-space: nowrap; font-weight: 560; }
.state.good { color: var(--good); }
.state.bad { color: var(--bad); }

.viz-stage { background: var(--plate); padding: 0.8rem 1.1rem 0.4rem; min-height: 9rem; position: relative; }
.viz-stage svg { display: block; max-width: 100%; height: auto; margin: 0 auto; }
.viz-stage.busy svg { opacity: 0.55; transition: opacity 0.15s 0.25s; }
.viz-stage .waiting { font-family: var(--sans); font-size: 0.86rem; color: var(--ink-2); padding: 2.6rem 0; text-align: center; }
.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 0.7rem 1.6rem;
  padding: 0.9rem 1.1rem;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.86rem;
}
.control label { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: 0.15rem; }
.control output { font-variant-numeric: tabular-nums; font-weight: 600; }
.control input[type="range"] { width: 100%; accent-color: var(--link); }
.control input[type="number"], .control input[type="text"], .control select {
  width: 100%; background: var(--paper); border: 1px solid var(--rule-strong); border-radius: 4px; padding: 0.3rem 0.5rem;
}
.control.check label { justify-content: flex-start; gap: 0.5rem; align-items: center; }
.caption { padding: 0.8rem 1.1rem 0.9rem; border-top: 1px solid var(--rule); font-size: 0.93rem; color: var(--ink-2); }
.caption p:last-child { margin: 0; }
.viz-foot { padding: 0.5rem 0.7rem; border-top: 1px solid var(--rule); }
.editor-wrap { border-top: 1px solid var(--rule); }
.editor-actions { padding: 0.6rem 1.1rem; border-top: 1px solid var(--rule); }

.output {
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  padding: 0.7rem 1.1rem;
  border-top: 1px solid var(--rule);
  border-radius: 0;
  max-height: 16rem;
  overflow: auto;
}
.output.error { background: var(--bad-wash); color: var(--bad); }

.CodeMirror {
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.55;
  height: auto;
  background: var(--paper);
  color: var(--ink);
}
.CodeMirror-scroll { min-height: 6rem; max-height: 30rem; }
.CodeMirror-gutters { background: var(--paper); border-right: 1px solid var(--rule); }
.CodeMirror-linenumber { color: var(--rule-strong); }
.CodeMirror-cursor { border-left-color: var(--ink); }
.CodeMirror-selected, .CodeMirror-focused .CodeMirror-selected { background: var(--rule); }
.cm-s-default .cm-keyword { color: #7a3fb5; }
.cm-s-default .cm-def { color: #1757ac; }
.cm-s-default .cm-string { color: #a1470f; }
.cm-s-default .cm-number { color: #0a6b5a; }
.cm-s-default .cm-comment { color: var(--ink-2); font-style: italic; }
.cm-s-default .cm-builtin { color: #1757ac; }
.cm-s-default .cm-variable, .cm-s-default .cm-variable-2, .cm-s-default .cm-property, .cm-s-default .cm-operator { color: var(--ink); }
:root[data-theme="dark"] .cm-s-default .cm-keyword { color: #c4a5f5; }
:root[data-theme="dark"] .cm-s-default .cm-def, :root[data-theme="dark"] .cm-s-default .cm-builtin { color: #8bbcf5; }
:root[data-theme="dark"] .cm-s-default .cm-string { color: #f0a877; }
:root[data-theme="dark"] .cm-s-default .cm-number { color: #6fd6bf; }

/* ------------------------------------------------------------ exercises */

.exercise-body { padding: 1rem 1.1rem 1.1rem; }
.exercise-body > .prompt > :last-child { margin-bottom: 0.9rem; }
.answer-line { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; font-family: var(--sans); font-size: 0.9rem; }
.answer-line input[type="text"] {
  width: 12rem; border: 1px solid var(--rule-strong); background: var(--paper); border-radius: 4px; padding: 0.42rem 0.6rem;
  font-family: var(--mono); font-size: 0.88rem;
}
.options { list-style: none; padding: 0; margin: 0 0 0.9rem; }
.options li { margin: 0; }
.options label {
  display: flex; gap: 0.65rem; align-items: baseline; padding: 0.4rem 0.6rem; border-radius: 4px; cursor: pointer;
}
.options label:hover { background: var(--wash); }
.options label p { margin: 0; }
.options input { accent-color: var(--link); flex: none; }
.exercise textarea {
  width: 100%; min-height: 7rem; border: 1px solid var(--rule-strong); background: var(--paper); border-radius: 4px;
  padding: 0.6rem 0.7rem; margin-bottom: 0.7rem; resize: vertical; line-height: 1.5;
}
.exercise .editor-wrap { border: 1px solid var(--rule); border-radius: 4px; overflow: hidden; margin-bottom: 0.7rem; }
.feedback { font-family: var(--sans); font-size: 0.9rem; font-weight: 560; margin-top: 0.8rem; }
.feedback.good { color: var(--good); }
.feedback.bad { color: var(--bad); }
.tests { list-style: none; margin: 0.8rem 0 0; padding: 0; font-family: var(--sans); font-size: 0.88rem; }
.tests li { padding: 0.35rem 0; border-top: 1px solid var(--rule); display: grid; grid-template-columns: 1.4rem 1fr; }
.tests .pass { color: var(--good); }
.tests .fail { color: var(--bad); }
.tests pre { grid-column: 2; margin: 0.3rem 0 0; font-size: 0.78rem; white-space: pre-wrap; }
.exercise .output { border: 1px solid var(--rule); border-radius: 4px; margin-top: 0.8rem; }
.aside {
  margin-top: 0.9rem; padding: 0.8rem 1rem; border-radius: 4px; background: var(--note-wash); font-size: 0.95rem;
}
.aside.solution { background: var(--wash); }
.aside .aside-title { font-family: var(--sans); font-weight: 640; font-size: 0.82rem; margin-bottom: 0.3rem; }
.aside > :last-child { margin-bottom: 0; }
.aside pre { background: var(--paper); }
.help { margin-top: 0.8rem; }

/* ------------------------------------------------------------ pages */

.lesson-foot { margin-top: 3.5rem; padding-top: 1.4rem; border-top: 1px solid var(--rule-strong); display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

.course-list { list-style: none; margin: 2.2rem 0 0; padding: 0; border-top: 1px solid var(--rule-strong); }
.course-list > li { padding: 1.5rem 0 1.6rem; border-bottom: 1px solid var(--rule); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.4rem 2rem; align-items: start; }
.course-list h2 { margin: 0 0 0.3rem; font-size: 1.5rem; }
.course-list h2 a { color: inherit; text-decoration: none; }
.course-list h2 a:hover { text-decoration: underline; }
.course-list p { margin: 0; color: var(--ink-2); max-width: 34rem; }
.course-list .unwritten h2 { color: var(--ink-2); font-weight: 560; }
.progress { font-family: var(--sans); font-size: 0.82rem; color: var(--ink-2); margin-top: 0.8rem; display: flex; align-items: center; gap: 0.7rem; }
.bar { width: 11rem; height: 6px; background: var(--rule); border-radius: 3px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--link); border-radius: 3px; }

.unit { margin-top: 2.6rem; }
.unit h2 { margin: 0 0 0.2rem; }
.unit > p { color: var(--ink-2); margin: 0 0 0.8rem; }
.lesson-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule-strong); font-family: var(--sans); font-size: 0.95rem; }
.lesson-list li { border-bottom: 1px solid var(--rule); }
.lesson-list a, .lesson-list .planned { display: grid; grid-template-columns: 1.5rem minmax(0, 1fr) auto; gap: 0.3rem; padding: 0.7rem 0.2rem; text-decoration: none; color: inherit; align-items: baseline; }
.lesson-list a:hover .name { text-decoration: underline; }
.lesson-list .tick { color: var(--good); }
.lesson-list .sub { display: block; color: var(--ink-2); font-size: 0.84rem; font-family: var(--serif); margin-top: 0.1rem; }
.lesson-list .side { color: var(--ink-2); font-size: 0.8rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lesson-list .planned { color: var(--ink-2); }

.notice { font-family: var(--sans); font-size: 0.9rem; background: var(--note-wash); color: var(--ink); border-radius: 4px; padding: 0.7rem 1rem; margin: 1.6rem 0 0; display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.empty { color: var(--ink-2); margin-top: 2rem; }
.problem { font-family: var(--sans); background: var(--bad-wash); color: var(--bad); padding: 0.8rem 1rem; border-radius: 4px; }
.review-from { font-family: var(--sans); font-size: 0.8rem; color: var(--ink-2); margin: 2.2rem 0 -1.6rem; }

.login { display: grid; gap: 0.6rem; max-width: 22rem; margin-top: 1.6rem; font-family: var(--sans); font-size: 0.9rem; }
.login input { font-size: 16px; padding: 0.55rem 0.7rem; border: 1px solid var(--rule-strong); border-radius: 4px; background: var(--paper); }
.login .btn { justify-self: start; margin-top: 0.3rem; }

@media (max-width: 860px) {
  html { font-size: 16px; }
  .shell { display: block; }
  /* the board becomes a bar that stays at the top and opens over the page */
  .rail { position: sticky; top: 0; z-index: 20; height: auto; max-height: 100vh; max-height: 100dvh; }
  .rail-top { display: flex; align-items: center; justify-content: space-between; }
  .rail .wordmark { padding: 0.7rem 1rem; font-size: 1.25rem; }
  .menu-button { display: block; margin-right: 0.8rem; background: none; border: 1px solid var(--board-line); color: var(--chalk); border-radius: 4px; padding: 0.5rem 0.9rem; font-size: 0.86rem; cursor: pointer; min-height: 2.5rem; }
  .rail:not(.open) .rail-nav, .rail:not(.open) .rail-course, .rail:not(.open) .rail-foot { display: none; }
  .rail { font-size: 0.95rem; }
  .rail-nav a, .rail-lesson { padding: 0.65rem 0.7rem; }
  .rail-foot button { padding: 0.55rem 0.8rem; font-size: 0.86rem; }
  main { padding: 1.5rem 1rem 4rem; }
  h1 { font-size: 1.85rem; overflow-wrap: break-word; }
  h2 { font-size: 1.3rem; }
  .lede { font-size: 1.05rem; }
  .meta { margin-bottom: 1.6rem; }
  /* figures and exercises run edge to edge so they get the full width */
  .viz, .exercise { margin-left: -1rem; margin-right: -1rem; border-left: 0; border-right: 0; border-radius: 0; }
  .column > .viz, .column > .exercise { width: auto; }
  .block-head, .controls, .caption, .editor-actions, .output, .exercise-body { padding-left: 1rem; padding-right: 1rem; }
  .block-head { flex-wrap: wrap; }
  /* keep figure text readable: let a figure scroll sideways before it shrinks too far */
  .viz-stage { padding: 0.6rem 0.5rem 0.3rem; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .viz-stage svg, .exercise .figure svg { min-width: 27rem; }
  .exercise .figure { overflow-x: auto; }
  .controls { grid-template-columns: 1fr; }
  .control input[type="range"] { height: 2rem; }
  /* 16px inputs stop phones zooming the page on focus; larger targets for fingers */
  .answer-line input[type="text"], .control input, .control select, .exercise textarea { font-size: 16px; }
  .answer-line input[type="text"] { flex: 1 1 8rem; width: auto; min-width: 0; }
  .btn { padding: 0.65rem 1rem; font-size: 0.92rem; }
  .btn.quiet { padding-left: 0.5rem; padding-right: 0.5rem; }
  .options label { padding: 0.65rem 0.5rem; }
  .CodeMirror { font-size: 0.8rem; }
  .CodeMirror-scroll { max-height: 22rem; }
  .lesson-foot { flex-direction: column-reverse; }
  .lesson-foot .btn { text-align: center; }
  .course-list > li { grid-template-columns: 1fr; }
  .course-list .btn { justify-self: start; }
  .lesson-list a, .lesson-list .planned { grid-template-columns: 1.3rem minmax(0, 1fr); padding: 0.85rem 0.1rem; }
  .lesson-list .side { grid-column: 2; }
  .bar { width: 7rem; }
  .viz, .exercise, h2, h3 { scroll-margin-top: 4rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
@media print {
  .rail, .viz-foot, .lesson-foot, .help { display: none; }
  .shell { display: block; }
}
