/* One column of text with figures that respond to it, after Bret Victor's explorable
   explanations. Ink, paper and one red for everything the model produces. */

:root {
  --paper: #fbfaf6;
  --ink: #1f1d1a;
  --muted: #6e6a62;
  --faint: #d8d3c8;
  --rule: #c9c3b6;
  --accent: #b3261e;
  --keyed: #9d978c;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #171614;
    --ink: #e9e5dc;
    --muted: #9b968c;
    --faint: #3a3732;
    --rule: #4a463f;
    --accent: #f0715f;
    --keyed: #6f6a61;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #171614;
  --ink: #e9e5dc;
  --muted: #9b968c;
  --faint: #3a3732;
  --rule: #4a463f;
  --accent: #f0715f;
  --keyed: #6f6a61;
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.55;
  font-variant-numeric: oldstyle-nums;
}

main {
  max-width: 41rem;
  margin: 0 auto;
  padding: 2.5rem 16px 4rem;
}

h1 {
  font-size: 2.4rem;
  font-weight: normal;
  letter-spacing: 0.01em;
  margin: 0;
  line-height: 1.1;
}

h2 {
  font-size: 1.3rem;
  font-weight: normal;
  font-style: italic;
  margin: 2.6rem 0 0.6rem;
}

p { margin: 0 0 1rem; }

.byline { color: var(--muted); margin: 0.3rem 0 1.6rem; }
.lede { font-size: 1.1rem; }

a { color: inherit; text-decoration-color: var(--rule); text-underline-offset: 0.15em; }
a:hover { text-decoration-color: currentColor; }

code, .mono, pre { font-family: var(--mono); font-size: 0.8em; font-variant-numeric: normal; }
pre {
  overflow-x: auto;
  padding: 0.2rem 0 0.2rem 1rem;
  border-left: 2px solid var(--rule);
  line-height: 1.5;
  margin: 0 0 1rem;
}
pre code { font-size: 1em; }

.muted { color: var(--muted); }
.accent { color: var(--accent); }

figure { margin: 1.6rem 0 2rem; }
figcaption { color: var(--muted); font-size: 0.9rem; margin: 0.4rem 0 0.8rem; }

/* Values you drag. */
.adjust {
  color: var(--accent);
  border-bottom: 1px dashed var(--accent);
  cursor: ew-resize;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  white-space: nowrap;
  padding: 0 1px;
}
.adjust:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.adjust.dragging { background: color-mix(in srgb, var(--accent) 12%, transparent); }

.controls-text { font-size: 1.05rem; }

button {
  font: inherit;
  font-size: 0.9rem;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 0;
  padding: 0.15rem 0.6rem;
  cursor: pointer;
}
button:hover { border-color: var(--ink); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button:disabled { color: var(--muted); cursor: default; border-color: var(--faint); }

.buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: baseline; margin: 0.6rem 0; }
#status { font-size: 0.9rem; }

/* Figures. */
.roll-wrap { width: 100%; }
svg { display: block; max-width: 100%; height: auto; overflow: visible; }
svg text { font-family: var(--mono); font-size: 10px; fill: var(--muted); }
svg text.accent { fill: var(--accent); }
svg .grid { stroke: var(--faint); stroke-width: 1; }
svg .split { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 2 2; }
svg .note.prompt { fill: var(--ink); }
svg .note.gen { fill: var(--accent); }
svg .note.truth { fill: none; stroke: var(--muted); stroke-width: 1; }
svg .playhead { stroke: var(--accent); stroke-width: 1.5; }
svg .bar.ok { fill: var(--ink); }
svg .bar.keyed { fill: var(--keyed); }
svg .bar.off { fill: var(--faint); }
svg .bar.chosen, svg .marker { fill: var(--accent); }

/* Tables, ruled like a printed table: no boxes, no stripes. */
table.numbers {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.9rem;
  font-variant-numeric: lining-nums tabular-nums;
  margin: 0.4rem 0 1rem;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
}
table.numbers th, table.numbers td { text-align: right; padding: 0.2rem 0 0.2rem 0.8rem; vertical-align: baseline; }
table.numbers th:first-child, table.numbers td:first-child { text-align: left; padding-left: 0; }
table.numbers thead th { font-weight: normal; color: var(--muted); border-bottom: 1px solid var(--rule); }
table.numbers tbody th { font-weight: normal; }
#stats { max-width: 26rem; }
#candidates td:last-child { color: var(--muted); }
#candidates tr.chosen td { color: var(--accent); }
.meter {
  display: inline-block;
  width: calc(var(--w) * 3rem);
  height: 0.55em;
  background: currentColor;
  margin-right: 0.35rem;
  vertical-align: baseline;
  opacity: 0.7;
}

/* Token stream. */
.tokens {
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.7;
  max-height: 12.5rem;
  overflow-y: auto;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 0.4rem 0;
  margin: 0 0 1rem;
  overflow-wrap: anywhere;
}
.tokens div { margin: 0; }
.tk { font: inherit; border: 0; padding: 0; background: none; color: inherit; }
.tk.prompt { color: var(--muted); }
.tk.gen { color: var(--accent); cursor: pointer; }
.tk.gen:hover, .tk.current { text-decoration: underline; text-underline-offset: 0.2em; }
.tk.current { color: var(--paper); background: var(--accent); text-decoration: none; }

.step-head { display: flex; gap: 0.5rem; align-items: center; }
.step-head input[type="range"] { flex: 1; min-width: 4rem; accent-color: var(--accent); }
.step-label { font-size: 0.9rem; margin: 0.4rem 0 0.6rem; overflow-wrap: anywhere; }

.refs { padding-left: 1.4rem; font-size: 0.9rem; }
.refs li { margin-bottom: 0.4rem; }

footer { margin-top: 3rem; border-top: 1px solid var(--rule); padding-top: 0.8rem; color: var(--muted); font-size: 0.9rem; }

@media (max-width: 560px) {
  body { font-size: 17px; }
  main { padding-top: 1.6rem; }
  h1 { font-size: 2rem; }
  table.wide { font-size: 0.78rem; }
  table.wide th, table.wide td { padding-left: 0.45rem; }
  #step-pitch { display: none; }
}
