/* Matrix: site chrome. Book-like and quiet: one serif, no italics, no labels in capitals.
   The figures themselves carry the colour. */

:root {
  --serif: Baskerville, "Baskerville Old Face", "Libre Baskerville", "Hoefler Text", Georgia, serif;
  --paper: #fbfaf6;
  --ink: #1f1e1c;
  --ink-2: #4a4843;
  --muted: #8b877e;
  --rule: #e2ded4;
  --tile: #f1eee6;
  --accent: #a3341f;          /* used only inside the index drawings */
  --wash: rgba(31, 30, 28, 0.06);
  --wash-accent: rgba(163, 52, 31, 0.13);
  --grain-opacity: 0.05;
  --measure: 40rem;
  --wide: 72rem;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0a0a0a; --ink: #ececec; --ink-2: #b4b4b4; --muted: #7a7a7a; --rule: #232323;
    --tile: #121212; --accent: #f07c64; --wash: rgba(255, 255, 255, 0.06); --wash-accent: rgba(240, 124, 100, 0.16);
    --grain-opacity: 0;
  }
}
:root[data-theme="dark"] {
  --paper: #0a0a0a; --ink: #ececec; --ink-2: #b4b4b4; --muted: #7a7a7a; --rule: #232323;
  --tile: #121212; --accent: #f07c64; --wash: rgba(255, 255, 255, 0.06); --wash-accent: rgba(240, 124, 100, 0.16);
  --grain-opacity: 0;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 19px/1.55 var(--serif);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-variant-numeric: lining-nums;
}
/* Paper grain: a fixed layer of fine noise, too faint to notice until it is gone. */
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.2 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
body > * { position: relative; z-index: 1; }

em, i, cite { font-style: normal; }
a { color: inherit; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.18em; text-decoration-color: var(--rule); transition: text-decoration-color .2s; }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
::selection { background: var(--wash-accent); }
h1, h2, h3 { font-weight: 400; margin: 0; letter-spacing: 0; }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 12px; background: var(--paper); padding: 6px 10px; z-index: 10; }

.page { max-width: var(--wide); margin: 0 auto; padding: 0 24px; }
.prose { max-width: var(--measure); }

/* Top line: the site name, where you are, and the theme switch. Small and grey. */
.topline { display: flex; align-items: baseline; gap: 0.6em; padding: 22px 0 0; font-size: 16px; color: var(--muted); }
.topline a { text-decoration: none; color: var(--muted); }
.topline a:hover { color: var(--ink); }
.topline .sep { color: var(--rule); }
.topline .here { color: var(--ink-2); }
.theme { margin-left: auto; align-self: center; display: grid; place-items: center; width: 32px; height: 32px; margin-right: -6px;
  color: var(--muted); background: none; border: 0; border-radius: 50%; padding: 0; cursor: pointer; transition: color .2s, background-color .2s; }
.theme:hover { color: var(--ink); background: var(--wash); }
.theme svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.theme .i-auto .fill { fill: currentColor; stroke: none; }
.theme .i-light, .theme .i-dark { display: none; }
.theme[data-mode="light"] .i-auto, .theme[data-mode="dark"] .i-auto { display: none; }
.theme[data-mode="light"] .i-light, .theme[data-mode="dark"] .i-dark { display: block; }

/* ---------------------------------------------------------------- index */
.masthead { padding: 72px 0 8px; }
.masthead h1 { font-size: clamp(44px, 7vw, 64px); line-height: 1.05; }
.masthead p { margin: 18px 0 0; color: var(--ink-2); max-width: 34rem; }

.course { padding-top: 64px; }
.course h2 { font-size: 30px; padding-bottom: 10px; border-bottom: 1px solid var(--rule); display: flex; align-items: baseline; gap: 14px; }
.course h2 .count { margin-left: auto; font-size: 16px; color: var(--muted); }

.entries { list-style: none; margin: 0; padding: 32px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 44px 36px; }
.entry a { display: block; text-decoration: none; color: inherit; }
.entry .tile { display: block; aspect-ratio: 5 / 3; background: var(--tile); color: var(--ink); border: 1px solid var(--rule); transition: border-color .25s; }
.entry a:hover .tile { border-color: var(--muted); }
.entry .title { display: block; margin-top: 14px; font-size: 21px; line-height: 1.3; }
.entry .title .no { color: var(--muted); margin-right: 0.45em; }
.entry a:hover .title-text { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.18em; text-decoration-color: var(--muted); }
.entry .desc { display: block; margin-top: 6px; font-size: 17px; line-height: 1.5; color: var(--ink-2); }
.entry .week { display: block; margin-top: 8px; font-size: 15px; color: var(--muted); }

/* ---------------------------------------------------------------- index drawings */
.motif { width: 100%; height: 100%; display: block; overflow: hidden; }
.motif line, .motif path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.motif .m-axis line { stroke: var(--muted); stroke-width: 0.8; opacity: 0.6; }
.motif .m-ink { stroke: currentColor; stroke-width: 1.8; }
.motif .m-accent { stroke: var(--accent); stroke-width: 2; }
.motif .m-thin { stroke-width: 1.1; }
.motif .m-faint { stroke: var(--muted); stroke-width: 1.1; stroke-dasharray: 3 3; opacity: 0.8; }
.motif .m-dash { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.motif .m-band { stroke: var(--rule); stroke-width: 1; stroke-dasharray: 1 3; }
.motif .m-grid { stroke: var(--muted); stroke-width: 0.5; opacity: 0.45; }
.motif .m-sheet { fill: var(--wash); stroke: var(--muted); stroke-width: 0.8; }
.motif .m-dot { fill: currentColor; }
.motif .m-dot-accent, .motif .m-accent-fill { fill: var(--accent); }
.motif .m-open { fill: var(--tile); stroke: currentColor; stroke-width: 1.4; }
.motif .m-node { fill: var(--tile); stroke: currentColor; stroke-width: 1.4; }
.motif .m-node-accent { fill: var(--accent); stroke: var(--accent); stroke-width: 1.4; }
.motif .m-wash { fill: var(--wash); }
.motif .m-wash-accent { fill: var(--wash-accent); }
.motif .m-frame { fill: var(--tile); stroke: currentColor; stroke-width: 1; }
.motif .m-frame-accent { fill: var(--wash-accent); stroke: var(--accent); stroke-width: 1.3; }
.motif .m-cell { fill: none; stroke: var(--muted); stroke-width: 0.8; }
.motif .m-cell-ink { fill: var(--wash); stroke: currentColor; stroke-width: 1; }
.motif .m-cell-accent { fill: var(--wash-accent); stroke: var(--accent); stroke-width: 1; }
.motif .m-cell-sel { fill: var(--accent); stroke: var(--accent); }
.motif text { font-family: var(--serif); fill: var(--muted); }
.motif .m-op { font-size: 16px; fill: var(--muted); text-anchor: middle; }
.motif .m-label { font-size: 11px; }
.motif .m-weight { font-size: 9px; text-anchor: middle; fill: var(--ink-2); paint-order: stroke; stroke: var(--tile); stroke-width: 3px; }
.motif .m-weight-accent { fill: var(--accent); }

/* ---------------------------------------------------------------- figure page */
.fig-head { padding: 56px 0 0; }
.fig-head h1 { font-size: clamp(34px, 5vw, 48px); line-height: 1.12; }
.fig-head p { margin: 16px 0 0; color: var(--ink-2); }

.fig { margin: 36px 0 0; }
.plate-frame { background: #121212; min-height: 240px; }
.plate-frame iframe { display: block; width: 100%; height: 720px; border: 0; background: transparent; }
.fig figcaption { margin-top: 14px; font-size: 17px; line-height: 1.5; color: var(--ink-2); }
.fig figcaption .no { color: var(--muted); margin-right: 0.3em; }
.fig figcaption .alone { color: var(--muted); white-space: nowrap; }

.notes { margin-top: 28px; }
.notes p { margin: 0 0 14px; }

.pager { display: flex; gap: 24px; justify-content: space-between; margin: 56px 0 0; padding-top: 18px; border-top: 1px solid var(--rule); font-size: 17px; }
.pager a { text-decoration: none; color: var(--ink-2); max-width: 46%; }
.pager a:hover { color: var(--ink); }
.pager .next { margin-left: auto; text-align: right; }
.pager .dir { display: block; font-size: 15px; color: var(--muted); }

/* ---------------------------------------------------------------- footer */
.colophon { margin-top: 96px; padding: 20px 0 36px; border-top: 1px solid var(--rule); font-size: 15px; color: var(--muted); }
.colophon p { margin: 0; }

/* ---------------------------------------------------------------- 404 */
.notfound .masthead p a { color: var(--ink); }

@media (max-width: 640px) {
  body { font-size: 18px; }
  .page { padding: 0 16px; }
  .masthead { padding-top: 48px; }
  .course { padding-top: 48px; }
  .course h2 { font-size: 26px; }
  .fig-head { padding-top: 36px; }
  .fig { margin-left: -16px; margin-right: -16px; }
  .fig figcaption { padding: 0 16px; }
  .topline .crumb-course { display: none; }
  .pager { flex-direction: column; }
  .pager a { max-width: none; }
  .pager .next { text-align: left; margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
