/* ── COMPONENTS ── */
/* Buttons, sliders, inputs, legend chips, panels */

/* ── BUTTONS: PRIMARY ── */
.btn-primary {
  height: var(--btn-height-primary);
  min-width: 100px;
  padding: 0 var(--space-6);
  background: var(--accent-orange);
  color: #fff;
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.04em;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background var(--transition-ui), transform var(--transition-ui), box-shadow var(--transition-ui);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  min-width: 44px;
}

.btn-primary:hover:not(:disabled) {
  background: #c96e28;
  box-shadow: var(--shadow-glow-orange);
}

.btn-primary:active:not(:disabled) {
  transform: scale(0.97);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── BUTTONS: SECONDARY ── */
.btn-secondary {
  height: var(--btn-height-secondary);
  padding: 0 var(--space-4);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 500;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background var(--transition-ui), border-color var(--transition-ui), transform var(--transition-ui);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  min-width: 44px;
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-panel);
  border-color: var(--accent-orange);
  color: var(--accent-orange);
}

.btn-secondary:active:not(:disabled) {
  transform: scale(0.97);
}

.btn-secondary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── BUTTONS: PRESET ── */
.btn-preset {
  height: var(--btn-height-secondary);
  padding: 0 var(--space-4);
  background: var(--bg-panel);
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.05em;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-ui), color var(--transition-ui), border-color var(--transition-ui);
  min-height: 44px;
}

.btn-preset:hover:not(:disabled) {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--accent-orange);
}

.btn-preset.active {
  background: var(--accent-orange);
  color: #fff;
  border-color: var(--accent-orange);
}

.btn-preset:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── PLAY/PAUSE BUTTON STATE ── */
.btn-primary.playing {
  background: var(--accent-lavender);
}

.btn-primary.playing:hover:not(:disabled) {
  background: #5a46b0;
}

/* ── RESET BUTTON ── */
.btn-reset {
  height: var(--btn-height-secondary);
  padding: 0 var(--space-4);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: color var(--transition-ui), border-color var(--transition-ui);
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

.btn-reset:hover:not(:disabled) {
  color: var(--bar-pivot);
  border-color: var(--bar-pivot);
}

.btn-reset:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── SLIDERS ── */
.slider-wrapper {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.slider-track {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.slider-value {
  font-size: var(--text-xs);
  color: var(--accent-orange);
  font-weight: 600;
  min-width: 32px;
  text-align: right;
}

input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  height: 4px;
  background: var(--bg-surface);
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-orange);
  border: 2px solid var(--bg-main);
  cursor: pointer;
  transition: transform var(--transition-ui), box-shadow var(--transition-ui);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 0 0 4px var(--accent-orange-glow);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-orange);
  border: 2px solid var(--bg-main);
  cursor: pointer;
}

input[type="range"]:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── CUSTOM ARRAY INPUT ── */
.custom-input-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.custom-input {
  flex: 1;
  min-width: 200px;
  max-width: 400px;
  height: var(--btn-height-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
  transition: border-color var(--transition-ui);
}

.custom-input::placeholder {
  color: var(--text-muted);
}

.custom-input:focus {
  outline: none;
  border-color: var(--accent-orange);
}

.custom-input.error {
  border-color: var(--bar-pivot);
}

/* ── ERROR MESSAGE ── */
.error-message {
  font-size: var(--text-xs);
  color: var(--bar-pivot);
  margin-top: var(--space-1);
  min-height: 16px;
  display: block;
}

/* ── LEGEND CHIPS ── */
.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.legend-chip-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── INFO PANEL ── */
.step-description {
  font-size: var(--text-base);
  color: var(--text-primary);
  min-height: 24px;
  line-height: 1.6;
}

.step-counter {
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.step-counter strong {
  color: var(--accent-orange);
}

/* ── CALL STACK PANEL ── */
.callstack-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: var(--space-4);
  box-shadow: var(--shadow-card);
}

.callstack-title {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.callstack-title::before {
  content: '';
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--bar-active);
}

.callstack-frames {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-xs);
}

.callstack-frame {
  padding: var(--space-2) var(--space-3);
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  border-left: 2px solid var(--bar-active);
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.callstack-frame.depth-0 {
  border-left-color: var(--bar-pivot);
  color: var(--text-primary);
}

.callstack-frame.depth-1 {
  border-left-color: var(--bar-active);
}

.callstack-frame.depth-2 {
  border-left-color: var(--bar-comparing);
  opacity: 0.7;
}

.callstack-empty {
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-style: italic;
}
