/* 메트로놈 페이지 */

.metro {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 26px 16px 20px;
}

.metro__tempo {
  display: flex;
  align-items: center;
  gap: 18px;
}

.metro__step {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

@media (hover: hover) {
  .metro__step:hover {
    background: var(--surface-2);
  }
}

.metro__bpm {
  display: grid;
  justify-items: center;
}

.metro__bpm-input {
  width: 3.4ch;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: none;
  font-size: 76px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  text-align: center;
  -moz-appearance: textfield;
  appearance: textfield;
}

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

.metro__bpm-unit {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.metro__tempo-name {
  min-height: 1.5em;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 700;
}

/* 슬라이더 양옆에 −10 / +10 */
.metro__coarse {
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(620px, 100%);
}

.metro__step--ten {
  flex: none;
  width: 54px;
  height: 38px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* 슬라이더는 기본 폭보다 줄지 않으므로 0 에서 남는 자리만큼 늘린다 */
.metro__slider {
  flex: 1;
  width: 0;
  min-width: 0;
  accent-color: var(--accent);
}

/* 자주 쓰는 빠르기: 지금 빠르기와 같으면 주황 */
.metro__presets {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  max-width: 620px;
}

.metro__preset {
  min-width: 50px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

@media (hover: hover) {
  .metro__preset:hover {
    border-color: var(--accent);
  }
}

.metro__preset[aria-pressed='true'] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

/* 박 표시: 지금 박이 켜지고, 첫 박은 주황 테두리 */
.metro__beats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  min-height: 44px;
  margin: 6px 0;
}

.metro__beat {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 2px solid var(--border);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 800;
  /* 박에 맞춰 바로 켜고 끈다 (전환 애니메이션을 두면 박마다 여러 번 다시 그리고, 깜박임도 박보다 늦게 끝난다) */
}

.metro__beat.is-accent {
  border-color: var(--accent);
}

.metro__beat.is-on {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
  transform: scale(1.15);
}

.metro__beat.is-accent.is-on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.metro__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.metro__play {
  min-width: 150px;
}

/* 재생 중: 테두리만 있는 "멈춤" 버튼 (마우스를 올려도 그대로) */
.metro__play[aria-pressed='true'],
.metro__play[aria-pressed='true']:hover:not(:disabled) {
  background: var(--surface);
  color: var(--text);
  filter: none;
}

.metro__tap {
  min-width: 110px;
}

.metro__tap.is-tapped {
  animation: metro-tap 0.25s ease;
}

@keyframes metro-tap {
  0% {
    background: var(--accent);
    color: var(--on-accent);
  }
}

.metro__hint {
  margin: 0;
  text-align: center;
}

.range {
  width: 170px;
  height: 38px;
  margin: 0;
  accent-color: var(--accent);
}

/* 박 표시 맞추기: 한 줄을 다 쓴다 */
.metro__offset-field {
  flex: 1 1 100%;
}

.metro__offset {
  display: flex;
  align-items: center;
  gap: 8px;
}

.metro__offset-step {
  flex: none;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

@media (hover: hover) {
  .metro__offset-step:hover {
    background: var(--surface-2);
  }
}

.metro__offset-slider {
  width: 220px;
}

.metro__offset-value {
  min-width: 84px;
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.metro__offset-hint {
  max-width: 560px;
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

@media (max-width: 640px) {
  .metro__bpm-input {
    font-size: 64px;
  }

  .metro__beat {
    width: 34px;
    height: 34px;
  }

  .metro__coarse {
    gap: 8px;
  }

  /* 자주 쓰는 빠르기 10개를 5개씩 두 줄로 고르게 */
  .metro__presets {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    width: min(420px, 100%);
  }

  .metro__preset {
    min-width: 0;
    padding: 0;
  }

  /* 슬라이더는 기본 폭보다 줄지 않으므로 0 에서 남는 자리만큼 늘린다 */
  .metro__offset-slider {
    flex: 1;
    width: 0;
    min-width: 0;
  }
}
