/* 스케일 · 코드 페이지 (지판 자체의 모양은 board.css) */

/* ---------- 근음 · 스케일 고르기 ---------- */

.picker {
  display: grid;
  gap: 14px;
}

.roots {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 6px;
}

.root {
  position: relative;
  display: block;
}

.root input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.root span {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 46px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.1;
  white-space: nowrap;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}

.root span small {
  font-size: 11px;
  font-weight: 700;
  opacity: 0.75;
}

.root.is-accidental span {
  background: #2b221c;
  border-color: #2b221c;
  color: #eee5d8;
}

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

.root input:checked + span {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.root input:focus-visible + span {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.picker__type .select {
  width: 100%;
  max-width: 380px;
}

/* ---------- 스케일 정보 ---------- */

.scale__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.scale__title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.scale__sub {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 700;
}

.scale__about {
  margin-top: 10px;
}

.scale__play {
  flex: none;
}

/* 듣기 버튼과 빠르기 */
.scale__listen {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.tempo {
  display: flex;
  align-items: center;
  gap: 6px;
}

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

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

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

.tempo__slider {
  width: 140px;
  accent-color: var(--accent);
}

.tempo__value {
  min-width: 66px;
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.scale__label {
  margin: 18px 0 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
}

.tones,
.steps {
  display: flex;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tones {
  gap: 8px;
}

.tone {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 54px;
  padding: 8px 8px 6px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
  line-height: 1.15;
  transition: transform 0.12s ease;
}

.tone b {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 19px;
  font-weight: 800;
  white-space: nowrap;
}

.tone b small {
  font-size: 11px;
  font-weight: 700;
  opacity: 0.75;
}

.tone > small {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

/* 코드: 근음에서의 음정 (장3도 · 완전5도 …) */
.tone i {
  margin-top: 1px;
  color: var(--text-muted);
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
  white-space: nowrap;
}

/* E♯ = F 처럼 흔히 쓰는 이름 */
.tone em {
  color: var(--text-muted);
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
  white-space: nowrap;
}

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

.tone.is-root > small,
.tone.is-root i,
.tone.is-root em {
  color: inherit;
  opacity: 0.75;
}

/* 스케일에서 코드를 고르면 그 코드의 음만 밝게 */
.tones.has-focus .tone:not(.is-chord) {
  opacity: 0.4;
}

.tones.has-focus .tone.is-chord {
  box-shadow: 0 0 0 2px var(--accent);
}

/* 지금 소리가 나는 음 (스케일 듣기 · 지판을 누르고 있을 때) */
.tone.is-playing,
.tone.is-held {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
  transform: translateY(-3px);
}

.steps {
  gap: 6px;
}

.step {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

/* 반음과 온음 반은 스케일의 색깔을 정하는 곳이라 눈에 띄게 */
.step--1 {
  color: var(--accent-text);
}

.step--3 {
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border);
}

/* ---------- 스케일 안의 코드 ---------- */

.diatonic__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 12px;
  margin: 18px 0 8px;
}

.diatonic__head .scale__label {
  margin: 0;
}

.segmented--sm span {
  padding: 3px 10px;
  font-size: 13px;
}

.diatonic {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dchord {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 52px;
  padding: 5px 9px 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  line-height: 1.2;
  cursor: pointer;
}

.dchord small {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.dchord b {
  font-size: 15px;
  font-weight: 800;
  white-space: nowrap;
}

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

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

.dchord[aria-pressed='true'] small {
  color: inherit;
  opacity: 0.75;
}

.diatonic__note {
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 14px;
}

.diatonic__note b {
  color: var(--text);
}

/* 글자처럼 보이는 버튼 */
.link {
  margin-left: 8px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-text);
  font-size: 14px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.relatives {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.relative {
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

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

/* ---------- 지판 ---------- */

.board__tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 0 16px 14px;
}

.board__tools-label {
  margin: 0;
}

/* 스케일 음은 모두 밝게, 근음은 주황색. 스케일에 없는 음은 감추되 눌러 볼 수는 있다. */
.cell.is-scale {
  --note-bg: #f7f1e3;
  --note-fg: #2b1b10;
}

.cell.is-root {
  --note-bg: var(--accent);
  --note-fg: var(--on-accent);
}

.cell.is-root .note {
  box-shadow: 0 0 10px rgba(249, 115, 22, 0.55), 0 1px 3px rgba(0, 0, 0, 0.45);
}

.cell.is-out .note {
  visibility: hidden;
}

/* 스케일에서 고른 코드: 코드에 없는 스케일 음은 흐리게 */
.fretboard.has-focus .cell.is-scale:not(.is-chord) .note {
  opacity: 0.3;
}

/* 스케일 듣기: 지금 짚는 자리 */
.cell.is-playing .note {
  transform: scale(1.25);
  box-shadow: 0 0 0 3px #fff, 0 0 16px 4px rgba(249, 115, 22, 0.75);
}

.legend__swatch .is-root {
  background: var(--accent);
}

.legend__swatch .is-scale {
  background: #f7f1e3;
}

.legend__swatch .is-other {
  background: #f7f1e3;
  opacity: 0.3;
}

/* ---------- 작은 화면 ---------- */

@media (max-width: 640px) {
  .roots {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .picker__type .select {
    max-width: none;
  }

  .dchord {
    min-width: 0;
    flex: 1 0 calc(25% - 6px);
  }

  .scale__title {
    font-size: 22px;
  }

  .scale__play {
    width: 100%;
  }

  .scale__listen {
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
    justify-items: stretch;
  }

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

  .tones {
    gap: 6px;
  }

  .tone {
    min-width: 46px;
    padding: 7px 6px 5px;
  }

  .tone b {
    font-size: 17px;
  }
}
