/* --------------------------------------------------------------------------
   Tuning Fork (left of the pinned piano)
   -------------------------------------------------------------------------- */

.board-tuning-fork {
  position: absolute;
  bottom: 20px;
  right: 246px;
  z-index: 25;
  height: 94px;
  pointer-events: auto;
  user-select: none;
  cursor: grab;
  touch-action: none;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.15));
}

.board-tuning-fork.is-hidden,
.board-pinned-piano.is-hidden {
  display: none !important;
}

.board-tuning-fork img {
  display: block;
  height: 100%;
  width: auto;
  pointer-events: none;
}

.board-tuning-fork.is-dragging {
  cursor: grabbing;
  z-index: 50;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.35));
}

/* Same dark shadow on both themes */
[data-theme="dark"] .board-tuning-fork {
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.15));
}

[data-theme="dark"] .board-tuning-fork.is-dragging {
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.35));
}

/* Mechanical Metronome Widget */
.board-metronome {
  position: absolute;
  bottom: 20px;
  right: 322px;
  z-index: 25;
  width: 86px;
  height: 104px;
  pointer-events: auto;
  user-select: none;
  cursor: default;
  touch-action: none;
  transition: opacity 0.25s ease, filter 0.25s ease;
}

.board-metronome.is-hidden {
  display: none !important;
}

.board-metronome:hover {
  cursor: ns-resize;
}

/* Shadow lives on the visual wrapper so the "beats" text stays shadow-free */
.metronome-visual {
  position: absolute;
  inset: 0;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.35));
}

.board-metronome.is-widget-dragging {
  z-index: 50;
}

.board-metronome.is-widget-dragging .metronome-visual {
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.45));
}

.board-metronome.is-tempo-dragging .metronome-body,
.board-metronome.is-tempo-dragging .metronome-rod {
  cursor: ns-resize;
}

.board-metronome.is-widget-dragging .metronome-base {
  cursor: grabbing;
}

/* Orange hint ring around the pendulum weight when hovering the BPM slider area */
.board-metronome.is-tempo-hover .metronome-weight,
.board-metronome.is-tempo-dragging .metronome-weight {
  outline: 1.5px solid #ea580c;
  outline-offset: 0.5px;
}

.board-metronome.is-running .metronome-body {
  box-shadow: 0 0 12px rgba(214, 186, 138, 0.22);
}

.metronome-body {
  position: absolute;
  left: 0;
  right: 0;
  top: 10px;
  bottom: 16px;
  background: linear-gradient(105deg, #57504a 0%, #322c27 38%, #1a1714 100%);
  /* Truncated pyramid: small flat top, wide flat bottom (like a real metronome) */
  clip-path: polygon(38% 0%, 62% 0%, 88% 100%, 12% 100%);
  border-radius: 3px 3px 0 0;
  transition: box-shadow 0.25s ease;
}

.metronome-base {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 16px;
  background: linear-gradient(180deg, #8a6134 0%, #5d4023 55%, #3f2b17 100%);
  /* Sides continue the upper trapezoid's slope */
  clip-path: polygon(12% 0, 88% 0, 93.3% 100%, 6.7% 100%);
  border-radius: 0 0 4px 4px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
  cursor: grab;
}

.metronome-beats {
  position: absolute;
  top: calc(100% + 3px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  padding: 2px 5px;
  border-radius: 4px;
  border: none;
  background: none;
  box-shadow: none;
  color: var(--graphite-dark);
  font-family: var(--font-main);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease;
}

.metronome-beats:hover {
  background: rgba(234, 88, 12, 0.12);
}

.metronome-face {
  position: absolute;
  left: 50%;
  top: 7px;
  bottom: 8px;
  width: 42px;
  transform: translateX(-50%);
  background: #0d0b09;
  clip-path: polygon(40% 0%, 60% 0%, 84% 100%, 16% 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  overflow: hidden;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.8);
}

.metronome-scale {
  position: absolute;
  left: 50%;
  top: 8px;
  bottom: 16px;
  width: 14px;
  transform: translateX(-50%);
  background: repeating-linear-gradient(
    180deg,
    rgba(222, 196, 148, 0.85) 0,
    rgba(222, 196, 148, 0.85) 1px,
    transparent 1px,
    transparent 4px
  );
  opacity: 0.75;
}

.metronome-bpm {
  position: relative;
  z-index: 2;
  font-family: var(--font-mono);
  font-size: 0.5rem;
  font-weight: 700;
  line-height: 1;
  color: #d8c39a;
  margin-bottom: 4px;
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.9);
}

.metronome-rod {
  position: absolute;
  left: 50%;
  bottom: 18px;
  width: 3.5px;
  height: 68px;
  margin-left: -1.75px;
  background: linear-gradient(90deg, #79766f 0%, #f4f2ee 45%, #8f8c86 100%);
  border-radius: 2px;
  transform-origin: 50% 100%;
  will-change: transform;
  z-index: 4;
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.45);
}

.metronome-rod.is-parking {
  transition: transform 0.25s cubic-bezier(0.33, 0, 0.2, 1);
}

.metronome-rod-tip {
  position: absolute;
  left: 50%;
  top: -3px;
  width: 7px;
  height: 7px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fdfcf9, #7e7b74 75%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.metronome-weight {
  position: absolute;
  left: 50%;
  top: 20%;
  width: 11px;
  height: 14px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, #8a6c3f 0%, #f0dba9 50%, #75592f 100%);
  border-radius: 3px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

/* Close button: dismisses metronome from board (top-right corner) */
.metronome-close {
  position: absolute;
  top: -4px;
  right: -2px;
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f4efe4;
  color: #79716b;
  border: 1px solid rgba(0, 0, 0, 0.22);
  cursor: pointer;
  z-index: 7;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
  transition: opacity 0.15s ease, transform 0.12s ease, color 0.15s ease, background 0.15s ease;
}

.board-metronome:hover .metronome-close,
.board-pinned-piano:hover .synth-close {
  opacity: 1;
  pointer-events: auto;
}

.metronome-close:hover {
  transform: scale(1.14);
  color: #a3352c;
  background: #fff;
}

[data-theme="dark"] .metronome-close {
  background: #2b2621;
  color: #a8a29e;
  border-color: rgba(255, 255, 255, 0.22);
}

[data-theme="dark"] .metronome-close:hover {
  color: #e0836f;
  background: #38312a;
}

@media (max-width: 820px) {
  .latency-label-prefix,
  .align-btn-label,
  .tools-btn-label,
  .voicings-btn-label {
    display: none !important;
  }

  .board-pinned-piano {
    top: auto;
    bottom: 64px;
    right: 10px;
    left: auto;
    max-width: calc(100vw - 20px);
  }

  .board-tuning-fork {
    top: auto;
    bottom: 64px;
    right: 228px;
    left: auto;
    height: 80px;
  }

  .board-metronome {
    top: auto;
    bottom: 184px;
    right: 10px;
    left: auto;
    transform-origin: bottom right;
    transform: scale(0.9);
  }
}

@media (max-width: 400px) {
  .board-pinned-piano {
    transform-origin: bottom right;
    transform: scale(0.92);
  }

  .board-tuning-fork {
    right: 206px;
    height: 72px;
  }
}
