/* One stylesheet, no framework. The page is four controls, a chart and a table, and a
   build step for a page that size costs more than it saves. */

:root {
  --ink: #16181d;
  --muted: #5c6270;
  --line: #dcdfe6;
  --paper: #ffffff;
  --wash: #f6f7f9;
  --selected: #1f5fbf;
  --selected-band: rgba(31, 95, 191, 0.16);
  --random: #8a8f9a;
  --up: #14724a;
  --down: #a4242c;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e7e9ee;
    --muted: #a2a8b6;
    --line: #333843;
    --paper: #14161a;
    --wash: #1b1e24;
    --selected: #6ba4f0;
    --selected-band: rgba(107, 164, 240, 0.22);
    --random: #767c88;
    --up: #4fc08a;
    --down: #e77b82;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

main { max-width: 820px; margin: 0 auto; padding: 32px 20px 64px; }

h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 12px; }
h2 { font-size: 1.05rem; margin: 36px 0 6px; }

.lead { font-size: 1.05rem; margin: 0 0 12px; }
.note { color: var(--muted); font-size: 0.87rem; margin: 0 0 10px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9em; }

.controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 20px;
  margin: 24px 0 8px;
  padding: 16px;
  background: var(--wash);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.control.wide { grid-column: 1 / -1; }
.control label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 4px; }
select, input[type="range"] { width: 100%; }
select {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
}
output { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }

.headline { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin: 22px 0 8px; }
.stat { padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; }
.figure { display: block; font-size: 1.5rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.caption { display: block; color: var(--muted); font-size: 0.8rem; margin-top: 2px; }
.stat.up .figure { color: var(--up); }
.stat.down .figure { color: var(--down); }

#chart svg { width: 100%; height: auto; display: block; }
.grid { stroke: var(--line); stroke-width: 1; }
.zero { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 3; }
.tick, .axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.band { fill: var(--selected-band); stroke: none; }
.selected { fill: none; stroke: var(--selected); stroke-width: 2.2; }
.random { fill: none; stroke: var(--random); stroke-width: 1.6; stroke-dasharray: 5 4; }
.cursor { stroke: var(--ink); stroke-width: 1; opacity: 0.45; }
.dot { fill: var(--selected); }

.legend { color: var(--muted); font-size: 0.82rem; margin-top: 6px; }
.key { display: inline-block; width: 22px; height: 3px; vertical-align: middle; margin: 0 4px 0 14px; }
.key.selected { background: var(--selected); }
.key.random { background: var(--random); }

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 0.9rem; }
th, td { text-align: right; padding: 5px 8px; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child, th:nth-child(2), td:nth-child(2) { text-align: left; }
thead th { color: var(--muted); font-weight: 600; font-size: 0.8rem; }
.list { max-height: 420px; overflow-y: auto; }

footer { margin-top: 44px; padding-top: 16px; border-top: 1px solid var(--line); }

@media (max-width: 640px) {
  .controls, .headline { grid-template-columns: 1fr; }
}
