/* Flexoki palette, https://stephango.com/flexoki. Light uses accent 600, dark uses 400. */
:root {
  color-scheme: light dark;
  --bg: #fffcf0;
  --bg-2: #f2f0e5;
  --ui: #e6e4d9;
  --ui-2: #dad8ce;
  --ui-3: #cecdc3;
  --tx-3: #b7b5ac;
  --tx-2: #6f6e69;
  --tx: #100f0f;
  --re: #af3029;
  --or: #bc5215;
  --ye: #ad8301;
  --gr: #66800b;
  --cy: #24837b;
  --bl: #205ea6;
  --pu: #5e409d;
  --ma: #a02f6f;
  --bl-muted: #92bfdb;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #100f0f;
    --bg-2: #1c1b1a;
    --ui: #282726;
    --ui-2: #343331;
    --ui-3: #403e3c;
    --tx-3: #575653;
    --tx-2: #878580;
    --tx: #cecdc3;
    --re: #d14d41;
    --or: #da702c;
    --ye: #d0a215;
    --gr: #879a39;
    --cy: #3aa99f;
    --bl: #4385be;
    --pu: #8b7ec8;
    --ma: #ce5d97;
    --bl-muted: #1a4f8c;
  }
}

/* Signal roles, so every figure colors the same quantity the same way. Cyan and magenta are held for I and Q, except that magenta also marks the scanning beam in the video sections, which have no Q. */
:root {
  --carrier: var(--bl);
  --carrier-muted: var(--bl-muted);
  --message: var(--or);
  --modulated: var(--pu);
  --demod: var(--gr);
  --lo: var(--ye);
  --i: var(--cy);
  --q: var(--ma);
  --beam: var(--ma);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--tx);
  font-family: system-ui, sans-serif;
  line-height: 1.6;
}

main {
  max-width: 56rem;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
}

/* Prose keeps a readable measure while figures use the full column. */
main > article > :not(section),
section > :not(figure, section) {
  max-width: 42rem;
  margin-inline: auto;
}

h1 {
  line-height: 1.2;
  margin: 1rem 0;
}
h2 {
  margin-top: 4rem;
  font-size: 1.75rem;
}
h3 {
  margin-top: 3rem;
  font-size: 1.3rem;
}
.part > h2 + section > h3 {
  margin-top: 1.5rem;
}

.lede {
  color: var(--tx-2);
  font-size: 1.1rem;
}

code {
  font-family: ui-monospace, monospace;
  font-size: 0.92em;
}

.tex.display {
  margin: 1rem 0;
  font-size: 1.15rem;
  overflow-x: auto;
}

.c-carrier {
  color: var(--carrier);
}
.c-message {
  color: var(--message);
}
.c-modulated {
  color: var(--modulated);
}
.c-demod {
  color: var(--demod);
}
.c-lo {
  color: var(--lo);
}
.c-i {
  color: var(--i);
}
.c-q {
  color: var(--q);
}

figure {
  margin: 1.5rem 0;
}

figcaption {
  margin-top: 0.5rem;
  color: var(--tx-2);
  font-size: 0.9rem;
}

.figure-stage {
  position: relative;
  border: 1px solid var(--ui);
  border-radius: 0.5rem;
  background: var(--bg-2);
  overflow: hidden;
}

.figure-stage canvas {
  display: block;
  width: 100%;
  cursor: pointer;
}

.figure-play {
  position: absolute;
  left: 0.5rem;
  bottom: 0.5rem;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--ui-2);
  border-radius: 50%;
  background: var(--bg);
  color: var(--tx-2);
  cursor: pointer;
}
.figure-play:hover {
  color: var(--tx);
}
.figure-play svg {
  width: 0.9rem;
  height: 0.9rem;
}
.figure-play[data-playing="true"] .icon-play,
.figure-play[data-playing="false"] .icon-pause {
  display: none;
}

.figure-readout {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin-top: 0.5rem;
  font-family: ui-monospace, monospace;
  font-size: 0.85rem;
  color: var(--tx-2);
}
.figure-readout:empty {
  display: none;
}
.figure-readout b {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: pre;
}

.figure-controls {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 0.5rem 1.5rem;
  margin-top: 0.75rem;
}

.control {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0 0.5rem;
  font-size: 0.9rem;
  color: var(--tx-2);
}
.control input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  margin: 0;
  accent-color: var(--control-color, var(--tx-2));
}
.control output {
  font-family: ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  color: var(--tx);
}
.control-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}
.control-toggle input {
  accent-color: var(--control-color, var(--tx-2));
}

/* Stands in for a figure that hasn't been built yet. */
.planned {
  margin-block: 1.5rem;
  padding: 0.75rem 1rem;
  border: 1px dashed var(--ui-3);
  border-radius: 0.5rem;
  color: var(--tx-2);
  font-size: 0.9rem;
}
