/* pads.css — the pad grid and its states. */

/* pads.js writes the grid's pixel size from a ResizeObserver so it FILLS the
   container in both axes, only pulling back when a pad would get more elongated
   than `AR_MAX`. CSS alone cannot: on a grid, `aspect-ratio` + `max-height`
   clamps the height without recomputing the width, silently breaking the ratio.
   The `gap`/`padding` below are read back by fitGrid(), so they are the single
   source of truth for the grid's frame — change them here, not there. */
.pads {
  --cols: 4; --rows: 4;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows), minmax(0, 1fr));
  gap: 6px; padding: 5px; margin: auto;
  width: 100%; height: 100%; max-width: 100%; max-height: 100%;
  touch-action: none; user-select: none;
  -webkit-user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.pads-empty { margin: auto; padding: 24px; text-align: center; }

.pad {
  position: relative; overflow: hidden; min-width: 0; min-height: 44px;
  border-radius: var(--r); border: 1px solid var(--border); background: var(--card);
  display: flex; align-items: flex-end; padding: 6px 8px; color: var(--text);
  /* Only transform animates: a flash must never move the neighbours. */
  transition: transform 90ms ease-out;
  will-change: transform;
}

/* The colour wash lives on a pseudo-element so a flash is one opacity write,
   and so it works without color-mix() on older iOS. */
.pad::before {
  content: ''; position: absolute; inset: 0;
  background: var(--pad-color); opacity: 0.22;
  transition: opacity 90ms ease-out; pointer-events: none;
}

.pad.is-empty { border-style: dashed; border-color: #2c3140; }
.pad.is-empty::before { opacity: 0.06; }

/* Held — gate/toggle/loop, or any sustaining voice, reported by voices.js. */
.pad.is-on::before { opacity: 0.6; }

/* Our own 90 ms hit flash. */
.pad.is-hit { transform: scale(0.97); }
.pad.is-hit::before { opacity: 1; }

.pad:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* One line, always: a wrapping name would change the pad's height. */
.pad-name {
  position: relative; z-index: 1; max-width: 100%;
  font-size: var(--fs-xs); font-weight: 600; line-height: 1.15;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.pad-flags {
  position: absolute; z-index: 1; top: 5px; right: 5px;
  display: flex; gap: 3px; color: var(--text); opacity: 0.75;
  pointer-events: none;
}
.pad-flags svg { display: block; }

/* Landscape 8x2 pads are shorter, so trim padding rather than the label. */
.pads.is-wide .pad { padding: 4px 6px; }

@media (max-height: 420px) {
  .pads { gap: 4px; padding: 4px; }
  .pad-flags { top: 3px; right: 3px; }
}

/* --- pad recording ------------------------------------------------------ */

/* The grid gets its own box so the mic strip above it changes how much room the
   pads have, instead of overlapping them. pads.js measures this element. */
.pads-box { flex: 1 1 auto; min-height: 0; position: relative; display: flex; }

.prc-host { flex: 0 0 auto; }

.prc-bar {
  display: flex; flex-direction: column; gap: 4px;
  padding: 5px 8px; border-bottom: 1px solid var(--border);
  background: var(--card);
}
.prc-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.prc-row .meter { flex: 0 0 56px; height: 6px; }

.prc-hint {
  flex: 1 1 auto; min-width: 0;
  font-size: var(--fs-xs); color: var(--sub); line-height: 1.2;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.prc-bar.is-live .prc-hint { color: var(--rec); font-weight: 600; }

.prc-chips { justify-content: space-between; }
.prc-group { display: flex; gap: 4px; }

.prc-chip {
  min-height: 28px; padding: 0 9px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: transparent; color: var(--sub);
  font-size: var(--fs-xs); font-weight: 500; white-space: nowrap;
  touch-action: manipulation;
}
.prc-chip.is-on { background: var(--accent); border-color: var(--accent); color: #0d0f12; }
/* The two processing switches are settings, not the choice you came here to
   make — an "on" option chip reads as selected without shouting like the
   hold/tap selector next to it. */
.prc-chip.prc-opt.is-on {
  background: transparent; border-color: var(--accent); color: var(--accent);
}
.prc-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* In mic mode a pad is a record button, so the colour wash steps back and the
   dashed "empty" border stops meaning anything — every pad is a target. */
.pads.is-micmode .pad::before { opacity: 0.12; }
.pads.is-micmode .pad.is-empty { border-style: solid; }

.pad.is-rec { border-color: var(--rec); }
.pad.is-rec::before { background: var(--rec); opacity: 0.55; }
.pad.is-rec::after {
  content: ''; position: absolute; inset: 3px;
  border: 2px solid var(--rec); border-radius: calc(var(--r) - 3px);
  pointer-events: none;
  animation: pad-rec 1s ease-in-out infinite;
}
@keyframes pad-rec {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

.pad.is-saving::before { background: var(--warn); opacity: 0.35; }

@media (prefers-reduced-motion: reduce) {
  .pad.is-rec::after { animation: none; }
}
