/* WaveSynth — PPG Wave 2.2 (1982) */

:root {
  /* The PPG is the severe one: near-black navy, hard white legends, and
     orange used only where the machine actually glows — the wave display
     and the LEDs. Restraint is what separates it from the Roland. */
  --chassis: #0b1220;
  --chassis-edge: rgba(0, 0, 0, 0.8);
  --bg: #0a1120;
  --panel-bg: #111c31;
  --panel-border: #2b4166;
  --accent: #e8eefc;          /* legends are white on a PPG, not orange */
  --accent-dim: #6d81a8;
  --accent-bright: #ffffff;
  --text: #dce5f6;
  --text-dim: #7d90b4;
  --knob-track: #060c18;
  --slider-thumb: #c8d4ea;
  --danger: #ff4466;
  --led: #ff7a00;
  --cap: #dfe6f2;
  --display-bg: #070a10;
  --display-ink: #ff8c1a;     /* the glow lives in the display */
  --display-grid: rgba(255, 140, 26, 0.12);
  --readout-ink: #ff9f3d;
  --readout-bg: #070a10;
  --panel-radius: 2px;
  --label-weight: 700;
  --label-tracking: 1.3px;
  --title-tracking: 3px;
  --shadow-strength: 0.9;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 12px;
  overflow-x: hidden;
}

/* ─── Layout ─────────────────────────────────────────────────────────────── */

.synth-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px;
}

.synth-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  margin-bottom: 8px;
}

.synth-header h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.synth-header .subtitle {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 1px;
}

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

.synth-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.synth-row {
  display: grid;
  grid-template-columns: 1fr 1fr 2fr;
  gap: 8px;
  margin-bottom: 8px;
}

.synth-row-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.effects-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}

.bottom-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

/* ─── Panel ──────────────────────────────────────────────────────────────── */

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 10px;
}

.panel-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--accent);
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--panel-border);
}

.section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent-dim);
  margin: 6px 0 2px;
}

/* ─── Controls ───────────────────────────────────────────────────────────── */

.control-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.control-row label {
  width: 60px;
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  flex-shrink: 0;
}

.control-row .val {
  width: 50px;
  text-align: right;
  font-size: 10px;
  font-family: 'Courier New', monospace;
  color: var(--accent);
  flex-shrink: 0;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 4px;
  background: var(--knob-track);
  border-radius: 2px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--slider-thumb);
  cursor: pointer;
  box-shadow: 0 0 4px rgba(0, 204, 255, 0.4);
}

input[type="range"]::-webkit-slider-thumb:hover {
  box-shadow: 0 0 8px rgba(0, 204, 255, 0.7);
}

select {
  background: #222;
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 3px;
  padding: 2px 4px;
  font-size: 11px;
  outline: none;
}

select:focus { border-color: var(--accent); }

input[type="checkbox"] { accent-color: var(--accent); }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.checkbox-row label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */

.btn {
  background: var(--accent-dim);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: background 0.15s;
}

.btn:hover { background: var(--accent); color: #000; }
.btn:disabled { background: #333; color: #666; cursor: default; }
.btn-small { padding: 3px 8px; font-size: 10px; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #ff6688; color: #fff; }

/* ─── ADSR Group ─────────────────────────────────────────────────────────── */

.adsr-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 8px;
}

.adsr-group .control-row label { width: 14px; }

/* ─── Mod Matrix ─────────────────────────────────────────────────────────── */

.mod-slot {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 4px;
  padding: 3px;
  background: rgba(0,0,0,0.2);
  border-radius: 3px;
}

.mod-slot select { flex: 1; min-width: 0; }
.mod-slot input[type="range"] { flex: 1; }
.mod-slot .slot-num {
  font-size: 10px;
  color: var(--accent-dim);
  width: 14px;
  flex-shrink: 0;
}

/* ─── Wave Sequence Editor ───────────────────────────────────────────────── */

.seq-editor {
  width: 100%;
}

.seq-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.seq-toolbar select { min-width: 80px; }

.seq-steps {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.seq-step {
  min-width: 80px;
  padding: 6px 8px;
  background: var(--seq-step);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  cursor: pointer;
  text-align: center;
  flex-shrink: 0;
  transition: all 0.15s;
  position: relative;
}

.seq-step:hover { border-color: var(--accent-dim); }
.seq-step.selected { border-color: var(--accent); background: var(--seq-selected); }
.seq-step.playing { background: var(--seq-active); box-shadow: 0 0 8px rgba(0, 204, 255, 0.3); }

.seq-step .step-num {
  font-size: 9px;
  color: var(--text-dim);
  margin-bottom: 2px;
}

.seq-step .step-wave {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.seq-step .step-dur {
  font-size: 9px;
  color: var(--text-dim);
}

.seq-step-add {
  min-width: 40px;
  padding: 6px;
  background: transparent;
  border: 1px dashed var(--panel-border);
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.seq-step-add:hover { border-color: var(--accent-dim); color: var(--accent); }

.seq-params {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 8px;
  background: rgba(0,0,0,0.15);
  border-radius: 4px;
}

.seq-params .control-row label { width: 50px; }

/* ─── Effects Panel ──────────────────────────────────────────────────────── */

.fx-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.fx-header .panel-title { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }

/* ─── Scope ──────────────────────────────────────────────────────────────── */

#scope {
  width: 100%;
  height: 120px;
  border-radius: 4px;
  background: var(--panel-bg);
}

/* ─── Wave Display ───────────────────────────────────────────────────────── */

.wave-display {
  height: 50px;
  background: #0a0e1a;
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  margin-bottom: 6px;
}

.wave-display canvas {
  width: 100%;
  height: 100%;
  border-radius: 3px;
}

/* ─── Piano Keyboard ─────────────────────────────────────────────────────── */

#piano-keyboard {
  position: relative;
  height: 100px;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.white-key {
  display: inline-block;
  width: 38px;
  height: 100px;
  background: linear-gradient(180deg, #f8f8f8, #e8e8e8);
  border: 1px solid #999;
  border-radius: 0 0 4px 4px;
  position: relative;
  cursor: pointer;
  vertical-align: top;
  margin-right: 1px;
}

.white-key:hover { background: linear-gradient(180deg, #fff, #f0f0f0); }
.white-key.active { background: linear-gradient(180deg, #aad5f5, #66aadd); }

.black-key {
  position: absolute;
  width: 24px;
  height: 60px;
  background: linear-gradient(180deg, #333, #111);
  border: 1px solid #000;
  border-radius: 0 0 3px 3px;
  cursor: pointer;
  z-index: 2;
  top: 0;
}

.black-key:hover { background: linear-gradient(180deg, #444, #222); }
.black-key.active { background: linear-gradient(180deg, #0088aa, #005566); }

.key-label {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  color: #999;
  pointer-events: none;
}

/* ─── Status Bar ─────────────────────────────────────────────────────────── */

.status-bar {
  display: flex;
  gap: 16px;
  font-size: 10px;
  color: var(--text-dim);
  padding: 4px 0;
}

.status-bar span { font-family: 'Courier New', monospace; }

/* ─── Mode Toggle ────────────────────────────────────────────────────────── */

.mode-toggle {
  display: flex;
  gap: 2px;
  margin-bottom: 6px;
}

.mode-toggle button {
  flex: 1;
  padding: 3px 6px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  background: #222;
  color: var(--text-dim);
  border: 1px solid var(--panel-border);
  cursor: pointer;
  transition: all 0.15s;
}

.mode-toggle button:first-child { border-radius: 3px 0 0 3px; }
.mode-toggle button:last-child { border-radius: 0 3px 3px 0; }
.mode-toggle button.active { background: var(--accent-dim); color: #fff; border-color: var(--accent); }

/* ─── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .synth-grid { grid-template-columns: 1fr; }
  .synth-row { grid-template-columns: 1fr; }
  .effects-row { grid-template-columns: 1fr 1fr; }
  .seq-params { grid-template-columns: 1fr 1fr; }
}


/* ─── PPG hairline rules ───────────────────────────────────────────────────
   Section titles are set as thin white rules rather than coloured bars —
   the opposite move from the Jupiter next door, and true to the machine. */
.panel-title {
  color: var(--accent);
  border-bottom: 1px solid rgba(232, 238, 252, 0.22);
}

/* The wave sequence editor is the instrument's reason to exist, so it gets
   the PPG's orange-on-black display treatment: the steps read as a lit
   readout, not as another row of buttons. */
.seq-editor .seq-steps {
  background: linear-gradient(180deg, #05080e, #0a0f1a);
  border: 1px solid #2b3d5a;
  border-radius: 2px;
  padding: 8px;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.8);
}
.seq-editor .seq-step {
  background: #0a1220;
  border: 1px solid #2b3d5a;
  border-radius: 2px;
}
.seq-editor .seq-step .step-num { color: var(--display-ink); opacity: 0.55; }
.seq-editor .seq-step .step-wave {
  color: var(--display-ink);
  font-family: 'Share Tech Mono', 'Courier New', monospace;
  text-shadow: 0 0 6px rgba(255, 140, 26, 0.5);
}
.seq-editor .seq-step .step-dur { color: #6d81a8; }
.seq-editor .seq-step.selected {
  border-color: var(--display-ink);
  background: #14202f;
  box-shadow: inset 0 0 0 1px rgba(255, 140, 26, 0.35);
}
.seq-editor .seq-step.playing {
  background: #2a1a08;
  border-color: var(--display-ink);
  box-shadow: 0 0 12px rgba(255, 140, 26, 0.55);
}
.seq-editor .seq-step-add {
  background: transparent;
  border: 1px dashed #2b3d5a;
  color: #4d5f80;
}
.seq-editor .seq-step-add:hover { border-color: var(--display-ink); color: var(--display-ink); }
