/*
 * The Hip Hop Lab: merchandise (Home #merch, artist strip, /merch/). Revision 0.4, section 9.
 * Products are cut-outs straight on the dark page [owner: "that transparent look"]; a tile is
 * the product's name and price only (ruling 12). Each one
 * stands in its own soft pool of light on a hairline floor, so a black tee still reads on the
 * ink ground. No tile box, no border.
 * Colours, sizes and timings come from tokens.css only. .btn, .btn--quiet and .section-head
 * belong to system.css (stage lane); this file only positions them.
 */

/* --------------------------------------------------------------- section */

.merch-band {
  padding-block: var(--section-pad);
  padding-inline: var(--gutter);
  color: var(--text);
}

.merch-band__inner {
  max-width: 100%;
  margin-inline: auto;
}

.merch-band__title {
  margin: 0;
}

.merch-band__title--strip {
  font-size: calc(var(--fs-title) * 0.72);
}

/* --------------------------------------------------------------- grid */

.merch-grid {
  --merch-cols: 2;
  display: grid;
  grid-template-columns: repeat(var(--merch-cols), minmax(0, 1fr));
  gap: clamp(2rem, 4vw, 3rem) clamp(0.75rem, 2vw, 1.75rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 48em) {
  .merch-grid { --merch-cols: 3; }
  .merch-grid--strip { --merch-cols: 3; }
}

@media (min-width: 64em) {
  .merch-grid { --merch-cols: 4; }
  .merch-grid--strip { --merch-cols: 4; }
}

@media (min-width: 80em) {
  .merch-grid { --merch-cols: 5; }
  .merch-grid--strip { --merch-cols: 4; }
}

/* Home and the strip keep whole rows: 4 tiles in 2 columns, 3 in 3, 4 in 4, 5 in 5.
   The rest stay one click away under "Shop all". */
@media (max-width: 47.99em) {
  .merch-grid--band > :nth-child(n + 5) { display: none; }
}

@media (min-width: 48em) and (max-width: 63.99em) {
  .merch-grid--band > :nth-child(n + 4),
  .merch-grid--strip > :nth-child(n + 4) { display: none; }
}

@media (min-width: 64em) and (max-width: 79.99em) {
  .merch-grid--band > :nth-child(n + 5) { display: none; }
}

/* The hidden attribute always wins: filtered-out tiles, and the filter chips until merch.js
   reveals them (with JavaScript off they would be dead buttons). */
.merch-band [hidden] {
  display: none !important;
}

/* --------------------------------------------------------------- tile */

.merch-tile {
  min-width: 0;
}

.merch-tile__link {
  display: block;
  color: var(--text);
  text-decoration: none;
  border-radius: var(--tile-radius);
  outline: none;
}

/* The product's stage: a square with a pool of light and a hairline floor. */
.merch-tile__media {
  position: relative;
  display: block;
  aspect-ratio: 1;
  border-radius: var(--tile-radius);
  background:
    radial-gradient(ellipse 58% 44% at 50% 56%, var(--ink-2), transparent 100%),
    linear-gradient(var(--line), var(--line)) 50% 100% / 100% 1px no-repeat;
  transition: background-color var(--dur-ui) var(--ease-out);
}

.merch-tile__link:focus-visible .merch-tile__media {
  box-shadow: var(--focus-on-dark);
}

.merch-tile__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  /* Photos are trimmed cut-outs (tools/sync_merch.py); one even frame gives every product a
     similar presence. The bottom inset leaves the floor line visible under the product. */
  padding: 9% 8% 10%;
  transform-origin: 50% 90%;
  transition: opacity var(--dur-fade) var(--ease-out), transform var(--dur-stage) var(--ease-stage);
}

.merch-tile__img--alt {
  opacity: 0;
}

/* A photo with its own ground (catalogue "ground": "photo"): no box. The scene fades into the
   ink from an oval, like the light pool the cut-outs stand in. */
.merch-tile__img--photo {
  inset: 4%;
  width: 92%;
  height: 92%;
  padding: 0;
  object-fit: cover;
  filter: brightness(0.8);
  -webkit-mask-image: radial-gradient(closest-side, black 52%, transparent 100%);
  mask-image: radial-gradient(closest-side, black 52%, transparent 100%);
}

/* Title (clamped at two lines) and price share one block of fixed height, so every tile in a
   row is the same height with a one- or two-line title. */
.merch-tile__text {
  display: block;
  min-height: calc(0.875rem + 2 * 1.3 * var(--fs-body) + 0.25rem + 1.45 * var(--fs-small));
  padding-top: 0.875rem;
}

.merch-tile__title {
  display: -webkit-box;
  overflow: hidden;
  font-size: var(--fs-body);
  font-weight: 500;
  line-height: 1.3;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.merch-tile__price {
  display: block;
  margin-top: 0.25rem;
  font-size: var(--fs-small);
  font-weight: 600;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}

.merch-tile__was {
  margin-left: 0.4em;
  color: var(--text-2);
  font-weight: 400;
}

.merch-tile__arrow {
  display: inline-block;
  margin-left: 0.4em;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity var(--dur-ui) var(--ease-out), transform var(--dur-ui) var(--ease-out);
}

/* Hover and keyboard focus: the light comes up, the product lifts, the second view swaps in,
   the arrow appears. */
.merch-tile__link:is(:hover, :focus-visible) .merch-tile__media {
  background-color: var(--ink-1);
}

.merch-tile__link:is(:hover, :focus-visible) .merch-tile__img {
  transform: translateY(-3%) scale(1.04);
}

.merch-tile__link:is(:hover, :focus-visible) .merch-tile__img--alt {
  opacity: 1;
}

.merch-tile__link:is(:hover, :focus-visible) .merch-tile__img--swap {
  opacity: 0;
}

.merch-tile__link:is(:hover, :focus-visible) .merch-tile__arrow {
  opacity: 1;
  transform: none;
}

.merch-tile__link:hover .merch-tile__title {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

/* --------------------------------------------------------------- filters (/merch/) */

.merch-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem 0.75rem;   /* clears style b's offset shadow */
  margin: 0 0 clamp(2rem, 4vw, 3rem);
}

/* Full colour, never dimmed: on style b's pressed (brand red) chip a dimmed count fell below 4.5:1. */
.merch-chip__count {
  font-variant-numeric: tabular-nums;
  font-weight: 400;
}

/* --------------------------------------------------------------- reveal */

@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .merch-tile {
      animation: merch-rise linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 40%;
    }
  }
}

@keyframes merch-rise {
  from { opacity: 0.35; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}

/* --------------------------------------------------------------- reduced motion */

@media (prefers-reduced-motion: reduce) {
  .merch-tile,
  .merch-tile__media,
  .merch-tile__img,
  .merch-tile__arrow {
    animation: none !important;
    transition: none !important;
  }

  .merch-tile__link:is(:hover, :focus-visible) .merch-tile__img,
  .merch-tile__arrow {
    transform: none;
  }
}

@media (forced-colors: active) {
  .merch-tile__media { border: 1px solid CanvasText; }
}
