/* Tools › Metronome. Uses the Program Partner tokens from style.css. */

.metro {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
}

.metro h1,
.metro-eyebrow {
  margin: 0;
}

.metro-tempo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.metro-step {
  width: 3rem;
  height: 3rem;
  padding: 0;
  border-radius: 999px;
  background: var(--card);
  color: var(--foreground);
  border-color: var(--input-border);
}

.metro-step .icon {
  width: 1.4rem;
  height: 1.4rem;
}

.metro-number {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.metro-bpm {
  width: 4.2ch;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--foreground);
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 4.5rem;
  line-height: 1.05;
  text-align: center;
  -moz-appearance: textfield;
  appearance: textfield;
}

.metro-bpm::-webkit-outer-spin-button,
.metro-bpm::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.metro-bpm:hover,
.metro-bpm:focus {
  border-color: var(--input-border);
}

.metro-unit {
  color: var(--muted-foreground);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.06em;
}

.metro-marking {
  margin: 0;
  color: var(--accent-foreground);
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 1.25rem;
}

.metro-slider,
.metro-settings input[type='range'] {
  width: 100%;
  accent-color: var(--primary);
}

.metro-slider {
  max-width: 32rem;
}

.metro-beat-note {
  margin: -0.65rem 0 0;
}

/* The beat dots (roadmap phase 30): each a button showing its beat's number,
   tapped to make the beat normal, accented or silent. Each state has its own
   shape as well as its color: an accent has a thick ring and an accent mark,
   a silent beat a dashed ring. */
.metro-dots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.5rem;
}

.metro-dot {
  position: relative;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--input-border);
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  color: var(--muted-foreground);
  font-size: 0.85rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  transition: none;
}

button.metro-dot:hover {
  opacity: 1;
  border-color: var(--foreground);
}

.metro-dot[data-state='a'] {
  border-width: 3px;
  border-color: var(--primary);
  color: var(--primary);
}

/* The accent mark (>) over the number. */
.metro-dot[data-state='a']::before {
  content: '>';
  position: absolute;
  top: 0.1rem;
  left: 50%;
  transform: translateX(-50%) scaleX(0.85);
  font-size: 0.72rem;
  font-weight: 700;
}

.metro-dot[data-state='a'] > span,
span.metro-dot[data-state='a'] {
  padding-top: 0.35rem;
}

.metro-dot[data-state='s'] {
  border-style: dashed;
  color: var(--muted-foreground);
  text-decoration: line-through;
}

/* Lit: the beat that's sounding. */
.metro-dot.on {
  background: var(--foreground);
  border-color: var(--foreground);
  color: var(--card);
}

.metro-dot[data-state='a'].on {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-foreground);
}

/* A silent beat, or a measure the gap trainer keeps silent: the light moves on, in outline. */
.metro-dot[data-state='s'].on,
.metro-dot.on.rest {
  background: var(--muted);
  border-style: dashed;
  border-color: var(--foreground);
  color: var(--foreground);
}

/* The count-in: a ring around the dot, not a fill. */
.metro-dot.on.count {
  background: var(--card);
  border-style: solid;
  border-color: var(--foreground);
  color: var(--foreground);
  box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--ring);
}

.metro-dots-hint {
  margin: -0.5rem 0 0;
}

/* Where a run is: the count-in, the gap trainer's measures, the tempo trainer's tempo. */
.metro-status {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0 0.75rem;
  min-height: 1.5rem;
  margin: -0.5rem 0 0;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.metro-status.count {
  color: var(--accent-foreground);
}

.metro-phase:empty,
.metro-now:empty {
  display: none;
}

.metro-newer {
  margin: 0;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  background: var(--muted);
}

.metro-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.metro-start {
  min-width: 9rem;
}

.metro-tap {
  height: 2.5rem;
  background: var(--card);
  color: var(--foreground);
  border-color: var(--input-border);
}

.metro-tap-status {
  flex-basis: 100%;
  min-height: 1.25em;
}

.metro-settings,
.metro-tools,
.metro-share {
  width: 100%;
  max-width: 40rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  text-align: left;
}

.metro-settings {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 1rem;
}

.metro-notes {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0;
}

.metro-tools summary,
.metro-share summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 500;
}

.metro-share[open] > * + * {
  margin-top: 0.75rem;
}

/* Count-in, trainers and flash (roadmap phase 30). */
.metro-tools[open] > * + * {
  margin-top: 1.25rem;
}

.metro-tool {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
}

.metro-tool .field-label {
  font-weight: 500;
}

.metro-tool .check {
  height: auto;
  min-height: 2.25rem;
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
}

.metro-tool-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr));
  gap: 0.75rem;
  width: 100%;
}

.metro-tool-fields[hidden] {
  display: none;
}

.metro-tool-fields input[type='number'] {
  font: inherit;
  width: 100%;
  height: 2.25rem;
  padding: 0 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--input-border);
  background: var(--card);
  color: var(--foreground);
}

.metro-tool-note {
  margin: 0;
}

/* The flash on the beat, over the whole screen. With reduced motion it's a
   soft glow at the screen's edge that fades in and out instead. */
.metro-flash {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  background: var(--primary);
  opacity: 0;
  transition: opacity 0.16s ease-out;
}

/* A page's stack spaces its children; the flash covers the whole screen. */
.stack > .metro-flash {
  margin: 0;
}

.metro-flash.on {
  opacity: 0.45;
  transition: none;
}

.metro-flash.on.strong {
  opacity: 0.7;
}

/* No flash at all when the device asks for reduced motion; the page doesn't light it either. */
@media (prefers-reduced-motion: reduce) {
  .metro-flash {
    display: none;
  }
}

@media (max-width: 560px) {
  .metro-bpm {
    font-size: 3.75rem;
  }
}

/* Twelve beats wrap into two rows of six on a phone. */
@media (max-width: 420px) {
  .metro-dots {
    gap: 0.375rem;
  }

  .metro-dot {
    width: 2.25rem;
    height: 2.25rem;
  }
}

/* On a touch screen the beats are 44 px across (UX plan phase 92). The
   narrowest phones keep 36 px, so twelve beats still make two rows of six. */
@media (pointer: coarse) and (min-width: 341px) {
  .metro-dot {
    width: 2.75rem;
    height: 2.75rem;
  }
}

@media (pointer: coarse) and (max-width: 340px) {
  .metro-dots .metro-dot {
    min-height: 0;
  }
}
