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

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

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

.placed-component--selected {
  outline: 0.4px dashed #0EA5E9;
}

.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;
}
.zone-handle {
  fill: #0EA5E9;
  stroke: #0D0D0D;
  stroke-width: 0.3;
  cursor: nwse-resize;
}
.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; }

/* Module designer — marquee selection rectangle (drawn in mm space) */
.marquee {
  fill: rgba(14, 165, 233, 0.12);
  stroke: #0EA5E9;
  stroke-width: 0.2;
  stroke-dasharray: 1 0.6;
  pointer-events: none;
}

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

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

.props-stepper input {
  flex: 1;
  text-align: center;
  background: #0D0D0D;
  border: 1px solid #2A2A2A;
  border-left: none;
  border-right: none;
  color: #E5E5E5;
  font-family: 'IBM Plex Mono', monospace;
}
