/* ==========================================================================
   Synth Controls Library
   Knobs, switches, and sliders for patch editors
   ========================================================================== */

/* --- Knob (rotary potentiometer) --- */

.knob {
  position: relative;
  display: inline-block;
  cursor: grab;
}

.knob:active {
  cursor: grabbing;
}

.knob__inner {
  border-radius: 50%;
}

.knob__inner svg {
  width: 100%;
  height: 100%;
}

.knob--a .knob__inner {
  width: 75px;
  height: 75px;
}

.knob--b .knob__inner {
  width: 80px;
  height: 80px;
}

.knob--c .knob__inner {
  width: 98px;
  height: 98px;
}

/* --- Switch (multi-position toggle) --- */

.switch {
  position: relative;
  display: inline-block;
  cursor: pointer;
}

.switch__inner {
  background-repeat: no-repeat;
  overflow: hidden;
}

/* Round switch: SVG inline rendering */
.switch--round .switch__inner {
  width: 120px;
  height: 120px;
}

.switch--round .switch__inner svg {
  width: 100%;
  height: 100%;
}

/* Toggle switch: 64x64, SVG inline rendering */
.switch--toggle .switch__inner {
  width: 64px;
  height: 64px;
}

.switch--toggle .switch__inner svg {
  width: 100%;
  height: 100%;
}

/* Toggle frames: show/hide based on data-value */
.switch__toggle-frame { display: none; }
.switch__inner[data-value="0"] .switch__toggle-frame--0 { display: block; }
.switch__inner[data-value="1"] .switch__toggle-frame--1 { display: block; }

/* Round switch frames: show/hide based on data-value */
.switch__round-frame { display: none; }
.switch__inner[data-value="0"] .switch__round-frame--0 { display: block; }
.switch__inner[data-value="1"] .switch__round-frame--1 { display: block; }
.switch__inner[data-value="2"] .switch__round-frame--2 { display: block; }

/* --- LED button (small clickable indicator with glow when ON) --- */

.led-button {
  position: relative;
  display: block;
  cursor: pointer;
}

.led-button__inner {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.led-button__inner svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.led-button__frame { display: none; }
.led-button__inner[data-value="0"] .led-button__frame--0 { display: block; }
.led-button__inner[data-value="1"] .led-button__frame--1 { display: block; }

/* --- Jack socket --- */

.jack {
  display: inline-block;
  width: 34px;
  height: 34px;
}

.jack svg {
  width: 100%;
  height: 100%;
}

/* --- Jack point anchor (SVG circle for CableManager) --- */

@keyframes jack-blink {
  0%, 100% { stroke-opacity: 1; }
  50% { stroke-opacity: 0.3; }
}

.jack-point {
  cursor: pointer;
}

.jack-point--active {
  animation: jack-blink 0.8s ease-in-out infinite;
}

/* --- Interactive controls override panel scroll grab cursor --- */

.switch,
.switch__inner,
.jack,
.led-button,
.led-button__inner {
  cursor: pointer;
}

.switch--toggle,
.switch--toggle .switch__inner {
  cursor: pointer;
}

/* --- Slider (vertical fader) --- */

.slider {
  position: relative;
  width: 70px;
  height: 243px;
  display: inline-block;
  cursor: grab;
  /* Track groove */
  background: linear-gradient(
    to right,
    transparent 30px,
    #555 30px,
    #555 32px,
    #333 32px,
    #333 38px,
    #555 38px,
    #555 40px,
    transparent 40px
  );
}

.slider:active {
  cursor: grabbing;
}

/* Verbos-style slot fader: a thin black vertical slot (the "fente") the oval
   handle slides in. The slot is a centred pill with rounded ends (top/bottom),
   drawn as a ::before so only the slot is rounded, not the whole box. */
.slider--slot {
  background: none;
  position: relative;
}
.slider--slot::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 24%;
  transform: translateX(-50%);
  background: #0a0a0a;
  border-radius: 999px;
}
/* The handle is a compact vertical oval, narrower than the mixer cap. */
.slider--slot .slider__inner {
  width: 14px;
  height: 20px;
  left: 50%;
  transform: translateX(-50%);
}
/* Keep the slot handle compact even when placed (overrides the generic
   .placed-component .slider__inner { width/height: 100% !important }). */
.placed-component .slider--slot .slider__inner {
  width: 45% !important;
  height: auto !important;
  aspect-ratio: 20 / 28;
  left: 50%;
  transform: translateX(-50%);
}

/* Handle-only variant — no track background, handle scales to its container at ~90% width with native ratio */
.slider-handle-only .slider {
  background: none;
  width: 100%;
  height: 100%;
  cursor: default;
}
.slider-handle-only .slider__inner {
  width: 90%;
  left: 5%;
  aspect-ratio: 70 / 28;
  height: auto;
  cursor: grab;
}
.slider-handle-only .slider__inner:active {
  cursor: grabbing;
}

.slider__inner {
  display: block;
  width: 70px;
  height: 28px;
  position: absolute;
  bottom: 0;
  left: 0;
}

.slider__inner svg {
  width: 100%;
  height: 100%;
}

/* Module designer: placed components and selection state */
.placed-component {
  cursor: move;
}

/* Force every component's inner SVG to fill its foreignObject box, so the
   drawing matches its mm footprint instead of rendering at its intrinsic size
   (which made components overflow / be mis-cropped). */
.placed-component > div,
.module-palette .palette-item > div,
.size-presets {
  display: block;
}

.placed-component svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* In the module designer (placed components + palette), every control must
   fill its box. The shared controls.css gives Knob/Slider/Switch fixed px sizes
   (for the Pulsar/Matriarch panels) — override them here only, scoped, so we
   don't break those panels. */
.placed-component .knob,
.placed-component .knob__inner,
.placed-component .slider,
.placed-component .slider__inner,
.placed-component .switch,
.placed-component .switch__inner,
.placed-component .jack,
.placed-component .led,
.placed-component .trimmer,
.placed-component .button,
.placed-component .xlr-socket,
.placed-component .bnc-socket,
.module-palette .palette-item .knob,
.module-palette .palette-item .knob__inner,
.module-palette .palette-item .slider,
.module-palette .palette-item .slider__inner,
.module-palette .palette-item .switch,
.module-palette .palette-item .switch__inner {
  width: 100% !important;
  height: 100% !important;
  /* block (not inline-block) so no baseline gap pushes the SVG down when the
     box is resized — this is what made the switch float/clip out of its box. */
  display: block !important;
}

.module-palette .palette-item svg {
  width: 100%;
  height: 100%;
  display: block;
}

.placed-component--selected {
  outline: 1px solid #0EA5E9;
  outline-offset: 0.5px;
  background: rgba(14, 165, 233, 0.15);
  border-radius: 2px;
}

.palette-item:active {
  cursor: grabbing;
}

/* Module designer — palette categories */
.palette-category {
  margin-bottom: 14px;
}

.palette-category__title {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: 1px;
  color: #737373;
  text-transform: uppercase;
  margin-bottom: 6px;
}

/* Module designer — background zone editor */
/* The module designer SVG must not inherit the panel-scroll "grab" cursor on its
   parent — grab/grabbing are reserved for zone editing. Default elsewhere. */
[data-module-designer-target="svg"] { cursor: default; }

/* Active zone-mode button: clearly highlighted so the current mode is obvious. */
[data-module-designer-target="zoneButton"].is-active {
  background: #0EA5E9 !important;
  color: #0D0D0D !important;
  border-color: #0EA5E9 !important;
  font-weight: 700;
}

/* A subtle accent outline on the panel while zone mode is active. */
.zone-mode { outline: 2px dashed #0EA5E9; outline-offset: 2px; }

.zone-mode { cursor: crosshair; }
/* In zone mode, components are inactive → no "move" cursor on them. */
.zone-mode .placed-component { cursor: default; }
/* In zone mode, existing zones are grabbable (move); closed hand while dragging. */
.zone-mode .background-zones rect { cursor: grab; }
.zone-mode.zone-dragging,
.zone-mode.zone-dragging .background-zones rect { cursor: grabbing; }
.zone-draft {
  fill-opacity: 0.6;
  stroke: #0EA5E9;
  stroke-width: 0.2;
  stroke-dasharray: 1 0.6;
}

/* Active text-mode button: clearly highlighted so the current mode is obvious. */
[data-module-designer-target="textButton"].is-active {
  background: #0EA5E9 !important;
  color: #0D0D0D !important;
  border-color: #0EA5E9 !important;
  font-weight: 700;
}

/* A subtle accent outline on the panel while text mode is active. */
.text-mode { outline: 2px dashed #0EA5E9; outline-offset: 2px; }
/* In text mode, every non-text component is inactive → no "move" cursor on it. */
.text-mode .placed-component { cursor: default; }
/* Text graphics stay grabbable (selectable / movable) in text mode. */
.text-mode .placed-component[data-component-type="text"] { cursor: move; }
.props-delete {
  width: 100%;
  margin-top: 12px;
  padding: 8px;
  background: #3a1414;
  color: #f87171;
  border: 1px solid #5a1414;
  border-radius: 4px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  cursor: pointer;
}
.props-delete:hover { background: #4a1818; }

/* Group action buttons (align / distribute) in the multi-selection panel. */
.props-group-button {
  width: 100%;
  margin-top: 6px;
  padding: 8px;
  background: #0D0D0D;
  color: #E5E5E5;
  border: 1px solid #2A2A2A;
  border-radius: 4px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  cursor: pointer;
}
.props-group-button:hover { background: #1A1A1A; border-color: #0EA5E9; }

/* Module designer — marquee selection rectangle (drawn in mm space) */
/* Marquee selection rectangle drawn as a fixed screen overlay so it is visible
   from the click point even when the drag starts outside the module. */
.marquee-overlay {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  background: rgba(14, 165, 233, 0.18);
  border: 1px dashed #0EA5E9;
}

/* Module designer — properties panel: color field (picker + hex) */
.props-color {
  display: flex;
  gap: 6px;
  align-items: center;
}

.props-color__picker {
  width: 32px;
  height: 28px;
  padding: 0;
  border: 1px solid #2A2A2A;
  border-radius: 4px;
  background: #0D0D0D;
  cursor: pointer;
}

.props-color__hex {
  flex: 1;
}

/* Module designer — properties panel: component type heading */
.props-type {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  font-weight: 700;
  color: #0EA5E9;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #2A2A2A;
}

/* Module designer — properties panel fields (OPTIONS / STATE / POSITION) */
.props-section {
  border-top: 1px solid #2A2A2A;
  padding-top: 10px;
  margin-top: 10px;
}

.props-section__title {
  font-size: 10px;
  letter-spacing: 1px;
  color: #737373;
  margin-bottom: 8px;
}

.props-field {
  margin-bottom: 10px;
}

.props-field__label {
  display: block;
  font-size: 11px;
  color: #737373;
  margin-bottom: 4px;
}

.props-input {
  width: 100%;
  background: #0D0D0D;
  border: 1px solid #2A2A2A;
  border-radius: 4px;
  color: #E5E5E5;
  padding: 6px;
  font-size: 12px;
  font-family: 'IBM Plex Mono', monospace;
}

.props-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  margin-bottom: 8px;
  cursor: pointer;
}

.props-stepper {
  display: flex;
  align-items: stretch;
  min-width: 0;
}

.props-stepper button {
  width: 28px;
  background: #0D0D0D;
  border: 1px solid #2A2A2A;
  color: #E5E5E5;
  cursor: pointer;
  font-size: 14px;
}

.props-stepper input {
  flex: 1;
  /* width:0 lets the number input shrink below its intrinsic size so the
     properties columns never overflow horizontally. */
  width: 0;
  min-width: 0;
  text-align: center;
  background: #0D0D0D;
  border: 1px solid #2A2A2A;
  border-left: none;
  border-right: none;
  color: #E5E5E5;
  font-family: 'IBM Plex Mono', monospace;
}
