/* Public site styling.
 *
 * Reading-first: a single measure for prose, generous line height, serif body.
 * Neutrals carry a slight blue bias so they read as chosen rather than default,
 * with one plot-blue accent and a warm secondary reserved for the places where
 * the learner acts (answers, run buttons) rather than reads. */

:root {
  --paper: #fafbfc;
  --panel: #f1f4f8;
  --ink: #12161c;
  --muted: #5c6675;
  --rule: #dde3ea;
  --accent: #1f5fa8;
  --accent-dim: #e7eff8;
  --warm: #9a5b16;
  --warm-dim: #fbf3e8;
  --good: #1d7a4c;
  --bad: #a52f2f;

  --measure: 36rem;
  --wide: 62rem;
  --serif: Charter, "Bitstream Charter", "Iowan Old Style", Georgia, serif;
  --grotesque: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f1319;
    --panel: #171d25;
    --ink: #e4e9ef;
    --muted: #8c96a5;
    --rule: #262e39;
    --accent: #74a9e6;
    --accent-dim: #15202d;
    --warm: #d3a066;
    --warm-dim: #221a10;
    --good: #5cc48d;
    --bad: #e08585;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.68;
  -webkit-text-size-adjust: 100%;
}

main { max-width: var(--wide); margin: 0 auto; padding: 2.5rem 1.25rem 6rem; }
main > .course, main > article { max-width: var(--measure); margin: 0 auto; }

/* ------------------------------------------------------------- chrome */

.site-header {
  border-bottom: 1px solid var(--rule);
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 0.9rem 1.25rem;
  font-family: var(--grotesque);
  max-width: var(--wide); margin: 0 auto;
}
.wordmark { font-weight: 700; letter-spacing: -0.01em; text-decoration: none; color: var(--ink); }
.site-header nav a { margin-left: 1.1rem; font-size: 0.9rem; color: var(--muted); text-decoration: none; }
.site-header nav a:hover { color: var(--accent); }

.site-footer {
  border-top: 1px solid var(--rule);
  max-width: var(--wide); margin: 0 auto; padding: 1.5rem 1.25rem 3rem;
  font-family: var(--grotesque); font-size: 0.82rem; color: var(--muted);
}

.crumbs { font-family: var(--grotesque); font-size: 0.85rem; color: var(--muted); margin-bottom: 1.6rem; }
.crumbs a { color: var(--accent); text-decoration: none; }

/* ------------------------------------------------------------ typography */

h1, h2, h3, h4 { font-family: var(--grotesque); line-height: 1.22; text-wrap: balance; font-weight: 650; }
h1 { font-size: clamp(1.7rem, 1.3rem + 1.8vw, 2.2rem); letter-spacing: -0.02em; margin: 0 0 0.5rem; }
h2 { font-size: 1.3rem; margin: 3rem 0 0.9rem; padding-top: 1.3rem; border-top: 1px solid var(--rule); }
h3 { font-size: 1.08rem; margin: 2rem 0 0.6rem; }

p { margin: 0 0 1.15em; }
a { color: var(--accent); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }

.subtitle { color: var(--muted); font-family: var(--grotesque); font-size: 1.02rem; }
.meta, .blurb { font-family: var(--grotesque); font-size: 0.85rem; color: var(--muted); }
.prereqs { font-family: var(--grotesque); font-size: 0.88rem; color: var(--muted); }

pre, table { overflow-x: auto; max-width: 100%; }
pre {
  background: var(--panel); border: 1px solid var(--rule); border-radius: 5px;
  padding: 0.9rem 1.05rem; font-size: 0.85em; line-height: 1.55;
}
code { font-family: var(--mono); font-size: 0.875em; }
p code, li code { background: var(--panel); border: 1px solid var(--rule); padding: 0.06em 0.3em; border-radius: 3px; }
pre code { background: none; border: 0; padding: 0; }
img, svg { max-width: 100%; height: auto; display: block; margin: 1.9em auto; }
video { width: 100%; border-radius: 6px; background: #000; border: 1px solid var(--rule); }

table { border-collapse: collapse; font-family: var(--grotesque); font-size: 0.9em; margin: 1.6em 0; }
th, td { border: 1px solid var(--rule); padding: 0.5em 0.75em; text-align: left; }
th { background: var(--panel); font-weight: 600; }

/* --------------------------------------------------------------- cards */

.hero { max-width: var(--measure); margin: 1rem auto 3rem; }
.cards { list-style: none; padding: 0; margin: 0; display: grid; gap: 1rem;
         grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--rule); border-radius: 6px; padding: 1.1rem 1.25rem; }
.card h3 { margin: 0 0 0.4rem; font-size: 1.02rem; }
.card a { text-decoration: none; }
.card p { font-family: var(--grotesque); font-size: 0.88rem; color: var(--muted); margin: 0 0 0.4rem; }

/* --------------------------------------------------------------- track */

.track-list { list-style: none; padding: 0; counter-reset: step; max-width: var(--measure); margin: 2rem auto; }
.track-list li { display: grid; grid-template-columns: 2.4rem 1fr; gap: 1rem; padding: 1rem 0; border-top: 1px solid var(--rule); }
.step {
  font-family: var(--grotesque); font-variant-numeric: tabular-nums; font-weight: 650;
  color: var(--accent); background: var(--accent-dim);
  width: 2rem; height: 2rem; border-radius: 50%;
  display: grid; place-items: center; font-size: 0.85rem;
}
.track-list a { font-family: var(--grotesque); font-weight: 600; text-decoration: none; }
.after { color: var(--muted); }

/* ---------------------------------------------------------- objectives */

.objectives { background: var(--panel); border: 1px solid var(--rule); border-radius: 6px; padding: 1.1rem 1.35rem; margin: 2rem 0; }
.objectives h2 { margin: 0 0 0.7rem; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); border: 0; padding: 0; }
.objectives ul { margin: 0; padding-left: 1.1rem; font-size: 0.95rem; }
.bloom { font-family: var(--grotesque); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em;
         color: var(--accent); background: var(--accent-dim); padding: 0.1em 0.45em; border-radius: 3px; margin-right: 0.5rem; }

.toc { background: var(--panel); border: 1px solid var(--rule); border-radius: 5px; padding: 1rem 1.25rem; margin-bottom: 2.5rem; font-family: var(--grotesque); font-size: 0.9rem; }
.toc-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin: 0 0 0.5rem; font-weight: 600; }
.toc ul { list-style: none; padding-left: 0; margin: 0; }
.toc ul ul { padding-left: 1rem; }
.toc a { color: var(--ink); text-decoration: none; }
.toc a:hover { color: var(--accent); }

/* ---------------------------------------------------------------- quiz */

.quiz { margin-top: 3rem; }
.quiz-q { border: 1px solid var(--rule); border-radius: 6px; padding: 1.1rem 1.25rem; margin: 1rem 0; background: var(--panel); }
.quiz-q .prompt { font-weight: 600; margin-bottom: 0.8rem; }
/* Flex, not block: a long option must wrap under its own text, not back to
   the left margin where it reads as a separate line. */
.quiz-opt {
  display: flex; align-items: flex-start; gap: 0.55rem;
  padding: 0.45rem 0.6rem; border-radius: 4px; cursor: pointer; font-size: 0.96rem;
}
.quiz-opt:hover { background: var(--accent-dim); }
.quiz-opt input { margin: 0.35rem 0 0; flex: none; }
.quiz-q.correct { border-color: var(--good); }
.quiz-q.incorrect { border-color: var(--bad); }
.verdict { font-family: var(--grotesque); font-size: 0.85rem; font-weight: 600; margin-top: 0.7rem; }
.verdict.correct { color: var(--good); }
.verdict.incorrect { color: var(--bad); }
.explanation { background: var(--warm-dim); border-left: 3px solid var(--warm); border-radius: 4px; padding: 0.7rem 0.9rem; margin-top: 0.7rem; font-size: 0.93rem; }
.quiz input[type="text"], .quiz input[type="number"] {
  font: inherit; padding: 0.4rem 0.6rem; border: 1px solid var(--rule);
  border-radius: 4px; background: var(--paper); color: var(--ink); width: 100%; max-width: 22rem;
}
button {
  font-family: var(--grotesque); font-size: 0.88rem; font-weight: 600;
  background: var(--accent); color: #fff; border: 0; border-radius: 4px;
  padding: 0.45rem 0.9rem; cursor: pointer;
}
button.secondary { background: transparent; color: var(--accent); border: 1px solid var(--rule); }
button:hover { filter: brightness(1.08); }

/* ------------------------------------------------------------ sandbox */

.sandbox { border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; margin: 1.5rem 0; }
.sandbox h3 { margin: 0; padding: 0.8rem 1.1rem; background: var(--panel); border-bottom: 1px solid var(--rule); font-size: 0.95rem; }
.sandbox > p { padding: 0 1.1rem; font-size: 0.93rem; color: var(--muted); }
.sandbox-code {
  width: 100%; min-height: 16rem; border: 0; border-top: 1px solid var(--rule);
  font-family: var(--mono); font-size: 0.85rem; line-height: 1.55;
  padding: 0.9rem 1.1rem; resize: vertical; background: var(--paper); color: var(--ink);
}
.sandbox-bar { display: flex; align-items: center; gap: 0.6rem; padding: 0.7rem 1.1rem; background: var(--panel); border-top: 1px solid var(--rule); }
.sandbox-bar .status { font-family: var(--grotesque); font-size: 0.8rem; color: var(--muted); }
.sandbox-output { margin: 0; border-top: 1px solid var(--rule); border-radius: 0; min-height: 2.5rem; white-space: pre-wrap; }
.sandbox-output:empty { display: none; }
.sandbox-output.error { color: var(--bad); }

/* ---------------------------------------------------- assignments etc */

.assignment { border: 1px solid var(--rule); border-radius: 6px; padding: 1.2rem 1.35rem; margin: 1.2rem 0; }
.deliverable { background: var(--accent-dim); border-radius: 4px; padding: 0.7rem 0.9rem; font-size: 0.94rem; }
.rubric { width: 100%; }
.resources ul { list-style: none; padding: 0; }
.resources li { padding: 0.7rem 0; border-top: 1px solid var(--rule); }
.resources .meta { display: block; }
.chapters { list-style: none; padding: 0; font-family: var(--grotesque); }
.chapters li { display: grid; grid-template-columns: 4rem 1fr; gap: 0.8rem; padding: 0.4rem 0; border-top: 1px solid var(--rule); }
.chapters button { background: none; color: var(--accent); padding: 0; font-variant-numeric: tabular-nums; }

.csl-entry { font-family: var(--grotesque); font-size: 0.88rem; color: var(--muted); margin-bottom: 0.7em; padding-left: 1.4em; text-indent: -1.4em; }
#refs { margin-top: 3rem; padding-top: 1.4rem; border-top: 2px solid var(--rule); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
