/* Merch Wall — soundmap v2 / Phase 7 (photoreal AI templates)
   Each tile is a pre-composited <img> shirt rendered at runtime via canvas.
   No clip-path, no mix-blend-mode at the wall level — the photorealism is
   already baked into the per-tile PNG. */

#tab-merchwall {
  padding: 20px;
}

.merchwall {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 1400px;
  margin: 0 auto;
}

/* ── Top controls bar ───────────────────────────────────────── */
.merchwall-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px;
  background: rgba(40, 42, 54, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  align-items: center;
}

.merchwall-controls .ctrl-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.merchwall-controls .ctrl-group--row {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.merchwall-controls label {
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #a0aec0;
  font-weight: 600;
}

.merchwall-controls input[type="range"] {
  -webkit-appearance: none;
  width: 220px;
  height: 6px;
  background: linear-gradient(90deg, #44475a, #6272a4);
  border-radius: 3px;
  outline: none;
}
.merchwall-controls input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  background: #bd93f9;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}
.merchwall-controls input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px;
  background: #bd93f9;
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

.merchwall-controls .grid-size-buttons {
  display: flex;
  gap: 4px;
}
.merchwall-controls .grid-size-btn {
  background: #44475a;
  color: #f8f8f2;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: monospace;
}
.merchwall-controls .grid-size-btn:hover { background: #525560; }
.merchwall-controls .grid-size-btn.active {
  background: #6272a4;
  border-color: #bd93f9;
  color: #fff;
}

.merchwall-controls .play-btn {
  background: #bd93f9;
  color: #282a36;
  border: none;
  border-radius: 50%;
  width: 40px; height: 40px;
  font-size: 1.2rem;
  cursor: pointer;
  transition: transform 80ms;
}
.merchwall-controls .play-btn:hover { transform: scale(1.06); }
.merchwall-controls .play-btn:active { transform: scale(0.96); }

.merchwall-controls .speed-select,
.merchwall-controls .listener-select {
  background: #44475a;
  color: #f8f8f2;
  border: 1px solid #6272a4;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.85rem;
  cursor: pointer;
}

.merchwall-period-display {
  font-family: monospace;
  font-size: 0.85rem;
  color: #f8f8f2;
  background: rgba(0, 0, 0, 0.3);
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ── The wall: pegboard / merch-store backdrop ──────────────── */
.merch-wall {
  display: grid;
  grid-template-columns: repeat(var(--cols, 8), 1fr);
  gap: 12px;
  padding: 28px 24px 36px;
  background-color: #131520;
  background-image:
    radial-gradient(ellipse 80% 60% at 50% 30%,
      rgba(189, 147, 249, 0.06) 0%,
      transparent 60%),
    radial-gradient(circle at 12px 12px,
      rgba(0, 0, 0, 0.35) 1.2px,
      transparent 1.5px),
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.012) 0 1px,
      transparent 1px 80px,
      rgba(0, 0, 0, 0.18) 80px 81px,
      transparent 81px 82px
    ),
    linear-gradient(180deg, #16182a 0%, #0f1018 100%);
  background-size: auto, 24px 24px, auto, auto;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  min-height: 400px;
  box-shadow:
    inset 0 6px 24px rgba(0, 0, 0, 0.5),
    inset 0 -2px 6px rgba(255, 255, 255, 0.03);
}

/* ── Single tile ────────────────────────────────────────────── */
.merch-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  cursor: pointer;
  transition: transform 200ms ease-out;
}

.merch-tile:hover {
  transform: translateY(-6px);
}

/* The shirt frame just holds the <img>. The pre-composited image carries
   the photoreal cotton, fabric folds, hanger, and printed album art. */
.merch-tile .shirt-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Subtle drop shadow under the hanging shirt — applied via CSS so it can
     react to hover without reprocessing the canvas. */
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.55));
  transition: filter 200ms ease-out;
}

.merch-tile:hover .shirt-frame {
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.65));
}

.merch-tile .shirt-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  /* Slight rotation on hover for the "shirt swaying" feel */
  transform-origin: 50% 4%;
  transition: transform 220ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.merch-tile:hover .shirt-img {
  animation: shirt-sway 1.6s ease-in-out 220ms infinite alternate;
}

@keyframes shirt-sway {
  from { transform: rotate(-1.5deg); }
  to   { transform: rotate(1.5deg); }
}

/* ── Folded-stack canvas ─────────────────────────────────────── */
.merch-tile .stack-wrap {
  width: 76%;
  margin-top: 4px;
  display: flex;
  justify-content: center;
}
.merch-tile canvas.stack {
  width: 100%;
  height: 60px;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.4));
}

.merch-tile.empty-stack canvas.stack {
  opacity: 0.2;
}

/* ── Tooltip ─────────────────────────────────────────────────── */
.merch-tooltip {
  position: fixed;
  background: rgba(15, 16, 22, 0.96);
  border: 1px solid rgba(189, 147, 249, 0.4);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.82rem;
  pointer-events: none;
  z-index: 1000;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  max-width: 240px;
  display: none;
}
.merch-tooltip.visible { display: block; }
.merch-tooltip .album-name {
  font-weight: 700;
  color: #bd93f9;
  margin-bottom: 2px;
}
.merch-tooltip .artist-name {
  color: #f8f8f2;
  margin-bottom: 6px;
}
.merch-tooltip .play-line {
  color: #a0aec0;
  font-family: monospace;
  font-size: 0.78rem;
}

/* ── Loading + empty states ──────────────────────────────────── */
.merchwall-empty {
  text-align: center;
  padding: 60px 20px;
  color: #a0aec0;
  font-size: 0.95rem;
  grid-column: 1 / -1;
}
.merchwall-empty .big {
  font-size: 1.4rem;
  color: #f8f8f2;
  margin-bottom: 10px;
}

/* Tile fade transitions when grid recomposes */
.merch-tile {
  animation: tile-in 320ms ease-out;
}
@keyframes tile-in {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Compact info above wall */
.merchwall-stats {
  display: flex;
  gap: 16px;
  font-size: 0.82rem;
  color: #a0aec0;
}
.merchwall-stats .stat-num {
  color: #bd93f9;
  font-weight: 700;
  font-family: monospace;
}

/* Responsive */
@media (max-width: 700px) {
  .merchwall-controls input[type="range"] { width: 140px; }
  .merch-wall { gap: 8px; padding: 14px; }
}
