/* The site's look (site/style.css): a paper page, hairline rules, square corners, one sans at one weight and a
 * monospace for labels and the ledger. The device is the one dark object on the page. */
:root {
  --page: #f6f8f7; --ink: #000; --muted: #6f6f6f; --hairline: #e5e5e5; --note: #ff8fb1;
  --plate: #0f0e12; --plate-edge: #2a272f; --plate-ink: #f6f8f7; --plate-muted: #8d8a93;
  --led: #ff8fb1; --led-ink: #0f0e12; --key-white: #f6f8f7; --key-black: #0f0e12; --focus: #000;
  --button: #1b191f; --button-hover: #262330; --button-down: #3a3542;
  --sans: "Helvetica Neue", Helvetica, Inter, Arial, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); font: 300 15px/1.5 var(--sans); }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--note); }
.home {
  text-decoration: none; font-size: 24px; display: block; height: 66px; line-height: 66px;
  border-bottom: 1px solid var(--hairline); margin-bottom: 22px;
}
main { max-width: 820px; margin: 0 auto; padding: 24px 16px 40px; }
h1 { margin: 0; font-size: 24px; font-weight: 300; }
h1 small { color: var(--muted); font-weight: 300; margin-left: 10px; font-size: 15px; }
.vol, #watch th, .scope figcaption, .enc span, .tour .n {
  font: 11px/1.5 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
}
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
::selection { background: var(--led); color: var(--led-ink); }
kbd { font: 13px var(--mono); border: 1px solid var(--hairline); padding: 0 4px; }
.help { color: var(--muted); font-size: 13px; }

/* the bar: four groups of controls divided by hairlines: run it | what it plays | MIDI | what you keep */
.bar { display: grid; gap: 12px 16px; margin-bottom: 20px; }
.bar h1 { align-self: center; }
.bar-controls { display: flex; flex-wrap: wrap; row-gap: 10px; align-items: stretch; }
.group { display: flex; gap: 8px; align-items: center; padding: 0 12px; border-left: 1px solid var(--hairline); }
.group:last-child { flex-basis: 100%; padding: 0; border-left: 0; }          /* what you keep: its own row */
#status { margin: 0; color: var(--muted); min-height: 1.45em; }
button {
  font: inherit; font-size: 14px; color: var(--ink); background: transparent; border: 1px solid var(--ink);
  border-radius: 0; padding: 6px 12px; cursor: pointer;
}
button:hover { border-color: var(--note); }
button.primary { background: var(--ink); color: var(--page); min-width: 88px; }
button.primary:hover { border-color: var(--ink); background: #222; }
button.on { border-color: var(--note); box-shadow: inset 0 -2px 0 var(--note); }
button:disabled { opacity: .4; cursor: default; }
button:disabled:hover { border-color: var(--ink); }
.vol { display: flex; gap: 8px; align-items: center; }
.vol input[type=range] { accent-color: var(--ink); width: 96px; margin: 0; }
select {
  font: inherit; font-size: 14px; color: var(--ink); background: transparent; border: 1px solid var(--ink);
  border-radius: 0; padding: 5px 8px; max-width: 176px;
}
select:disabled { opacity: .4; }

/* the device: one dark plate; the controls are flat fills with a lip of shadow where a cap meets the panel */
.device {
  background: var(--plate); color: var(--plate-ink); padding: 22px; user-select: none; -webkit-user-select: none;
  touch-action: none; box-shadow: inset 0 0 0 1px var(--plate-edge), inset 0 1px 0 #3a3542;
}
.device :focus-visible { outline-color: var(--plate-ink); }
.top { display: grid; grid-template-columns: auto 1fr; gap: 28px; align-items: start; }
.screen-wrap {
  position: relative; padding: 12px; background: #000; border: 1px solid #000;
  box-shadow: inset 0 0 0 1px var(--plate-edge), 0 1px 0 rgba(255, 255, 255, .05), 0 6px 14px rgba(0, 0, 0, .55);
}
#screen {
  width: 288px; height: 288px; image-rendering: pixelated; display: block; background: #000;
  box-shadow: 0 0 0 1px #1a1820;
}
.screen-off {
  position: absolute; inset: 12px; display: grid; place-items: center; color: var(--plate-muted);
  background: #050507; font: 11px var(--mono); text-transform: uppercase; letter-spacing: .08em;
  box-shadow: 0 0 0 1px #1a1820;
}
.screen-off[hidden] { display: none; }
.controls { display: grid; gap: 22px; }
.encoders { display: grid; grid-template-columns: repeat(7, 1fr); gap: 12px 6px; }
.enc { display: grid; justify-items: center; gap: 7px; text-align: center; }
.enc span { color: var(--plate-muted); font-size: 10px; letter-spacing: .06em; }
.knob {
  width: 46px; height: 46px; border-radius: 50%; background: var(--button); border: 1px solid #000;
  position: relative; cursor: ns-resize;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08), inset 0 0 0 1px var(--plate-edge), 0 2px 0 #000,
    0 4px 8px rgba(0, 0, 0, .5);
}
.knob::before { content: ""; position: absolute; inset: 7px; border-radius: 50%; border: 1px solid #000; }
.knob::after {                                           /* the pointer; --rot is set by sim.js per detent */
  content: ""; position: absolute; left: 50%; top: 4px; width: 2px; height: 13px; margin-left: -1px;
  background: var(--plate-ink); transform-origin: 50% 18px; transform: rotate(var(--rot, 0deg));
  transition: transform 70ms ease-out;
}
.knob:hover { background: var(--button-hover); }
.knob:active {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08), inset 0 0 0 1px var(--plate-edge), 0 1px 0 #000,
    0 2px 4px rgba(0, 0, 0, .5);
}
.buttons { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px 8px; }
.btn { display: grid; justify-items: center; gap: 5px; }
.btn button {
  width: 100%; padding: 7px 0 8px; font: 11px var(--mono); letter-spacing: .06em; color: var(--plate-ink);
  background: var(--button); border-color: #000;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07), inset 0 -2px 0 #000;
}
.btn button:hover { background: var(--button-hover); border-color: #000; }
.btn button.down { background: var(--button-down); box-shadow: inset 0 1px 3px #000; transform: translateY(1px); }
.led {
  width: 7px; height: 7px; border-radius: 50%; background: #221f27; box-shadow: inset 0 0 0 1px #000;
  transition: background 60ms, box-shadow 60ms;
}
.led.lit { background: var(--led); box-shadow: 0 0 4px var(--led), 0 0 10px rgba(255, 143, 177, .45); }

/* the keybed: a rule above; on a narrow screen it scrolls sideways rather than shrinking the keys */
.keybed {
  margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--plate-edge); overflow-x: auto;
  overscroll-behavior-x: contain; touch-action: pan-x;
}
.keys { position: relative; height: 150px; display: flex; padding: 0 0 2px; min-width: 560px; }
.key { cursor: pointer; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 8px; }
.key.white {
  flex: 1 1 0; background: var(--key-white); border: 1px solid #000; margin: 0 1px;
  box-shadow: inset 0 -4px 0 #d9dcdb, inset -1px 0 0 #e5e5e5;
}
.key.black {
  position: absolute; top: 0; height: 90px; width: calc(100% / 16 * .6); background: var(--key-black);
  border: 1px solid #000; z-index: 1;
  box-shadow: inset 0 -5px 0 #000, inset 1px 1px 0 #3a3542, 0 2px 3px rgba(0, 0, 0, .6);
}
.key.white.down { background: #dcdedd; box-shadow: inset 0 2px 4px rgba(0, 0, 0, .25); }
.key.black.down { background: #2a272f; box-shadow: inset 0 1px 3px #000; }
.key .led { width: 6px; height: 6px; background: #c8cbca; box-shadow: inset 0 0 0 1px #b4b7b6; }
.key.black .led { background: #2a272f; box-shadow: inset 0 0 0 1px #000; }
.key .led.lit { background: var(--led); box-shadow: 0 0 4px var(--led), 0 0 10px rgba(255, 143, 177, .45); }

/* the scope: what leaves the device, one ink line on the paper */
.scope { margin: 0; }
.scope figcaption { padding: 8px 0 2px; }
.scope canvas { display: block; width: 100%; height: 64px; }
.scope.live figcaption::before {
  content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--note);
  margin-right: 8px; vertical-align: 1px;
}

/* the tour's caption: one strip of ink under the device, the step count in the margin, the control named in the note */
.tour {
  display: flex; gap: 16px; align-items: baseline; padding: 10px 0 8px; border-bottom: 1px solid var(--hairline);
}
.tour[hidden] { display: none; }
.tour .n { flex: none; min-width: 48px; }
.tour .say { font-size: 15px; transition: opacity 220ms ease; }
.tour .say.out { opacity: 0; }
.tour b { font-weight: 400; color: var(--note); }

@media (max-width: 720px) {
  main { padding: 16px 12px 32px; }
  .group, .group:last-child { width: 100%; border-left: 0; border-top: 1px solid var(--hairline); padding: 10px 0 0; }
  .group:first-child { border-top: 0; padding-top: 0; }
  .group:nth-child(2) { display: grid; gap: 8px; }                      /* volume and patch: two labelled rows */
  .vol { display: grid; grid-template-columns: 64px 1fr; align-items: center; min-width: 0; }
  .vol input[type=range], .vol select { width: 100%; max-width: none; min-width: 0; }
  #watch { font-size: 12px; }
  #watch td:first-child { white-space: normal; overflow-wrap: anywhere; }
  .device { padding: 16px; }
  .top { grid-template-columns: 1fr; justify-items: center; gap: 22px; }
  .controls { width: 100%; }
  #screen { width: 240px; height: 240px; }
  .screen-wrap { padding: 10px; }
  .screen-off { inset: 10px; }
  .encoders { grid-template-columns: repeat(4, 1fr); gap: 14px 6px; }
  .buttons { grid-template-columns: repeat(5, 1fr); gap: 10px 6px; }
  .keybed { margin: 20px -16px 0; padding: 16px 16px 0; }
  .keys { height: 120px; min-width: 520px; }
  .key.black { height: 72px; }
}

/* the ledger: the twelve watched statements; numbers right, the state in ink or in the note */
.watch { margin-top: 28px; border-top: 1px solid var(--hairline); padding-top: 16px; }
.watch h2 { margin: 0 0 6px; font-size: 15px; font-weight: 300; }
.watch h2 small { color: var(--muted); margin-left: 10px; }
#watch {
  border-collapse: collapse; font: 13px/1.6 var(--mono); font-variant-numeric: tabular-nums; width: 100%;
  margin-top: 12px;
}
#watch th { text-align: left; font-weight: 400; border-bottom: 1px solid var(--ink); padding: 0 0 6px; }
#watch td { padding: 4px 0; border-bottom: 1px solid var(--hairline); white-space: nowrap; }
#watch th:nth-child(2), #watch td:nth-child(2) { text-align: right; padding-left: 16px; }
#watch th:nth-child(3), #watch td:nth-child(3) { padding-left: 24px; width: 1%; }
#watch a { text-decoration: none; }
#watch a:hover { text-decoration: underline; }
#watch td.held, #watch td.fail { color: var(--ink); }
#watch td.held::before, #watch td.fail::before {
  content: ""; display: inline-block; width: 6px; height: 6px; background: currentColor; margin-right: 8px;
  vertical-align: 1px;
}
#watch td.fail { color: var(--note); font-weight: 400; }
#watch td.wait, #watch td.empty { color: var(--muted); }
