/* Site stylesheet. Copied to site/assets/style.css by build_site.py.
   Palette roles (see PRODUCT.md): blue = action/link, green = progress,
   orange = numbering and highlights. Light by default, dark by system setting. */
:root {
  color-scheme: light dark;
  --bg: light-dark(#f6f7f9, #0d1117);
  --panel: light-dark(#ffffff, #161b22);
  --line: light-dark(#d0d7de, #30363d);
  --fg: light-dark(#1f2328, #e6edf3);
  --muted: light-dark(#59636e, #9da7b3);
  --accent: light-dark(#1865f2, #5b9cff);
  --accent-ink: light-dark(#ffffff, #0d1117);
  --accent-soft: light-dark(#eef4ff, #15294d);
  --ok: light-dark(#2e7d00, #58cc02);
  --hl: light-dark(#b45309, #f48024);
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Source Sans 3", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}
* { box-sizing: border-box; }
body {
  margin: 0; color: var(--fg); font: 16px/1.6 var(--sans);
  background: var(--bg);
}
::selection { background: var(--accent); color: var(--accent-ink); }
* { scrollbar-color: var(--line) transparent; }
.wrap { max-width: 1000px; margin: 0 auto; padding: 32px 20px 72px; }
a { color: var(--accent); text-decoration: none; text-underline-offset: 3px; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
header {
  border-bottom: 1px solid var(--line); padding-bottom: 20px; margin-bottom: 28px;
}
h1 {
  margin: 0 0 8px; font: 600 clamp(2rem, 4vw, 2.75rem) / 1.1 var(--serif);
  letter-spacing: -0.015em; text-wrap: balance;
}
h2 { font: 600 1.375rem / 1.25 var(--serif); margin: 34px 0 10px; text-wrap: balance; }
h3 { font: 600 1.125rem / 1.3 var(--serif); margin: 24px 0 8px; }
.sub { color: var(--muted); margin: 0; font-size: 1rem; }
.back {
  display: inline-flex; align-items: center; min-height: 44px; margin-bottom: 8px;
  font-size: 1rem;
}
footer {
  margin-top: 48px; padding-top: 18px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: 0.8125rem;
}

/* Home: books, parts, lesson rows */
h2.book { font-size: 1.75rem; margin: 44px 0 4px; }
h2.part { margin: 28px 0 4px; font: 600 1.25rem / 1.3 var(--serif); color: var(--muted); }
.lesson {
  position: relative; display: grid; grid-template-columns: 4.5rem 1fr auto;
  align-items: baseline; gap: 2px 16px; padding: 16px 12px;
  border-bottom: 1px solid var(--line); color: var(--fg);
  transition: background-color 0.2s var(--ease);
}
a.lesson:hover { background: var(--accent-soft); text-decoration: none; }
a.lesson:hover .t { color: var(--accent); }
.lesson .id { font: 600 1.5rem / 1 var(--serif); color: var(--hl); }
.lesson .t { font: 600 1.125rem / 1.3 var(--serif); }
.lesson .m {
  color: var(--muted); font-size: 0.875rem; font-variant-numeric: tabular-nums;
}
.lesson .prog {
  position: absolute; left: 0; bottom: -1px; height: 2px; width: 0;
  background: var(--ok);
}
.lesson.done .m { color: var(--ok); }
.resume {
  display: block; margin: 0 0 8px; padding: 14px 16px; border-radius: 10px;
  background: var(--accent-soft); color: var(--fg);
}
.resume[hidden] { display: none; }
.resume b { font-family: var(--serif); }

/* Lesson page: tabs, split layout, notes */
.tabs { display: flex; gap: 4px; margin: 0 0 18px; border-bottom: 1px solid var(--line); }
.tabs a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px;
  color: var(--muted); font-size: 1rem; border-bottom: 3px solid transparent;
  margin-bottom: -1px;
}
.tabs a:hover { color: var(--fg); text-decoration: none; }
.tabs a[aria-current="page"] { color: var(--accent); font-weight: 600; border-color: var(--accent); }
.wrap:has(.split) { max-width: 1500px; }
.split {
  display: grid; gap: 28px; align-items: start;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
}
.media { position: sticky; top: 16px; }
.notes { max-height: calc(100vh - 32px); overflow-y: auto; padding-right: 12px; }
.notes > :first-child { margin-top: 0; }
article { font: 1.0625rem / 1.7 var(--serif); max-width: 70ch; }
article h2 { margin: 34px 0 10px; }
article h2 { font-size: 1.75rem; }
article h3 { font-size: 1.375rem; }
article pre {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 14px; overflow-x: auto; font-size: 0.8125rem; line-height: 1.4;
}
article code { font-size: 0.92em; }
article table { border-collapse: collapse; display: block; overflow-x: auto; }
article th, article td { border: 1px solid var(--line); padding: 6px 10px; }
article blockquote {
  margin: 14px 0; padding: 6px 16px; background: var(--panel);
  border-radius: 8px; color: var(--muted);
}
.math.block { overflow-x: auto; }

/* Player */
.stage {
  background: #000; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--line);
}
.screen { position: relative; aspect-ratio: 16 / 9; }
.screen video {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block;
  opacity: 0; pointer-events: none;
}
.screen video.on { opacity: 1; pointer-events: auto; cursor: pointer; }
.overlay {
  position: absolute; inset: 0; display: grid; place-content: center; gap: 14px;
  justify-items: center; text-align: center; background: rgb(0 0 0 / 0.55); color: #fff;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity 0.3s var(--ease), visibility 0s 0.3s;
}
.stage[data-state="idle"] #big, .stage[data-state="ended"] #end,
.stage[data-state="error"] #msg, .stage[data-state="loading"] #msg {
  opacity: 1; visibility: visible; transition-delay: 0s;
}
.stage[data-state="idle"] #big, .stage[data-state="ended"] #end,
.stage[data-state="error"] #msg { pointer-events: auto; }
#big { background: none; }
#msg { background: rgb(0 0 0 / 0.7); font-size: 0.9375rem; }
.round {
  width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); border: 0; cursor: pointer;
}
.round svg { width: 30px; height: 30px; }
#end .links { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.btn {
  font: inherit; color: inherit; background: transparent; cursor: pointer;
  border: 1px solid currentColor; border-radius: 8px; padding: 8px 16px;
}
.btn:hover { background: rgb(255 255 255 / 0.12); text-decoration: none; }
.stage:fullscreen { display: flex; flex-direction: column; justify-content: center; }
.stage:fullscreen .screen { aspect-ratio: auto; flex: 1; }
.ctl {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  background: var(--panel); font-size: 0.875rem; font-variant-numeric: tabular-nums;
}
.ctl button, .ctl select {
  font: inherit; color: var(--fg); background: transparent; cursor: pointer;
  border: 1px solid var(--line); border-radius: 6px; padding: 0 10px;
  min-height: 44px; min-width: 44px; touch-action: manipulation; display: inline-grid; place-items: center;
}
.ctl button:hover, .ctl select:hover { border-color: var(--accent); }
.ctl button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.ctl svg { width: 18px; height: 18px; fill: currentColor; }
#pp .i-pause, #pp[data-playing] .i-play { display: none; }
#pp[data-playing] .i-pause { display: block; }
.bar { position: relative; flex: 1; display: flex; align-items: center; min-width: 0; }
.bar input {
  width: 100%; margin: 0; min-height: 44px; accent-color: var(--accent);
  touch-action: pan-y;
}
#ticks { position: absolute; inset: 0; pointer-events: none; }
#ticks i {
  position: absolute; top: 25%; bottom: 25%; width: 2px; background: var(--hl);
}
.keys { margin: 10px 0 0; color: var(--muted); font-size: 0.8125rem; }
.keys summary { cursor: pointer; }
.keys dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; margin: 8px 0 0; }
.keys dt { color: var(--fg); font-variant-numeric: tabular-nums; }
.keys dd { margin: 0; }
details.chapters { margin-top: 14px; }
details.chapters > summary {
  cursor: pointer; font: 600 0.875rem var(--sans); color: var(--muted);
}
ol.clips { list-style: none; padding: 0; margin: 10px 0 0; }
ol.clips li { margin-bottom: 8px; }
.media ol.clips { max-height: 38vh; overflow-y: auto; }
button.clip {
  width: 100%; text-align: left; cursor: pointer; font: inherit; min-height: 44px;
  background: var(--panel); color: var(--fg); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 14px; display: flex;
  justify-content: space-between; gap: 12px; align-items: center;
  transition: border-color 0.2s var(--ease);
}
button.clip:hover { border-color: var(--accent); }
button.clip[aria-current="true"] { border-color: var(--accent); background: var(--accent-soft); }
button.clip[aria-current="true"] .n::after { content: " ·"; }
button.clip .n {
  color: var(--hl); font-variant-numeric: tabular-nums; margin-right: 10px;
}
button.clip .d {
  color: var(--muted); font-size: 0.8125rem; font-variant-numeric: tabular-nums;
}

@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; }
  .media { display: contents; }
  .stage { position: sticky; top: 0; z-index: 5; }
  .notes { max-height: none; }
  .media ol.clips { max-height: 40vh; }
}
@media (max-width: 560px) {
  .wrap { padding: 20px 14px 56px; }
  .ctl { flex-wrap: wrap; }
  .bar { order: -1; flex-basis: 100%; }
  .lesson { grid-template-columns: 3.5rem 1fr; }
  .lesson .m { grid-column: 2; }
}
/* Home: course cards (a .lesson row without an id column) */
.lesson.course { grid-template-columns: 1fr auto; padding: 18px 6px; }
.lesson.course .t { font-size: 1.375rem; }

.skip {
  position: absolute; left: 12px; top: -64px; z-index: 10; padding: 10px 16px;
  background: var(--accent); color: var(--accent-ink); border-radius: 8px;
}
.skip:focus { top: 12px; }

/* Lesson drawings: inline SVG from ```svg fences, coloured by the site theme */
figure.diagram { margin: 20px 0; }
.diagram svg { display: block; width: 100%; max-width: 640px; height: auto; margin: 0 auto; }
.diagram text { fill: var(--fg); font: 16px var(--sans); text-anchor: middle; }
.diagram text.big { font: 600 30px var(--serif); }
.diagram text.sm { font-size: 13px; fill: var(--muted); }
.diagram text.t-hl { fill: var(--hl); }
.diagram text.t-ac { fill: var(--accent); }
.diagram .box { fill: var(--panel); stroke: var(--line); stroke-width: 2; }
.diagram .ax { stroke: var(--fg); stroke-width: 2; fill: none; }
.diagram .tk { stroke: var(--muted); stroke-width: 1.5; fill: none; }
.diagram .hl { stroke: var(--hl); stroke-width: 3; fill: none; }
.diagram .ac { stroke: var(--accent); stroke-width: 3; fill: none; }
.diagram .fa { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 2; }
.diagram .fh { fill: color-mix(in srgb, var(--hl) 22%, transparent); stroke: var(--hl); stroke-width: 2; }
.diagram .dot { fill: var(--hl); stroke: none; }
.diagram .dot.ac { fill: var(--accent); }
.diagram polygon.hl { fill: var(--hl); stroke: none; }
.diagram text.l { text-anchor: start; }
.diagram text.r { text-anchor: end; }
.diagram .fo { fill: color-mix(in srgb, var(--ok) 22%, transparent); stroke: var(--ok); stroke-width: 2; }
.diagram .ok { stroke: var(--ok); stroke-width: 3; fill: none; }
.diagram text.t-ok { fill: var(--ok); }
.diagram .thin { stroke: var(--muted); stroke-width: 1; fill: none; }
.diagram .curve { stroke: var(--accent); stroke-width: 3; fill: none; stroke-linejoin: round; }
.diagram .curve2 { stroke: var(--hl); stroke-width: 3; fill: none; stroke-linejoin: round; }
.diagram .hole { fill: var(--bg); stroke: var(--hl); stroke-width: 3; }
