/* app.css — the physical modeling synthesizer.
 *
 * Colour means one thing: the sign of the plate's displacement. Positive
 * antinodes go warm (--plus), negative go cool (--minus), zero is --node.
 * All controls and readout follow precision synthesizer rack hierarchy.
 */

:root {
  --node:  #0b0e10;   /* zero displacement. at rest, the whole surface */
  --plus:  #e0714a;   /* positive antinode */
  --minus: #4b6cb7;   /* negative antinode */
  --sand:  #e8e2d4;   /* node lines, and the active ink */
  --dim:   #93a2a9;   /* readable secondary context */
  --faint: #414f56;   /* structural rules, inactive boundaries */
  --lock:  #9ecfd0;   /* one hue, one meaning: active offer or selected state */

  --display: 'Space Grotesk', -apple-system, 'Segoe UI', system-ui, sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --sans: -apple-system, 'Segoe UI', system-ui, sans-serif;

  /* The harmonic type ladder */
  --say:  12px;       /* action fundamental — inputs, buttons */
  --read: 11px;       /* harmonic tier — telemetry, parameters */
  --tag:  9.5px;      /* overtone tier — module tags, units */

  --edge: 24px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--node);
  color: var(--sand);
  font-family: var(--sans);
  font-size: var(--say);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  overflow: hidden;
}

/* ── the field is the page ────────────────────────────────────────────────── */

#surface-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

/* ── the readout follows your hand ────────────────────────────────────────── */

.at-hand {
  position: fixed;
  z-index: 4;
  pointer-events: none;
  font-family: var(--mono);
  font-size: var(--read);
  line-height: 1.5;
  color: var(--sand);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9);
  opacity: 0;
  transition: opacity 260ms ease;
  white-space: pre;
  transform: translate(14px, -50%);
}
.at-hand.on { opacity: 0.92; }

/* ── header: instrument identity & global utilities ───────────────────────── */

.top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  padding: 12px var(--edge);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(to bottom, rgba(11, 14, 16, 0.96) 60%, rgba(11, 14, 16, 0));
  pointer-events: none;
}
.top a, .top-right, .top-left { pointer-events: auto; }

.top-left {
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
  max-width: 65vw;
}

.wordmark {
  font-family: var(--display);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sand);
}

.named {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.name {
  font-family: var(--display);
  font-style: normal;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--sand);
}

.made-of {
  font-family: var(--mono);
  font-size: var(--read);
  color: var(--dim);
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}
.made-of b { font-weight: 500; color: var(--sand); }
.made-of .num { color: #85969e; }
.made-of .made { color: var(--dim); }
.made-of .sep { color: var(--faint); margin: 0 4px; }

.top-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

.tool-btn, .motion-btn {
  background: rgba(11, 14, 16, 0.6);
  border: 1px solid var(--faint);
  color: var(--dim);
  font-family: var(--mono);
  font-size: var(--tag);
  padding: 3px 8px;
  cursor: pointer;
  letter-spacing: 0.06em;
  text-transform: lowercase;
  border-radius: 2px;
  transition: border-color 160ms ease, color 160ms ease, background-color 160ms ease;
}
.tool-btn:hover, .motion-btn:hover { border-color: var(--sand); color: var(--sand); }
.motion-btn.on { border-color: var(--lock); color: var(--lock); }

#run-mode { color: var(--faint); font-family: var(--mono); font-size: var(--tag); }

/* ── synthesizer console (dock) ───────────────────────────────────────────── */

.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  padding: 10px var(--edge) 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: linear-gradient(to top, rgba(11, 14, 16, 0.98) 75%, rgba(11, 14, 16, 0));
  border-top: 1px solid var(--faint);
}

.contexts {
  display: flex;
  gap: 18px;
  align-items: baseline;
  border-bottom: 1px solid var(--faint);
  padding-bottom: 6px;
}
.ctx {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: var(--mono);
  font-size: var(--tag);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
  transition: color 150ms ease;
}
.ctx:hover { color: var(--dim); }
.ctx.on { color: var(--sand); font-weight: 500; }

.band {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  min-height: 48px;
}
.band[hidden] { display: none; }

/* ── synth console rack layout ────────────────────────────────────────────── */

.synth-console {
  display: grid;
  grid-template-columns: minmax(280px, 1.4fr) minmax(180px, 0.9fr) minmax(280px, 1.4fr) auto;
  gap: 16px;
  align-items: stretch;
  width: 100%;
}

.module {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-right: 1px solid var(--faint);
  padding-right: 16px;
}
.module:last-of-type { border-right: none; }

.mod-label {
  font-family: var(--mono);
  font-size: var(--tag);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 500;
}

.mod-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.console-actions {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-end;
  gap: 4px;
  padding-left: 8px;
}

/* ── controls & knobs ─────────────────────────────────────────────────────── */

.ask { flex: 1 1 140px; min-width: 120px; display: flex; }
.ask input {
  flex: 1 1 auto;
  min-width: 0;
  background: rgba(11, 14, 16, 0.5);
  border: none;
  border-bottom: 1px solid var(--faint);
  padding: 4px 6px;
  font-family: var(--mono);
  font-size: var(--say);
  letter-spacing: 0.01em;
  color: var(--sand);
  outline: none;
  transition: border-color 180ms ease;
}
.ask input::placeholder { color: var(--faint); }
.ask input:focus { border-bottom-color: var(--sand); }

.knob {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 74px;
  flex: 1 1 74px;
  max-width: 140px;
}
.knob > span {
  font-family: var(--mono);
  font-size: var(--tag);
  letter-spacing: 0.08em;
  color: var(--dim);
  text-transform: lowercase;
}
.knob > em {
  font-family: var(--mono);
  font-style: normal;
  font-size: var(--tag);
  color: var(--sand);
  min-height: 12px;
}
.knob[hidden] { display: none; }

input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 14px;
  background: none;
  outline: none;
  cursor: ew-resize;
}
input[type=range]::-webkit-slider-runnable-track { height: 1px; background: var(--faint); }
input[type=range]::-moz-range-track { height: 1px; background: var(--faint); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 3px;
  height: 12px;
  margin-top: -5.5px;
  background: var(--sand);
  border: none;
  border-radius: 0;
}
input[type=range]::-moz-range-thumb {
  width: 3px; height: 12px; background: var(--sand); border: none; border-radius: 0;
}
input[type=range]:focus-visible::-webkit-slider-thumb { background: var(--lock); }

select {
  background: rgba(11, 14, 16, 0.5);
  border: none;
  border-bottom: 1px solid var(--faint);
  color: var(--sand);
  font-family: var(--mono);
  font-size: var(--say);
  padding: 3px 4px;
  outline: none;
  cursor: pointer;
  width: 100%;
}
select option { background: var(--node); color: var(--sand); }

.act {
  font-family: var(--mono);
  font-size: var(--say);
  letter-spacing: 0.02em;
  color: var(--sand);
  background: none;
  border: 1px solid var(--faint);
  padding: 5px 11px;
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease;
}
.act:hover:not(:disabled) { border-color: var(--dim); }
.act:disabled { color: var(--faint); cursor: default; }
.act.primary { border-color: var(--sand); }
.act.primary:hover:not(:disabled) { background: var(--sand); color: var(--node); }
.act[hidden] { display: none; }

.link {
  background: none;
  border: none;
  font-family: var(--mono);
  font-size: var(--read);
  color: var(--dim);
  cursor: pointer;
  padding: 4px 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link:hover { color: var(--sand); }
.link.on { color: var(--sand); }

.reading {
  font-family: var(--mono);
  font-size: var(--read);
  color: var(--dim);
  min-width: 0;
}

.where { display: inline-flex; gap: 10px; align-items: baseline; }
.where[hidden] { display: none; }

/* ── record lookup drawer ─────────────────────────────────────────────────── */

.lookup {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
  padding-top: 8px;
  border-top: 1px solid var(--faint);
}
.lookup[hidden] { display: none; }
.lookup input {
  font-family: var(--mono);
  font-size: var(--read);
  color: var(--sand);
  background: none;
  border: none;
  border-bottom: 1px solid var(--faint);
  padding: 4px 0;
  min-width: 180px;
  flex: 0 1 260px;
  outline: none;
}
.lookup input::placeholder { color: var(--faint); }
.lookup input:focus { border-bottom-color: var(--sand); }
.found {
  font-family: var(--mono);
  font-size: var(--read);
  color: var(--dim);
  flex: 1 1 auto;
  min-width: 0;
}
.found.waiting { color: var(--faint); }
.pick { display: inline-flex; gap: 10px; }

/* ── rack, shelf, notices ─────────────────────────────────────────────────── */

.rack {
  position: fixed;
  right: var(--edge);
  top: 50%;
  transform: translateY(-50%);
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rack:empty { display: none; }
.pad {
  font-family: var(--mono);
  font-size: var(--read);
  color: var(--sand);
  background: rgba(11, 14, 16, 0.8);
  border: 1px solid var(--faint);
  padding: 8px 12px;
  min-width: 60px;
  text-align: left;
  cursor: pointer;
}
.pad:hover { border-color: var(--dim); }
.pad.lit { border-color: var(--sand); }

.shelf {
  position: fixed;
  left: var(--edge);
  top: 54px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  font-family: var(--mono);
  font-size: var(--tag);
  color: var(--faint);
}
.shelf:empty { display: none; }

.say {
  position: fixed;
  left: var(--edge);
  bottom: 110px;
  z-index: 12;
  max-width: min(60ch, 66vw);
  font-family: var(--mono);
  font-size: var(--read);
  line-height: 1.55;
  color: var(--lock);
  opacity: 0;
  transition: opacity 300ms ease;
  pointer-events: none;
}
.say.on { opacity: 0.95; }
.say .take {
  pointer-events: auto;
  background: none;
  border: 1px solid var(--lock);
  color: var(--lock);
  font-family: var(--mono);
  font-size: var(--tag);
  padding: 2px 7px;
  margin-left: 4px;
  cursor: pointer;
}
.say .take:hover { background: var(--lock); color: var(--node); }
.say:has(.take) { pointer-events: auto; }

.stage-hint {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  font-family: var(--mono);
  font-size: var(--read);
  letter-spacing: 0.12em;
  color: var(--faint);
  pointer-events: none;
  transition: opacity 500ms ease;
}
.stage-hint.gone { opacity: 0; }

/* ── responsive adjustments ───────────────────────────────────────────────── */

@media (max-width: 900px) {
  .synth-console {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
  .module { border-right: none; }
  .console-actions { align-items: flex-start; }
}

@media (max-width: 600px) {
  :root { --edge: 12px; }
  .synth-console { grid-template-columns: 1fr; }
  .top-left { max-width: 90vw; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 1ms !important; }
}

:focus-visible { outline: 1px solid var(--lock); outline-offset: 2px; }
