/* Shared styles for every page in the course. Lessons link this file and nothing else. */
:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --surface-2: #f2f0ea;
  --text: #1d1d1b;
  --muted: #5f5e58;
  --border: #e2dfd6;
  --accent: #2f5bd3;
  --accent-soft: #e6ecfb;
  --dlg: #c2410c;      /* section colour: deep learning project */
  --dlg-soft: #fbeadf;
  --mlp: #0f766e;      /* section colour: machine learning project */
  --mlp-soft: #ddf1ee;
  --good: #15803d;
  --bad: #b91c1c;
  --code-bg: #f4f2ec;
  --radius: 12px;
  --maxw: 860px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141413; --surface: #1d1d1b; --surface-2: #262623; --text: #ecebe6; --muted: #a8a69e;
    --border: #34332f; --accent: #8aa8ff; --accent-soft: #232c45; --dlg: #fb923c; --dlg-soft: #3a2518;
    --mlp: #2dd4bf; --mlp-soft: #13302c; --good: #4ade80; --bad: #f87171; --code-bg: #232320;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141413; --surface: #1d1d1b; --surface-2: #262623; --text: #ecebe6; --muted: #a8a69e;
  --border: #34332f; --accent: #8aa8ff; --accent-soft: #232c45; --dlg: #fb923c; --dlg-soft: #3a2518;
  --mlp: #2dd4bf; --mlp-soft: #13302c; --good: #4ade80; --bad: #f87171; --code-bg: #232320;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.65 var(--font); -webkit-font-smoothing: antialiased;
}
body[data-section="dlg"] { --sec: var(--dlg); --sec-soft: var(--dlg-soft); }
body[data-section="mlp"] { --sec: var(--mlp); --sec-soft: var(--mlp-soft); }
body:not([data-section]) { --sec: var(--accent); --sec-soft: var(--accent-soft); }

a { color: var(--accent); text-underline-offset: 2px; }
img, video, canvas, svg { max-width: 100%; }
code, pre, kbd { font-family: var(--mono); font-size: 0.88em; }
:not(pre) > code { background: var(--code-bg); padding: 0.1em 0.35em; border-radius: 5px; }
pre {
  background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; overflow-x: auto; line-height: 1.5;
}
h1, h2, h3 { line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.8rem, 4vw, 2.5rem); margin: 0.2em 0 0.3em; }
h2 { font-size: 1.5rem; margin-top: 2.2em; padding-top: 0.4em; border-top: 1px solid var(--border); }
h3 { font-size: 1.15rem; margin-top: 1.6em; }
table { border-collapse: collapse; width: 100%; font-size: 0.93em; margin: 1em 0; }
th, td { border-bottom: 1px solid var(--border); padding: 8px 10px; text-align: left; }
th { background: var(--surface-2); font-weight: 600; }
.table-wrap { overflow-x: auto; }

/* ---------- Layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.topbar .brand { font-weight: 700; text-decoration: none; color: var(--text); }
.topbar .crumb { color: var(--muted); font-size: 0.92em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .spacer { flex: 1; }
.icon-btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 8px; padding: 6px 10px; cursor: pointer; font: inherit; font-size: 0.9em;
}
.progress-bar { position: fixed; top: 0; left: 0; height: 3px; background: var(--sec); z-index: 30; width: 0; }

main { max-width: var(--maxw); margin: 0 auto; padding: 24px 16px 80px; }
main.wide { max-width: 1100px; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.78rem; font-weight: 700; color: var(--sec); }
.lede { font-size: 1.15rem; color: var(--muted); }

/* ---------- Building blocks lessons can use ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; margin: 1.2em 0;
}
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.callout { border-left: 4px solid var(--sec); background: var(--sec-soft); padding: 12px 16px; border-radius: 0 var(--radius) var(--radius) 0; margin: 1.2em 0; }
.callout.tip { border-color: var(--good); }
.callout.warn { border-color: var(--bad); }
.callout > :first-child { margin-top: 0; }
.callout > :last-child { margin-bottom: 0; }
.keypoints { background: var(--surface); border: 1px dashed var(--sec); border-radius: var(--radius); padding: 12px 20px; }
figure { margin: 1.5em 0; }
figure img, figure video { display: block; width: 100%; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
figcaption { color: var(--muted); font-size: 0.88em; margin-top: 6px; }
.stat-row { display: flex; flex-wrap: wrap; gap: 12px; margin: 1em 0; }
.stat { flex: 1 1 140px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.stat .v { font-size: 1.6rem; font-weight: 700; color: var(--sec); font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: 0.85em; }

/* Interactive demo container */
.demo {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin: 1.6em 0;
}
.demo > .demo-title { font-weight: 700; margin: 0 0 4px; }
.demo > .demo-title::before { content: "▶ Try it  "; color: var(--sec); font-size: 0.8em; letter-spacing: 0.05em; }
.demo .controls { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; margin: 10px 0; }
.demo label { font-size: 0.9em; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.demo input[type="range"] { accent-color: var(--sec); width: 180px; }
.demo button, .btn {
  background: var(--sec); color: #fff; border: 0; border-radius: 8px; padding: 7px 14px;
  font: inherit; font-size: 0.92em; cursor: pointer;
}
.demo button.secondary, .btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.demo .out { font-family: var(--mono); font-size: 0.9em; color: var(--muted); }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-top: 1em; flex-wrap: wrap; }
.tabs button { background: none; border: 0; padding: 8px 12px; cursor: pointer; color: var(--muted); font: inherit; border-bottom: 2px solid transparent; }
.tabs button[aria-selected="true"] { color: var(--text); border-color: var(--sec); }
.tab-panel[hidden] { display: none; }

/* Quiz: <div class="quiz" data-answer="1"><p class="q">…</p><ol><li>…</li></ol><p class="why">…</p></div> */
.quiz { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; margin: 1.2em 0; }
.quiz .q { font-weight: 600; margin-top: 0; }
.quiz ol { list-style: upper-alpha; padding-left: 1.4em; }
.quiz li { cursor: pointer; padding: 4px 8px; border-radius: 6px; margin: 2px 0; }
.quiz li:hover { background: var(--surface-2); }
.quiz li.right { background: color-mix(in srgb, var(--good) 18%, transparent); }
.quiz li.wrong { background: color-mix(in srgb, var(--bad) 18%, transparent); }
.quiz .why { display: none; color: var(--muted); font-size: 0.93em; margin-bottom: 0; }
.quiz.answered .why { display: block; }

/* Lesson pager */
.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 3em; flex-wrap: wrap; }
.pager a { flex: 1 1 200px; text-decoration: none; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; background: var(--surface); color: var(--text); }
.pager a:hover { border-color: var(--sec); }
.pager small { display: block; color: var(--muted); }
.pager .next { text-align: right; }

/* Lesson list on section / home pages */
.lesson-list { list-style: none; padding: 0; counter-reset: l; }
.lesson-list li { counter-increment: l; margin: 10px 0; }
.lesson-list a { display: flex; gap: 14px; align-items: baseline; text-decoration: none; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; }
.lesson-list a:hover { border-color: var(--sec); }
.lesson-list a::before { content: counter(l, decimal-leading-zero); font-family: var(--mono); color: var(--sec); font-weight: 700; }
.lesson-list .done-mark { margin-left: auto; color: var(--good); font-size: 0.9em; }
.lesson-list span.desc { display: block; color: var(--muted); font-size: 0.9em; }

.hero { padding: 40px 0 10px; }
.section-card { display: block; text-decoration: none; color: var(--text); border-top: 6px solid var(--sec); }
.section-card:hover { box-shadow: 0 6px 24px rgb(0 0 0 / 0.08); }

/* ---------- Course navigation (built by course.js) ---------- */
a.icon-btn { text-decoration: none; display: inline-flex; align-items: center; }
.icon-btn:hover { border-color: var(--sec); }
.section-links { display: flex; gap: 4px; }
.section-links a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 8px; font-size: 0.9em; }
.section-links a:hover { color: var(--text); background: var(--surface-2); }
.section-links a[aria-current] { color: var(--text); font-weight: 600; box-shadow: inset 0 -2px 0 var(--sec); }

.course-nav {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 40; width: min(300px, 86vw);
  overflow-y: auto; background: var(--surface); border-right: 1px solid var(--border);
  padding: 16px 12px 40px; transform: translateX(-100%); transition: transform 0.2s ease;
  font-size: 0.92rem; line-height: 1.4;
}
.nav-open .course-nav { transform: none; box-shadow: 0 0 40px rgb(0 0 0 / 0.2); }
.nav-scrim { position: fixed; inset: 0; z-index: 35; background: rgb(0 0 0 / 0.35); opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }
.course-nav ul { list-style: none; margin: 0; padding: 0; }
.course-nav a { display: flex; gap: 8px; align-items: baseline; color: var(--text); text-decoration: none; padding: 6px 10px; border-radius: 8px; }
.course-nav a:hover { background: var(--surface-2); }
.course-nav a[aria-current="page"] { background: var(--sec-soft); font-weight: 600; }
.nav-home { font-weight: 700; margin-bottom: 6px; }
.nav-section { margin-top: 14px; }
.nav-sec-title { margin: 0 0 4px; padding: 0 10px; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.nav-section[data-sec="dlg"] .nav-sec-title { color: var(--dlg); }
.nav-section[data-sec="mlp"] .nav-sec-title { color: var(--mlp); }
.nav-num { font-family: var(--mono); font-size: 0.8em; color: var(--muted); }
.nav-done { margin-left: auto; color: var(--good); }
.nav-toc { margin: 2px 0 6px 26px !important; border-left: 2px solid var(--border); }
.nav-toc a { padding: 3px 10px; color: var(--muted); font-size: 0.88em; border-radius: 0 6px 6px 0; margin-left: -2px; border-left: 2px solid transparent; }
.nav-toc a.active { color: var(--text); border-left-color: var(--sec); }

/* Wide screens: keep the contents pinned open beside the page. */
@media (min-width: 1240px) {
  .course-nav { transform: none; width: 280px; box-shadow: none !important; }
  body:has(.course-nav) { padding-left: 280px; }
  .progress-bar { left: 280px; }
  #nav-btn, .nav-scrim { display: none; }
}
@media (max-width: 720px) {
  .hide-sm { display: none; }
  .topbar { gap: 6px; padding: 8px 12px; }
  .topbar .crumb { display: none; }
}

footer.site { text-align: center; color: var(--muted); font-size: 0.85em; padding: 30px 16px; border-top: 1px solid var(--border); }

@media (max-width: 600px) {
  body { font-size: 16px; }
  .demo input[type="range"] { width: 130px; }
}
