/* BPM to Millisecond Calculator — Tool styles
   Uses the site's global design tokens (css/styles.css) so it renders
   consistently with the rest of theaudiotoolkit.com. */

/* Tempo layout: input + tap on the left, live readout on the right */
.tempo-grid {
  display: grid;
  gap: var(--spacing-lg);
  align-items: stretch;
}
@media (min-width: 640px) {
  .tempo-grid { grid-template-columns: 1fr 1fr; }
}

.tempo-input-col {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

/* Live readout — presented as a bordered hero card so the column carries
   visual weight and the number anchors inside a panel (not floating).
   On desktop the card is nudged down by the BPM label height + gap so its
   top edge meets the input *box* (not the label) — see @media below. */
/* On desktop the card is pushed down by the BPM label height + gap so its
   TOP meets the input *box* (not the label), and its HEIGHT is set to fill
   the rest of the column so its BOTTOM meets the TAP button bottom. */
.tempo-readout-col {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin-top: calc(1.375rem + var(--spacing-xs));
  height: calc(100% - 1.375rem - var(--spacing-xs));
  padding: var(--spacing-lg);
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
@media (max-width: 639px) {
  /* Single-column: card sits below the TAP button, content-sized + flush */
  .tempo-readout-col { margin-top: 0; height: auto; }
}

/* Tap button — single, prominent target; grows to fill the remaining
   height of the input column while keeping the normal column gap */
.tap-btn {
  width: 100%;
  flex: 1 1 auto;
  min-height: 64px;
  font-family: var(--font-sans);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--color-bg);
  background: var(--color-primary);
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: var(--shadow-md);
  transition: transform var(--transition), background var(--transition), box-shadow var(--transition);
}
.tap-btn:hover { background: var(--color-primary-hover); transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.tap-btn:active { transform: scale(0.97); }
.tap-btn:focus-visible { outline: 3px solid var(--color-primary); outline-offset: 3px; }
.tap-btn.tapping { animation: tap-flash 0.12s ease-out; }

@keyframes tap-flash {
  0%   { transform: scale(1); }
  50%  { transform: scale(0.94); background: var(--color-primary-hover); }
  100% { transform: scale(1); }
}

/* Big live readout — the single BPM figure */
.bpm-readout {
  text-align: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: clamp(2.25rem, 6vw, 3rem);
  line-height: 1;
  color: var(--color-primary);
}
.bpm-readout span {
  display: block;
  margin-top: var(--spacing-xs);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--color-text-muted);
}
.readout-hint {
  margin-top: var(--spacing-sm);
  text-align: center;
  font-size: 0.8125rem;
}

/* Field errors — slot collapses when empty so the hint tucks directly under
   the input (matches the spacing convention used by the other site tools) */
.error-message {
  color: var(--color-error);
  font-size: 0.8125rem;
  margin-top: 0;
  min-height: 0;
}
input[aria-invalid="true"] { border-color: var(--color-error) !important; }
input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.2); }

/* Results table */
.table-wrap {
  overflow-x: auto;
  margin-top: var(--spacing-lg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}
.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}
.results-table caption {
  padding: var(--spacing-sm) var(--spacing-md);
  text-align: left;
  font-weight: 600;
  color: var(--color-text-muted);
}
.results-table th,
.results-table td {
  padding: var(--spacing-sm) var(--spacing-md);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}
.results-table th {
  background: var(--color-bg);
  font-weight: 600;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}
.results-table th:last-child { text-align: right; }
.results-table td { transition: background var(--transition); }
.results-table td:first-child {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--color-text);
}
.results-table td:last-child {
  text-align: right;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--color-primary);
}
.results-table tbody tr:nth-child(even) td { background: var(--color-bg-elevated); }
.results-table tbody tr:hover td { background: var(--color-primary-dim); }

/* Tempo matches list */
.tempo-matches {
  list-style: none;
  margin: var(--spacing-md) 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}
.tempo-matches li {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: background var(--transition), border-color var(--transition);
}
.tempo-matches li:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-dim);
}
.tempo-match-tempo {
  font-family: var(--font-mono);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--color-primary);
}
.tempo-match-note { color: var(--color-text); font-weight: 500; }
.tempo-match-exact {
  margin-left: auto;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-primary);
}

/* Visually hidden (screen-reader only) */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .tap-btn.tapping { animation: none; }
}
