/* TAI 100 lecture notes: shared stylesheet for every week.
   Layout: the course-site template applied to lecture notes. Masthead, then a sticky "on this page"
   list beside one reading column. Same tokens, type and components as the course pages. */
:root {
  --paper: #FFFFFF;
  --ink: #1B1B1A;
  --muted: #5E5D59;
  --rule: #D9D7D1;
  --wash: #F6F5F1;
  --link: #1F4A73;
  --sheep: #FFB901;
  --f-serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --f-sans: "Source Sans 3", "Helvetica Neue", Arial, sans-serif;
  --f-mark: "Poppins", "Helvetica Neue", Arial, sans-serif;
  --f-code: "Source Code Pro", ui-monospace, Menlo, monospace;
  --c2: #0072B2; --c3: #009E73; --c4: #CC79A7; --c5: #B07800;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #151514; --ink: #E9E7E1; --muted: #A5A39C; --rule: #34332F; --wash: #1D1D1B; --link: #8DB8E2;
    --c2: #4FA6E0; --c3: #3CC49B; --c4: #DE9AC2; --c5: #F2B544;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #151514; --ink: #E9E7E1; --muted: #A5A39C; --rule: #34332F; --wash: #1D1D1B; --link: #8DB8E2;
  --c2: #4FA6E0; --c3: #3CC49B; --c4: #DE9AC2; --c5: #F2B544;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--f-serif); font-size: 17px; line-height: 1.65; -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-underline-offset: 0.14em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.gutter { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.frame { max-width: 1060px; margin: 0 auto; }

/* masthead (shared with course pages) */
.masthead { border-top: 4px solid var(--sheep); border-bottom: 1px solid var(--rule); }
.inst { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding-block: 16px; border-bottom: 1px solid var(--rule); }
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.brand img { width: 40px; height: 40px; display: block; border-radius: 6px; }
.brand .wm { font-family: var(--f-mark); font-weight: 700; font-size: 14px; line-height: 1; letter-spacing: 0.02em; }
.brand .sub { display: block; margin-top: 4px; font-family: var(--f-sans); font-weight: 400; font-size: 13px; color: var(--muted); }
.inst nav { display: flex; gap: 22px; font-family: var(--f-sans); font-size: 15px; }
.inst nav a { color: var(--ink); text-decoration: none; }
.inst nav a:hover { text-decoration: underline; }
.course { padding-block: 34px 30px; display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 0 56px; }
.course .code { font-family: var(--f-sans); font-size: 14px; color: var(--muted); padding-top: 10px; line-height: 1.4; }
.course .code b { display: block; font-size: 22px; font-weight: 600; color: var(--ink); }
.course .kicker { font-family: var(--f-sans); font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.course h1 { font-family: var(--f-serif); font-weight: 400; font-size: clamp(2rem, 4.2vw, 2.85rem); line-height: 1.1; letter-spacing: -0.01em; margin: 0; text-wrap: balance; }
.course .dek { font-size: 1.125rem; color: var(--muted); margin: 10px 0 0; max-width: 60ch; }
.course .facts { font-family: var(--f-sans); font-size: 14px; color: var(--muted); margin: 14px 0 0; display: flex; flex-wrap: wrap; }
.course .facts span + span::before { content: "·"; margin: 0 10px; }

/* shell */
.shell { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 0 56px; padding-block: 36px 72px; }
nav.toc { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 24px); align-self: start; font-family: var(--f-sans); }
nav.toc .lbl { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
nav.toc ol { list-style: none; margin: 10px 0 0; padding: 0; border-top: 1px solid var(--rule); }
nav.toc li { border-bottom: 1px solid var(--rule); }
nav.toc a { display: grid; grid-template-columns: 1.5rem minmax(0, 1fr); padding: 7px 0 7px 10px; color: var(--ink); text-decoration: none; font-size: 14.5px; line-height: 1.35; }
nav.toc a span { color: var(--muted); font-variant-numeric: tabular-nums; }
nav.toc a:hover { color: var(--link); }
nav.toc a.on { font-weight: 700; box-shadow: inset 3px 0 0 var(--ink); }
nav.toc .weeks { margin-top: 18px; font-size: 14px; line-height: 1.5; }
nav.toc .weeks a { display: inline; padding: 0; color: var(--link); }

main { min-width: 0; max-width: 720px; }
main h2 { font-weight: 600; font-size: 1.55rem; line-height: 1.25; margin: 44px 0 12px; padding-top: 14px; border-top: 1px solid var(--rule); text-wrap: balance; scroll-margin-top: 16px; }
main h2 .sn { display: inline-block; min-width: 2rem; color: var(--muted); font-weight: 400; }
main h3 { font-weight: 600; font-size: 1.15rem; margin: 26px 0 8px; }
main p { margin: 0 0 14px; }
main ul, main ol { margin: 0 0 14px; padding-left: 1.4rem; }
main li { margin: 4px 0; }
.note { color: var(--muted); font-size: 15px; }
blockquote { margin: 6px 0 18px; padding: 2px 0 2px 20px; border-left: 2px solid var(--ink); font-style: italic; }

/* at a glance */
.glance { border: 1px solid var(--rule); border-top: 3px solid var(--ink); padding: 16px 20px 6px; }
.glance h2 { margin: 0 0 8px; padding: 0; border: none; font-size: 1.15rem; }
.glance dl { display: grid; grid-template-columns: 9rem minmax(0, 1fr); margin: 0; }
.glance dt, .glance dd { margin: 0; padding: 8px 0; border-top: 1px solid var(--rule); }
.glance dt { font-family: var(--f-sans); font-weight: 600; font-size: 15px; }
.glance dd ul { margin: 0; }

/* two callout types only */
.box { margin: 18px 0; padding: 12px 18px; background: var(--wash); border-left: 3px solid var(--ink); }
.box .t { display: block; font-family: var(--f-sans); font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 4px; }
.box p:last-child, .box ul:last-child { margin-bottom: 0; }
.box.warn { border-left-color: var(--c5); }

/* code */
pre { margin: 12px 0 18px; padding: 14px 16px; background: var(--wash); border: 1px solid var(--rule); overflow-x: auto; font-family: var(--f-code); font-size: 14px; line-height: 1.55; }
code { font-family: var(--f-code); font-size: 0.9em; }
pre code { font-size: inherit; }
.c { color: var(--muted); }

/* tables (booktabs) */
.tbl { overflow-x: auto; margin: 8px 0 16px; }
table { border-collapse: collapse; width: 100%; font-size: 15.5px; min-width: 480px; border-bottom: 1.5px solid var(--ink); }
caption { caption-side: top; text-align: left; font-family: var(--f-sans); font-size: 14px; color: var(--muted); padding-bottom: 8px; }
caption b { color: var(--ink); }
@media (max-width: 600px) { table { min-width: 0; font-size: 14px; } }
thead th { font-family: var(--f-sans); font-weight: 600; font-size: 14px; text-align: left; padding: 8px 12px 7px 0; border-top: 1.5px solid var(--ink); border-bottom: 1px solid var(--ink); vertical-align: bottom; }
td { padding: 8px 12px 8px 0; vertical-align: top; line-height: 1.45; }
tbody tr + tr td { border-top: 1px solid var(--rule); }
.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--f-sans); }
tr.best td { font-weight: 600; }

/* definition list */
dl.defs { margin: 6px 0 16px; display: grid; grid-template-columns: 11rem minmax(0, 1fr); border-top: 1px solid var(--rule); }
dl.defs dt, dl.defs dd { padding: 9px 0; border-bottom: 1px solid var(--rule); margin: 0; }
dl.defs dt { font-family: var(--f-sans); font-weight: 600; font-size: 15px; padding-right: 16px; }

/* evidence label */
.st { font-family: var(--f-sans); font-size: 14.5px; white-space: nowrap; }
.st::before { content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 7px; background: var(--k, var(--muted)); }
.st.established { --k: var(--c3); } .st.replicated { --k: var(--c2); } .st.hypothesis { --k: var(--c5); } .st.exploratory { --k: var(--c4); }

/* questions */
ol.qa { padding-left: 1.4rem; }
ol.qa > li { margin: 0 0 14px; }
details { margin-top: 6px; font-size: 16px; }
summary { cursor: pointer; font-family: var(--f-sans); font-size: 14.5px; color: var(--link); }
details[open] summary { margin-bottom: 6px; }
details > div { padding: 8px 14px; background: var(--wash); border-left: 3px solid var(--rule); }
details > div p:last-child { margin-bottom: 0; }

.pager { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 48px; padding-top: 16px; border-top: 1.5px solid var(--ink); font-family: var(--f-sans); font-size: 15px; }
.pager span { color: var(--muted); }

footer { border-top: 1px solid var(--rule); }
footer .frame { padding-block: 22px 34px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px 24px; font-family: var(--f-sans); font-size: 13.5px; color: var(--muted); }
footer .brand img { width: 30px; height: 30px; border-radius: 4px; }

@media (max-width: 860px) {
  .course, .shell { grid-template-columns: minmax(0, 1fr); }
  .course .code { padding-top: 0; margin-bottom: 10px; }
  .course .code b { display: inline; font-size: 15px; margin-right: 8px; }
  nav.toc { position: static; margin-bottom: 8px; }
  nav.toc ol { columns: 2; column-gap: 20px; }
  nav.toc li { break-inside: avoid; }
}
@media (max-width: 560px) {
  body { font-size: 16.5px; }
  .inst nav { display: none; }
  nav.toc ol { columns: 1; }
  .glance dl, dl.defs { grid-template-columns: minmax(0, 1fr); }
  .glance dt, dl.defs dt { border-bottom: none; padding-bottom: 0; }
  .glance dd, dl.defs dd { border-top: none; padding-top: 2px; }
  dl.defs dd { border-bottom: 1px solid var(--rule); }
}

/* equations */
.eq { display: grid; grid-template-columns: minmax(0, 1fr) 3rem; align-items: center; gap: 8px; margin: 10px 0 16px; }
.eq .tex { min-height: 2.4em; overflow-x: auto; }
.eq .no { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-family: var(--f-sans); }
