/* The harmonic grid itself. */

.grid-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 8px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.012), transparent 40%), var(--panel);
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow-1);
  overscroll-behavior: contain;
}

.grid {
  display: grid;
  grid-template-columns: 58px repeat(var(--steps, 16), minmax(30px, 1fr));
  grid-template-rows: 20px repeat(var(--rows, 12), minmax(30px, 1fr));
  gap: 4px;
  min-height: 100%;
  min-width: 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.grid-corner {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 800;
}

.step-head {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 9px;
  color: var(--dim);
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}

.step-head.beat {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.025);
}

.step-head.is-playing {
  color: #1a1206;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(255, 157, 46, 0.45);
}

.row-label {
  position: sticky;
  left: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 0 7px;
  border-radius: 6px;
  background: #141821;
  border: 1px solid transparent;
  overflow: hidden;
}

.row-note {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-2);
  white-space: nowrap;
}

.row-deg {
  font-size: 8px;
  color: var(--dim);
  font-weight: 700;
  white-space: nowrap;
}

.row-label.root {
  background: #1e1a15;
  border-color: rgba(255, 157, 46, 0.12);
}

.row-label.root .row-note {
  color: var(--accent-hi);
}

.cell {
  position: relative;
  border-radius: 7px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.012));
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
  touch-action: none;
  transition: background var(--fast) var(--ease), box-shadow var(--fast) var(--ease),
    border-color var(--fast) var(--ease), transform 60ms var(--ease);
}

.cell.beat {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
}

.cell.root {
  border-color: rgba(255, 157, 46, 0.13);
}

.cell:hover {
  border-color: rgba(255, 255, 255, 0.16);
}

.cell.on {
  background: linear-gradient(180deg, #ffc46b, #ff8a1f);
  border-color: rgba(255, 196, 107, 0.75);
  box-shadow:
    0 0 0 1px rgba(255, 157, 46, 0.35),
    0 0 16px rgba(255, 157, 46, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.cell.on::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(60% 60% at 50% 28%, rgba(255, 255, 255, 0.55), transparent 70%);
  opacity: 0.45;
  pointer-events: none;
}

.cell.is-playing {
  box-shadow: inset 0 0 0 1px rgba(58, 210, 255, 0.45);
}

.cell.on.is-playing {
  box-shadow:
    0 0 0 1px rgba(58, 210, 255, 0.6),
    0 0 22px rgba(255, 157, 46, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.cell.flash {
  animation: cell-flash 200ms var(--ease);
}

@keyframes cell-flash {
  0% {
    transform: scale(0.94);
    filter: brightness(1.5);
  }
  100% {
    transform: scale(1);
    filter: brightness(1);
  }
}

/* Live mode gets a different cursor affordance. */
.grid.is-live .cell {
  cursor: pointer;
}

.grid.is-live .cell:hover {
  background: linear-gradient(180deg, rgba(58, 210, 255, 0.16), rgba(58, 210, 255, 0.05));
  border-color: rgba(58, 210, 255, 0.35);
}

@media (max-width: 860px) {
  .grid {
    grid-template-columns: 48px repeat(var(--steps, 16), minmax(26px, 1fr));
    grid-template-rows: 18px repeat(var(--rows, 12), minmax(28px, 1fr));
    gap: 3px;
  }

  .row-label {
    padding: 0 5px;
  }

  .row-deg {
    display: none;
  }

  .grid-scroll {
    padding: 6px;
  }
}

/* ------------------------------------------------------- playable pad grid */

.play-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: flex;
  padding: 8px;
  border-radius: var(--radius);
  background:
    radial-gradient(620px 320px at 50% 50%, rgba(255, 157, 46, 0.055), transparent 70%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.012), transparent 40%),
    var(--panel);
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow-1);
  overscroll-behavior: contain;
}

.play-stage {
  --cell-max: min(96px, calc((100dvh - 300px) / var(--rows, 4)));
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: calc(var(--cols, 7) * var(--cell-max) + (var(--cols, 7) - 1) * 6px);
  margin: auto;
}

.play-readout {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px;
  min-height: 44px;
}

.readout-note {
  font-family: var(--mono);
  font-size: clamp(24px, 5.4vw, 40px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.01em;
  color: var(--text);
  transition: color 120ms var(--ease);
}

.readout-note.is-root {
  color: var(--accent-hi);
}

.readout-meta {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
  text-align: right;
  white-space: nowrap;
}

.play-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 7), minmax(0, 1fr));
  gap: 6px;
  width: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.play-cell {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015));
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  touch-action: none;
  transition: background var(--fast) var(--ease), box-shadow var(--fast) var(--ease),
    border-color var(--fast) var(--ease), transform 60ms var(--ease);
}

.play-cell .note {
  font-family: var(--mono);
  font-size: clamp(10px, 2.4vw, 18px);
  font-weight: 700;
  line-height: 1.1;
  color: var(--text-2);
}

.play-cell .deg {
  font-size: 8px;
  font-weight: 700;
  line-height: 1;
  color: var(--dim);
}

.play-cell.root {
  border-color: var(--accent-line);
  background: linear-gradient(180deg, rgba(255, 157, 46, 0.14), rgba(255, 157, 46, 0.035));
}

.play-cell.root .note {
  color: var(--accent-hi);
}

.play-cell:hover {
  border-color: rgba(255, 255, 255, 0.16);
}

.play-cell.is-down {
  background: linear-gradient(180deg, var(--accent-hi), var(--accent-lo));
  border-color: rgba(255, 196, 107, 0.8);
  box-shadow:
    0 0 0 1px rgba(255, 157, 46, 0.4),
    0 0 24px rgba(255, 157, 46, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transform: scale(0.97);
}

.play-cell.is-down .note,
.play-cell.is-down .deg {
  color: #1a1206;
}

@media (max-width: 860px) {
  .play-scroll {
    padding: 6px;
  }

  .play-stage {
    gap: 10px;
    max-width: calc(var(--cols, 7) * var(--cell-max) + (var(--cols, 7) - 1) * 5px);
  }

  .play-grid {
    gap: 5px;
  }

  .play-readout {
    min-height: 34px;
  }

  .play-cell {
    border-radius: 8px;
  }
}
