/* ==========================================================================
 * components/keyboard.css — 48 键可交互立式钢琴键盘（C2 – B5）
 *
 * 键位 DOM 由 js/modules/piano-keyboard.js 动态生成：
 *   .piano-keys > .white-key ×28  +  .black-key ×20（绝对定位，left 为百分比）
 * 高亮状态类 .key-active 由 js 在音符触发时短暂添加。
 *
 * 尺寸换算（务必保持成比例，否则黑键会歪）：
 *   白键宽 = 容器宽 / 28        → 黑键 left 的分母由 JS 写死为 28
 *   黑键宽 = 白键宽 × 0.65 ≈ 容器宽 × 2.33%
 *   min-width 880px = 28 × 31.4px，即音域从 21 键拓宽到 28 键前的单键宽度，
 *   保证桌面端琴键手感不变，窄屏则靠横向滚动查看全部音域。
 * ========================================================================== */

.piano-keyboard-wrap {
  margin-top: 1rem;
  background: #141A17;
  padding: 1.1rem 1rem 0.85rem;
  border-radius: 16px;
  box-shadow: inset 0 6px 16px rgba(0, 0, 0, 0.45);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  /* 滑到尽头时不要把整页一起带着横移 */
  overscroll-behavior-x: contain;
}
.piano-keyboard-hint {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.3rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: rgba(250, 247, 242, 0.55);
  margin-bottom: 0.65rem;
  padding: 0 0.25rem;
}
.piano-keys {
  position: relative;
  display: flex;
  height: 128px;
  min-width: 880px;
  user-select: none;
  -webkit-user-select: none;
  /*
    点按琴键要发声、横向拖动要翻页，二者共存：
    pan-x 把横向手势交给浏览器滚动，纵向与长按不接管；
    JS 侧靠 pointerdown 发声、pointercancel 复位，天然不冲突。
  */
  touch-action: pan-x;
}

/* 白键 */
.white-key {
  flex: 1;
  height: 128px;
  background: linear-gradient(180deg, #FBF9F5 0%, #EAE4D8 100%);
  border: 1px solid #C5BEB0;
  border-radius: 0 0 6px 6px;
  margin: 0 1px;
  position: relative;
  cursor: pointer;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 6px;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: #8C857B;
  transition: transform 0.08s ease, background 0.12s ease;
  transform-origin: top center;
}
.white-key:active,
.white-key.key-active {
  background: linear-gradient(180deg, #D8E6DC 0%, #94B49F 100%);
  color: var(--forest-deep);
  font-weight: 600;
  transform: translateY(3px) scaleY(0.98);
  box-shadow: 0 0 14px rgba(148, 180, 159, 0.6);
}

/* 黑键 */
.black-key {
  position: absolute;
  top: 0;
  width: 2.33%;
  height: 62%;
  background: linear-gradient(180deg, #2B2E2C 0%, #121413 100%);
  border: 1px solid #000;
  border-radius: 0 0 5px 5px;
  z-index: 5;
  cursor: pointer;
  transform: translateX(-50%);
  transition: transform 0.08s ease, background 0.12s ease;
  box-shadow: 0 4px 8px rgba(0,0,0,0.4);
}
.black-key:active,
.black-key.key-active {
  background: linear-gradient(180deg, #D97F64 0%, #B85D43 100%);
  transform: translateX(-50%) translateY(2px);
  box-shadow: 0 0 12px rgba(184, 93, 67, 0.7);
}

/* ---------- 手机：压低琴键高度，缩短最小宽度，减少横向滚动距离 ---------- */
@media (max-width: 640px) {
  .piano-keyboard-wrap {
    padding: 0.85rem 0.7rem 0.6rem;
    border-radius: 12px;
  }
  .piano-keyboard-hint {
    font-size: 0.62rem;
    line-height: 1.5;
  }
  .piano-keys {
    height: 104px;
    min-width: 780px;
  }
  .white-key {
    height: 104px;
    font-size: 0.56rem;
    padding-bottom: 4px;
  }
  .black-key {
    height: 60%;
  }
}
