/* VA Synth — Roland Jupiter-8 (1981) */

:root {
  /* The Jupiter-8 is not a black box: warm charcoal panel in a wood shell,
     with each function group carrying its own colour band across the top.
     That colour-coding is the thing you recognise from across a room, so
     it is this synth's signature rather than another orange accent. */
  --chassis: #6a4526;         /* wood cheeks */
  --chassis-edge: rgba(28, 16, 6, 0.7);
  --cheek: var(--wood);       /* panel-hw.css end cheeks */
  --cheek-w: 22px;
  --bg: #211e1b;
  --panel-bg: #2f2b27;
  --panel-border: #4b443c;
  --accent: #ff9d2e;
  --accent-dim: #a8621a;
  --accent-bright: #ffc078;
  --text: #f1ede7;
  --text-dim: #9c9388;
  --knob-track: #16130f;
  --slider-thumb: #d8d2c8;    /* pale slider caps, Roland-style */
  --danger: #e8455c;
  --led: #ff3b30;
  --cap: #ded8ce;
  --display-bg: #0e0c0a;
  --display-ink: #ffa845;
  --display-grid: rgba(255, 157, 46, 0.10);
  --panel-radius: 3px;
  --title-tracking: 2.2px;

  /* Jupiter group colours, applied as the band over each section title. */
  --band-1: #e8622a;
  --band-2: #d8a72c;
  --band-3: #3f8f6a;
  --band-4: #3d6ea8;
  --band-5: #9a5ca8;
}

/* Wood shell around the whole instrument. */
body::before,
body::after {
  content: '';
  position: fixed;
  top: 0;
  bottom: 0;
  width: 14px;
  background:
    repeating-linear-gradient(180deg,
      rgba(0,0,0,0.16) 0 2px, rgba(255,255,255,0.04) 2px 5px),
    linear-gradient(90deg, #4d3018, var(--chassis) 45%, #3d260f);
  z-index: 5;
  pointer-events: none;
}
body::before { left: 0; box-shadow: inset -2px 0 6px rgba(0,0,0,0.5); }
body::after { right: 0; box-shadow: inset 2px 0 6px rgba(0,0,0,0.5); }

* { 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;
}

.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;
}

.perf-row {
  margin-bottom: 8px;
}

.perf-row .panel {
  width: 100%;
}

.perf-controls {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px 16px;
  align-items: center;
}

.arp-row {
  margin-bottom: 8px;
}

.arp-row .panel {
  width: 100%;
}

.arp-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px 16px;
}

.effects-row {
  display: grid;
  grid-template-columns: repeat(5, 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);
}

/* ─── 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, 255, 136, 0.4);
}

input[type="range"]::-webkit-slider-thumb:hover {
  box-shadow: 0 0 8px rgba(0, 255, 136, 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;
}

/* ─── 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);
}

/* ─── 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, #aaf5cc, #66ddaa); }

.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, #00aa55, #006633); }

.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; }

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

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


/* ─── Jupiter-8 section colour bands ───────────────────────────────────────
   The band is the panel's identity: you find OSCILLATORS by its orange bar,
   not by reading. Cycling by DOM order keeps neighbours distinguishable. */
.panel[data-group="source"] { --band: var(--band-1); }  /* oscillators   */
.panel[data-group="shape"]  { --band: var(--band-2); }  /* filter + envs */
.panel[data-group="mod"]    { --band: var(--band-3); }  /* LFOs + matrix */
.panel[data-group="play"]   { --band: var(--band-4); }  /* arp + perform */
.panel[data-group="fx"]     { --band: var(--band-5); }  /* effects       */
.panel[data-group="out"]    { --band: #8d8377; }        /* master + scope*/
.panel                      { --band: #8d8377; }

.panel-title {
  position: relative;
  padding-left: 10px;
  /* Full-width rule in the group colour — readable across the panel, the
     way the Jupiter's printed bands are. */
  border-bottom: 2px solid var(--band);
}
.panel-title::before {
  content: '';
  position: absolute;
  left: 0;
  top: 1px;
  bottom: 5px;
  width: 4px;
  border-radius: 1px;
  background: var(--band);
  box-shadow: 0 0 6px color-mix(in srgb, var(--band) 60%, transparent);
}
.fx-header .panel-title { padding-left: 10px; }
