/* Lesson stylesheet, in the style of the model-merging detail notes:
   paper background, one reading column, concept cards with a fixed anatomy
   (What / Why we need it / Example / drawn / PyTorch line) and bridges between them.
   Two accents mark the two instances of every concept: LLM = violet, point cloud = teal. */

:root {
  --ink: #1f2430;
  --muted: #5b6472;
  --paper: #fbfaf7;
  --card: #ffffff;
  --line: #d9d5cc;
  --accent: #0e7490;        /* section accent, teal */
  --llm: #6d28d9;           /* the GPT instance of a concept */
  --llm-bg: #f3f0fa;
  --pc: #0e7490;            /* the point-cloud instance */
  --pc-bg: #e8f4f6;
  --warn-bg: #fef3e7;
  --warn-line: #d97706;
  --def-bg: #e8f4f6;
  --def-line: #0e7490;
  --note-bg: #f1f0ea;
  --code-bg: #f4f2ec;
  --out-bg: #f3f8f3;
  --out-line: #3c9a34;
  --here-bg: #d4f5cf;
  --here-line: #3c9a34;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink);
       font: 16px/1.65 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 1.6rem 1.6rem 4rem; }

/* ---------- top nav ---------- */
.topnav { display: flex; flex-wrap: wrap; gap: 0.3rem 0.9rem; font-size: 0.85rem; margin-bottom: 1.2rem; align-items: center; }
.topnav a { color: var(--accent); text-decoration: none; font-weight: 600; padding: 0.15rem 0.5rem; border-radius: 999px; }
.topnav a.here { background: var(--here-bg); color: #1f6b1a; }
.topnav a:hover { text-decoration: underline; }
.topnav .sep { color: var(--line); }

/* ---------- header ---------- */
.step-head { border-bottom: 3px solid var(--accent); padding-bottom: 1.1rem; margin-bottom: 2rem; }
.step-badge { display: inline-block; background: var(--accent); color: #fff; font-size: 0.78rem; font-weight: 700;
              letter-spacing: 0.08em; padding: 0.25rem 0.7rem; border-radius: 999px; text-transform: uppercase; }
.step-head h1 { margin: 0.5rem 0 0.3rem; font-size: 1.9rem; line-height: 1.25; }
.step-head .lede { color: var(--muted); font-size: 1.05rem; margin: 0.2rem 0 0; }
.crumbs { font-size: 0.85rem; color: var(--muted); margin-top: 0.7rem; }
.crumbs a { color: var(--accent); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }

/* ---------- sections ---------- */
h2 { font-size: 1.35rem; margin: 2.4rem 0 0.8rem; padding-top: 0.4rem; }
h2 .secno { color: var(--accent); font-weight: 800; margin-right: 0.45rem; }
h3 { font-size: 1.05rem; margin: 1.6rem 0 0.5rem; }
p { margin: 0.6rem 0; }
ul, ol { margin: 0.5rem 0 0.8rem; padding-left: 1.4rem; }
li { margin: 0.25rem 0; }
strong { color: #10151f; }

/* ---------- boxes ---------- */
.box { border-left: 4px solid var(--line); background: var(--card); border-radius: 0 8px 8px 0;
       padding: 0.9rem 1.1rem; margin: 1.1rem 0; }
.box .box-tag { font-size: 0.72rem; font-weight: 800; letter-spacing: 0.09em; text-transform: uppercase;
                display: block; margin-bottom: 0.35rem; }
.box.def  { background: var(--def-bg);  border-color: var(--def-line); }
.box.def .box-tag { color: var(--def-line); }
.box.warn { background: var(--warn-bg); border-color: var(--warn-line); }
.box.warn .box-tag { color: var(--warn-line); }
.box.note { background: var(--note-bg); border-color: #6b7280; }
.box.note .box-tag { color: #6b7280; }

/* the concept card: defined BEFORE first use, with a micro example that can be checked by hand */
.box.term { background: #f3f0fa; border-color: #6d28d9; }
.box.term .box-tag { color: #6d28d9; }
.box.term .term-name { font-weight: 800; }
.ex { background: #fff; border: 1px dashed var(--line); border-radius: 6px; padding: 0.55rem 0.85rem; margin-top: 0.55rem; font-size: 0.9rem; }
.ex .ex-tag { font-size: 0.7rem; font-weight: 800; letter-spacing: 0.08em; color: var(--muted); text-transform: uppercase; margin-right: 0.45rem; }
.ex img, .ex svg { max-width: 100%; height: auto; display: block; margin-top: 0.4rem; background: #fff; border-radius: 4px; }
.ex .figcap { margin-top: 0.4rem; }

/* WHY strip: the reason the concept is needed, between What and Example */
.whyline { background: #fff7ed; border-left: 3px solid #d97706; border-radius: 0 6px 6px 0; padding: 0.5rem 0.8rem; margin: 0.6rem 0; font-size: 0.92rem; }
.whyline b { color: #b45309; }

/* the two instances of one concept, side by side inside a card */
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0.8rem; margin-top: 0.6rem; }
@media (max-width: 820px) { .two { grid-template-columns: 1fr; } }
.inst { border: 1px solid var(--line); border-radius: 8px; padding: 0.6rem 0.8rem; background: #fff; min-width: 0; }
.inst .inst-tag { display: inline-block; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase;
                  padding: 0.1rem 0.5rem; border-radius: 999px; color: #fff; margin-bottom: 0.4rem; }
.inst.llm { border-top: 3px solid var(--llm); } .inst.llm .inst-tag { background: var(--llm); }
.inst.pc  { border-top: 3px solid var(--pc); }  .inst.pc  .inst-tag { background: var(--pc); }
.inst p { margin: 0.35rem 0; font-size: 0.92rem; }
.inst img, .inst svg { max-width: 100%; height: auto; display: block; margin: 0.4rem 0; background: #fff; border: 1px solid #eee; border-radius: 4px; }
.inst pre { margin: 0.4rem 0; }

/* bridge between consecutive concept cards */
.bridge { text-align: center; color: var(--muted); font-style: italic; font-size: 0.92rem; margin: 0.9rem 0; }

/* "how to do this in PyTorch" line at the end of a card / instance */
.pyref { border-top: 1px dashed var(--line); margin-top: 0.6rem; padding-top: 0.45rem; font-size: 0.85rem; color: var(--muted); }
.pyref code { background: #fff; }
.pyref a { color: var(--accent); text-decoration: none; font-weight: 600; }
.pyref a:hover { text-decoration: underline; }

/* ---------- formula ---------- */
.formula { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 0.9rem 1.2rem; margin: 1rem 0;
           text-align: center; font-family: "STIX Two Math", "Cambria Math", Georgia, serif; font-size: 1.2rem; }
.formula .expl { display: block; font-size: 0.85rem; color: var(--muted); margin-top: 0.5rem; font-family: -apple-system, "Segoe UI", Roboto, sans-serif; }

/* ---------- tables ---------- */
.tbl-scroll { overflow-x: auto; margin: 1rem 0; }
table { border-collapse: collapse; width: 100%; background: var(--card); font-size: 0.92rem; }
caption { caption-side: top; text-align: left; font-size: 0.85rem; color: var(--muted); padding: 0.3rem 0.2rem; }
th, td { border: 1px solid var(--line); padding: 0.45rem 0.7rem; text-align: left; vertical-align: top; }
th { background: #efede6; font-weight: 700; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
th.l { color: var(--llm); } th.p { color: var(--pc); }
.roadmap td:first-child { white-space: nowrap; font-weight: 700; }
.roadmap tr.here { background: var(--here-bg); }

/* ---------- code and output ---------- */
code, kbd { font: 0.86em/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace; background: var(--code-bg); border-radius: 4px; padding: 0.1em 0.35em; }
pre { background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px; padding: 0.8rem 1rem; overflow-x: auto; font-size: 0.8rem; line-height: 1.5; margin: 0.6rem 0; }
pre code { background: none; padding: 0; }
pre.out { background: var(--out-bg); border-left: 3px solid var(--out-line); }
pre.out::before { content: "output"; display: block; font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--out-line); margin-bottom: 0.3rem; font-weight: 800; }
.src { font-size: 0.75rem; color: var(--muted); font-family: ui-monospace, Menlo, monospace; margin-bottom: -0.3rem; }
details.more { border: 1px dashed var(--line); border-radius: 8px; padding: 0.4rem 0.8rem; margin: 0.6rem 0; background: #fff; }
details.more summary { cursor: pointer; font-size: 0.88rem; color: var(--accent); font-weight: 600; }

/* ---------- figures ---------- */
.figure { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1.1rem 1.2rem 0.8rem; margin: 1.3rem 0; }
.figure svg, .figure img { width: 100%; height: auto; display: block; max-width: 100%; }
.figure img.book { max-width: 760px; margin: 0 auto; }
.figcap { font-size: 0.85rem; color: var(--muted); margin-top: 0.6rem; border-top: 1px dashed var(--line); padding-top: 0.5rem; }
.figcap b { color: var(--ink); }

/* ---------- interactive viz card ---------- */
.viz { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.1rem; margin: 1.2rem 0; }
.viz h4 { margin: 0 0 0.5rem; font-size: 0.8rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.viz .controls { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; font-size: 0.88rem; margin-bottom: 0.6rem; }
.viz label.l { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; width: 100%; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: #fff; }
.seg button { font: inherit; font-size: 0.84rem; background: none; border: 0; border-right: 1px solid var(--line); padding: 0.3rem 0.65rem; color: var(--muted); cursor: pointer; }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.btn { font: inherit; font-size: 0.84rem; background: #f4f2ec; color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 0.32rem 0.75rem; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
input[type="range"] { accent-color: var(--accent); }
input[type="text"], select { font: inherit; font-size: 0.95rem; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 0.4rem 0.6rem; width: 100%; }
.readout { font: 0.8rem/1.5 ui-monospace, Menlo, monospace; color: var(--muted); background: var(--code-bg); border-radius: 6px; padding: 0.45rem 0.6rem; min-height: 2.3em; white-space: pre-wrap; }
.canvas-wrap { position: relative; width: 100%; max-width: 100%; }
.canvas-wrap canvas { width: 100%; height: 100%; display: block; border-radius: 6px; border: 1px solid var(--line); background: #f7f6f1; touch-action: none; }
.tip { position: absolute; pointer-events: none; background: var(--ink); color: #fff; font-size: 0.78rem; padding: 0.3rem 0.5rem; border-radius: 6px; white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); opacity: 0; transition: opacity .12s; z-index: 5; }
.tip.on { opacity: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.chip { display: inline-grid; justify-items: center; gap: 0.05rem; background: #f4f2ec; border: 1px solid var(--line); border-radius: 6px; padding: 0.25rem 0.5rem; font: 0.8rem ui-monospace, Menlo, monospace; }
.chip small { font-size: 0.7rem; color: var(--muted); }
.chip.unk { background: #fde6dc; border-color: #d97706; color: #7a2e0e; }
.chip.special { background: var(--def-bg); border-color: var(--accent); }
.heat { display: grid; gap: 2px; font: 0.72rem ui-monospace, Menlo, monospace; font-variant-numeric: tabular-nums; }
.heat .hd { color: var(--muted); text-align: center; align-self: end; padding-bottom: 2px; font-size: 0.7rem; }
.heat .rl { color: var(--muted); text-align: right; padding-right: 6px; align-self: center; font-size: 0.7rem; }
.heat .c { border-radius: 3px; display: grid; place-items: center; min-height: 26px; color: var(--ink); }
.heat .c.hi { outline: 2px solid var(--ink); outline-offset: -2px; }
.heat .c.masked { background: repeating-linear-gradient(45deg, #f4f2ec, #f4f2ec 3px, #e4e1d8 3px, #e4e1d8 5px); color: var(--muted); }
.heat-big { display: block; width: 100%; height: auto; image-rendering: pixelated; border: 1px solid var(--line); border-radius: 6px; }
.emb-table { border-collapse: collapse; font: 0.8rem ui-monospace, Menlo, monospace; font-variant-numeric: tabular-nums; width: auto; }
.emb-table td, .emb-table th { padding: 0.3rem 0.55rem; border: 1px solid var(--line); text-align: right; }
.emb-table tr.hi td { background: var(--llm-bg); }

/* ---------- quiz & nav ---------- */
.quiz details { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 0.6rem 0.9rem; margin: 0.5rem 0; }
.quiz summary { cursor: pointer; font-weight: 600; }
.stepnav { display: flex; justify-content: space-between; gap: 1rem; margin-top: 3rem; border-top: 2px solid var(--line); padding-top: 1rem; font-size: 0.92rem; }
.stepnav a { color: var(--accent); text-decoration: none; font-weight: 600; }
.stepnav a:hover { text-decoration: underline; }

/* ---------- index cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0.9rem; margin: 1.1rem 0; }
.card { background: var(--card); border: 1px solid var(--line); border-top: 4px solid var(--accent); border-radius: 8px; padding: 0.8rem 1rem; text-decoration: none; color: var(--ink); display: block; }
.card:hover { border-color: var(--accent); }
.card h4 { margin: 0 0 0.3rem; font-size: 1rem; }
.card p { margin: 0.25rem 0; font-size: 0.88rem; color: var(--muted); }
.card .q { color: var(--ink); font-style: italic; }

@media print { body { background: #fff; } .wrap { max-width: none; padding: 0; } .stepnav, .topnav { display: none; } }

/* ---------- layout: instances stacked by default; body.side puts them side by side ---------- */
.two { grid-template-columns: 1fr; }
.two.keep { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 900px) { .two.keep { grid-template-columns: 1fr; } }
body.side .wrap { max-width: 1320px; }
@media (min-width: 1100px) { body.side .two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.inst img, .ex img { max-width: 760px; margin-left: auto; margin-right: auto; }
.inst img.wide { max-width: 100%; }
.topnav button.layout { margin-left: auto; font: inherit; font-size: 0.8rem; background: #f4f2ec; color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: 0.2rem 0.7rem; cursor: pointer; }
.topnav button.layout:hover { border-color: var(--accent); }

/* ---------- the clickable end-to-end architecture figure (partials/architecture.html) ---------- */
svg.arch { display: block; width: 100%; height: auto; max-width: 100%; color: var(--ink); font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
svg.arch text { fill: currentColor; font-size: 11px; }
svg.arch .t { font-size: 10px; fill: var(--muted); }
svg.arch .tb { font-size: 11px; font-weight: 600; fill: var(--ink); }
svg.arch .tn { font-size: 9.5px; fill: var(--muted); }
svg.arch .rowlab { font-size: 12px; font-weight: 700; }
svg.arch .box { fill: #f4f2ec; stroke: var(--line); }
svg.arch .in { fill: #fff; stroke: var(--line); stroke-dasharray: 3 2; }
svg.arch .llm { fill: var(--llm-bg); stroke: var(--llm); }
svg.arch .pc { fill: var(--pc-bg); stroke: var(--pc); }
svg.arch .grp { fill: none; stroke: var(--line); stroke-dasharray: 4 3; }
svg.arch .wire { stroke: currentColor; stroke-width: 1.2; fill: none; }
svg.arch .wire-ghost { stroke: var(--line); stroke-width: 1.2; fill: none; }
svg.arch a { cursor: pointer; }
svg.arch a:hover rect.stage, svg.arch a:focus rect.stage { stroke-width: 2.2; }
svg.arch .num { font-weight: 700; font-size: 10px; fill: #fff; }
.inst img[src*="fig/gen/"], .ex img[src*="fig/gen/"] { max-width: 100%; }

/* ---------- placeholder for a book figure that is not in this clone ---------- */
.book-missing { border: 1px dashed var(--line); border-radius: 6px; background: #fff; padding: 0.7rem 0.9rem; margin: 0.4rem auto; max-width: 760px; font-size: 0.88rem; color: var(--muted); }
.book-missing b { color: var(--ink); }
.book-missing span { color: var(--ink); font-style: italic; }

/* ---------- Present mode: one card per screen, stepped with the arrow keys ---------- */
body.present { background: #fff; font-size: 19px; }
body.present .wrap { max-width: 1400px; padding: 3.6rem 2.2rem 4rem; min-height: 100vh; }
body.present .wrap > * { display: none; }
body.present .wrap > .slide-on { display: block; }
body.present .wrap > .two.slide-on { display: grid; }
body.present .topnav { display: none; }
body.present .step-head { border-bottom: 0; margin-top: 12vh; }
body.present .step-head h1 { font-size: 2.6rem; }
body.present .step-head .lede { font-size: 1.3rem; }
body.present .box { font-size: 1.05em; }
body.present .box.part-head .two { display: none; }
body.present .box.part-llm .inst.pc, body.present .box.part-pc .inst.llm { display: none; }
body.present .box.part-llm .whyline, body.present .box.part-pc .whyline { display: none; }
body.present .box.part-llm .two, body.present .box.part-pc .two { grid-template-columns: 1fr; }
body.present .inst img, body.present .ex img { max-width: 900px; }
body.present .inst img[src*="fig/gen/"] { max-width: 100%; }
body.present .figure img { max-width: 100%; }
body.present pre { font-size: 0.9rem; }
body.present .two.keep { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.present-bar { display: none; }
body.present .present-bar { display: flex; position: fixed; top: 0; left: 0; right: 0; z-index: 20; align-items: center; gap: 1rem; padding: 0.45rem 1.2rem; background: var(--accent); color: #fff; font-size: 0.85rem; }
.present-bar .lesson { font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.present-bar .section { opacity: 0.9; }
.present-bar .count { margin-left: auto; font-variant-numeric: tabular-nums; }
.present-bar button { font: inherit; font-size: 0.8rem; color: #fff; background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.4); border-radius: 6px; padding: 0.15rem 0.6rem; cursor: pointer; }
.present-bar button:hover { background: rgba(255,255,255,0.3); }
.present-foot { display: none; }
body.present .present-foot { display: block; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; padding: 0.5rem 1.2rem; background: #fff; border-top: 1px solid var(--line); color: var(--muted); font-style: italic; font-size: 0.95rem; text-align: center; }
body.present .present-foot:empty { display: none; }

/* long lines wrap instead of running out of the pane */
pre { white-space: pre-wrap; overflow-wrap: anywhere; }
