/* =========================================================
   Metronome — tool-specific styles.
   Layered on top of /tools/_shared/tool.css.
   Only the widget's unique pieces live here.
   ========================================================= */

/* ---------- Tempo display ---------- */
.tempo-display {
  text-align: center;
  margin-bottom: var(--space-6);
}

.tempo-readout {
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-2);
  margin-bottom: var(--space-1);
}

.bpm-readout {
  font-family: var(--font-mono);
  font-size: 64px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
@media (min-width: 640px) {
  .bpm-readout { font-size: 76px; }
}

.bpm-unit {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.tempo-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  margin-bottom: var(--space-5);
}

/* ---------- Beat indicator ---------- */
.beat-indicator {
  display: flex;
  justify-content: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  min-height: 32px;
  margin-top: var(--space-4);
}

.beat-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: background 0.08s ease, transform 0.08s ease,
              border-color 0.08s ease;
}
.beat-dot.is-downbeat {
  border-color: var(--accent);
}
.beat-dot.is-active {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.35);
}
.beat-dot.is-downbeat.is-active {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 0 0 4px var(--accent-ring);
}

@media (prefers-reduced-motion: reduce) {
  .beat-dot,
  .beat-dot.is-active,
  .beat-dot.is-downbeat.is-active {
    transition: background 0.08s ease, border-color 0.08s ease;
    transform: none;
    box-shadow: none;
  }
}

/* ---------- Transport (start/stop) ---------- */
.transport {
  margin-bottom: var(--space-6);
}

.transport-hint {
  margin-top: var(--space-3);
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}
.transport-hint kbd {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  color: var(--text-secondary);
}

/* Hide stop icon by default; show when transport is running */
.icon-stop { display: none; }
#btn-start[aria-pressed="true"] .icon-play { display: none; }
#btn-start[aria-pressed="true"] .icon-stop { display: inline-block; }

/* ---------- Options block ---------- */
.options { margin-bottom: var(--space-2); }

/* ---------- Tempo control (slider + numeric input) ---------- */
.tempo-control {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  transition: var(--transition-colors);
}

.tempo-control-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-3);
}
.tempo-control-header label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.tempo-input-wrap {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px;
  transition: var(--transition-colors);
}
.tempo-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.tempo-input-wrap input[type="number"] {
  width: 56px;
  padding: 6px 4px;
  font: inherit;
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  background: transparent;
  border: none;
  color: var(--text);
  outline: none;
  -moz-appearance: textfield;
}
.tempo-input-wrap input[type="number"]::-webkit-outer-spin-button,
.tempo-input-wrap input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.tempo-step {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-muted);
  background: transparent;
  transition: background 0.15s ease, color 0.15s ease;
}
.tempo-step:hover { background: var(--surface-2); color: var(--accent); }
.tempo-step:active { transform: translateY(1px); }

.tempo-bounds {
  display: flex;
  justify-content: space-between;
  margin-top: var(--space-2);
  font-size: 12px;
  color: var(--text-subtle);
}

/* The shared range track is var(--surface-2) — the same color as the
   .tempo-control / .volume-control panels behind it, which makes the
   track vanish. Give it a contrasting track (works in both themes); the
   thumb keeps the accent color. */
.tempo-control input[type="range"],
.volume-control input[type="range"] {
  background: var(--border);
}

/* ---------- Tap tempo row ---------- */
.tap-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}
.tap-row .btn { flex-shrink: 0; }
.tap-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
  flex: 1;
  min-width: 0;
}

/* ---------- Beats per measure (segmented control) ---------- */
.beats-control {
  border: none;
  padding: 0;
  margin: 0 0 var(--space-4);
}
.beats-control legend {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: var(--space-3);
}

.beats-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--space-2);
}
@media (max-width: 480px) {
  .beats-grid { grid-template-columns: repeat(3, 1fr); }
}

.beat-option {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.beat-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  inset: 0;
  cursor: pointer;
}
.beat-option span {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  transition: var(--transition-colors);
}
.beat-option:hover span {
  border-color: var(--border-strong);
  color: var(--text);
}
.beat-option input[type="radio"]:checked + span {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}
.beat-option input[type="radio"]:focus-visible + span {
  outline: 2px solid var(--accent-ring);
  outline-offset: 2px;
}

/* ---------- Volume control ---------- */
.volume-control {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  transition: var(--transition-colors);
}
.volume-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-3);
}
.volume-header label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}
