/*
 * JamJar — Chords instrument. All rules scoped under .jj-inst-chords.
 * Yellow is the hero fill; text and outlines stay ink.
 */

.jj-inst-chords {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

/* ---------- top row: REC toggle, Clear, key readout ---------- */

.jj-inst-chords .chords-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.jj-inst-chords .chords-rec,
.jj-inst-chords .chords-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 2.625rem;
  min-width: 4.75rem;
  padding: 0.3rem 0.85rem;
  border-radius: var(--toy-radius-pill);
  font-family: var(--toy-font-body);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.jj-inst-chords .chords-rec .dot {
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 50%;
  border: 2px solid var(--toy-ink);
  background: var(--toy-panel);
}

/* REC on = latched-in yellow with a filled dot (shape + depth, not hue alone). */
.jj-inst-chords .chords-rec[aria-pressed="true"] {
  background: var(--toy-yellow-fill);
  box-shadow: var(--toy-shadow-pressed);
  transform: translateY(2px);
}

.jj-inst-chords .chords-rec[aria-pressed="true"] .dot {
  background: var(--toy-ink);
}

/* Clear armed = red fill + "Sure?" label. */
.jj-inst-chords .chords-clear.armed {
  background: var(--toy-red);
}

.jj-inst-chords .chords-key {
  margin-left: auto;
  min-width: 0;
  text-align: right;
  font-family: var(--toy-font-body);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.25;
  color: var(--toy-text);
}

/* ---------- the six chord pads ---------- */

.jj-inst-chords .chords-pads {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: repeat(3, minmax(88px, 1fr));
  gap: 10px;
  touch-action: none;
}

.jj-inst-chords .chords-pad {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px;
  border-radius: var(--toy-radius-lg);
}

/* Progressive hold feedback: yellow rises from the bottom over the 350ms hold. */
.jj-inst-chords .chords-pad .swell {
  position: absolute;
  inset: 0;
  background: var(--toy-yellow-fill);
  transform: scaleY(0);
  transform-origin: 50% 100%;
  transition: transform 120ms var(--toy-ease-out);
  pointer-events: none;
}

.jj-inst-chords .chords-pad.holding .swell {
  transform: scaleY(1);
  transition: transform 350ms linear;
}

.jj-inst-chords .chords-pad.held {
  background: var(--toy-yellow-fill);
}

.jj-inst-chords .chords-pad .numeral {
  position: relative;
  font-size: clamp(2.1rem, 10vw, 2.7rem);
  line-height: 1;
  color: var(--toy-ink);
}

.jj-inst-chords .chords-pad .root {
  position: relative;
  font-family: var(--toy-font-body);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--toy-text);
}

/* With reduced motion the global rule kills the transition, so gate the fill
   to the confirmed .held state instead of snapping full at pointerdown. */
@media (prefers-reduced-motion: reduce) {
  .jj-inst-chords .chords-pad.holding:not(.held) .swell {
    transform: scaleY(0);
  }
}

/* ---------- loop strip: 16 slots, 8 per row ---------- */

.jj-inst-chords .chords-strip {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
}

.jj-inst-chords .chords-slot {
  appearance: none;
  margin: 0;
  padding: 2px 0 0;
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--toy-panel);
  border: 2px solid var(--toy-ink);
  border-radius: 0.5rem;
  color: var(--toy-ink);
  font-family: var(--toy-font-display);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
  opacity: 0.45;
  cursor: default;
  -webkit-tap-highlight-color: transparent;
  transition:
    background var(--toy-duration-state),
    box-shadow var(--toy-duration-fast),
    transform var(--toy-duration-fast);
}

/* Beat starts (1, 5, 9, 13) read a little stronger, like the shell LEDs. */
.jj-inst-chords .chords-slot:nth-child(4n + 1) {
  opacity: 0.7;
}

.jj-inst-chords .chords-slot.filled {
  opacity: 1;
  background: var(--toy-yellow-fill);
  box-shadow: 0 2px 0 var(--toy-ink);
  cursor: pointer;
}

.jj-inst-chords .chords-slot.filled:active {
  box-shadow: 0 1px 0 var(--toy-ink);
  transform: translateY(1px);
}

/* Playhead: the current slot lifts on its hard shadow. */
.jj-inst-chords .chords-slot.now {
  opacity: 1;
  transform: translateY(-2px);
  box-shadow: 0 3px 0 var(--toy-ink);
}

/* Sustained chords (len 8) carry an ink underline beneath the numeral. */
.jj-inst-chords .chords-slot .deg {
  padding: 0 3px 1px;
  border-bottom: 3px solid transparent;
}

.jj-inst-chords .chords-slot.long .deg {
  border-bottom-color: var(--toy-ink);
}

/* More than one chord stacked on a step: a small ink corner dot. */
.jj-inst-chords .chords-slot.multi {
  position: relative;
}

.jj-inst-chords .chords-slot.multi::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--toy-ink);
}
