Files
ProcessControl/_extensions/notes/theme.css
T
MatsuneMikuroiandClaude Opus 5 f7fa60ba81 Night-mode styling, French cross-references, and the log through Part VI
- theme.scss and figures draw with the extension's --calc-… tokens; light/dark
  pair plus the high-contrast button; a11y highlight style for html
- figure labels split so none leaves its viewBox in any language
- _quarto-fr.yml: French cross-reference prefixes
- notes extension synced to 2.8.18
- conv/: Parts IV, V and VI logged, pasted terminal output redacted

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-10-06 03:36:51 +02:00

241 lines
11 KiB
CSS

/* 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;
}