/* Pitch Quantizer — one-octave pitch-class keyboard face */

/* Every length is a container unit so the face scales exactly with its box
   (canvas tiles, embeds). Values equal the old px at the zoom-1 face:
   face container 264px (1px = 0.378789cqi), keyboard container 248px content
   (1px = 0.403227cqi). The face is only the size container; the plate inside
   carries what used to be the face's padding, border and background (an
   element's own lengths cannot use its own container units). */
.node-pitch-quantizer-face {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  container-type: inline-size;
  box-sizing: border-box;
}

.node-pitch-quantizer-plate {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 2.272728cqi;
  overflow: hidden;
  border: 0.378789cqi solid rgba(243, 241, 236, 0.12);
  border-radius: 2.272728cqi;
  background:
    linear-gradient(180deg, rgba(127, 199, 217, 0.08), transparent 42%),
    #080a0c;
  box-sizing: border-box;
}

/* Scale jack driving the mask (e.g. Chord Pad) — keyboard is display-only. */
.node-pitch-quantizer-face.scale-jacked > .node-pitch-quantizer-plate {
  border-color: rgba(242, 93, 93, 0.45);
}

.node-pitch-quantizer-face.scale-jacked .node-pitch-quantizer-key {
  cursor: default;
  opacity: 0.95;
}

.node-pitch-quantizer-keyboard {
  position: relative;
  container-type: inline-size;
  width: 100%;
  height: 100%;
  min-height: 27.272728cqi;
  overflow: hidden;
  border: 0.378789cqi solid rgba(243, 241, 236, 0.14);
  border-radius: 1.89394cqi;
  background: #050607;
}

.node-pitch-quantizer-white-row {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  align-items: stretch;
  min-width: 0;
}

.node-pitch-quantizer-key {
  box-sizing: border-box;
  margin: 0;
  min-width: 0;
  border: 0;
  cursor: var(--node-dot-cursor);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  user-select: none;
  touch-action: manipulation;
}

.node-pitch-quantizer-key-white {
  position: relative;
  z-index: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 100%;
  padding: 0 0.403227cqi 2.419356cqi;
  border-right: 0.403227cqi solid rgba(5, 6, 7, 0.72);
  color: rgba(5, 6, 7, 0.78);
  /* Pure container units: scales with the face (canvas tiles, embeds). The old
     clamp(0.5rem, 6cqi, 0.78rem) hit its 0.78rem cap on the 250px zoom-1
     keyboard, so a bigger tile kept 12.48px text. 12.48 / 248 (content box). */
  font-size: 5.032cqi;
  background: linear-gradient(180deg, #f7f2e8 0%, #cfc7b8 72%, #a79f93 100%);
}

.node-pitch-quantizer-key-white:last-child {
  border-right: 0;
}

.node-pitch-quantizer-key-white.active {
  color: #fff4f2;
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 210, 205, 0.9), transparent 30%),
    linear-gradient(180deg, #ff8a7a 0%, #e23b3b 74%, #7a1010 100%);
  box-shadow:
    inset 0 0 0 0.403227cqi rgba(255, 210, 205, 0.75),
    inset 0 0 6.451614cqi rgba(226, 59, 59, 0.4);
  text-shadow: 0 0 2.419356cqi rgba(255, 244, 242, 0.8);
}

.node-pitch-quantizer-black-row {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.node-pitch-quantizer-key-black {
  position: absolute;
  top: 0;
  left: var(--key-left, 0%);
  z-index: 2;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 58%;
  padding: 0 0.403227cqi 2.01613cqi;
  border: 0.403227cqi solid rgba(127, 199, 217, 0.22);
  border-radius: 0 0 1.612904cqi 1.612904cqi;
  color: rgba(243, 241, 236, 0.88);
  /* Was clamp(0.4rem, 4cqi, 0.62rem), capped at 9.92px on the 250px keyboard. */
  font-size: 4cqi;
  background: linear-gradient(180deg, #2a3036 0%, #0a0c0f 100%);
  box-shadow: 0 2.419356cqi 5.645162cqi rgba(0, 0, 0, 0.45);
  pointer-events: auto;
}

.node-pitch-quantizer-key-black.active {
  border-color: rgba(255, 140, 130, 0.9);
  color: #fff4f2;
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 160, 150, 0.65), transparent 32%),
    linear-gradient(180deg, #c42828 0%, #3a0808 100%);
  box-shadow:
    inset 0 0 0 0.403227cqi rgba(255, 190, 180, 0.7),
    0 0 5.645162cqi rgba(242, 93, 93, 0.55);
  text-shadow: 0 0 2.419356cqi rgba(255, 244, 242, 0.75);
}

.node-pitch-quantizer-key:focus-visible {
  outline: 0.806453cqi solid rgba(127, 199, 217, 0.85);
  outline-offset: -0.806453cqi;
}
.node-pitch-quantizer-key-black:focus-visible {
  z-index: 3;
}

/* Fallback stack before apply writes --node-module-stack-rows.
   LayoutA: header | io | face | params | lip */
.dsp-node.pitch-quantizer-layout:not(.module-stack) {
  grid-template-rows:
    var(--node-header-height)
    minmax(var(--node-io-section-min-height), auto)
    var(--node-module-scope-height)
    auto
    var(--node-module-bottom-gap-track, minmax(2px, 1fr));
}

.dsp-node.pitch-quantizer-layout:not(.module-stack) > .dsp-node-io-section {
  grid-row: 2;
}

.dsp-node.pitch-quantizer-layout > .node-pitch-quantizer-face {
  align-self: stretch;
  width: 100%;
  height: 100%;
  min-height: 0;
  pointer-events: auto;
}

.dsp-node.pitch-quantizer-layout:not(.module-stack) > .node-pitch-quantizer-face {
  grid-row: 3;
}
