/* 튜너 페이지 */

.tuner {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 22px 16px 20px;
  text-align: center;
}

.tuner__top {
  display: grid;
  justify-items: center;
  gap: 8px;
}

.tuner__status {
  max-width: 520px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 700;
}

.tuner__status:empty {
  display: none;
}

.tuner__status[data-tone='error'] {
  color: var(--danger-text);
}

/* 큰 음이름 */
.tuner__note {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  min-height: 1.15em;
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 96px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
  transition: color 0.12s;
}

.tuner__note small {
  margin-left: 4px;
  color: var(--text-muted);
  font-size: 0.32em;
  letter-spacing: 0;
}

.tuner.is-active .tuner__note {
  color: var(--text);
}

.tuner.is-in-tune .tuner__note {
  color: var(--success-text);
}

.tuner__reading {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 14px;
  min-height: 1.5em;
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

#tuner-cents {
  color: var(--text);
}

/* 바늘: -50 ~ +50 센트, 가운데 초록 칸(±5)이 맞는 범위 */
.meter {
  position: relative;
  width: min(560px, 100%);
  height: 64px;
  margin-top: 6px;
  overflow: hidden;
  border-radius: 14px;
  background:
    linear-gradient(90deg, transparent calc(50% - 1px), var(--text-muted) calc(50% - 1px) calc(50% + 1px), transparent 0),
    repeating-linear-gradient(90deg, var(--border) 0 1px, transparent 1px 10%),
    var(--surface-2);
}

.meter__zone {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 45%;
  width: 10%;
  background: rgba(34, 197, 94, 0.22);
}

/* 미터 폭 전체를 덮는 투명한 판을 transform 으로 옮기고(1% = 미터 폭의 1%), 가운데에 바늘을 그린다.
   left 로 옮기면 움직일 때마다 화면 배치를 다시 계산하지만, transform 은 그래픽 처리만으로 움직인다. */
.meter__needle {
  position: absolute;
  inset: 8px 0;
  transform: translateX(calc(var(--cents, 0) * 1%));
  transition: transform 0.12s ease-out;
  pointer-events: none;
}

.meter__needle::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(50% - 3px);
  width: 6px;
  border-radius: 3px;
  background: var(--text-muted);
  opacity: 0.35;
  transition: background-color 0.12s, opacity 0.12s;
}

.tuner.is-active .meter__needle::before {
  background: var(--accent);
  opacity: 1;
}

.tuner.is-in-tune .meter__needle::before {
  background: #22c55e;
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.7);
}

.meter__labels {
  display: flex;
  justify-content: space-between;
  width: min(560px, 100%);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.tuner__guide {
  min-height: 1.6em;
  font-size: 19px;
  font-weight: 800;
}

.tuner.is-in-tune .tuner__guide {
  color: var(--success-text);
}

.tuner.is-low .tuner__guide,
.tuner.is-high .tuner__guide {
  color: var(--accent-text);
}

/* 줄 고르기 */
.tuner__strings {
  display: grid;
  justify-items: center;
  gap: 10px;
  width: 100%;
  margin-top: 10px;
}

.tuner__label {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
}

.tuner__chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.string-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 46px;
  padding: 0 14px 0 9px;
  border: 2px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}

.string-chip small {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.string-chip__no {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  color: var(--text-muted);
  font-size: 11px;
}

.string-chip--auto {
  padding: 0 16px;
  font-size: 15px;
}

.string-chip.is-detected {
  border-color: var(--accent);
}

.string-chip.is-in-tune {
  border-color: #22c55e;
  background: rgba(34, 197, 94, 0.16);
}

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

.string-chip[aria-pressed='true'] small,
.string-chip[aria-pressed='true'] .string-chip__no {
  color: inherit;
}

@media (max-width: 640px) {
  .tuner__note {
    font-size: 80px;
  }

  .string-chip {
    height: 42px;
    padding: 0 11px 0 7px;
    font-size: 16px;
  }
}
