/* ============================================================
   v6 Tempo cluster — number input + slider + Tap-tempo button
   ============================================================
   Goal: replace the coarse range-only tempo with a precision-first
   control. Number input is the canonical entry (any BPM 40–240,
   decimals allowed); slider is for quick drags; Tap is for musicians
   who think in pulse, not numbers.

   Density: fits inside the existing .playback-settings row.
*/

@layer v6-components {

  .v6-tempo-cluster {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    /* Override the inline .setting-compact display so children space cleanly */
    flex-wrap: nowrap;
  }

  .v6-tempo-input {
    width: 56px;
    height: 24px;
    padding: 0 6px;
    background: var(--surface-400, #1f1f23);
    border: 1px solid var(--v6-border, rgba(255, 255, 255, 0.10));
    border-radius: 6px;
    color: var(--text-primary, #fafafa);
    font-family: var(--font-mono, monospace);
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    /* Hide the browser spinner buttons — they're tiny and ugly in dark mode */
    -moz-appearance: textfield;
    appearance: textfield;
  }
  .v6-tempo-input::-webkit-inner-spin-button,
  .v6-tempo-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
  }
  .v6-tempo-input:focus {
    outline: none;
    border-color: var(--accent-primary, #8b5cf6);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.30);
  }
  .v6-tempo-input:hover {
    border-color: var(--v6-border-strong, rgba(255, 255, 255, 0.18));
  }

  .v6-tempo-unit {
    font-family: var(--font-mono, monospace);
    font-size: 9px;
    color: var(--text-muted, #71717a);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    user-select: none;
  }

  /* The slider is now secondary — slim it down. */
  .v6-tempo-cluster .v6-tempo-slider {
    width: 90px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(90deg,
      rgba(255, 255, 255, 0.08) 0%,
      rgba(139, 92, 246, 0.35) 100%);
    border-radius: 999px;
    cursor: pointer;
    outline: none;
  }
  .v6-tempo-cluster .v6-tempo-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: #fff;
    border: 2px solid var(--accent-primary, #8b5cf6);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18);
  }
  .v6-tempo-cluster .v6-tempo-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: #fff;
    border: 2px solid var(--accent-primary, #8b5cf6);
    border-radius: 50%;
    cursor: pointer;
  }

  /* Tap button — small, ghost-style, pulses on tap */
  .v6-tempo-tap {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 24px;
    padding: 0 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--v6-border, rgba(255, 255, 255, 0.10));
    border-radius: 999px;
    color: var(--text-secondary, #a1a1aa);
    font-family: var(--font-sans, system-ui);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition:
      background var(--duration-fast, 120ms),
      border-color var(--duration-fast, 120ms),
      color var(--duration-fast, 120ms),
      transform var(--duration-instant, 50ms);
  }
  .v6-tempo-tap:hover {
    background: rgba(139, 92, 246, 0.15);
    border-color: var(--accent-primary, #8b5cf6);
    color: #fff;
  }
  .v6-tempo-tap:active {
    transform: scale(0.95);
  }
  .v6-tempo-tap .v6-icon {
    width: 11px;
    height: 11px;
  }
  .v6-tempo-tap--pulse {
    background: rgba(139, 92, 246, 0.40) !important;
    border-color: var(--accent-primary, #8b5cf6) !important;
    color: #fff !important;
    box-shadow: 0 0 12px rgba(139, 92, 246, 0.60);
  }

  /* SR-only — keep the legacy #tempoValue node alive for code that may still
     reference it, but invisible to sighted users. */
  .v6-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  /* Compact mode at narrow widths — hide the slider, keep input + tap */
  @media (max-width: 1200px) {
    .v6-tempo-cluster .v6-tempo-slider { display: none; }
  }
  @media (max-width: 1000px) {
    .v6-tempo-tap__label { display: none; }
    .v6-tempo-tap { padding: 0 6px; }
  }
}
