This commit is contained in:
MatsuneMikuroi committed 2026-10-16 09:05:43 +02:00
1 parent 8bbcf8ecd9
commit 45dd65b48e
116 files changed
+20457 -1164

No files matched your search

@@ -0,0 +1,88 @@
/* exo — exercise cards, hint folds (sequential unlock), solution fold */
.exo {
margin: 1.2rem 0;
padding: 0.6rem 0.9rem;
border: 1px solid color-mix(in srgb, var(--calc-notecolor, #B45309) 35%, transparent);
border-left: 3px solid var(--calc-notecolor, #B45309);
border-radius: 0.35rem;
scroll-margin-top: 5rem;
}
/* keep wide content inside the card: display math (and tables/code) scroll
on their own rather than spilling past the border. overflow-y stays hidden
so Firefox doesn't add a phantom vertical bar, as in .calc */
.exo mjx-container[display="true"],
.exo .katex-display {
max-width: 100%;
overflow-x: auto;
overflow-y: hidden;
padding-bottom: 0.35em; /* keep descenders clear of a horizontal bar */
/* a centred overflowing box clips its left side out of reach, so centre
only while the formula fits (browsers without `safe` keep plain centring) */
display: flex;
justify-content: center;
justify-content: safe center;
}
.exo .math.display { display: block; max-width: 100%; }
.exo :is(pre, table) { max-width: 100%; overflow-x: auto; }
.exo img, .exo svg { max-width: 100%; }
.exo-head p { margin: 0 0 0.4rem; }
.exo-head strong { color: var(--calc-notecolor, #B45309); }
.exo details {
margin: 0.45rem 0;
border-radius: 0.3rem;
}
.exo details > summary {
cursor: pointer;
list-style: none;
user-select: none;
font-size: 0.9em;
font-weight: 600;
}
.exo details > summary::-webkit-details-marker { display: none; }
.exo details > summary::before { content: "▸ "; }
.exo details[open] > summary::before { content: "▾ "; }
/* hints: small highlight boxes */
.exo-hint {
background: color-mix(in srgb, var(--calc-notecolor, #B45309) 6%, transparent);
border: 1px solid color-mix(in srgb, var(--calc-notecolor, #B45309) 30%, transparent);
padding: 0.25rem 0.6rem;
}
.exo-hint > summary { color: var(--calc-notecolor, #B45309); }
/* locked hints: unlock one by one */
.exo-hint.exo-locked > summary {
cursor: not-allowed;
opacity: 0.45;
}
.exo-hint.exo-locked > summary::before { content: "🔒 "; }
/* solution: closed by default, visually separated */
.exo-sol {
border-top: 1px dashed color-mix(in srgb, var(--calc-notecolor, #B45309) 40%, transparent);
padding: 0.35rem 0.1rem 0.1rem;
scroll-margin-top: 5rem;
}
/* Quarto greys every summary (#6c757d): 3.4:1 on darkly */
.exo-sol > summary { color: var(--calc-muted, #57606a); }
/* in a numbered part, the fold lines up with the part's text */
.exo li > details { margin-left: 0; }
/* hand-in extracts (handin.sh, html output) */
.exo-handin-sol, .exo-handin-hint {
margin: 0.6rem 0;
padding: 0.2rem 0 0.2rem 0.8rem;
border-left: 2px solid var(--calc-notecolor, #B45309);
}
.exo-fold-body { margin-top: 0.3rem; }
.exo-fold-body > p:first-child { margin-top: 0; }
.exo-fold-body > p:last-child { margin-bottom: 0; }
@media print {
.exo details > summary::before { content: ""; }
.exo-hint.exo-locked > summary { opacity: 1; cursor: default; }
}
@@ -0,0 +1,39 @@
// exo — hints unlock one by one within a part; everything unfolds for printing
(function () {
// block opening a locked hint
document.addEventListener("click", function (e) {
var s = e.target.closest ? e.target.closest("details.exo-hint.exo-locked > summary") : null;
if (s) e.preventDefault();
});
// opening hint n of a part unlocks hint n+1 of the same part, wherever it
// sits in the exercise (toggle doesn't bubble: use capture)
document.addEventListener("toggle", function (e) {
var d = e.target;
if (!d.classList || !d.classList.contains("exo-hint") || !d.open) return;
var chain = d.getAttribute("data-exo-chain");
var n = parseInt(d.getAttribute("data-exo-hint"), 10);
if (!chain || isNaN(n)) return;
var hints = document.querySelectorAll("details.exo-hint[data-exo-chain]");
for (var i = 0; i < hints.length; i++) {
if (hints[i].getAttribute("data-exo-chain") === chain &&
parseInt(hints[i].getAttribute("data-exo-hint"), 10) === n + 1) {
hints[i].classList.remove("exo-locked");
}
}
}, true);
// print: open all hints/solutions, restore afterwards
window.addEventListener("beforeprint", function () {
document.querySelectorAll(".exo details").forEach(function (d) {
d.dataset.exoWasOpen = d.open ? "1" : "0";
d.open = true;
});
});
window.addEventListener("afterprint", function () {
document.querySelectorAll(".exo details").forEach(function (d) {
d.open = d.dataset.exoWasOpen === "1";
delete d.dataset.exoWasOpen;
});
});
})();
@@ -0,0 +1,34 @@
/* further — "to go further" notes: optional material, set apart in purple */
.further {
margin: 1.1rem 0;
padding: 0.5rem 0.9rem 0.6rem;
border: 1px solid color-mix(in srgb, var(--calc-furthercolor, #6B3FA0) 30%, transparent);
border-left: 3px solid var(--calc-furthercolor, #6B3FA0);
border-radius: 0.35rem;
background: color-mix(in srgb, var(--calc-furthercolor, #6B3FA0) 4%, transparent);
}
.further-head {
color: var(--calc-furthercolor, #6B3FA0);
font-weight: 600;
font-size: 0.92em;
margin-bottom: 0.35rem;
}
.further-body > p:first-child { margin-top: 0; }
.further-body > p:last-child { margin-bottom: 0; }
/* keep wide content inside the box, as .calc and .exo do */
.further mjx-container[display="true"],
.further .katex-display {
max-width: 100%;
overflow-x: auto;
overflow-y: hidden;
padding-bottom: 0.35em;
display: flex;
justify-content: center;
justify-content: safe center;
}
.further :is(pre, table) { max-width: 100%; overflow-x: auto; }
.further img, .further svg { max-width: 100%; }
@@ -0,0 +1,76 @@
/* glossary — usages, entries, hover tooltip */
/* usages: dotted underline, keep math color */
a.gls-sym,
mjx-container a {
color: inherit;
text-decoration: none;
}
.gls-sym {
border-bottom: 1px dotted currentColor;
cursor: help;
}
/* rendered glossary list */
.glossary .gls-entry {
margin: 0.8rem 0;
padding: 0.35rem 0.7rem;
border-left: 3px solid var(--calc-notecolor, #B45309);
scroll-margin-top: 5rem; /* don't hide behind Quarto's sticky header */
}
.glossary .gls-entry p { margin: 0 0 0.2rem; }
.glossary .gls-entry:target {
background: color-mix(in srgb, var(--calc-notecolor, #B45309) 10%, transparent);
border-radius: 0.25rem;
}
/* floating hover tooltip (filled by glossary.js) */
.gls-float {
position: absolute;
z-index: 1000;
max-width: 26rem;
padding: 0.5rem 0.75rem;
border: 1px solid var(--calc-notecolor, #B45309);
border-radius: 0.4rem;
background: var(--calc-surface, #fff);
color: var(--bs-body-color, #1a1a1a);
box-shadow: 0 4px 14px var(--calc-shadow, rgba(0, 0, 0, 0.15));
font-size: 0.9em;
line-height: 1.4;
}
.gls-float p { margin: 0 0 0.25rem; }
.gls-float p:last-child { margin-bottom: 0; }
/* in-place definition cards and property sub-entries */
.gls-inline {
margin: 1rem 0;
padding: 0.4rem 0.8rem;
border-left: 3px solid var(--calc-notecolor, #B45309);
scroll-margin-top: 5rem;
}
.gls-inline p { margin: 0 0 0.3rem; }
.gls-inline:target,
.gls-prop-entry:target {
background: color-mix(in srgb, var(--calc-notecolor, #B45309) 10%, transparent);
border-radius: 0.25rem;
}
.gls-prop-entry {
margin: 0.5rem 0 0.5rem 1.2rem;
padding: 0.25rem 0.6rem;
border-left: 2px solid color-mix(in srgb, var(--calc-notecolor, #B45309) 45%, transparent);
font-size: 0.95em;
scroll-margin-top: 5rem;
}
.gls-back {
font-size: 0.85em; /* smaller, not fainter: at 0.75 opacity the link read 3.4:1 */
}
/* standalone property cards keep the section flow (no indent) */
.gls-prop-entry.gls-standalone {
margin-left: 0;
font-size: 1em;
}
.glossary .gls-prop-line {
margin: 0.1rem 0 0.1rem 1.2rem;
font-size: 0.9em;
}
@@ -0,0 +1,68 @@
// glossary — hover tooltip for .gls-sym usages (prose links and MathJax \class nodes)
(function () {
var tip = null;
function ensureTip() {
if (tip === null) {
tip = document.createElement("div");
tip.className = "gls-float";
tip.style.display = "none";
document.body.appendChild(tip);
}
return tip;
}
function keyOf(el) {
if (el.dataset && el.dataset.glsKey) return el.dataset.glsKey;
for (var i = 0; i < el.classList.length; i++) {
var c = el.classList[i];
if (c.indexOf("gls-key-") === 0) return c.slice(8);
}
return null;
}
function show(target) {
var key = keyOf(target);
if (!key) return;
var entry = document.getElementById("gls-" + key);
var t = ensureTip();
if (entry) {
// for a main entry, don't drag every property into the popup
var node = entry.cloneNode(true);
node.querySelectorAll(".gls-prop-entry").forEach(function (n) { n.remove(); });
t.innerHTML = node.innerHTML;
} else if (window.__glsData && window.__glsData[key]) {
// entry lives on another page (book chapters render separately)
t.innerHTML = window.__glsData[key];
} else {
return;
}
t.style.display = "block";
if (window.MathJax && window.MathJax.typesetPromise) {
window.MathJax.typesetPromise([t]).catch(function () {});
}
var r = target.getBoundingClientRect();
var x = r.left + window.scrollX;
var y = r.bottom + window.scrollY + 6;
// keep it on screen horizontally
var w = t.offsetWidth;
var maxX = window.scrollX + document.documentElement.clientWidth - w - 12;
t.style.left = Math.max(window.scrollX + 8, Math.min(x, maxX)) + "px";
t.style.top = y + "px";
}
function hide() {
if (tip !== null) tip.style.display = "none";
}
document.addEventListener("mouseover", function (e) {
var el = e.target.closest ? e.target.closest(".gls-sym") : null;
if (el) show(el);
});
document.addEventListener("mouseout", function (e) {
var el = e.target.closest ? e.target.closest(".gls-sym") : null;
if (el) hide();
});
document.addEventListener("click", hide);
window.addEventListener("scroll", hide, { passive: true });
})();
@@ -0,0 +1,45 @@
/* latex-tables — HTML rendering of LaTeX tabular environments */
.ltx-table {
border-collapse: collapse;
margin: 1rem auto;
max-width: 100%;
overflow-x: auto;
display: table;
}
.ltx-table th,
.ltx-table td {
padding: 0.35em 0.7em;
vertical-align: top;
line-height: 1.4;
}
.ltx-table th {
font-weight: 600;
}
/* alignment */
.ltx-l { text-align: left; }
.ltx-c { text-align: center; }
.ltx-r { text-align: right; }
/* vertical rules (from | in the column spec) */
.ltx-bl { border-left: 1px solid currentColor; }
.ltx-br { border-right: 1px solid currentColor; }
/* horizontal rules: t = above the row, b = below.
1 = \hline / \midrule / \cline, 2 = booktabs \toprule / \bottomrule,
d = doubled rule (\hline\hline) */
.ltx-t1 { border-top: 1px solid currentColor; }
.ltx-b1 { border-bottom: 1px solid currentColor; }
.ltx-t2 { border-top: 1.6px solid currentColor; }
.ltx-b2 { border-bottom: 1.6px solid currentColor; }
.ltx-td { border-top: 3px double currentColor; }
.ltx-bd { border-bottom: 3px double currentColor; }
/* keep wide tables usable on narrow screens */
@media (max-width: 700px) {
.ltx-table { font-size: 0.9em; }
.ltx-table th, .ltx-table td { padding: 0.25em 0.45em; }
}
@@ -0,0 +1,115 @@
/* calc-notes — HTML layout for the calc / calc* environments */
.calc {
display: grid;
/* lhs | rhs | notes | equation number */
grid-template-columns: max-content max-content minmax(8rem, 1fr) auto;
column-gap: 0.35rem;
row-gap: 0.6rem;
align-items: baseline;
margin: 1rem 0 1.4rem;
/* allow horizontal scrolling for very wide equations, but never show a
vertical bar (Firefox computes phantom vertical overflow otherwise) */
overflow-x: auto;
overflow-y: hidden;
padding-bottom: 0.4em; /* keep descenders clear of a horizontal bar */
}
.calc-row { display: contents; }
.calc-lhs { grid-column: 1; justify-self: end; }
.calc-rhs { grid-column: 2; justify-self: start; }
.calc-full { grid-column: 1 / 3; justify-self: start; }
/* ---- notes ------------------------------------------------------- */
.calc-notes {
grid-column: 3;
display: flex;
flex-wrap: wrap;
gap: 0.35rem 0.75rem;
align-items: baseline;
min-width: 0;
padding-left: 0.9rem;
}
.calc-note {
color: var(--calc-notecolor, #B45309);
font-size: 0.85em;
line-height: 1.35;
}
.calc-note > summary {
cursor: pointer;
list-style: none; /* remove the default triangle ... */
user-select: none;
font-style: italic; /* quiet by style and --calc-muted (theme.css), not by
opacity, which took it under 4.5:1 */
}
.calc-note > summary::-webkit-details-marker { display: none; }
.calc-note > summary::before { content: "▸ "; font-style: normal; }
.calc-note[open] > summary::before { content: "▾ "; }
.calc-note > summary:hover { opacity: 1; }
.calc-note[open] {
background: color-mix(in srgb, var(--calc-notecolor, #B45309) 8%, transparent);
border-left: 2px solid var(--calc-notecolor, #B45309);
border-radius: 0.25rem;
padding: 0.15rem 0.45rem;
}
.calc-note-body { margin-top: 0.1rem; }
.calc-note-body p { margin: 0; }
/* \mnote: math note (no extra styling needed — body is typeset math) */
.calc-note-math .calc-note-body { padding: 0.1rem 0; }
/* ---- calc*: boxed final result ----------------------------------- */
.calc-box {
display: inline-block;
border: 1.5px solid currentColor;
border-radius: 0.3em;
padding: 0.3em 0.65em;
margin-top: 0.15em;
background: color-mix(in srgb, currentColor 4%, transparent);
}
/* ---- labelled blocks: equation number on the last line ----------- */
.calc-tag {
grid-column: 4;
justify-self: end;
padding-left: 1rem;
white-space: nowrap;
}
/* ---- printing: show notes unfolded, like the PDF ------------------ */
@media print {
.calc-note > summary { display: none; }
.calc-note[open] { background: none; border: none; padding: 0; }
}
/* small screens: notes drop under the equation line */
@media (max-width: 560px) {
.calc { grid-template-columns: max-content 1fr; }
.calc-notes { grid-column: 1 / 3; padding-left: 1.5rem; }
.calc-full { grid-column: 1 / 3; }
.calc-tag { grid-column: 1 / -1; }
}
/* --- interactive figures ------------------------------------------------
A figure that is dragged — a rotatable 3d view, a point moved with the
mouse — must not select its own labels while the pointer travels over
them: the browser would paint the axis names and captions as selected
text. The readouts and captions around the drawing stay selectable, so a
value can still be copied. The hooks are the ones every course's figure
scripts build into. */
[data-notes-fig] svg,
[data-notes-plot] svg,
[data-notes-fig] canvas,
[data-notes-plot] canvas {
-webkit-user-select: none;
user-select: none;
}
@@ -0,0 +1,70 @@
// calc-notes — open every note before printing, restore afterwards
(function () {
window.addEventListener("beforeprint", function () {
document.querySelectorAll("details.calc-note").forEach(function (d) {
d.dataset.calcWasOpen = d.open ? "1" : "0";
d.open = true;
});
});
window.addEventListener("afterprint", function () {
document.querySelectorAll("details.calc-note").forEach(function (d) {
d.open = d.dataset.calcWasOpen === "1";
delete d.dataset.calcWasOpen;
});
});
})();
// --- high contrast: a switch of its own, beside Quarto's light/dark one ----
// The class is already set before the first paint by the script calc-notes.lua
// puts in the head; this only builds the control and remembers a choice.
// Precedence: what the reader picked here, then `high-contrast: true` in the
// book, then the reader's system setting.
(function () {
var KEY = "notes-contrast";
var root = document.documentElement;
var LABELS = {
de: { on: "Hoher Kontrast aus", off: "Hoher Kontrast ein" },
fr: { on: "Désactiver le contraste élevé", off: "Activer le contraste élevé" },
en: { on: "Turn high contrast off", off: "Turn high contrast on" }
};
var lang = (root.lang || "en").slice(0, 2).toLowerCase();
var L = LABELS[lang] || LABELS.en;
function store(v) {
try { localStorage.setItem(KEY, v ? "more" : "normal"); } catch (e) {}
}
function paint() {
var on = root.classList.contains("hc");
document.querySelectorAll(".notes-contrast-toggle").forEach(function (b) {
b.setAttribute("aria-pressed", String(on));
b.setAttribute("title", on ? L.on : L.off);
b.setAttribute("aria-label", on ? L.on : L.off);
});
}
function build() {
var anchors = document.querySelectorAll(".quarto-color-scheme-toggle");
if (anchors.length === 0) return; // a page without Quarto's own tools
anchors.forEach(function (a) {
var b = document.createElement("button");
b.type = "button";
b.className = "quarto-navigation-tool px-1 notes-contrast-toggle";
// bootstrap-icons ships with these books; the glyph is the fallback
b.innerHTML = '<i class="bi bi-circle-half" aria-hidden="true"></i>';
b.addEventListener("click", function () {
var on = !root.classList.contains("hc");
root.classList.toggle("hc", on);
store(on);
paint();
});
a.parentNode.insertBefore(b, a.nextSibling);
});
paint();
}
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", build);
} else { build(); }
})();
@@ -0,0 +1,316 @@
/* high-contrast.css — the high-contrast pair, taken from GitHub's
"GitHub Light High Contrast" and "GitHub Dark High Contrast" VS Code
themes (the Primer `light_high_contrast` / `dark_high_contrast` scales).
It is switched by `hc` on <html>, which calc-notes.lua sets from
high-contrast: true
in the document metadata, and which the same in-header script sets for a
reader whose system asks for `prefers-contrast: more`. One class rather
than a class and a media query, so the palette below is written once.
It rides on top of the ordinary light/dark pair: `html.hc` restyles the
light theme, `html.hc body.quarto-dark` the night one, so the reader's own
light/dark toggle keeps working.
GitHub's two high-contrast themes separate things by outline rather than by
fill: text sits at full strength (fg.muted == fg.default), borders are
strong, and the tinted panels of the ordinary themes lose their tint. The
rules here do the same to the notes environments. */
/* ---------------------------------------------------------------- light -- */
html.hc {
/* Primer light_high_contrast */
--hc-canvas: #ffffff; /* canvas.default */
--hc-inset: #ffffff; /* canvas.inset — separation is by border */
--hc-fg: #0e1116; /* fg.default, and fg.muted, which equals it */
--hc-subtle: #66707b; /* fg.subtle — the only softened ink */
--hc-border: #20252c; /* border.default */
--hc-border-soft: #88929d; /* border.muted */
--hc-accent: #0349b4; /* accent.fg */
--hc-danger: #a0111f; /* danger.fg */
--hc-success: #055d20; /* success.fg */
--hc-attention: #4e2c00; /* attention.fg */
--hc-severe: #702c00; /* severe.fg */
--hc-done: #622cbc; /* done.fg */
/* the extension's own tokens */
--calc-ink: var(--hc-fg);
--calc-muted: var(--hc-fg);
--calc-line: var(--hc-border);
--calc-grid: var(--hc-border-soft);
--calc-accent-a: var(--hc-accent);
--calc-accent-b: var(--hc-severe);
--calc-accent-c: var(--hc-success);
--calc-danger: var(--hc-danger);
--calc-surface: var(--hc-canvas);
--calc-faint: var(--hc-border-soft);
--calc-shadow: rgba(14, 17, 22, 0.4);
--calc-domface: var(--hc-canvas);
--calc-domtop: #d8dee4;
--calc-notecolor: var(--hc-attention);
--calc-furthercolor: var(--hc-done);
/* the page itself */
--bs-body-bg: var(--hc-canvas);
--bs-body-color: var(--hc-fg);
--bs-emphasis-color: var(--hc-fg);
--bs-secondary-color: var(--hc-fg);
--bs-tertiary-color: var(--hc-subtle);
--bs-border-color: var(--hc-border);
--bs-link-color: var(--hc-accent);
--bs-link-hover-color: var(--hc-accent);
--bs-code-color: var(--hc-fg);
--bs-heading-color: var(--hc-fg);
}
/* ----------------------------------------------------------------- dark -- */
html.hc body.quarto-dark {
/* Primer dark_high_contrast, except for the canvas: the theme's own
#0a0c10 still reads as a very dark grey next to a black one, so the page
goes fully black and every other value keeps its relation to it. */
--hc-canvas: #000000; /* canvas.default is #0a0c10 upstream */
--hc-inset: #000000; /* canvas.inset */
--hc-subtle-bg: #272b33; /* canvas.subtle */
--hc-fg: #f0f3f6; /* fg.default == fg.muted */
--hc-subtle: #9ea7b3; /* fg.subtle */
--hc-border: #7a828e; /* border.default */
--hc-border-soft: #7a828e; /* border.muted — the same in this theme */
--hc-accent: #71b7ff; /* accent.fg */
--hc-danger: #ff9492; /* danger.fg */
--hc-success: #26cd4d; /* success.fg */
--hc-attention: #f0b72f; /* attention.fg */
--hc-severe: #ff803d; /* severe.fg */
--hc-done: #cb9eff; /* done.fg */
/* a stroke on near-black wants the text colour, not the border grey */
--calc-line: var(--hc-fg);
--calc-grid: var(--hc-border);
--calc-domface: var(--hc-subtle-bg);
--calc-domtop: #3d444d;
--calc-shadow: rgba(1, 4, 9, 0.8);
}
/* the tokens that only alias, so they follow whichever block is in force */
html.hc body.quarto-dark {
--calc-ink: var(--hc-fg);
--calc-muted: var(--hc-fg);
--calc-accent-a: var(--hc-accent);
--calc-accent-b: var(--hc-severe);
--calc-accent-c: var(--hc-success);
--calc-danger: var(--hc-danger);
--calc-surface: var(--hc-canvas);
--calc-faint: var(--hc-border);
--calc-notecolor: var(--hc-attention);
--calc-furthercolor: var(--hc-done);
--bs-body-bg: var(--hc-canvas);
--bs-body-color: var(--hc-fg);
--bs-emphasis-color: var(--hc-fg);
--bs-secondary-color: var(--hc-fg);
--bs-tertiary-color: var(--hc-subtle);
--bs-border-color: var(--hc-border);
--bs-link-color: var(--hc-accent);
--bs-link-hover-color: var(--hc-accent);
--bs-code-color: var(--hc-fg);
--bs-heading-color: var(--hc-fg);
}
/* --------------------------------------------------------- page chrome -- */
/* Quarto's own furniture is compiled from the bootswatch theme, so the
variables above do not reach all of it. */
html.hc body {
background-color: var(--hc-canvas);
color: var(--hc-fg);
}
html.hc :is(h1, h2, h3, h4, h5, h6, p, li, dt, dd, caption, figcaption, th, td) {
color: var(--hc-fg);
}
html.hc :is(.text-muted, .quarto-figure figcaption, figcaption.figure-caption,
.quarto-title-meta-heading, .quarto-title-meta-contents,
.callout-title-container, .footnotes) {
color: var(--hc-fg);
}
html.hc a:not(.nav-link):not(.sidebar-item-text) { color: var(--hc-accent); }
html.hc a:focus-visible,
html.hc button:focus-visible,
html.hc summary:focus-visible { outline: 2px solid var(--hc-accent); outline-offset: 2px; }
html.hc :is(#quarto-sidebar, #quarto-margin-sidebar, .sidebar, .sidebar-navigation,
#quarto-header, .navbar, .quarto-secondary-nav) {
background-color: var(--hc-canvas);
color: var(--hc-fg);
border-color: var(--hc-border);
}
html.hc :is(.sidebar-item-text, .sidebar .nav-link, nav[role="doc-toc"] a, .navbar .nav-link,
.quarto-secondary-nav .nav-link) {
color: var(--hc-fg);
opacity: 1;
}
html.hc .sidebar nav[role="doc-toc"] ul > li > a,
html.hc .sidebar-navigation .sidebar-item a,
html.hc .sidebar-navigation .sidebar-item .sidebar-item-text {
color: var(--hc-fg);
opacity: 1;
}
/* the active entry: Quarto writes its colour with !important, so this is the
one place the palette has to answer in kind */
html.hc .sidebar nav[role="doc-toc"] ul > li > a.active,
html.hc .sidebar nav[role="doc-toc"] ul > li > ul > li > a.active,
html.hc .sidebar nav[role="doc-toc"] ul > li > a:hover,
html.hc .sidebar-navigation .sidebar-item a.active,
html.hc .sidebar-navigation .sidebar-item a:hover {
color: var(--hc-accent) !important;
border-left-color: var(--hc-accent);
font-weight: 600;
}
html.hc nav[role="doc-toc"] { border-left: 1px solid var(--hc-border-soft); }
/* the breadcrumb of the collapsed header carries its own fill in both
bootswatch themes, and its ink is the weakest contrast on the page */
html.hc .breadcrumb {
background-color: var(--hc-canvas);
border: 1px solid var(--hc-border);
}
html.hc :is(.breadcrumb, .breadcrumb-item, .breadcrumb-item a, .quarto-btn-toggle) {
color: var(--hc-fg);
}
html.hc .breadcrumb-item a { color: var(--hc-accent); }
html.hc :is(hr, .quarto-title-block .quarto-title-banner, header#title-block-header) {
border-color: var(--hc-border);
}
html.hc hr { background-color: var(--hc-border); opacity: 1; }
html.hc blockquote {
border-left: 4px solid var(--hc-border);
color: var(--hc-fg);
}
html.hc :is(table, th, td) { border-color: var(--hc-border-soft); }
html.hc thead { border-bottom: 2px solid var(--hc-border); }
/* ------------------------------------------------------------- code ----- */
/* GitHub's high-contrast themes give a block an outline instead of a fill. */
html.hc :is(pre, div.sourceCode, pre.sourceCode) {
background-color: var(--hc-inset);
border: 1px solid var(--hc-border);
color: var(--hc-fg);
}
html.hc :not(pre) > code {
background-color: var(--hc-inset);
border: 1px solid var(--hc-border-soft);
border-radius: 3px;
color: var(--hc-fg);
padding: 0 0.2em;
}
html.hc code { color: var(--hc-fg); }
/* the syntax palette of the same two themes, mapped onto pandoc's classes */
html.hc code span:is(.co, .cv, .do, .an, .in) { color: var(--hc-subtle); font-style: italic; }
html.hc code span:is(.kw, .cf) { color: var(--hc-danger); }
html.hc code span:is(.st, .ch, .sc, .ss, .vs){ color: #032563; }
html.hc code span:is(.dv, .bn, .fl, .cn) { color: #023b95; }
html.hc code span:is(.fu, .ex) { color: #512598; }
html.hc code span:is(.va, .at) { color: var(--hc-severe); }
html.hc code span:is(.dt, .bu) { color: var(--hc-success); }
html.hc code span:is(.im, .pp) { color: var(--hc-severe); }
html.hc code span:is(.er, .wa, .al) { color: var(--hc-danger); font-weight: 600; }
html.hc code span:is(.op, .ot) { color: var(--hc-fg); }
html.hc body.quarto-dark code span:is(.st, .ch, .sc, .ss, .vs) { color: #addcff; }
html.hc body.quarto-dark code span:is(.dv, .bn, .fl, .cn) { color: #91cbff; }
html.hc body.quarto-dark code span:is(.fu, .ex) { color: #dbb7ff; }
html.hc body.quarto-dark code span:is(.co, .cv, .do, .an, .in) { color: #bdc4cc; }
/* ------------------------------------------- the notes environments ----- */
/* out goes the tint; the outline carries the box, at full accent strength */
html.hc :is(.exo, .further, .quiz, .gls-inline, .gls-float, .calc-note,
.exo-sol, .exo-hint, .quiz-opt) {
background: var(--hc-canvas);
}
html.hc .exo { border-color: var(--calc-notecolor); }
html.hc :is(.exo-sol, .exo-hint) { border-color: var(--calc-notecolor); }
html.hc .exo-head strong,
html.hc .exo-hint > summary { color: var(--calc-notecolor); }
html.hc .further { border-color: var(--calc-furthercolor); }
html.hc .gls-float { border-color: var(--calc-notecolor); box-shadow: 0 4px 14px var(--calc-shadow); }
html.hc :is(.gls-inline, .calc-note) { border-left-width: 4px; }
html.hc .gls-sym { text-decoration-color: var(--calc-notecolor); }
html.hc .quiz { --quiz-ok: var(--hc-success); --quiz-bad: var(--hc-danger); --quiz-ink: var(--hc-fg); }
html.hc :is(.quiz-opt.quiz-ok, .quiz-opt.quiz-bad) { background: var(--hc-canvas); }
html.hc .quiz-opt.quiz-ok { outline: 2px solid var(--hc-success); }
html.hc .quiz-opt.quiz-bad { outline: 2px solid var(--hc-danger); }
/* Quarto's own callouts, so a page does not mix outlined boxes with filled
ones; the callout keeps its colour, in its left bar and its title */
html.hc .callout {
background-color: var(--hc-canvas) !important;
border: 1px solid var(--hc-border);
}
html.hc .callout > .callout-header {
background-color: var(--hc-canvas) !important;
border-bottom: 1px solid var(--hc-border-soft);
}
html.hc :is(.callout-body, .callout-title-container, .callout-body-container p) {
color: var(--hc-fg);
}
html.hc .callout.callout-style-default > div.callout-header { font-weight: 600; }
/* Quarto's search box: its widget is not themed by the bootswatch pair, so it
stays white on a dark page unless it is told otherwise (see theme.css) */
html.hc :is(.aa-Form, .aa-InputWrapper, .aa-Panel, .aa-Item) {
background-color: var(--hc-canvas);
color: var(--hc-fg);
border-color: var(--hc-border);
}
html.hc :is(.aa-Autocomplete, .aa-DetachedFormContainer)
.aa-Form .aa-InputWrapper .aa-Input,
html.hc :is(.aa-Autocomplete, .aa-DetachedFormContainer)
.aa-Form .aa-InputWrapperSuffix .aa-ClearButton,
html.hc :is(.aa-Autocomplete, .aa-DetachedFormContainer)
.aa-Form .aa-InputWrapperPrefix :is(.aa-Label, .aa-LoadingIndicator) svg {
color: var(--hc-fg);
}
html.hc :is(.aa-Autocomplete, .aa-DetachedFormContainer)
.aa-Form .aa-InputWrapper .aa-Input::placeholder {
color: var(--hc-fg);
opacity: 0.75;
}
/* the results panel: Quarto colours the cards through an id, so this does too */
html.hc :is(.aa-DetachedOverlay, #quarto-search-results) li.aa-Item .search-item,
html.hc :is(.aa-DetachedOverlay, #quarto-search-results) li.aa-Item .search-item
:is(.search-result-title-container, .search-result-text-container,
.search-result-section, .search-result-text, .search-result-more) {
background-color: var(--hc-canvas);
color: var(--hc-fg);
}
html.hc :is(.aa-DetachedOverlay, #quarto-search-results) li.aa-Item[aria-selected="true"] .search-item,
html.hc :is(.aa-DetachedOverlay, #quarto-search-results) li.aa-Item[aria-selected="true"] .search-item
:is(.search-result-title-container, .search-result-text-container,
.search-result-section, .search-result-text, .search-result-more) {
background-color: var(--hc-accent);
color: var(--hc-canvas);
}
/* a hit is marked by weight and a rule, not by a block of colour */
html.hc :is(.aa-DetachedOverlay, #quarto-search-results) li.aa-Item .search-item
:is(mark.search-match, .search-match.mark) {
background-color: transparent;
color: inherit;
font-weight: 700;
text-decoration: underline;
}
/* the figure buttons of the animated schemes */
html.hc :is(.ns-btn, .nc-btn, .nd-replay) {
background: var(--hc-canvas);
color: var(--hc-fg);
border-color: var(--hc-border);
}
html.hc :is(.notes-spiral, .notes-cantor) :is(.ns-btn, .nc-btn)[aria-pressed="true"] {
background: var(--hc-canvas);
border-color: var(--hc-accent);
color: var(--hc-accent);
font-weight: 600;
}
/* the last tinted fills: a calc box and a note keep their outline instead */
html.hc :is(.calc-box, .calc-note, .calc-note[open]) { background: transparent; }
@@ -0,0 +1,106 @@
/* narrow.css — the book on a phone.
Nothing in the flow may be wider than the screen: a wide formula, table or
figure scrolls inside its own box instead of pushing the whole page
sideways (which leaves the text cut off at the left edge).
Loaded with calc-notes.css, so every page of every book gets it. */
/* --- display maths ------------------------------------------------------
The boxes of this extension (.calc, .exo, .further) already scroll their
own maths; this covers every other display formula on the page. */
:is(main, .quarto-title-block) :is(mjx-container[display="true"], .math.display) {
max-width: 100%;
overflow-x: auto;
overflow-y: hidden; /* Firefox computes phantom vertical overflow */
padding-bottom: 0.35em; /* keep descenders clear of a scrollbar */
/* a centred formula that overflows would hide its left side out of reach,
so centre it only while it fits */
justify-content: safe center;
}
/* --- everything else that can be wider than a phone ---------------------- */
main :is(pre, .sourceCode) { max-width: 100%; overflow-x: auto; }
main :is(img, svg) { max-width: 100%; height: auto; }
main table:not(.ltx-table) { display: block; max-width: 100%; overflow-x: auto; }
/* the animated figures of lesson-style chapters */
.notes-cantor, .notes-spiral, .notes-dominos { max-width: 100%; overflow-x: auto; }
/* the glossary popup: never wider than the screen */
.gls-float { max-width: min(92vw, 26rem); }
/* --- phone-sized screens ------------------------------------------------- */
@media (max-width: 575.98px) {
/* the equation number of a labelled calc block goes under the line, so the
formula keeps the full width */
.calc { grid-template-columns: max-content 1fr; }
/* figure captions and the fold summaries read better tight */
.exo, .further { padding-left: 0.6rem; padding-right: 0.6rem; }
/* A bare url in prose, or a long identifier in a code span, is one word to
the line breaker and paints past its block on a narrow screen — no
element is oversized, so only the text itself overflows. */
#quarto-document-content :is(a, code) { overflow-wrap: break-word; }
/* Quarto lets inline code wrap only inside a <p> (white-space: pre-wrap);
in a list item or a table it keeps one line, and a formula such as
"{PersN} → {PersN, Name, Position, Room, …}" pushed a page to 947px. */
#quarto-document-content :not(pre) > code:not(.sourceCode) { white-space: pre-wrap; }
/* A long compound in running text — "Unternehmensarchitekturmanagement" in
a list item is 348px — has no break opportunity. The page's lang picks
the hyphenation dictionary; overflow-wrap is the fallback without one. */
#quarto-document-content { hyphens: auto; overflow-wrap: break-word; }
/* An inline formula MathJax cannot break (one long fraction or product)
is wider than a phone: 413px in ModernPhysics' first exercise. It scrolls
inside its own box instead of pushing the page; the padding keeps tall
glyphs clear of the box's edge. */
/* A Bootstrap grid (::: {.grid} with .g-col-* items) has 12 columns and 11
gaps of 1.5rem: 264px of gaps alone, more than a callout on a phone
(248px in SoftwareEngineering's git appendix), so the columns collapse to
0 and a full-width item overflows. A smaller gap keeps the layout;
min-width: 0 lets an item's text wrap instead of widening its track. */
.grid { --bs-gap: 0.75rem; }
.grid > [class*="g-col"] { min-width: 0; }
#quarto-document-content mjx-container:not([display="true"]) {
display: inline-block;
max-width: 100%;
overflow-x: auto;
overflow-y: hidden;
vertical-align: middle;
padding-block: 0.15em;
}
/* Quarto's own previous/next footer: the chapter titles are laid out in a
row that will not shrink, so a long title pushes the page sideways. */
.page-navigation { flex-wrap: wrap; row-gap: 0.75em; }
.nav-page, .nav-page .nav-page-text { min-width: 0; }
.nav-page .chapter-title { overflow-wrap: break-word; }
/* A long compound in a heading — "Implementierungsentscheidungen" is 366px
at h3 size — is wider than a 320px screen. The page's lang picks the
hyphenation dictionary; overflow-wrap is the fallback without one. */
#quarto-document-content :is(h1, h2, h3, h4, h5, h6),
.quarto-title .title {
hyphens: auto;
overflow-wrap: break-word;
}
/* The bar at the top of a phone page: menu button, the chapter's title,
search. The title is a flex item that will not shrink, so a long one
("3 Komplexitätsanalyse" in darkly's wider font) pushes the search button
off the screen. It now shrinks and ends in an ellipsis. */
.quarto-secondary-nav nav.quarto-page-breadcrumbs { min-width: 0; }
.quarto-secondary-nav nav.quarto-page-breadcrumbs .breadcrumb {
flex-wrap: nowrap;
min-width: 0;
}
.quarto-secondary-nav nav.quarto-page-breadcrumbs .breadcrumb-item {
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
@@ -0,0 +1,240 @@
/* theme.css — one palette for every part of the notes extension, in light
mode, in night mode and in high contrast.
Night mode keys off Quarto's own `body.quarto-dark`, which the light/dark
toggle sets — never off `prefers-color-scheme`, so a book configured
light-only stays light for a reader whose system is dark.
A book opts in with, in _quarto.yml:
format:
html:
theme:
light: [cosmo]
dark: [darkly]
High contrast is a separate sheet, high-contrast.css, after GitHub's two
high-contrast VS Code themes. It keys off `hc` on <html>, which
calc-notes.lua sets from `high-contrast: true` in the metadata and for a
reader whose system asks for `prefers-contrast: more`.
Loaded with calc-notes.css, so every page of every book has these tokens. */
:root {
--calc-ink: #1a1a1a; /* figure text, strong strokes */
--calc-muted: #57606a; /* captions, readouts, button text */
--calc-line: #444444; /* axes and rules */
--calc-grid: #cccccc; /* lattice dots, faint grid */
--calc-accent-a: #1F6FB4; /* lineA of the tikz preamble */
--calc-accent-b: #D1541F; /* lineB */
--calc-accent-c: #2E8B57; /* lineC */
--calc-danger: #B91C1C; /* an error state, e.g. a failed code run */
--calc-surface: var(--bs-body-bg, #ffffff);
--calc-faint: #e7e9ec; /* hairlines between rows */
--calc-shadow: rgba(0, 0, 0, 0.15); /* floats above the page */
--calc-domface: #DCE7F2; /* the domino figure's front face */
--calc-domtop: #B8CFE4; /* its top face */
/* --calc-notecolor-src and --calc-furthercolor-src come from the document
metadata (calc-notes.lua / further.lua) and are the book's own colours;
--calc-notecolor and --calc-furthercolor are what everything draws with,
and equal the source here. The dark block lifts them. */
}
body.quarto-dark {
--calc-ink: #e6e9ed;
--calc-muted: #9aa4b2;
--calc-line: #b6bec7;
--calc-grid: #4b535d;
--calc-accent-a: #6fb0ea;
--calc-accent-b: #f0956a;
--calc-accent-c: #64c49a;
--calc-danger: #f08a8a;
--calc-faint: #3a4049;
--calc-shadow: rgba(0, 0, 0, 0.55);
--calc-domface: #2b3b4d;
--calc-domtop: #365070;
/* The book's own accent is kept, not replaced: its print value is too dim
on a dark ground, so it is lifted to a light tone at the same hue rather
than swapped for a generic amber. A book that wants a specific night
value sets `notecolor-dark:` / `furthercolor-dark:` in its metadata.
On a browser without relative colour syntax the lift is dropped and the
book's own colour is used unchanged. */
--calc-notecolor:
var(--calc-notecolor-dark,
oklch(from var(--calc-notecolor-src, #B45309) 0.78 c h));
--calc-furthercolor:
var(--calc-furthercolor-dark,
oklch(from var(--calc-furthercolor-src, #6B3FA0) 0.80 c h));
}
/* --- generated line art -------------------------------------------------
The tikz figures are black-and-colour line drawings on transparent white.
Inverting them keeps the drawing readable and, with the hue rotation,
keeps blue blue and orange orange. Photographs live under img/ and are
left alone; an svg that is a photograph, or that carries its own dark
palette, opts out with class="no-invert". */
body.quarto-dark main img[src$=".svg"]:not(.no-invert) {
filter: invert(1) hue-rotate(180deg);
}
/* --- captions -----------------------------------------------------------
Quarto's caption grey reads 4.4:1 on cosmo's white, under WCAG AA. The
muted token reads about 6.4:1 in light and in dark, and high contrast
makes it the foreground. The list ends with Quarto's most specific caption
selector so that :is() gives every entry its weight. */
:is(.panel-caption, .figure-caption, .subfigure-caption, .table-caption,
figcaption, caption, .margin-caption, .column-margin figcaption,
.quarto-layout-cell[data-ref-parent] caption) {
color: var(--calc-muted, #57606a);
}
/* --- breadcrumbs --------------------------------------------------------
Quarto greys the current page (#6c757d) and Bootstrap the separators; on
darkly's breadcrumb band that reads 2.1:1. The ink token passes in every
mode. `body` outweighs Quarto's own selectors; pseudo-elements cannot go
inside :is(), hence the separate rule. */
body :is(.quarto-title-breadcrumbs .breadcrumb li:last-of-type a,
.breadcrumb-item.active) {
color: var(--calc-ink, #1a1a1a);
}
body .breadcrumb-item + .breadcrumb-item::before,
body .quarto-secondary-nav nav.quarto-page-breadcrumbs .breadcrumb-item::before,
body .quarto-secondary-nav nav.quarto-page-breadcrumbs a {
color: var(--calc-ink, #1a1a1a);
}
/* --- Quarto's other greys -----------------------------------------------
Quarto hard-codes #6c757d for every fold label (details > summary) and for
the previous/next page links, and a mid grey for section numbers: 3.4:1 on
darkly, 4.4:1 on cosmo. The muted token reads about 6.4:1 in both, and
high contrast makes it the foreground. An exercise hint keeps its accent
(.exo-hint > summary outweighs these), and the active entry of the
contents still inherits its colour. */
body details > summary,
body .nav-page a,
body .header-section-number {
color: var(--calc-muted, #57606a);
}
/* Quoted text: Quarto's .blockquote grey is 4.4:1 on cosmo, and it names the
paragraphs, so they are named here too. */
body :is(blockquote, .blockquote, blockquote p, .blockquote p) {
color: var(--calc-muted, #57606a);
}
/* Inline code: Bootstrap's pill is #f8f9fa in both themes, so darkly's light
code text sat on near-white (1.05:1). The pill is now a faint tint of the
page, which keeps each theme's code colour readable, and inherited muted
text (code in a caption) too. */
body :not(pre) > code:not(.sourceCode) {
background-color: color-mix(in srgb, var(--calc-faint, #e7e9ec) 60%,
var(--calc-surface, #ffffff));
}
/* A code block inside a tinted box (exercise, hint, solution, "to go
further", quiz): Quarto's block ground is 65% opaque, so the tint shows
through and a11y-light's keyword red drops to 4.4:1. Here the ground is
opaque, and the same light grey as on the page. */
body :is(.exo, .exo-hint, .exo-sol, .further, .quiz) div.sourceCode {
background-color: color-mix(in srgb, var(--calc-faint, #e7e9ec) 45%,
var(--calc-surface, #ffffff));
}
/* A static (not executed) block also gives its <code> the translucent
ground, so the two layers stack and darken it. The block carries the
ground; the code inside is transparent, as in an executed cell. */
body div.sourceCode > pre > code.sourceCode { background-color: transparent; }
/* --- Jupyter output: ANSI colours ---------------------------------------
A traceback comes out in the notebook's terminal palette, made for a dark
terminal: yellow is 1.9:1 and cyan 2.0:1 on the page. Each colour name
takes the matching token with a fifth of ink, which keeps the hue and passes
in all four modes. IPython's 256-colour spans carry inline styles and no
name, so they take the text colour. */
body :is(.ansi-black-fg, .ansi-bright-black-fg) { color: var(--calc-ink); }
body :is(.ansi-white-fg, .ansi-bright-white-fg) { color: var(--calc-muted); }
body :is(.ansi-red-fg, .ansi-bright-red-fg) {
color: color-mix(in srgb, var(--calc-danger) 85%, var(--calc-ink));
}
body :is(.ansi-green-fg, .ansi-bright-green-fg) {
color: color-mix(in srgb, var(--calc-accent-c) 75%, var(--calc-ink));
}
body :is(.ansi-yellow-fg, .ansi-bright-yellow-fg) {
color: color-mix(in srgb, var(--calc-accent-b) 75%, var(--calc-ink));
}
body :is(.ansi-blue-fg, .ansi-bright-blue-fg) {
color: color-mix(in srgb, var(--calc-accent-a) 80%, var(--calc-ink));
}
body :is(.ansi-magenta-fg, .ansi-bright-magenta-fg) {
color: color-mix(in srgb, var(--calc-furthercolor) 85%, var(--calc-ink));
}
body :is(.ansi-cyan-fg, .ansi-bright-cyan-fg) {
color: color-mix(in srgb,
color-mix(in srgb, var(--calc-accent-a) 50%, var(--calc-accent-c)) 75%,
var(--calc-ink));
}
body .ansi-escaped-output span[style*="color"] { color: inherit !important; }
/* --- higher contrast ---------------------------------------------------
The high-contrast pair lives in high-contrast.css, which is loaded with
this file and keys off `hc` on <html>. */
/* --- Quarto's search box -------------------------------------------------
The search widget keeps its own white surface whatever the bootswatch
theme says, so on a dark page it is a white slab with dark text. It is
given the page's own surface here rather than in each book. */
body.quarto-dark :is(.aa-Form, .aa-InputWrapper, .aa-Panel, .aa-Item,
.aa-DetachedContainer, .aa-DetachedFormContainer) {
background-color: var(--calc-surface, #222);
color: var(--calc-ink, #e6e9ed);
border-color: var(--calc-faint, #3a4049);
}
/* The ink inside the form is a separate problem from its surface: Quarto's
dark bundle sets the input, its placeholder, the clear button and the
magnifier to rgb(45,45,45) through a four-class selector, so a short one
loses the cascade and the typed text stays unreadable. The shape below
matches Quarto's own, which is the only way to win without !important. */
body.quarto-dark :is(.aa-Autocomplete, .aa-DetachedFormContainer)
.aa-Form .aa-InputWrapper .aa-Input,
body.quarto-dark :is(.aa-Autocomplete, .aa-DetachedFormContainer)
.aa-Form .aa-InputWrapperSuffix .aa-ClearButton,
body.quarto-dark :is(.aa-Autocomplete, .aa-DetachedFormContainer)
.aa-Form .aa-InputWrapperPrefix :is(.aa-Label, .aa-LoadingIndicator) svg {
color: var(--calc-ink, #e6e9ed);
}
body.quarto-dark :is(.aa-Autocomplete, .aa-DetachedFormContainer)
.aa-Form .aa-InputWrapper .aa-Input::placeholder {
color: var(--calc-muted, #9aa4b2);
}
/* --- search: the selected result ----------------------------------------
Quarto marks it with cosmo's primary (#2780e3) under white text, 3.97:1,
and its matched words with a lighter blue, worse still. The same hue at a
lower lightness passes. Night mode (darkly's #375a7f, 7.2:1) and high
contrast (high-contrast.css) keep their own. */
html:not(.hc) body:not(.quarto-dark) :is(.aa-DetachedOverlay, #quarto-search-results)
li.aa-Item[aria-selected="true"] :is(.search-item, .search-item *:not(mark, .mark)) {
background-color: oklch(from var(--bs-primary, #2780e3) 0.42 c h);
}
html:not(.hc) body:not(.quarto-dark) :is(.aa-DetachedOverlay, #quarto-search-results)
li.aa-Item[aria-selected="true"] .search-item :is(mark.search-match, .search-match.mark) {
background-color: oklch(from var(--bs-primary, #2780e3) 0.52 c h);
}
/* --- the high-contrast switch -------------------------------------------
Built by calc-notes.js next to Quarto's light/dark toggle, and styled to
sit with it rather than stand out. */
.notes-contrast-toggle {
background: none;
border: 0;
color: inherit;
line-height: 1;
cursor: pointer;
opacity: 0.85;
}
.notes-contrast-toggle:hover { opacity: 1; }
.notes-contrast-toggle[aria-pressed="true"] {
opacity: 1;
color: var(--calc-accent-a, #1F6FB4);
}
.notes-contrast-toggle:focus-visible {
outline: 2px solid var(--calc-accent-a, #1F6FB4);
outline-offset: 2px;
}
@@ -0,0 +1,178 @@
/* quiz — tick-box self-checks: options, per-option explanations, score bar
*
* The card borrows .exo's frame so a quiz and an exercise look related.
* Green and red are reserved for the verdict: nothing else on the page uses
* them, so a colour here always means "this answer was judged".
*/
.quiz {
--quiz-ok: #1a7f5a;
--quiz-bad: #a3324a;
--quiz-ink: #5a6879;
margin: 1.4rem 0;
padding: 0.7rem 1rem 0.85rem;
border: 1px solid color-mix(in srgb, var(--calc-notecolor, #B45309) 35%, transparent);
border-left: 3px solid var(--calc-notecolor, #B45309);
border-radius: 0.35rem;
scroll-margin-top: 5rem;
}
/* keep wide content inside the card, as in .calc and .exo */
.quiz mjx-container[display="true"],
.quiz .katex-display {
max-width: 100%;
overflow-x: auto;
overflow-y: hidden;
padding-bottom: 0.35em;
display: flex;
justify-content: center;
justify-content: safe center;
}
.quiz .math.display { display: block; max-width: 100%; }
.quiz :is(pre, table) { max-width: 100%; overflow-x: auto; }
.quiz img, .quiz svg { max-width: 100%; }
.quiz-head { margin: 0 0 0.45rem; }
.quiz-head strong { color: var(--calc-notecolor, #B45309); }
.quiz-tip {
margin: 0 0 0.7rem;
font-size: 0.82rem;
color: var(--quiz-ink);
}
/* ---- questions ------------------------------------------------------ */
.quiz-q + .quiz-q {
margin-top: 1.1rem;
padding-top: 0.9rem;
border-top: 1px dashed color-mix(in srgb, var(--calc-notecolor, #B45309) 30%, transparent);
}
.quiz-q-head { margin: 0 0 0.35rem; font-size: 0.9em; }
/* ---- options -------------------------------------------------------- */
.quiz-opts {
list-style: none;
margin: 0.55rem 0 0;
padding: 0;
}
.quiz-opt {
margin: 0;
padding: 0.22rem 0.4rem;
border-radius: 0.25rem;
border-left: 2px solid transparent;
}
.quiz-opt + .quiz-opt { margin-top: 0.15rem; }
/* the whole row is the click target, so a long formula is still easy to tick */
.quiz-label {
display: flex;
align-items: baseline;
gap: 0.55rem;
cursor: pointer;
}
.quiz-box {
flex: 0 0 auto;
width: 1rem;
height: 1rem;
margin: 0;
/* baseline-align the box with the first line of the option text */
transform: translateY(0.15rem);
accent-color: var(--calc-notecolor, #B45309);
cursor: pointer;
}
.quiz-opt-text { min-width: 0; }
.quiz-opt-text > :first-child { margin-top: 0; }
.quiz-opt-text > :last-child { margin-bottom: 0; }
/* judged options */
.quiz-opt.quiz-ok {
background: color-mix(in srgb, var(--quiz-ok) 8%, transparent);
border-left-color: var(--quiz-ok);
}
.quiz-opt.quiz-bad {
background: color-mix(in srgb, var(--quiz-bad) 8%, transparent);
border-left-color: var(--quiz-bad);
}
/* ---- explanations --------------------------------------------------- */
.quiz-why {
margin: 0.35rem 0 0.15rem 1.55rem;
padding: 0.3rem 0 0.3rem 0.7rem;
border-left: 2px solid var(--quiz-bad);
font-size: 0.88rem;
}
.quiz-why > :first-child { margin-top: 0; }
.quiz-why > :last-child { margin-bottom: 0; }
.quiz-why-q {
margin-left: 0;
margin-top: 0.5rem;
}
/* ---- verdict and bar ------------------------------------------------ */
.quiz-verdict {
margin: 0.5rem 0 0;
font-size: 0.85rem;
font-weight: 600;
}
.quiz-verdict.quiz-ok { color: var(--quiz-ok); }
.quiz-verdict.quiz-bad { color: var(--quiz-bad); }
.quiz-bar {
display: flex;
align-items: center;
gap: 0.6rem;
flex-wrap: wrap;
margin-top: 1rem;
padding-top: 0.7rem;
border-top: 1px solid color-mix(in srgb, var(--calc-notecolor, #B45309) 25%, transparent);
}
.quiz-bar button {
font: inherit;
font-size: 0.84rem;
padding: 0.2rem 0.85rem;
cursor: pointer;
border: 1px solid color-mix(in srgb, var(--calc-notecolor, #B45309) 45%, transparent);
border-radius: 999px;
background: transparent;
color: var(--calc-notecolor, #B45309);
}
.quiz-bar button:hover {
background: color-mix(in srgb, var(--calc-notecolor, #B45309) 10%, transparent);
}
.quiz-bar button.quiz-reset {
border-color: color-mix(in srgb, var(--quiz-ink) 40%, transparent);
color: var(--quiz-ink);
}
.quiz-bar button.quiz-reset:hover {
background: color-mix(in srgb, var(--quiz-ink) 10%, transparent);
}
.quiz-score {
font-size: 0.84rem;
color: var(--quiz-ink);
}
.quiz-score b { color: var(--calc-notecolor, #B45309); font-weight: 600; }
/* ---- dark theme ----------------------------------------------------- */
body.quarto-dark .quiz {
--quiz-ok: #4cb08a;
--quiz-bad: #e2798f;
--quiz-ink: #8b98a8;
}
/* ---- print ----------------------------------------------------------
* Printing the HTML is a fallback (the pdf format is the real print path).
* A printed quiz is one to fill in with a pen: the bar goes, the boxes stay
* empty, and anything already revealed on screen is kept so a checked quiz
* prints as it looks.
*/
@media print {
.quiz-bar { display: none; }
.quiz-opt.quiz-ok, .quiz-opt.quiz-bad { background: none; }
}
@@ -0,0 +1,126 @@
// quiz — judge the tick boxes of one quiz, explain what went wrong
//
// Every label the reader sees is written into the markup by quiz.lua, so the
// wording follows the book's language and nothing is translated twice. A
// quiz carries:
// data-quiz-score "{n} of {m} questions correct" ({n}/{m} substituted)
// data-quiz-right verdict of a question answered correctly
// data-quiz-wrong verdict of a question answered wrongly
//
// A question is right only when every one of its options is in the right
// state: ticked when true, left empty when false. That is the "multiple
// true/false" rule of the exam, and it is why a half-ticked question counts
// as wrong.
(function () {
"use strict";
function options(quiz) {
return quiz.querySelectorAll(".quiz-opt");
}
function judge(quiz) {
var questions = quiz.querySelectorAll(".quiz-q");
var right = 0;
questions.forEach(function (q) {
var ok = true;
q.querySelectorAll(".quiz-opt").forEach(function (opt) {
var box = opt.querySelector(".quiz-box");
if (!box) return;
var want = opt.dataset.correct === "1";
var hit = box.checked === want;
opt.classList.toggle("quiz-ok", hit);
opt.classList.toggle("quiz-bad", !hit);
// the explanation of an option is for the reader who got it wrong
var why = opt.querySelector(".quiz-why");
if (why) why.hidden = hit;
if (!hit) ok = false;
});
var verdict = q.querySelector(".quiz-verdict");
if (verdict) {
verdict.hidden = false;
verdict.textContent = ok
? (quiz.dataset.quizRight || "Correct")
: (quiz.dataset.quizWrong || "Not quite");
verdict.classList.toggle("quiz-ok", ok);
verdict.classList.toggle("quiz-bad", !ok);
}
// a question-level explanation backs up a wrong answer as a whole
var qwhy = q.querySelector(".quiz-why-q");
if (qwhy) qwhy.hidden = ok;
if (ok) right++;
});
var score = quiz.querySelector(".quiz-score");
if (score) {
var template = quiz.dataset.quizScore || "{n}/{m}";
score.innerHTML = "";
// built as nodes, not markup: the template comes from metadata
var parts = template.split(/\{n\}|\{m\}/);
var values = [];
(template.match(/\{n\}|\{m\}/g) || []).forEach(function (token) {
values.push(token === "{n}" ? right : questions.length);
});
parts.forEach(function (text, i) {
score.appendChild(document.createTextNode(text));
if (i < values.length) {
var b = document.createElement("b");
b.textContent = String(values[i]);
score.appendChild(b);
}
});
}
}
function reset(quiz) {
options(quiz).forEach(function (opt) {
var box = opt.querySelector(".quiz-box");
if (box) box.checked = false;
opt.classList.remove("quiz-ok", "quiz-bad");
var why = opt.querySelector(".quiz-why");
if (why) why.hidden = true;
});
quiz.querySelectorAll(".quiz-verdict").forEach(function (v) {
v.hidden = true;
v.textContent = "";
v.classList.remove("quiz-ok", "quiz-bad");
});
quiz.querySelectorAll(".quiz-why-q").forEach(function (w) { w.hidden = true; });
var score = quiz.querySelector(".quiz-score");
if (score) score.textContent = "";
}
document.addEventListener("click", function (event) {
var target = event.target;
if (!target.closest) return;
var check = target.closest(".quiz .quiz-check");
if (check) {
judge(check.closest(".quiz"));
return;
}
var again = target.closest(".quiz .quiz-reset");
if (again) {
reset(again.closest(".quiz"));
}
});
// re-ticking a box after checking clears that row's verdict, so a stale
// green or red never sits next to a box the reader has just changed
document.addEventListener("change", function (event) {
var box = event.target;
if (!box.closest || !box.classList || !box.classList.contains("quiz-box")) return;
var opt = box.closest(".quiz-opt");
if (!opt) return;
opt.classList.remove("quiz-ok", "quiz-bad");
var why = opt.querySelector(".quiz-why");
if (why) why.hidden = true;
});
})();