/* Converge website: content components inside chapters. */

.body { max-width: 640px; }
.body > p, .body > ul, .body > ol { margin: 0 0 1em; }
.body h3 {
  margin: 1.9em 0 0.55em; font-family: var(--display); font-weight: 800; font-variation-settings: "wdth" 82;
  font-size: 27px; line-height: 1.12; letter-spacing: -0.015em;
}
.body ul { padding-left: 1.2em; }
.body li { margin: 0.3em 0; }
.body li::marker { color: var(--teal); }
.lead { font-size: 21px; line-height: 1.55; color: var(--ink); }
code { font-family: var(--mono); font-size: 0.8em; background: var(--fill); padding: 0.08em 0.3em; border-radius: 3px; }
.wide { max-width: 880px; }

/* ---------- margin notes: like plt.annotate, an arrow and an italic line ---------- */
.body > .note, .note { position: relative; margin: 0 0 1.1em; padding-left: 30px; font-style: italic; font-size: 16.5px; line-height: 1.5; color: var(--teal); }
.note::before {
  content: ""; position: absolute; left: 0; top: 0.55em; width: 20px; height: 12px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 12'%3E%3Cpath d='M19 11 C12 11 7 7 3 2' fill='none' stroke='black' stroke-width='1.4'/%3E%3Cpath d='M1 0 L7 1.5 L3.2 5.6 Z' fill='black'/%3E%3C/svg%3E") no-repeat center / contain;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 12'%3E%3Cpath d='M19 11 C12 11 7 7 3 2' fill='none' stroke='black' stroke-width='1.4'/%3E%3Cpath d='M1 0 L7 1.5 L3.2 5.6 Z' fill='black'/%3E%3C/svg%3E") no-repeat center / contain;
}
@media (min-width: 1240px) {
  .body { position: relative; }
  .body > .note { float: right; clear: right; width: 198px; margin: 0.2em -242px 1em 0; padding-left: 0; padding-top: 18px; font-size: 15.5px; }
  .note::before { top: 0; left: 0; transform: scaleX(-1) rotate(8deg); }
  .body::after { content: ""; display: block; clear: both; }
}

/* ---------- rule cards: a rule and where it comes from ---------- */
.rule { margin: 1.4em 0; padding: 18px 20px 16px; background: var(--card); border: 1.5px solid var(--ink); box-shadow: var(--shadow); }
.rule__tag { display: inline-block; margin: 0 0 8px; padding: 2px 8px; background: var(--teal); color: var(--card); font-family: var(--mono); font-size: 12px; }
.rule__text { margin: 0; font-size: 19px; line-height: 1.5; font-weight: 600; }
.rule__src { margin: 10px 0 0; font-family: var(--mono); font-size: 12.5px; color: var(--ink-3); }
.rule__src a { color: var(--ink-3); }

/* ---------- traps ---------- */
.trap { margin: 1.4em 0; padding: 14px 18px; border-left: 4px solid var(--red); background: color-mix(in srgb, var(--red) 7%, transparent); }
.trap__h { display: block; margin-bottom: 4px; font-family: var(--display); font-weight: 800; font-size: 19px; color: var(--red); letter-spacing: -0.01em; }
.trap p { margin: 0; font-size: 17.5px; }

/* ---------- formulas ---------- */
.formula { margin: 1.3em 0; padding: 16px 18px; background: var(--card); border: 1px solid var(--rule); border-left: 4px solid var(--teal); overflow-x: auto; }
.formula__eq { margin: 0; font-family: var(--mono); font-size: 16px; line-height: 1.7; white-space: nowrap; }
.formula__eq var { font-style: normal; font-weight: 700; color: var(--teal); }
.formula__where { margin: 8px 0 0; font-family: var(--ui); font-size: 14.5px; color: var(--ink-2); line-height: 1.5; }
@media (max-width: 760px) { .formula__eq { white-space: normal; font-size: 14.5px; } }

/* ---------- tables ---------- */
.tbl { margin: 1.4em 0; overflow-x: auto; }
.tbl__cap { margin: 0 0 8px; font-family: var(--ui); font-size: 14px; color: var(--ink-3); }
table.ledger { width: 100%; border-collapse: collapse; font-family: var(--ui); font-size: 15px; line-height: 1.45; }
table.ledger th { text-align: left; padding: 8px 12px 8px 0; font-family: var(--mono); font-size: 12px; font-weight: 400; color: var(--ink-3); border-bottom: 1.5px solid var(--ink); vertical-align: bottom; }
table.ledger td { padding: 10px 12px 10px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
table.ledger td:first-child { font-weight: 650; color: var(--ink); }
table.ledger .n { font-family: var(--mono); font-size: 13px; color: var(--teal); font-weight: 700; width: 3em; }
table.ledger .muted { color: var(--ink-3); }
table.ledger .aside { color: var(--ink-3); font-style: italic; }
@media (max-width: 640px) {
  table.ledger--stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.ledger--stack, table.ledger--stack tbody, table.ledger--stack tr, table.ledger--stack td { display: block; width: 100%; }
  table.ledger--stack tr { padding: 10px 0; border-bottom: 1px solid var(--rule); }
  table.ledger--stack td { border: 0; padding: 2px 0; }
  table.ledger--stack td[data-l]::before { content: attr(data-l) ": "; color: var(--ink-3); font-family: var(--mono); font-size: 12px; }
  table.ledger--stack td:first-child::before { content: none; }
  table.ledger--weeks .aside { display: none; }
}

/* ---------- numbered steps ---------- */
ol.steps { list-style: none; margin: 1.2em 0; padding: 0; counter-reset: st; }
ol.steps > li { counter-increment: st; position: relative; padding: 0 0 14px 48px; margin: 0; }
ol.steps > li::before {
  content: counter(st); position: absolute; left: 0; top: 0.05em; width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; border: 1.5px solid var(--teal); color: var(--teal);
  font-family: var(--mono); font-size: 14px; font-weight: 700;
}
ol.steps > li b { color: var(--ink); }

/* ---------- chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 0; padding: 0; list-style: none; }
.chip { font-family: var(--mono); font-size: 13px; padding: 4px 10px; border: 1px solid currentColor; }

/* ---------- course cards (chapter 01) ---------- */
.courses { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 1.4em 0; max-width: 880px; }
.course { padding: 16px 18px; background: var(--card); border: 1px solid var(--ink); border-top: 6px solid var(--c); }
.course__code { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
.course h3 { margin: 2px 0 6px; font-family: var(--display); font-weight: 800; font-size: 25px; letter-spacing: -0.015em; line-height: 1.1; }
.course p { margin: 0 0 6px; font-family: var(--ui); font-size: 15px; line-height: 1.5; color: var(--ink-2); }
.course dl { margin: 10px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-family: var(--ui); font-size: 14px; }
.course dt { color: var(--ink-3); }
.course dd { margin: 0; }
@media (max-width: 700px) { .courses { grid-template-columns: 1fr; } }

/* ---------- resources ---------- */
.res { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 1em 0 1.6em; max-width: 880px; }
.res a {
  display: block; padding: 13px 15px 12px; background: var(--card); border: 1px solid var(--rule);
  color: var(--ink); text-decoration: none; position: relative;
}
.res a:hover { border-color: var(--ink); }
.res a:hover .res__t { text-decoration: underline; text-underline-offset: 0.15em; }
.res__t { display: block; font-family: var(--ui); font-weight: 650; font-size: 15.5px; line-height: 1.35; padding-right: 20px; }
.res__d { display: block; margin-top: 4px; font-family: var(--ui); font-size: 14px; line-height: 1.45; color: var(--ink-2); }
.res__tag { display: inline-block; margin-top: 8px; font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); }
.res__tag--off { color: var(--teal); }
.res a::after { content: "\2197"; position: absolute; top: 11px; right: 12px; color: var(--ink-3); font-family: var(--ui); }
@media (max-width: 700px) { .res { grid-template-columns: 1fr; } }

/* ---------- doubts ---------- */
.faq-search { display: flex; align-items: center; gap: 12px; margin: 0 0 12px; max-width: 880px; }
.faq-search input { flex: 1; min-width: 0; height: 46px; padding: 0 14px; border: 1.5px solid var(--ink); background: var(--card); font-family: var(--ui); font-size: 16px; border-radius: 0; }
.faq-count { font-family: var(--mono); font-size: 12.5px; color: var(--ink-3); white-space: nowrap; }
.faq { max-width: 880px; }
.faq details { border-top: 1px solid var(--rule); }
.faq details:last-child { border-bottom: 1px solid var(--rule); }
.faq summary {
  display: grid; grid-template-columns: 42px 1fr 20px; gap: 6px; align-items: baseline;
  padding: 13px 0; cursor: pointer; list-style: none; font-family: var(--ui); font-weight: 650; font-size: 16.5px; line-height: 1.4;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--teal); font-weight: 400; font-size: 20px; line-height: 1; text-align: right; }
.faq details[open] summary::after { content: "\2212"; }
.faq__n { font-family: var(--mono); font-size: 12px; font-weight: 400; color: var(--ink-3); }
.faq details p { margin: 0 0 14px 48px; font-size: 17px; color: var(--ink-2); }
.faq-empty { font-style: italic; color: var(--ink-3); }
@media (max-width: 640px) { .faq details p { margin-left: 0; } .faq summary { grid-template-columns: 34px 1fr 18px; } }

.gloss { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 8px 22px; font-family: var(--ui); font-size: 15.5px; line-height: 1.5; max-width: 880px; }
.gloss dt { font-family: var(--mono); font-size: 13.5px; font-weight: 700; color: var(--teal); padding-top: 2px; }
.gloss dd { margin: 0; color: var(--ink-2); }
@media (max-width: 640px) { .gloss { grid-template-columns: 1fr; gap: 0; } .gloss dd { margin-bottom: 10px; } }

/* course colour swatches */
.sw--mlf { --c: var(--c-mlf); background: var(--c-mlf); }
.sw--mlt { --c: var(--c-mlt); background: var(--c-mlt); }
.sw--mlp { --c: var(--c-mlp); background: var(--c-mlp); }
.sw--proj { --c: var(--c-proj); background: var(--c-proj); }
.c-mlf { --c: var(--c-mlf); }
.c-mlt { --c: var(--c-mlt); }
.c-mlp { --c: var(--c-mlp); }
.c-proj { --c: var(--c-proj); }

/* course swatch before a sub-heading */
.body h3 .sw { display: inline-block; width: 0.45em; height: 0.45em; margin-right: 0.3em; border-radius: 2px; vertical-align: 0.06em; }

/* the closing slab sits inside the last chapter */
.slab--end { margin-top: 44px; }
@media (min-width: 861px) { .slab--end h2 { font-size: clamp(34px, 4.2vw, 58px); } }
