:root {
  --bg: #fdfdfb;
  --fg: #1c1c1c;
  --muted: #6b6b6b;
  --rule: #e2e2dc;
  --link: #1a5fb4;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16171a;
    --fg: #e4e4e0;
    --muted: #9a9a94;
    --rule: #33353a;
    --link: #78aeed;
  }
}

body {
  margin: 0;
  padding: 2rem 1rem 5rem;
  background: var(--bg);
  color: var(--fg);
  font: 1.125rem/1.65 Charter, "Bitstream Charter", "Iowan Old Style", Georgia, serif;
}

main {
  max-width: 42rem;
  margin: 0 auto;
}

/* The site's navigation bar (see style.css), lined up with the article. */
.site-header {
  max-width: 42rem;
  margin: 2rem auto 3rem;
}

.site-header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 24px;
  font: 15px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.site-header nav a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
}

.site-header nav a:hover,
.site-header nav a[aria-current] {
  color: var(--fg);
}

.site-header nav a[aria-current] {
  font-weight: 500;
}

@media (max-width: 640px) {
  .site-header { margin: 0 auto 2rem; }
  .site-header nav { gap: 4px 18px; }
}

a { color: var(--link); }

h1, h2, h3 { line-height: 1.25; }
h1 { font-size: 2.1rem; margin: 0 0 0.4rem; }
h2 { font-size: 1.45rem; margin-top: 2.8rem; }

.date { color: var(--muted); margin: 0 0 2.5rem; }

blockquote {
  margin: 1.5rem 0;
  padding: 0.1rem 1.2rem;
  border-left: 3px solid var(--rule);
  color: var(--muted);
}

code {
  font-size: 0.9em;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

img { max-width: 100%; height: auto; display: block; margin: 1.5rem auto; }

/* Eigenvectors of S_n, phase as hue (posts/scripts/shift-eigen-steps.js). */
.shift-eigen-steps { margin: 1.5rem 0; }
.shift-eigen-steps canvas { display: block; width: min(400px, 100%); height: auto; margin: 0 auto 0.75rem; }
.shift-eigen-steps figcaption { margin-top: 0.25rem; text-align: center; }
/* Labeled n and k sliders, like .phase-signal's. */
.shift-eigen-steps label { display: flex; align-items: center; gap: 0.75rem; width: min(400px, 100%); margin: 0.25rem auto; }
.shift-eigen-steps label input[type="range"] { flex: 1; width: auto; margin: 0; }
.shift-eigen-steps label var { flex: none; width: 1em; text-align: center; }

/* An image shifted with wrap-around (posts/scripts/shift-steps.js). */
.shift-steps { margin: 1.5rem 0; }
.shift-steps canvas { display: block; width: min(400px, 100%); height: auto; margin: 0 auto 0.75rem; }
.shift-steps input[type="range"] { width: min(400px, 100%); display: block; margin: 0 auto; }
.shift-steps figcaption { margin-top: 0.25rem; text-align: center; }

/* An image beside a bar graph of one of its rows (posts/scripts/row-signal.js).
   A bit wider than the text column, like .adjacency-demo. */
.row-signal {
  --rs-mark: #e01b24;
  --rs-bar: #1a5fb4;
  --rs-w: min(100vw - 2rem, 50rem);
  width: var(--rs-w);
  margin: 1.5rem calc((100% - var(--rs-w)) / 2);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
}
.row-signal canvas {
  display: block;
  flex: 1 1 18rem;
  min-width: 0;
  max-width: 24rem;
  height: auto;
}
.row-signal .rs-image { cursor: crosshair; touch-action: none; }
.row-signal .rs-graph { cursor: crosshair; touch-action: none; }
.row-signal .rs-image:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
@media (prefers-color-scheme: dark) {
  .row-signal { --rs-bar: #78aeed; --rs-mark: #ff6b6b; }
}

/* The nth roots of unity in the complex plane, with a slider for n
   (posts/scripts/roots-of-unity.js). Each root's fill is its phase as a hue,
   matching .shift-eigen-steps. */
.roots-of-unity { margin: 1.5rem 0; }
.roots-of-unity svg { display: block; width: min(360px, 100%); height: auto; margin: 0 auto 0.5rem; }
.roots-of-unity .ru-axis { stroke: var(--muted); stroke-width: 0.012; }
.roots-of-unity .ru-unit { fill: none; stroke: var(--rule); stroke-width: 0.015; }
.roots-of-unity .ru-root { stroke: var(--fg); stroke-width: 0.012; }
.roots-of-unity .ru-label { fill: var(--muted); font-size: 0.14px; font-family: inherit; }
/* Root labels: a halo in the page color keeps the axes from crossing them. */
.roots-of-unity .ru-k {
  fill: var(--fg);
  stroke: var(--bg);
  stroke-width: 0.04px;
  paint-order: stroke;
  font-family: inherit;
}
.roots-of-unity .ru-sub { font-size: 0.75em; }
.roots-of-unity label { display: flex; align-items: center; gap: 0.75rem; width: min(360px, 100%); margin: 0 auto; }
.roots-of-unity label input[type="range"] { flex: 1; }
.roots-of-unity label var { flex: none; width: 1em; text-align: center; }
.roots-of-unity output { flex: none; width: 1.5em; text-align: right; font-variant-numeric: tabular-nums; }

/* A bar graph of an eigenvector of S_n, colored by phase
   (posts/scripts/phase-signal.js). Sized like one .row-signal graph. */
.phase-signal { --ps-axis: #6b6b6b; margin: 1.5rem 0; }
.phase-signal canvas { display: block; width: min(24rem, 100%); height: auto; margin: 0 auto 0.75rem; }
.phase-signal figcaption { margin-top: 0.25rem; text-align: center; }
.phase-signal label { display: flex; align-items: center; gap: 0.75rem; width: min(24rem, 100%); margin: 0.25rem auto; }
.phase-signal label input[type="range"] { flex: 1; width: auto; margin: 0; }
.phase-signal label var { flex: none; width: 1em; text-align: center; }
@media (prefers-color-scheme: dark) {
  .phase-signal { --ps-axis: #9a9a94; }
}

/* An image beside the DFT of its rows (posts/scripts/dft-rows.js). Laid out
   like .row-signal: a bit wider than the text column, stacking when narrow. */
.dft-rows {
  --dr-mark: #e01b24;
  --dr-bar: #1a5fb4;
  --dr-w: min(100vw - 2rem, 50rem);
  width: var(--dr-w);
  margin: 1.5rem calc((100% - var(--dr-w)) / 2);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  /* Bottom-aligned, not stretched: a graph's label above it makes its box
     taller than the image beside it, and stretching would distort that
     image. All the canvases are the same size, so aligning bottoms lines up
     the canvases, with the labels sticking up above. */
  align-items: flex-end;
  gap: 1rem;
}
.dft-rows > canvas, .dft-rows .dr-graph { display: block; flex: 1 1 18rem; min-width: 0; max-width: 24rem; }
.dft-rows canvas { height: auto; }
/* Each graph with its vector's name centered above it. */
.dft-rows .dr-graph { text-align: center; }
.dft-rows .dr-graph canvas { display: block; width: 100%; margin-top: 0.25rem; }
.dft-rows .dr-graph p { margin: 0; }
.dft-rows .dr-image, .dft-rows .dr-dft { cursor: crosshair; touch-action: none; }
.dft-rows .dr-image:focus-visible, .dft-rows .dr-dft:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
@media (prefers-color-scheme: dark) {
  .dft-rows { --dr-bar: #78aeed; --dr-mark: #ff6b6b; }
}

/* An image rebuilt from its rows' coefficients (posts/scripts/dft-rows.js):
   the reconstruction, with the latest coefficients and eigenvector side by
   side below it; a bit wider than the text column like .dft-rows, and one
   column when narrow. The controls and caption are centered below. */
.dft-partial {
  --dp-w: min(100vw - 2rem, 50rem);
  width: var(--dp-w);
  margin: 1.5rem calc((100% - var(--dp-w)) / 2);
}
/* A two-by-two grid: the reconstruction and the current term on top, the
   coefficient and eigenvector below. One column when narrow. */
.dft-partial .dp-images {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 24rem));
  justify-content: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}
.dft-partial .dp-image { min-width: 0; text-align: center; }
@media (max-width: 37rem) {
  .dft-partial .dp-images { grid-template-columns: minmax(0, 24rem); }
}
.dft-partial .dp-image canvas { display: block; width: 100%; height: auto; margin-top: 0.25rem; }
/* Pandoc may wrap each label in a <p>. */
.dft-partial .dp-image p { margin: 0; }
/* Play and reset, then step buttons on either side of the slider. */
.dft-partial .dp-controls { display: flex; align-items: center; gap: 0.75rem; width: min(32rem, 100%); margin: 0 auto; }
/* Pandoc wraps the slider and the button after it in a <p>, so that's a flex
   row too, stretching to fill what the first button leaves. */
.dft-partial .dp-controls p { flex: 1; min-width: 0; margin: 0; display: flex; align-items: center; gap: 0.75rem; }
.dft-partial .dp-controls input[type="range"] { flex: 1; min-width: 0; margin: 0; }
.dft-partial .dp-play, .dft-partial .dp-reset { flex: none; font: inherit; font-size: 0.9rem; width: 4.5em; padding: 0.15rem 0; cursor: pointer; }
.dft-partial .dp-step { flex: none; font: inherit; font-size: 0.8rem; line-height: 1; padding: 0.3rem 0.5rem; cursor: pointer; }
.dft-partial figcaption { margin-top: 0.25rem; text-align: center; }

/* A row of pixels with a button that shifts it (posts/scripts/shift-row.js). */
.shift-row .sr-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}
.shift-row .adj-grid { outline: 1px solid var(--rule); }
.shift-row .sr-vector > p { margin: 0; }
.shift-row .sr-apply { font: inherit; padding: 0.2rem 0.9rem; cursor: pointer; }

hr { border: 0; border-top: 1px solid var(--rule); margin: 3rem 0; }

/* notes.lua puts a "Notes" heading above the footnotes; drop pandoc's rule. */
.footnotes > hr { display: none; }

/* KaTeX's default is 1.21em; 10% smaller. Scoped to main so it beats
   katex.min.css, which loads after this file. */
main .katex { font-size: 1.1em; }

/* Adjacency matrix beside a small image (posts/scripts/adjacency-demo.js). */
.adjacency-demo {
  --adj-a: #e01b24;
  --adj-b: #1a5fb4;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 1rem 2rem;
  /* A bit wider than the text column so the image fits beside the matrix;
     on narrow screens, just the column. */
  --adj-w: min(100vw - 2rem, 46rem);
  width: var(--adj-w);
  margin: 1.5rem calc((100% - var(--adj-w)) / 2);
}
.adjacency-demo > p { margin: 0; min-width: 0; max-width: 100%; }
/* Room for the matrix's parentheses, which overhang by a pixel or two. */
.adjacency-demo .katex-display { padding: 0.3rem 0.2rem; }
.adj-live { cursor: default; }
.adjacency-demo .mord.adj-zero { opacity: 0.25; }
.adjacency-demo .mord.adj-zero.adj-one { opacity: 1; }
.adjacency-demo .mord.adj-row { background: rgba(127, 127, 127, 0.15); }
.adjacency-demo .mord.adj-one {
  background: var(--adj-b);
  color: #fff;
  border-radius: 2px;
}
.adj-grid {
  display: grid;
  grid-template-columns: repeat(4, 2.25rem);
  grid-auto-rows: 2.25rem;
  /* The pixels' grays are image data: keep them when the browser overrides
     page colors (Firefox's "Override colors", Windows high contrast). */
  forced-color-adjust: none;
}
.adj-grid > .adj-a { box-shadow: inset 0 0 0 3px var(--adj-a); }
.adj-grid > .adj-b { box-shadow: inset 0 0 0 3px var(--adj-b); }

@media (prefers-color-scheme: dark) {
  .adjacency-demo { --adj-b: #3584e4; }
}

/* Long equations scroll inside their own box instead of widening the page. */
.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.3rem 0;
}

/* An image with each row blurred by circular convolution
   (posts/scripts/conv-blur.js). Like .shift-steps. */
.conv-blur { margin: 1.5rem 0; }
.conv-blur canvas { display: block; width: min(400px, 100%); height: auto; margin: 0 auto 0.75rem; }
/* A labeled r slider, like .shift-eigen-steps's. */
.conv-blur label { display: flex; align-items: center; gap: 0.75rem; width: min(400px, 100%); margin: 0 auto; }
.conv-blur label input[type="range"] { flex: 1; width: auto; margin: 0; }
/* Wide enough for r=100, so the slider doesn't move as the label changes.
   .conv-steps's sliders match this slider's width, so keep them in step. */
.conv-blur .cb-r { flex: none; min-width: 3.5em; }
.conv-blur figcaption { margin-top: 0.25rem; text-align: center; }

/* A blurred image beside an eigenvector of S blurred the same way, in every
   row of an image (posts/scripts/eigen-blur.js). */
.eigen-blur { margin: 1.5rem 0; }
/* The blurred image and eigenvector side by side, stacking when narrow, like
   .dft-partial's images. */
.eigen-blur .eb-images {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 24rem));
  justify-content: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}
.eigen-blur .eb-image { min-width: 0; text-align: center; }
@media (max-width: 37rem) {
  .eigen-blur .eb-images { grid-template-columns: minmax(0, 24rem); }
}
.eigen-blur .eb-image canvas { display: block; width: 100%; height: auto; margin-top: 0.25rem; }
/* Pandoc may wrap each label in a <p>. */
.eigen-blur .eb-image p { margin: 0; }
.eigen-blur figcaption { margin-top: 0.25rem; text-align: center; }
/* A labeled r slider, like .conv-blur's. */
.eigen-blur label { display: flex; align-items: center; gap: 0.75rem; width: min(400px, 100%); margin: 0 auto; }
.eigen-blur label input[type="range"] { flex: 1; width: auto; margin: 0; }
/* Wide enough for r=100, so the slider doesn't move as the label changes. */
.eigen-blur .eb-r { flex: none; min-width: 3.5em; }

/* A row of pixels convolved one multiplication at a time
   (posts/scripts/conv-steps.js): labeled rows of pixels for x, c_0 and the
   partial sums, with a slider below. */
.conv-steps { --cs-mark: #e01b24; --cs-size: 2.75rem; margin: 1.5rem 0; }
.conv-steps .cs-rows {
  display: grid;
  grid-template-columns: auto auto auto;
  justify-content: center;
  align-items: center;
  gap: 0.5rem 1rem;
  margin-bottom: 0.5rem;
}
.conv-steps .cs-label { justify-self: end; }
/* The outlined cell's index, e.g. k=2. Wide enough for j-k=-7≡1, so the
   rows don't move as it changes. */
.conv-steps .cs-index { min-width: 7.5em; white-space: nowrap; }
.conv-steps .cs-cells {
  display: grid;
  grid-template-columns: repeat(8, var(--cs-size));
  grid-auto-rows: var(--cs-size);
  outline: 1px solid var(--rule);
}
.conv-steps .cs-cells > div {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}
/* Eight pixels plus a label don't fit a phone at full size. */
@media (max-width: 30rem) {
  .conv-steps { --cs-size: 2rem; }
  .conv-steps .cs-cells > div { font-size: 0.6rem; }
  .conv-steps .cs-rows { gap: 0.5rem 0.5rem; }
}
.conv-steps .cs-cells > .cs-mark { box-shadow: inset 0 0 0 3px var(--cs-mark); }
/* The step slider above the r slider, lined up in a grid: ◀ and the r label
   on the left, ▶ on the right. Step buttons styled like .dft-partial's. */
.conv-steps .cs-controls {
  display: grid;
  /* The sliders are as wide as .conv-blur's: its 400px row less the r=100
     label (3.5em) and the gap. The side columns share what's left, so the
     sliders are centered, and on narrow screens the sliders give way. */
  grid-template-columns:
    minmax(max-content, 1fr)
    minmax(0, calc(min(400px, 100%) - 3.5em - 0.75rem))
    minmax(max-content, 1fr);
  align-items: center;
  /* Don't stretch the buttons to fill the wide side columns. */
  justify-items: start;
  gap: 0.5rem 0.75rem;
  margin: 0.5rem 0 0;
}
/* Pandoc wraps the controls in a <p>; let its children be the grid items. */
.conv-steps .cs-controls p { display: contents; }
.conv-steps .cs-controls input[type="range"] { width: 100%; min-width: 0; margin: 0; }
/* ◀ and the r label sit right-aligned in the first column, each starting a
   row. */
.conv-steps .cs-r-label, .conv-steps .cs-step[data-step="-1"] { grid-column: 1; justify-self: end; }
.conv-steps .cs-step { flex: none; font: inherit; font-size: 0.8rem; line-height: 1; padding: 0.3rem 0.5rem; cursor: pointer; }
.conv-steps figcaption { margin-top: 0.5rem; text-align: center; }
@media (prefers-color-scheme: dark) {
  .conv-steps { --cs-mark: #ff6b6b; }
}
