/* 베이스 지판 (페이지 공용) — js/board.js 가 그리는 지판의 모양 */

.board {
  --label-w: 48px;
  --open-w: 56px;
  --fret-min: 40px;
  --row-h: 46px;
  --num-h: 30px;
  --badge: 32px;

  padding: 18px 0 16px;
  overflow: hidden;
}

.board__scroll {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding: 2px 16px 4px 0;
  /* 방향키로 움직일 때 고정된 줄 이름 칸 밑으로 숨지 않게 */
  scroll-padding-left: var(--label-w);
}

.fretboard {
  display: grid;
  width: 100%;
  min-width: calc(var(--label-w) + var(--open-w) + var(--frets, 20) * var(--fret-min));
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none; /* 길게 눌러도 메뉴가 뜨지 않게 */
}

/* 지판(나무) — 개방현 칸부터 끝까지 */
.neck {
  position: relative;
  grid-column: 2 / -1;
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 25%, transparent 70%, rgba(0, 0, 0, 0.28)),
    repeating-linear-gradient(180deg, rgba(0, 0, 0, 0.07) 0 1px, transparent 1px 5px),
    linear-gradient(90deg, #3e2618, #573826 45%, #4a2f1f);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.22);
}

/* 너트 왼쪽(개방현 자리)은 조금 어둡게 */
.neck::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--open-w);
  border-radius: 6px 0 0 6px;
  background: rgba(0, 0, 0, 0.3);
}

.nut {
  z-index: 2;
  grid-column: 2;
  justify-self: end;
  width: 8px;
  margin-right: -4px;
  border-radius: 2px;
  background: linear-gradient(90deg, #cfc4ae, #fbf6ea 50%, #d8ccb6);
  box-shadow: 1px 0 4px rgba(0, 0, 0, 0.45);
}

.fret-wire {
  z-index: 2;
  justify-self: end;
  width: 4px;
  margin-right: -2px;
  background: linear-gradient(90deg, #7d838b, #eef1f4 45%, #9aa0a8);
  box-shadow: 1px 0 2px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.inlay {
  position: relative;
  z-index: 1;
  pointer-events: none;
}

.inlay i {
  position: absolute;
  left: 50%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fffdf6, #e2d9c8 55%, #b9ad98);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
  transform: translate(-50%, -50%);
}

/* 한 칸 = 한 줄의 한 프렛 */
.cell {
  position: relative;
  z-index: 3;
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* 줄 */
.cell::before {
  content: '';
  position: absolute;
  top: 50%;
  right: 0;
  left: 0;
  height: var(--string-w, 2px);
  background: linear-gradient(180deg, #f4f4f2, #b8bcc2 55%, #6f747b);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  transform: translateY(-50%);
  pointer-events: none;
}

.cell:focus-visible {
  outline: none;
}

.cell.is-natural {
  --note-bg: #f7f1e3;
  --note-fg: #2b1b10;
}

.cell.is-accidental {
  --note-bg: #211812;
  --note-fg: #e9dfd0;
}

.note {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: var(--badge);
  height: var(--badge);
  padding: 0 6px;
  border-radius: 999px;
  background: var(--note-bg);
  color: var(--note-fg);
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  /* 크기만 부드럽게 바꾼다. 투명도·색·그림자까지 바꾸면 음을 누를 때마다 지판의 음 수십 개를
     여러 번 다시 그려서 휴대폰에서 느려진다 (색은 바로 바뀌어도 자연스럽다). */
  transition: transform 0.12s ease;
}

.note--both {
  gap: 2px;
}

.note--both small {
  font-size: 9.5px;
  font-weight: 700;
  opacity: 0.8;
}

.cell.is-accidental .note {
  font-size: 12px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.22), 0 1px 3px rgba(0, 0, 0, 0.45);
}

@media (hover: hover) {
  .cell:hover .note {
    transform: scale(1.1);
  }
}

.cell:focus-visible .note {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

/* 누르고 있는 동안: 그 줄이 떨리고, 누른 음이 은은하게 빛난다 */
.cell.is-ringing::before {
  animation: string-ring 0.08s linear infinite;
}

/* 빛은 따로 겹친 층의 투명도만 바꾼다 (그림자를 매번 다시 그리지 않게) */
.cell.is-held .note::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 0 3px #fff, 0 0 24px 8px rgba(249, 115, 22, 0.85);
  opacity: 0;
  animation: note-held 1s ease-in-out infinite;
  pointer-events: none;
}

@keyframes string-ring {
  50% {
    transform: translateY(calc(-50% + 1px));
  }
}

@keyframes note-held {
  50% {
    opacity: 1;
  }
}

/* 음이름을 감춘 지판 (퀴즈 등). 어떤 칸을 다시 보여 줄지는 페이지가 정한다. */
.fretboard.names-hidden .note {
  visibility: hidden;
}

/* 왼쪽 줄 이름 — 가로로 스크롤해도 보이도록 고정 */
.string-label,
.fret-corner {
  position: sticky;
  left: 0;
  z-index: 5;
  grid-column: 1;
  background: var(--surface);
}

.string-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 15px;
  font-weight: 800;
}

.string-label__no {
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 800;
}

.string-label.is-current,
.string-label.is-current .string-label__no {
  color: var(--accent);
}

.fret-num {
  display: grid;
  place-items: center;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.fret-num.is-marker {
  color: var(--text);
  font-weight: 800;
}

.fret-num.is-current {
  color: var(--accent);
  font-weight: 800;
}

/* ---------- 범례 / 안내 ---------- */

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 14px 16px 0;
  padding: 0;
  color: var(--text-muted);
  font-size: 13px;
  list-style: none;
}

.legend li {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend__swatch {
  display: grid;
  place-items: center;
  width: 26px;
  height: 22px;
  border-radius: 5px;
  background: #4a2f1f;
}

.legend__swatch i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

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

.legend__swatch .is-accidental {
  background: #211812;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.3);
}

.hint {
  margin: 10px 16px 0;
  color: var(--text-muted);
  font-size: 13px;
}

/* 터치 화면에서는 키보드 안내를 숨긴다 */
@media (hover: none) {
  .hint__keys {
    display: none;
  }
}

@media (max-width: 640px) {
  .board {
    --label-w: 40px;
    --open-w: 48px;
    --fret-min: 38px;
    --row-h: 42px;
    --badge: 29px;
  }
}
