/* Study-notes site. No external fonts or libraries. */
:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --surface-2: #f3f1ec;
  --text: #1d1c1a;
  --muted: #69655d;
  --border: #e3dfd6;
  --accent: #0e6b68;
  --accent-ink: #ffffff;
  --accent-soft: #e2f0ee;
  --code-bg: #f4f2ed;
  --code-text: #23221f;
  --note: #8a5a00;
  --note-soft: #fbf2e2;
  --ok: #2c7a4b;
  --video-bg: #14201f;
  --shadow: 0 1px 2px rgb(0 0 0 / 4%), 0 4px 16px rgb(0 0 0 / 4%);
  --radius: 10px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111413;
    --surface: #181c1b;
    --surface-2: #1f2423;
    --text: #e7e5e0;
    --muted: #a19d94;
    --border: #2c3230;
    --accent: #5cc4bd;
    --accent-ink: #0b1514;
    --accent-soft: #17302e;
    --code-bg: #1a1f1e;
    --code-text: #e2e0da;
    --note: #e3ac52;
    --note-soft: #2a2317;
    --ok: #6fcf97;
    --video-bg: #0c1312;
    --shadow: none;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.7 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.wrap { width: 100%; max-width: 50rem; margin: 0 auto; padding: 0 16px; }

.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 6px 12px; z-index: 10; }
.skip:focus { left: 8px; }

/* ---------- header / footer ---------- */
.site-header { border-bottom: 1px solid var(--border); background: var(--surface); }
.header-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 24px; padding-top: 14px; padding-bottom: 14px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 650; letter-spacing: -0.01em; }
.site-nav { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 15px; }
.site-nav a { color: var(--muted); text-decoration: none; padding: 2px 0; border-bottom: 2px solid transparent; }
.site-nav a:hover { color: var(--text); }
.site-nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }

.site-footer { margin-top: 72px; border-top: 1px solid var(--border); padding: 28px 0 40px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.site-footer p { margin: 0 0 6px; max-width: 42rem; }
.site-footer a { color: var(--muted); }

/* ---------- typography ---------- */
main.wrap { padding-top: 40px; }
h1, h2, h3 { line-height: 1.25; letter-spacing: -0.015em; font-weight: 680; }
h1 { font-size: clamp(1.75rem, 1.2rem + 2.2vw, 2.4rem); margin: 0 0 12px; }
h2 { font-size: 1.45rem; margin: 2.4em 0 0.6em; scroll-margin-top: 16px; }
h3 { font-size: 1.15rem; margin: 1.8em 0 0.5em; }
p, ul, ol, dl { margin: 0 0 1em; }
ul, ol { padding-left: 1.4em; }
li { margin: 0.25em 0; }
li > ul, li > ol { margin: 0.25em 0 0; }
strong { font-weight: 650; }
hr { border: 0; border-top: 1px solid var(--border); margin: 2.5em 0; }

code { font-family: var(--mono); font-size: 0.88em; background: var(--code-bg); padding: 0.1em 0.35em; border-radius: 5px; }
pre.code {
  position: relative;
  margin: 0 0 1.2em;
  padding: 16px 18px;
  overflow-x: auto;
  background: var(--code-bg);
  color: var(--code-text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: 14px/1.6 var(--mono);
  tab-size: 4;
}
pre.code code { background: none; padding: 0; font-size: inherit; }
pre.code[data-lang]::before {
  content: attr(data-lang);
  position: absolute; top: 6px; right: 10px;
  font: 11px var(--sans); color: var(--muted); text-transform: lowercase; letter-spacing: 0.04em;
}

.formula { font-family: var(--mono); font-size: 0.95em; background: var(--surface-2); border-radius: var(--radius); padding: 12px 16px; margin: 0 0 1.2em; overflow-x: auto; white-space: nowrap; }

table { border-collapse: collapse; width: 100%; margin: 0 0 1.2em; font-size: 15px; display: block; overflow-x: auto; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-weight: 650; background: var(--surface-2); }

/* ---------- boxes ---------- */
.tldr, .note, .exercises-box {
  border-radius: var(--radius);
  padding: 4px 20px;
  margin: 0 0 1.4em;
}
.tldr { background: var(--accent-soft); }
.tldr h2 { font-size: 1.05rem; margin: 16px 0 8px; text-transform: none; }
.tldr ul { margin-bottom: 16px; }

.note { background: var(--note-soft); border-left: 3px solid var(--note); padding: 14px 18px; }
.note p:last-child { margin-bottom: 0; }
.note strong:first-child { color: var(--note); }

ol.exercises { counter-reset: ex; list-style: none; padding: 0; }
ol.exercises > li { counter-increment: ex; position: relative; padding: 12px 16px 12px 52px; margin: 0 0 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
ol.exercises > li::before { content: counter(ex); position: absolute; left: 16px; top: 12px; width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font: 650 13px/24px var(--sans); text-align: center; }

ul.links { list-style: none; padding: 0; }
ul.links li { padding: 6px 0; border-bottom: 1px solid var(--border); }
ul.links li:last-child { border-bottom: 0; }
ul.links .what { display: block; color: var(--muted); font-size: 14px; line-height: 1.5; }

/* ---------- page head ---------- */
.page-head { margin-bottom: 24px; }
.eyebrow { margin: 0 0 8px; color: var(--muted); font-size: 14px; letter-spacing: 0.02em; }
.eyebrow a { color: var(--muted); }
.original { margin: 0 0 14px; color: var(--muted); font-style: italic; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 10px; list-style: none; padding: 0; margin: 0; font-size: 14px; }
.meta li { margin: 0; padding: 3px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--muted); }
.meta a { text-decoration: none; }

.lead { font-size: 1.15rem; line-height: 1.6; color: var(--text); max-width: 42rem; }

/* ---------- video ---------- */
.video { margin: 0 0 28px; }
.video-facade, .video iframe {
  display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: var(--radius); overflow: hidden;
}
.video-facade {
  position: relative; text-decoration: none; color: #fff;
  background:
    radial-gradient(120% 90% at 85% 10%, rgb(92 196 189 / 28%), transparent 60%),
    radial-gradient(90% 80% at 10% 100%, rgb(14 107 104 / 45%), transparent 60%),
    var(--video-bg);
}
.video-play {
  position: absolute; left: 50%; top: 50%; width: 76px; height: 76px; margin: -38px 0 0 -38px;
  border-radius: 50%; background: rgb(255 255 255 / 14%); border: 2px solid rgb(255 255 255 / 70%);
  transition: transform 0.15s, background 0.15s;
}
.video-play::after {
  content: ""; position: absolute; left: 30px; top: 22px;
  border-style: solid; border-width: 15px 0 15px 24px; border-color: transparent transparent transparent #fff;
}
.video-facade:hover .video-play { transform: scale(1.06); background: rgb(255 255 255 / 22%); }
.video-label { position: absolute; left: 20px; bottom: 18px; font-weight: 600; font-size: 16px; }
.video-dur { font-weight: 400; opacity: 0.8; }
.video-note { position: absolute; right: 20px; bottom: 18px; font-size: 13px; opacity: 0.65; }
.video figcaption { margin-top: 8px; color: var(--muted); font-size: 14px; }
@media (max-width: 520px) {
  .video-note { display: none; }
  .video-play { width: 60px; height: 60px; margin: -30px 0 0 -30px; }
  .video-play::after { left: 23px; top: 16px; border-width: 12px 0 12px 19px; }
}

/* ---------- table of contents ---------- */
.toc { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 14px 20px; margin: 0 0 28px; font-size: 15px; }
.toc-title { margin: 0 0 6px; font-weight: 650; }
.toc ol { margin: 0; padding-left: 1.3em; columns: 2; column-gap: 32px; }
.toc li { break-inside: avoid; margin: 2px 0; }
.toc a { text-decoration: none; }
@media (max-width: 640px) { .toc ol { columns: 1; } }

/* ---------- lecture list (home) ---------- */
.lesson-list { list-style: none; padding: 0; margin: 0 0 12px; }
.lesson { margin: 0 0 10px; }
.lesson a {
  display: grid; grid-template-columns: 44px 1fr 28px; gap: 4px 14px; align-items: start;
  padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); text-decoration: none; box-shadow: var(--shadow); transition: border-color 0.15s;
}
.lesson a:hover { border-color: var(--accent); }
.lesson-num { font: 650 15px/1.6 var(--mono); color: var(--accent); }
.lesson-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.lesson-title { font-weight: 650; line-height: 1.4; }
.lesson-blurb { color: var(--muted); font-size: 15px; line-height: 1.5; }
.lesson-meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.lesson-check { width: 22px; height: 22px; margin-top: 2px; border-radius: 50%; border: 1.5px solid var(--border); }
.lesson.done .lesson-check { border-color: var(--ok); background: var(--ok); position: relative; }
.lesson.done .lesson-check::after { content: ""; position: absolute; left: 6.5px; top: 3px; width: 5px; height: 10px; border: solid var(--bg); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.progress { color: var(--muted); font-size: 14px; }
@media (max-width: 520px) { .lesson a { grid-template-columns: 32px 1fr 24px; gap: 4px 10px; padding: 14px; } }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 12px; margin: 0 0 1.4em; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.card h3 { margin: 0 0 6px; font-size: 1rem; }
.card p { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.55; }

/* ---------- glossary ---------- */
.glossary dt { font-weight: 650; margin-top: 1.1em; scroll-margin-top: 16px; }
.glossary dt span[lang="en"] { font-weight: 400; color: var(--muted); }
.glossary dd { margin: 0.2em 0 0; padding-left: 0; }
.glossary dd a.lec { font-size: 14px; white-space: nowrap; }
.letters { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 1.4em; padding: 0; list-style: none; }
.letters a { display: inline-block; min-width: 30px; padding: 2px 8px; text-align: center; border: 1px solid var(--border); border-radius: 6px; text-decoration: none; background: var(--surface); }

/* ---------- done toggle + pager ---------- */
.done-row { margin: 40px 0 20px; }
.done-toggle {
  font: 600 15px var(--sans); padding: 10px 18px; border-radius: 999px; cursor: pointer;
  border: 1.5px solid var(--accent); background: transparent; color: var(--accent);
}
.done-toggle[aria-pressed="true"] { background: var(--ok); border-color: var(--ok); color: var(--bg); }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.pager a { display: block; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); text-decoration: none; color: var(--text); font-weight: 600; line-height: 1.4; }
.pager a span { display: block; font-weight: 400; font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.pager-next { text-align: right; grid-column: 2; }
.pager a:hover { border-color: var(--accent); }
@media (max-width: 560px) { .pager { grid-template-columns: 1fr; } .pager-next { grid-column: 1; } }
