/**
 * SL.1 — Synth Step Lane styling.
 *
 * Visual language deliberately *not* the TR-909 hardware look of 9zero9 —
 * the Synth Lane is part of the synth editor, not a separate hardware
 * faceplate. Subdued neon panel matching the rest of the synth-mode UI.
 */

.module-synth-lane {
  --sl-step-bg: rgba(20, 28, 44, 0.6);
  --sl-step-on-bg: rgba(80, 200, 220, 0.55);
  --sl-step-on-border: rgba(120, 240, 255, 0.85);
  --sl-step-playhead: rgba(255, 220, 90, 0.95);
  --sl-step-text: #cfe8ff;
  --sl-step-on-text: #052430;
}

.synth-lane-host {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.synth-lane-host[data-lane-enabled="0"] {
  opacity: 0.5;
  pointer-events: none;
}

.synth-lane-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.synth-lane-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.synth-lane-title {
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  color: #e4f4ff;
}

.synth-lane-help-btn {
  appearance: none;
  border: 1px solid color-mix(in srgb, var(--amber) 36%, var(--line));
  background: color-mix(in srgb, var(--panel) 78%, transparent);
  color: var(--amber);
  border-radius: 4px;
  padding: 4px 10px;
  font-family: var(--tracker-font);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.synth-lane-help-btn:hover,
.synth-lane-help-btn[aria-expanded="true"] {
  background: color-mix(in srgb, var(--amber) 18%, var(--panel));
  border-color: color-mix(in srgb, var(--amber) 70%, var(--line));
}

.synth-lane-help-panel {
  margin-top: 8px;
  padding: 10px 14px;
  background: color-mix(in srgb, var(--panel) 92%, var(--amber) 8%);
  border: 1px solid color-mix(in srgb, var(--amber) 28%, var(--line));
  border-radius: 4px;
  font-family: var(--tracker-font, ui-monospace, monospace);
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--text);
}

.synth-lane-help-panel h4 {
  font-family: var(--tracker-font);
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--amber);
  margin: 8px 0 4px;
  font-weight: 900;
}

.synth-lane-help-panel h4:first-child {
  margin-top: 0;
}

.synth-lane-help-panel ul {
  margin: 4px 0 8px;
  padding-left: 16px;
}

.synth-lane-help-panel li {
  margin: 3px 0;
}

.synth-lane-help-panel p {
  margin: 4px 0 0;
}

.synth-lane-help-panel strong {
  color: var(--amber);
}

.synth-lane-help-panel em {
  color: color-mix(in srgb, var(--accent) 78%, #ffffff 22%);
  font-style: normal;
}

.synth-lane-hint {
  font-size: 0.72rem;
  color: rgba(200, 220, 240, 0.7);
  line-height: 1.35;
}

.synth-lane-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}

.synth-lane-play {
  appearance: none;
  border: 1px solid rgba(120, 220, 255, 0.5);
  background: rgba(0, 50, 80, 0.7);
  color: #d8f4ff;
  padding: 6px 16px;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.synth-lane-play:hover {
  background: rgba(0, 80, 120, 0.85);
  border-color: rgba(180, 240, 255, 0.8);
}

.synth-lane-play[data-playing="1"] {
  background: rgba(180, 50, 80, 0.7);
  border-color: rgba(255, 140, 170, 0.7);
  color: #fff4f6;
}

.synth-lane-play[data-playing="1"]:hover {
  background: rgba(220, 70, 100, 0.85);
}

.synth-lane-tempo {
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 0.75rem;
  color: rgba(180, 210, 230, 0.85);
  letter-spacing: 0.04em;
}

/* ---- SL.3 toggle buttons (REC / Metro) ---- */

.synth-lane-toggle {
  appearance: none;
  border: 1px solid rgba(120, 160, 200, 0.5);
  background: rgba(15, 25, 40, 0.7);
  color: rgba(220, 235, 245, 0.85);
  padding: 5px 12px;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: background 0.12s, border-color 0.12s, color 0.12s, box-shadow 0.12s;
  font-family: ui-monospace, "SF Mono", monospace;
}

.synth-lane-toggle:hover {
  border-color: rgba(180, 220, 240, 0.7);
  background: rgba(25, 45, 70, 0.85);
}

.synth-lane-toggle[data-on="1"] {
  background: rgba(40, 100, 130, 0.8);
  border-color: rgba(140, 220, 255, 0.85);
  color: #f0fbff;
}

.synth-lane-rec[data-on="1"] {
  background: rgba(170, 30, 60, 0.85);
  border-color: rgba(255, 120, 150, 0.9);
  color: #fff;
  box-shadow: 0 0 8px rgba(255, 80, 120, 0.45);
  animation: synth-lane-rec-pulse 1.4s ease-in-out infinite;
}

@keyframes synth-lane-rec-pulse {
  0%, 100% { box-shadow: 0 0 6px rgba(255, 80, 120, 0.4); }
  50%      { box-shadow: 0 0 14px rgba(255, 120, 150, 0.75); }
}

.synth-lane-metro[data-on="1"] {
  background: rgba(180, 130, 30, 0.78);
  border-color: rgba(255, 200, 120, 0.85);
  color: #fff8e0;
}

/* ---- Quantize selector ---- */

.synth-lane-quantize {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 0.78rem;
  color: rgba(200, 220, 240, 0.85);
}

.synth-lane-quantize select {
  appearance: none;
  background: rgba(15, 25, 40, 0.8);
  color: #e0f0ff;
  border: 1px solid rgba(120, 160, 200, 0.5);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
}

.synth-lane-quantize select:hover {
  border-color: rgba(180, 220, 240, 0.7);
}

/* ---- SL.8 knob frame (uses shared .range-knob from synth-controls.css) ---- */

.synth-lane-knob-frame {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-family: var(--tracker-font);
  color: var(--muted);
  user-select: none;
  --accent: var(--amber); /* match synth-output knob accent */
}

.synth-lane-knob-label {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.66rem;
  font-weight: 800;
  color: var(--muted);
}

/* The .synth-lane-knob extra class is just a hook for the value-readout
 * spacing; the .range-knob class supplies all the visual work. */
.synth-lane-knob.range-knob {
  margin: 0;
}

.synth-lane-knob-value {
  font-family: var(--tracker-font);
  font-size: 0.66rem;
  font-weight: 900;
  color: var(--amber);
  letter-spacing: 0.02em;
  min-width: 2.4em;
  text-align: center;
  text-transform: uppercase;
}

/* ---- SL.2 step-count / stride selects (same skin as quantize) ---- */

.synth-lane-steps-select,
.synth-lane-resolution-select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 0.78rem;
  color: rgba(200, 220, 240, 0.85);
}

.synth-lane-steps-select select,
.synth-lane-resolution-select select {
  appearance: none;
  background: rgba(15, 25, 40, 0.8);
  color: #e0f0ff;
  border: 1px solid rgba(120, 160, 200, 0.5);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
}

.synth-lane-steps-select select:hover,
.synth-lane-resolution-select select:hover {
  border-color: rgba(180, 220, 240, 0.7);
}

/* ---- SL.2 loop-mode toggle (uses .synth-lane-toggle base) ---- */

.synth-lane-loopmode[data-on="1"] {
  background: rgba(60, 140, 90, 0.78);
  border-color: rgba(140, 240, 180, 0.85);
  color: #e8fff4;
}

/* ---- SL.2 export row ---- */

.synth-lane-export {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  padding: 6px 0;
  border-top: 1px dashed rgba(120, 160, 200, 0.25);
  font-size: 0.78rem;
}

.synth-lane-export-label {
  color: rgba(200, 220, 240, 0.8);
  letter-spacing: 0.03em;
}

.synth-lane-export select {
  appearance: none;
  background: rgba(15, 25, 40, 0.8);
  color: #e0f0ff;
  border: 1px solid rgba(120, 160, 200, 0.5);
  border-radius: 4px;
  padding: 4px 10px;
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 0.78rem;
  cursor: pointer;
}

.synth-lane-export-btn {
  appearance: none;
  background: rgba(20, 60, 100, 0.85);
  color: #f0fbff;
  border: 1px solid rgba(120, 200, 240, 0.65);
  border-radius: 4px;
  padding: 5px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: ui-monospace, "SF Mono", monospace;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.synth-lane-export-btn:hover {
  background: rgba(30, 90, 140, 0.95);
  border-color: rgba(180, 240, 255, 0.9);
}

.synth-lane-export-status {
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 0.72rem;
  color: rgba(180, 210, 230, 0.75);
}

.synth-lane-export-status[data-state="ok"] {
  color: rgba(140, 240, 180, 0.95);
}

.synth-lane-export-status[data-state="fail"] {
  color: rgba(255, 140, 140, 0.95);
}

/* ---- SL.2 wider step grids (32 / 64 wrap into multiple rows) ---- */

.synth-lane-grid[data-step-count="32"] {
  grid-template-rows: repeat(2, minmax(0, 1fr));
  grid-auto-flow: row;
}

.synth-lane-grid[data-step-count="64"] {
  grid-template-rows: repeat(4, minmax(0, 1fr));
  grid-auto-flow: row;
}

.synth-lane-grid {
  display: grid;
  grid-template-columns: repeat(16, minmax(0, 1fr));
  gap: 4px;
  align-items: stretch;
}

.synth-lane-step {
  appearance: none;
  background: var(--sl-step-bg);
  border: 1px solid rgba(120, 160, 200, 0.35);
  border-radius: 3px;
  color: var(--sl-step-text);
  padding: 8px 2px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  cursor: pointer;
  min-height: 56px;
  transition: background 0.08s, border-color 0.08s, color 0.08s;
  user-select: none;
}

.synth-lane-step:hover {
  border-color: rgba(170, 220, 240, 0.7);
}

.synth-lane-step[data-on="1"] {
  background: var(--sl-step-on-bg);
  border-color: var(--sl-step-on-border);
  color: var(--sl-step-on-text);
}

.synth-lane-step[data-active-step="0"] {
  opacity: 0.4;
}

.synth-lane-step[data-playhead="1"] {
  outline: 2px solid var(--sl-step-playhead);
  outline-offset: -2px;
  box-shadow: 0 0 8px var(--sl-step-playhead);
}

/* SL.12 — note drag-move affordance. A cell holding a note shows a grab cursor;
   while a drag is in flight the grid shows grabbing; the cell the note will land on
   gets a dashed accent ring. Role-token only (no literal) → themes inherit it.
   Purely visual — no effect on the grid layout, audio, or any existing interaction. */
.synth-lane-step[data-on="1"] {
  cursor: grab;
}
[data-dragging="1"] .synth-lane-step {
  cursor: grabbing;
}
.synth-lane-step[data-drag-target="1"] {
  outline: 2px dashed var(--role-accent-active);
  outline-offset: -2px;
}

/* SL-TIE — a held note spans several cells: the START cell keeps the on-fill
 * (data-held flattens its right edge) and the following continuation cells
 * (data-tie) carry the same fill with a connector that bridges the 4px grid
 * gap, so the run reads as ONE long bar. Token-only → themes for free. */
.synth-lane-step[data-tie="1"] {
  background: color-mix(in srgb, var(--sl-step-on-bg) 82%, transparent);
  border-color: var(--sl-step-on-border);
  color: var(--sl-step-on-text);
  position: relative;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}
.synth-lane-step[data-tie="1"]::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 0;
  bottom: 0;
  width: 6px;
  background: var(--sl-step-on-bg);
}
.synth-lane-step[data-held="1"] {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.synth-lane-step[data-tie="1"] .synth-lane-step-note {
  opacity: 0.5;
}
.synth-lane-step[data-tie="1"] .synth-lane-step-num {
  visibility: hidden;
}

/* SL-FIX — distinct "just recorded" flash so a step you play while
 * recording reads INSTANTLY, separate from the steady on-fill and the
 * playhead outline. Token-only (Theme-Parity / no-hardcoded-colors clean;
 * --sl-step-playhead is themed per skin). */
@keyframes synth-lane-just-recorded {
  0%   { transform: scale(1.14); box-shadow: 0 0 0 2px var(--sl-step-playhead); }
  100% { transform: scale(1); box-shadow: 0 0 10px 1px transparent; }
}
.synth-lane-step.is-just-recorded {
  animation: synth-lane-just-recorded 0.28s ease-out;
  border-color: var(--sl-step-playhead);
}

.synth-lane-step-note {
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.synth-lane-step-num {
  font-size: 0.66rem;
  opacity: 0.6;
  font-family: ui-monospace, "SF Mono", monospace;
}

.synth-lane-step[data-on="1"] .synth-lane-step-num {
  opacity: 0.75;
}

/* Beat markers — slightly emphasize every 4th step (downbeat). */
.synth-lane-step[data-step-index="0"],
.synth-lane-step[data-step-index="4"],
.synth-lane-step[data-step-index="8"],
.synth-lane-step[data-step-index="12"] {
  border-left-width: 2px;
  border-left-color: rgba(150, 200, 230, 0.65);
}

@media (max-width: 900px) {
  .synth-lane-grid {
    grid-template-columns: repeat(8, minmax(0, 1fr));
  }
}

/* ---- SL.10 patch source picker row ---- */

.synth-lane-source-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding: 4px 0;
  font-family: var(--tracker-font);
  font-size: 0.72rem;
}

.synth-lane-source-label {
  color: var(--muted);
  letter-spacing: 0.04em;
}

.synth-lane-source-row select,
.synth-lane-source-select {
  appearance: none;
  background: rgba(15, 25, 40, 0.8);
  color: #e0f0ff;
  border: 1px solid color-mix(in srgb, var(--accent) 36%, rgba(140, 180, 220, 0.32));
  border-radius: 4px;
  padding: 4px 10px;
  font-family: var(--tracker-font);
  font-size: 0.72rem;
  font-weight: 800;
  cursor: pointer;
}

.synth-lane-source-row select:hover,
.synth-lane-source-select:hover {
  border-color: color-mix(in srgb, var(--accent) 75%, rgba(140, 180, 220, 0.5));
}

/* SL-INSTR-CLEAR — make the per-lane source picker read as a picker on EVERY lane:
 * a short "Instr" label + a dropdown caret (the bare appearance:none <select>
 * looked like a static label). Caret uses currentColor → theme-adaptive, no new
 * colour literal (Theme-Parity + no-hardcoded-colors safe). */
.synth-lane-source-field {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
}
.synth-lane-source-label {
  flex: 0 0 auto;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  opacity: 0.7;
}
.synth-lane-source-field .synth-lane-source-select {
  flex: 1 1 auto;
  min-width: 0;
  padding-right: 24px;
}
.synth-lane-source-field::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  opacity: 0.65;
  transform: translateY(-2px);
  pointer-events: none;
}

/* ---- SL-ADD: stacked multi-lane rows ----------------------------------
 * Layout-only (colours come from existing tokens / inherited base classes),
 * so this stays no-hardcoded-colors clean + themes for free. */
.synth-lane-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.synth-lane-row {
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  border-radius: 6px;
  padding: 8px;
  background: color-mix(in srgb, var(--panel) 30%, transparent);
}

.synth-lane-row[data-active="1"] {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent);
}

.synth-lane-row-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.synth-lane-row-label {
  font-family: var(--tracker-font);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  user-select: none;
}

.synth-lane-row[data-active="1"] .synth-lane-row-label {
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

.synth-lane-row-label:hover {
  color: var(--text);
}

/* "＋ Lane" + "✕" reuse the .synth-lane-toggle base look; only spacing here. */
.synth-lane-add-lane {
  font-weight: 800;
}

.synth-lane-add-lane[data-disabled="1"] {
  opacity: 0.4;
  cursor: not-allowed;
}

.synth-lane-remove-lane {
  margin-left: auto;
  min-width: 26px;
  padding-left: 8px;
  padding-right: 8px;
  font-weight: 800;
  line-height: 1;
}

/* SLM — per-lane mixer strips. One row per lane: name · level fader · pan fader · mute.
 * Colour comes from role tokens / the .ghost-button base (theme-aware in all themes) — no
 * literals here, so Neon + Classic + Sand inherit it automatically. */
.synth-lane-mixer-host {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.6rem;
  margin-top: 0.5rem;
  padding: 0.4rem 0.55rem;
  border-radius: 0.4rem;
  background: var(--role-surface-sunken);
}
.synth-lane-mixer-host[data-empty="1"] {
  display: none; /* no added lanes → nothing to mix, hide the bay entirely */
}
.synth-lane-mixer-label {
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.7;
}
.synth-lane-mixer-strip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.synth-lane-mixer-strip.is-muted {
  opacity: 0.55;
}
.synth-lane-mixer-name {
  font-size: 0.74rem;
  min-width: 3.2rem;
}
/* Level + pan are KNOBS (.range-knob, sized by the shared knob CSS) — no width override here, or
 * we'd stretch the 48×48 dial. Just a touch of horizontal breathing room between channels. */
.synth-lane-mixer-vol,
.synth-lane-mixer-pan {
  flex: 0 0 auto;
}
