/* ============================================================
   Shared course stylesheet — every lesson links this.
   Tufte-inspired: readable serif body, generous margins,
   restrained color, printable.
   ============================================================ */

:root {
  --ink:        #1a1a1a;
  --muted:      #6b6b6b;
  --rule:       #e3e0d8;
  --bg:         #fffef9;
  --accent:     #7a1f1f;   /* deep red, used sparingly */
  --accent-2:   #1f4e7a;   /* deep blue */
  --good:       #1f6b3a;
  --bad:        #9b2226;
  --code-bg:    #f4f1ea;
  --maxw:       42rem;
}

* { box-sizing: border-box; }

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

body {
  margin: 0 auto;
  padding: 4rem 1.5rem 6rem;
  max-width: var(--maxw);
  background: var(--bg);
  color: var(--ink);
  font-family: Georgia, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
  font-size: 1.125rem;
  line-height: 1.62;
  text-rendering: optimizeLegibility;
}

/* ---- masthead ---- */
.masthead {
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.75rem;
  margin-bottom: 2.5rem;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.masthead a { color: var(--muted); text-decoration: none; }
.masthead a:hover { color: var(--accent); }

/* ---- headings ---- */
h1 {
  font-size: 2.1rem;
  line-height: 1.15;
  font-weight: 700;
  margin: 0 0 0.4rem;
  letter-spacing: -0.01em;
}
.subtitle {
  font-style: italic;
  color: var(--muted);
  font-size: 1.15rem;
  margin: 0 0 2.5rem;
}
h2 {
  font-size: 1.4rem;
  margin: 2.8rem 0 0.6rem;
  font-weight: 700;
}
h3 {
  font-size: 1.1rem;
  margin: 2rem 0 0.4rem;
  font-weight: 700;
  color: var(--accent-2);
}

p { margin: 0 0 1.1rem; }

a { color: var(--accent); text-underline-offset: 2px; }

/* ---- the "one win" callout ---- */
.win {
  border-left: 3px solid var(--accent);
  background: #fbf6f2;
  padding: 0.9rem 1.2rem;
  margin: 1.5rem 0 2rem;
  font-size: 1rem;
}
.win strong { color: var(--accent); }

/* ---- key idea / aside ---- */
.aside {
  font-size: 0.95rem;
  color: var(--muted);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 0.9rem 0;
  margin: 1.8rem 0;
}

/* ---- the two-phase comparison table ---- */
table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.5rem 0;
  font-size: 0.98rem;
}
th, td {
  text-align: left;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
thead th {
  border-bottom: 2px solid var(--ink);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
tbody th { font-weight: 700; color: var(--muted); white-space: nowrap; }

/* ---- code ---- */
code {
  font-family: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 0.85em;
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}
.formula {
  background: var(--code-bg);
  padding: 1rem 1.2rem;
  border-radius: 4px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 1.3rem 0;
  overflow-x: auto;
}

/* ---- figures & diagrams ---- */
.figure { margin: 2.2rem 0; }
.figure svg { width: 100%; height: auto; display: block; }
.figure figcaption {
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
  text-align: center;
  margin-top: 0.6rem;
}
.figure text { font-family: -apple-system, "Segoe UI", Roboto, system-ui, sans-serif; }
.dlabel { font-size: 13px; font-weight: 700; }
.dsub   { font-size: 11px; fill: var(--muted); }
.dtag   { font-size: 10px; letter-spacing: 0.05em; text-transform: uppercase; }

/* gentle flow animation on dashed paths; off for print & reduced-motion */
.flow { stroke-dasharray: 6 6; animation: dash 1.1s linear infinite; }
@keyframes dash { to { stroke-dashoffset: -24; } }
@media (prefers-reduced-motion: reduce) { .flow { animation: none; } }
@media print { .flow { animation: none; } }

/* embedded shared SVG (the animated hero) */
.embed {
  width: 100%;
  border: 1px solid var(--rule);
  border-radius: 10px;
  overflow: hidden;
  background: #fffdf7;
}
.embed object, .embed img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 720 / 320;
}

/* the analogy thread — warm amber, visually distinct from technical content */
.analogy-note {
  font-size: 0.92rem;
  background: #fdf6ee;
  border-left: 3px solid #c98a3a;
  padding: 0.55rem 0.85rem;
  margin: 0.4rem 0 0;
  border-radius: 0 5px 5px 0;
}
.analogy-note b { color: #9a5a12; }

.analogy-lead {
  background: #fdf6ee;
  border: 1px solid #ecd8bd;
  border-radius: 8px;
  padding: 1rem 1.2rem;
  margin: 1.5rem 0;
}
.analogy-lead h3 { margin-top: 0; color: #9a5a12; }

/* live-cluster callouts — green = real, measured on the 4×H100 lab */
.cluster {
  background: #eef6f0;
  border: 1px solid #bcdcc6;
  border-left: 4px solid #1f6b3a;
  border-radius: 8px;
  padding: 1rem 1.2rem;
  margin: 1.8rem 0;
  font-size: 0.95rem;
}
.cluster h3 { margin-top: 0; color: #1f6b3a; font-size: 1.05rem; }
.cluster .badge {
  display: inline-block; font-size: 0.66rem; letter-spacing: 0.06em;
  text-transform: uppercase; font-weight: 700; color: #fff; background: #1f6b3a;
  border-radius: 10px; padding: 0.1rem 0.5rem; margin-left: 0.4rem; vertical-align: middle;
}
.cluster code { background: #dcebe1; }

/* lesson variant tabs (predict-first ↔ diagram-first) */
.tabs {
  display: flex; gap: 1.75rem; border-bottom: 1px solid var(--rule);
  margin: 1.4rem 0 1.9rem;
}
.tabs button {
  font: inherit; font-size: 0.72rem; letter-spacing: 0.09em; text-transform: uppercase;
  font-weight: 700; cursor: pointer; background: none; border: none;
  color: var(--muted); padding: 0 0 0.7rem; margin-bottom: -1px;
  border-bottom: 2px solid transparent; transition: color .12s, border-color .12s;
}
.tabs button.active { color: var(--ink); border-bottom-color: var(--accent); }
.tabs button:hover:not(.active) { color: var(--ink); }
.variant { display: none; }
.variant.active { display: block; }

/* experimental-edition banner */
.flag {
  font-size: 0.82rem; background: #f6f3fc; border: 1px solid #d8d2f0; color: #463a86;
  border-radius: 6px; padding: 0.5rem 0.8rem; margin: 1rem 0;
}

/* active-recall checkpoint — answer stays blurred until you reveal it */
.recall {
  border: 1px dashed #c9b8e6; border-radius: 8px; background: #faf8ff;
  padding: 0.8rem 1rem; margin: 1.6rem 0; font-size: 0.96rem;
}
.recall .r-q { font-weight: 700; color: #5a4fa3; }
.recall .r-a {
  display: inline-block; margin-top: 0.4rem; filter: blur(5px);
  cursor: pointer; transition: filter 0.15s; user-select: none;
}
.recall .r-a:hover, .recall .r-a:focus, .recall .r-a.show { filter: none; user-select: text; }
.recall .r-hint { font-size: 0.78rem; color: var(--muted); margin-left: 0.4rem; }
@media print { .recall .r-a { filter: none; } }

/* bridge callouts — indigo = a bridge from the internals to the API/product you use daily */
.bridge {
  background: #f2f0fb;
  border: 1px solid #d8d2f0;
  border-left: 4px solid #5a4fa3;
  border-radius: 8px;
  padding: 1rem 1.2rem;
  margin: 1.8rem 0;
  font-size: 0.95rem;
}
.bridge h3 { margin-top: 0; color: #463a86; font-size: 1.05rem; }
.bridge .badge {
  display: inline-block; font-size: 0.66rem; letter-spacing: 0.06em;
  text-transform: uppercase; font-weight: 700; color: #fff; background: #5a4fa3;
  border-radius: 10px; padding: 0.1rem 0.5rem; margin-left: 0.4rem; vertical-align: middle;
}
.bridge code { background: #e6e1f7; }
.bridge table td:first-child { color: #463a86; white-space: nowrap; }

/* map table: real-world ↔ technical */
table.map td:first-child { color: #9a5a12; }
table.map td:last-child  { color: var(--ink); }

/* ---- citations ---- */
.cite { font-size: 0.8em; vertical-align: super; line-height: 0; }
.cite a { text-decoration: none; }
.refs {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-size: 0.85rem;
  color: var(--muted);
}
.refs ol { padding-left: 1.3rem; }
.refs li { margin-bottom: 0.4rem; }

/* ---- primary source box ---- */
.primary {
  background: #f2f6fa;
  border: 1px solid #d4e0ec;
  border-radius: 6px;
  padding: 1rem 1.2rem;
  margin: 2rem 0;
  font-size: 0.98rem;
}
.primary .label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-2);
  font-weight: 700;
  display: block;
  margin-bottom: 0.3rem;
}

/* ---- ask-your-teacher reminder ---- */
.teacher {
  margin: 2.5rem 0 0;
  padding: 1rem 1.2rem;
  border: 1px dashed var(--rule);
  border-radius: 6px;
  font-size: 0.95rem;
  background: #fcfbf6;
}
.teacher strong { color: var(--accent); }

/* ---- footer nav ---- */
.lesson-nav {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
}

/* ---- print ---- */
@media print {
  body { background: #fff; color: #000; padding: 1rem; max-width: none; }
  .teacher, .quiz button { display: none; }
  a { color: #000; }
}
