/* The on-screen piano along the bottom of the studio (keyboard.js). */

.keyboard {
  display: flex;
  height: 64px;
  border-top: 1px solid var(--line-2);
  background: linear-gradient(180deg, #141117, #0b0a0d);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.4);
  position: relative;
  z-index: 2;
}
/* The strip holds the computer keys (Alt+K): a gold edge says so. */
.keyboard.holding {
  border-top-color: var(--gold);
  box-shadow:
    0 -8px 24px rgba(0, 0, 0, 0.4),
    inset 0 2px 0 rgba(212, 175, 55, 0.55),
    0 -2px 14px rgba(212, 175, 55, 0.25);
}
/* The phrase played and not typed yet: over the keys' top right corner. */
.kb-phrase {
  position: absolute;
  right: 12px;
  bottom: calc(100% + 8px);
  max-width: min(60%, 640px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 5px 10px;
  border: 1px solid var(--gold);
  border-radius: 8px;
  background: rgba(11, 10, 13, 0.92);
  font: 500 12px/1.2 var(--mono);
  color: var(--champagne);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}
.kb-head {
  flex: none;
  width: 212px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding: 0 12px;
  border-right: 1px solid var(--line);
}
.kb-ch {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}
.kb-label {
  font-size: 9.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--dim);
}
.kb-ch b {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: italic 600 15px/1.1 var(--serif);
  color: var(--champagne);
  border-bottom: 2px solid var(--c, transparent);
}
/* What the keys play (keyboard.js targetView): it flashes in when it changes. */
.kb-target {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  animation: kb-target-in 0.9s ease-out;
}
@keyframes kb-target-in {
  0% {
    filter: brightness(2.2);
    transform: translateX(-4px);
  }
  100% {
    filter: none;
    transform: none;
  }
}
.kb-target.trying .kb-label {
  color: var(--gold-hi);
}
.kb-target.trying .kb-ch b {
  border-bottom-style: dashed;
}
.kb-detail {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
  color: var(--muted);
}
.kb-mini {
  flex: none;
  display: grid;
  place-items: center;
  width: 18px;
  height: 16px;
  padding: 0;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--ob-0);
  color: var(--gold);
  align-self: center;
}
.kb-mini:first-of-type {
  margin-left: auto;
}
.kb-mini .glyph {
  width: 11px;
  height: 11px;
}
.kb-mini:hover {
  color: var(--gold-hi);
  border-color: var(--line-3);
}
/* Phone: the name on the keys. */
.kb-tag {
  position: absolute;
  z-index: 2;
  top: 3px;
  right: 4px;
  max-width: 60%;
  padding: 1px 6px;
  border-radius: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: 600 10px/1.4 var(--sans);
  color: var(--champagne);
  background: rgba(12, 10, 14, 0.82);
  border-left: 3px solid var(--c, var(--gold));
  pointer-events: none;
  animation: kb-target-in 0.9s ease-out;
}
.kb-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.kb-oct,
.kb-tools {
  display: flex;
  align-items: center;
  gap: 4px;
}
.kb-octave {
  min-width: 30px;
  text-align: center;
  font: 600 11px/1 var(--mono);
  color: var(--gold-hi);
}
.kb-shift {
  display: grid;
  place-items: center;
  width: 26px;
  height: 22px;
  padding: 0;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--ob-0);
  color: var(--gold);
}
.kb-shift .glyph {
  width: 14px;
  height: 14px;
}
.kb-shift:hover {
  color: var(--gold-hi);
  border-color: var(--line-3);
}
.kb-rec {
  color: var(--rose);
}
.kb-type.on {
  color: var(--ob-0);
  background: var(--gold);
  border-color: var(--gold-hi);
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.45);
}
.kb-type.on:hover {
  color: var(--ob-0);
  background: var(--gold-hi);
}
.kb-rec.armed {
  color: #fff;
  background: radial-gradient(circle at 50% 40%, #e2717f, #8e2336);
  border-color: rgba(255, 170, 180, 0.7);
  box-shadow: 0 0 12px rgba(224, 112, 126, 0.6);
  animation: pulse 1.2s ease-in-out infinite;
}

/* The keys: laid out in pixels by keyboard.js, so no padding here. */
.kb-keys {
  position: relative;
  flex: 1;
  min-width: 0;
  margin: 5px 8px 6px 6px;
  overflow: hidden;
  touch-action: none;
  cursor: pointer;
  border-radius: 3px 3px 6px 6px;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.7),
    0 -1px 0 var(--line-3);
}
.kb-white {
  position: absolute;
  top: 0;
  bottom: 0;
  border-right: 1px solid rgba(40, 32, 20, 0.55);
  border-radius: 0 0 5px 5px;
  background: linear-gradient(180deg, #d9cfba 0%, #f4ecdc 18%, #fbf5e8 78%, #d7cbb1 100%);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.12);
}
.kb-white span {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 4px;
  text-align: center;
  font: 600 8.5px/1 var(--mono);
  color: #8a7a5a;
  pointer-events: none;
}
/* The computer key that plays a key (keyboard.js). */
.kb-typed {
  position: absolute;
  left: 0;
  right: 0;
  font: 600 8px/1 var(--mono);
  font-style: normal;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  pointer-events: none;
}
.kb-white .kb-typed {
  bottom: 16px;
  color: #6f5a2e;
}
.kb-black .kb-typed {
  bottom: 4px;
  color: #b9a88a;
}
.kb-white.down {
  background: var(--metal);
  box-shadow:
    inset 0 2px 6px rgba(80, 50, 0, 0.45),
    0 0 14px rgba(212, 175, 55, 0.5);
}
.kb-white.down span {
  color: #3a2808;
}
/* A key the music plays (keyboard.js): pushed down as a real key is, not lit. It sinks into the keybed
 * (lower, its front lip shorter), its far end slides under the shadow of the fallboard and of the keys
 * beside it, and its face, tilted away from the light, darkens toward the back. --press (0..1) is how
 * hard it was struck. Keys go down fast and come up a touch slower, as felt and springs do. */
.kb-white,
.kb-black {
  transform-origin: 50% 0;
  transition:
    transform 0.11s ease-out,
    background 0.11s ease-out,
    box-shadow 0.11s ease-out;
}
.kb-white.played {
  transform: translateY(calc(var(--press) * 2px)) scaleY(calc(1 - var(--press) * 0.02));
  background: linear-gradient(180deg, #5f5547 0%, #9a8f7a calc(6% + var(--press) * 8%), #cfc5b0 calc(30% + var(--press) * 10%), #e6ddca 82%, #c9bb9e 100%);
  box-shadow:
    inset 0 calc(4px + var(--press) * 10px) calc(5px + var(--press) * 6px) calc(var(--press) * -3px) rgba(25, 16, 6, 0.62),
    inset 3px 0 4px -2px rgba(40, 28, 12, 0.5),
    inset -3px 0 4px -2px rgba(40, 28, 12, 0.5),
    inset 0 -1px 0 rgba(0, 0, 0, 0.18);
  transition-duration: 0.04s;
}
.kb-black.played {
  transform: translateY(calc(var(--press) * 2px)) scaleY(calc(1 - var(--press) * 0.05));
  background: linear-gradient(180deg, #030204 0%, #0e0c11 50%, #18151c 90%, #1e1a22 100%);
  box-shadow:
    0 1px 1px rgba(0, 0, 0, 0.75),
    inset 0 4px 5px rgba(0, 0, 0, 0.7),
    inset 0 -1px 0 rgba(255, 240, 200, 0.03);
  transition-duration: 0.04s;
}
.kb-black {
  position: absolute;
  top: 0;
  height: 60%;
  z-index: 1;
  border-radius: 0 0 4px 4px;
  border: 1px solid #000;
  border-top: none;
  background: linear-gradient(180deg, #16131a 0%, #2e2835 80%, #3a3342 100%);
  box-shadow:
    0 3px 5px rgba(0, 0, 0, 0.6),
    inset 0 -2px 0 rgba(255, 240, 200, 0.08);
}
.kb-black.down {
  background: linear-gradient(180deg, #5c1d2b, #9c4a57);
  box-shadow:
    0 0 12px rgba(208, 138, 147, 0.6),
    inset 0 -2px 0 rgba(255, 240, 200, 0.15);
}

/* Phone layout: taller keys, a slim octave column instead of the header. */
.keyboard.compact {
  height: 76px;
}
.keyboard.compact .kb-head {
  width: auto;
  padding: 0 4px;
  align-items: center;
}
.keyboard.compact .kb-row {
  gap: 4px;
}
.keyboard.compact .kb-oct {
  flex-direction: column-reverse;
  gap: 3px;
}
.keyboard.compact .kb-shift {
  width: 34px;
  height: 24px;
}
.keyboard.compact .kb-shift .glyph {
  transform: rotate(-90deg);
}
.keyboard.compact .kb-type .glyph {
  transform: none;
}
.keyboard.compact .kb-octave {
  min-width: 0;
  font-size: 10px;
}
@media (max-height: 479px) {
  .keyboard.compact {
    height: 56px;
  }
  .keyboard.compact .kb-oct {
    flex-direction: row;
  }
  .keyboard.compact .kb-head {
    width: auto;
    padding: 0 6px;
  }
  .keyboard.compact .kb-shift {
    width: 28px;
  }
  .keyboard.compact .kb-shift .glyph {
    transform: none;
  }
}
