/*
  Music page: cover art row.

  Measured from the reference (music page.jpg): four square covers, 2% in from the left, the last one ending
  2.2% short of the right edge, about 4.2% between them, top edge at 41.9% of the page height. Everything is
  a % of the page width so the squares stay square.
*/
:root {
  --covers-left: 2%;
  --covers-width: 95.8%;
  --covers-top: 41.9%;
  --covers-gap: 4.38%;                       /* 4.2% of the page = 4.38% of the row */
  --cover-size: 20.8vw;                      /* (95.8% - 3 x 4.2%) / 4 */
}

.covers-wrap {
  position: absolute;
  left: var(--covers-left);
  width: var(--covers-width);
  top: var(--covers-top);
}

/* the row scrolls sideways when the playlist has more than four releases (arrows below, swipe, trackpad, keys) */
.covers {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: calc((100% - 3 * var(--covers-gap)) / 4);
  gap: var(--covers-gap);
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}
.covers::-webkit-scrollbar { display: none; }

.cover {
  scroll-snap-align: start;
  aspect-ratio: 1;
  background: #fff;
  transition: opacity 0.35s ease;
}

.cover > a,
.cover > .cover-link,
.cover .frame {
  display: block;
  width: 100%;
  height: 100%;
}
.cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* the hovered cover stands out, the rest step back (same idea as the header spotlight) */
@media (hover: hover) {
  .covers:hover .cover:not(:hover):not(:focus-within) { opacity: 0.5; }
}
.cover a:focus-visible { outline: 3px solid #0036cf; outline-offset: -3px; }

/* empty slot, straight from the reference: a white square that says "cover art" */
.cover.is-empty .frame {
  display: grid;
  place-items: center;
  color: #000;
  font-size: 3.5vw;
  line-height: 1.1;
  text-align: center;
}

/* arrows, only present when there is something to scroll to */
.covers-nav {
  position: absolute;
  right: 0;
  top: calc(var(--cover-size) + 1.6vw);
  display: flex;
  gap: 1.4vw;
}
.covers-nav[hidden] { display: none; }
.covers-nav button {
  padding: 0.3em 0.4em;
  border: 0;
  background: none;
  color: rgb(255 255 255 / 0.63);
  font: inherit;
  font-size: var(--type-header);
  line-height: 1;
  cursor: pointer;
  transition: color 0.25s ease, opacity 0.25s ease;
}
.covers-nav button:hover:not(:disabled),
.covers-nav button:focus-visible { color: #fff; }
.covers-nav button:disabled { opacity: 0.25; cursor: default; }
.covers-nav button:focus-visible { outline: 2px solid #0036cf; }

/* "#produced by Fedor Uskov" sits above the whole row of covers */
.produced-by {
  position: absolute;
  z-index: 1;
  left: 0;
  right: 0;
  top: calc(var(--covers-top) - 8vw);
  margin: 0;
  text-align: center;
  font-size: calc(var(--type-header) / 2);    /* half the header size */
  font-weight: 400;
  line-height: 1;
  white-space: nowrap;
  transform: scaleY(1.6);                    /* taller letters, same width: change 1.6 to stretch more or less */
  transform-origin: 50% 100%;                /* grows upward, so the gap to the covers stays put */
}

/* ---------- hover card: title, artist, credits, "Listen on Spotify" (js/music.js) ---------- */
.cover { position: relative; overflow: hidden; }
.cover > a, .cover > .cover-link { position: relative; }

.card-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.cover.has-video:hover .card-video,
.cover.has-video:focus-within .card-video,
.cover.has-video.is-open .card-video { opacity: 1; }

.card {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 1.4vw;
  color: #fff;
  background: linear-gradient(to top, rgb(0 0 0 / 0.82), rgb(0 0 0 / 0.55) 60%, rgb(0 0 0 / 0.7));
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.cover:hover .card,
.cover a:focus-visible .card,
.cover.is-open .card { opacity: 1; }

.card p, .card ul { margin: 0; }
.card-title { font-size: 1.7vw; line-height: 1.15; font-weight: 700; }
.card-artist { margin-top: 0.3vw; font-size: 1.2vw; color: rgb(255 255 255 / 0.8); }
.card-songs { gap: 1.1vw; justify-content: center; }
.card-song + .card-song { margin-top: 0; }
.card a.card-listen { display: block; margin-top: 0.35vw; color: inherit; text-decoration: underline; text-underline-offset: 0.25em; pointer-events: none; }
.cover:hover .card a.card-listen,
.cover.is-open .card a.card-listen { pointer-events: auto; }
.card-songs .card-listen { margin-top: 0.35vw; }
.card-listen {
  margin-top: auto;
  font-size: 1.2vw;
  text-decoration: underline;
  text-underline-offset: 0.25em;
}

@media (prefers-reduced-motion: reduce) {
  .card, .card-video { transition: none; }
}
