/* ============================================================================
   SIDE A — WHAT I DO (js/modules/tracklist.js)
   Default (reduced motion, no JS): a static list, every track open and in full ink.
   .tracks--pinned (desktop, set by tracklist.js): the stage pins, the record plays through
   the tracks; only the playing track is in full ink with its description open.
   ============================================================================ */
.tracks {
  /* padding: the page rhythm in editorial.css */
  background: var(--surface);
  color: var(--on-surface);
}

.tracks__label {
  margin-bottom: var(--space-md);
}

.tracks__title {
  max-width: 14ch;
  font-family: var(--font-serif);
  font-optical-sizing: auto;
  font-weight: 400;
  font-size: var(--fs-display-l);
  line-height: 1.05;
  letter-spacing: var(--ls-display);
  text-transform: uppercase;
}

/* ---------- the stage: tracklist left, record right ---------- */
.tracks__stage {
  display: grid;
  grid-template-columns: repeat(var(--cols-desktop), 1fr);
  column-gap: var(--gutter);
  align-items: center;
  margin-top: var(--space-xl);
}

.tracks--pinned .tracks__stage {
  height: 100svh;
  margin-top: 0;
  padding-top: var(--nav-h);
}

/* ---------- the record (drawn in CSS) and the tonearm (SVG), in one square ---------- */
.tracks__deck {
  grid-column: 7 / span 6;
  grid-row: 1;
  position: relative;
  width: min(100%, 64svh);
  aspect-ratio: 1;
  justify-self: center;
}

/* the record and its sheen sit in the SVG's 0–100 box: centre (44, 52), radius 40 */
.deck__record,
.deck__sheen {
  position: absolute;
  left: 4%;
  top: 12%;
  width: 80%;
  height: 80%;
  border-radius: 50%;
}

.deck__record {
  background:
    /* the centre hole: the page shows through */
    radial-gradient(circle closest-side, var(--cream) 0 3%, transparent 3.3%),
    /* a small mark on the label, so the turning reads */
    radial-gradient(circle closest-side at 50% 30%, rgba(243, 235, 223, 0.55) 0 1.4%, transparent 1.7%),
    /* the label, with a fine ring at its edge */
    radial-gradient(circle closest-side, var(--burgundy) 0 33.5%, #2a1418 33.8% 34.4%, transparent 34.6%),
    /* the run-out and the lead-in: smooth vinyl */
    radial-gradient(circle closest-side, transparent 0 38%, #191210 38.2% 41%, transparent 41.2% 96%, #191210 96.2%),
    /* the grooves */
    repeating-radial-gradient(circle closest-side, #1a1311 0 0.55%, #2b221e 0.75%, #1a1311 1.1%);
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.6),
    0 30px 60px -30px rgba(28, 21, 18, 0.45);
  animation: deck-spin 1.8s linear infinite; /* 33⅓ rpm */
  animation-play-state: paused;
}

.deck__record.is-spinning {
  animation-play-state: running;
}

@keyframes deck-spin {
  to { rotate: 360deg; }
}

/* light on the vinyl stays put while the record turns under it */
.deck__sheen {
  pointer-events: none;
  background: conic-gradient(
    from 210deg,
    transparent 0 8%,
    rgba(243, 235, 223, 0.09) 13%,
    transparent 19% 52%,
    rgba(243, 235, 223, 0.07) 58%,
    transparent 64%
  );
  -webkit-mask: radial-gradient(circle closest-side, transparent 0 35%, #000 35.5%);
  mask: radial-gradient(circle closest-side, transparent 0 35%, #000 35.5%);
}

/* the label's text stays upright over the turning label; it rolls to each new track */
.deck__label {
  position: absolute;
  left: 44%;
  top: 46.6%; /* the name sits in the label's upper half, clear of the centre hole */
  width: 21%;
  height: 7%;
  transform: translate(-50%, -50%);
  overflow: hidden;
  color: var(--cream);
  text-align: center;
}

.deck__label-roll {
  position: relative;
  width: 100%;
  height: 100%;
}

.deck__label-item {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25em;
  font-size: var(--fs-label);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  line-height: 1.15;
}

.deck__label-no {
  opacity: 0.6;
  font-variant-numeric: tabular-nums;
}

.deck__arm {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.deck__arm-tube {
  stroke: var(--ink);
  stroke-width: 1.1;
  stroke-linecap: round;
}

.deck__arm-head,
.deck__arm-weight {
  fill: var(--ink);
}

.deck__arm-base {
  fill: #2a221e;
  stroke: var(--ink);
  stroke-width: 0.6;
}

.deck__arm-cap {
  fill: var(--cream);
  opacity: 0.5;
}

/* ---------- the panel: now playing · the tracklist · the waveform ---------- */
.tracks__panel {
  grid-column: 1 / span 6;
  grid-row: 1;
}

.tracks__now,
.tracks__foot {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  color: var(--muted);
}

.tracks__now {
  margin-bottom: 1rem;
}

.tracks__count {
  font-variant-numeric: tabular-nums;
}

.tracks__count [data-track-count] {
  color: var(--burgundy);
}

.tracks__list {
  list-style: none;
}

/* the playing-position furniture only means something while the side is pinned to the scroll */
.tracks:not(.tracks--pinned) :is(.tracks__now, .tracks__wave, .tracks__foot) {
  display: none;
}

/* the side's waveform: the played part in wine, a fine playhead; it fills with the scroll */
.tracks__wave {
  position: relative;
  height: 38px;
  margin-top: clamp(1.25rem, 3svh, 2rem);
}

.wave__bars {
  position: absolute;
  inset: 0;
  display: flex;
  gap: 10px;
  color: rgba(28, 21, 18, 0.16);
}

.wave__bars--played {
  color: var(--burgundy);
  clip-path: inset(0 calc((1 - var(--p, 0)) * 100%) 0 0);
}

.wave__seg {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.wave__seg i {
  display: block;
  width: 2px;
  height: calc(var(--h) * 100%);
  border-radius: 2px;
  background: currentColor;
}

.wave__head {
  position: absolute;
  top: -5px;
  bottom: -5px;
  left: calc(var(--p, 0) * 100%);
  width: 1px;
  background: var(--burgundy);
}

.tracks__foot {
  margin-top: 0.9rem;
}

.tracks__cue {
  transition: opacity 0.6s var(--ease-out);
}

.tracks.is-started .tracks__cue {
  opacity: 0;
}

.tracks__cue-arrow {
  display: inline-block;
  margin-left: 0.3em;
}

@media (prefers-reduced-motion: no-preference) {
  .tracks__cue-arrow {
    animation: tracks-cue 1.8s var(--ease-in-out) infinite;
  }
}

@keyframes tracks-cue {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 3px; }
}

.track {
  position: relative;
}

.track__rule {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
}

/* (no track numbers: the first column only holds the playing dot) */
.track__row {
  display: grid;
  grid-template-columns: 1.25rem 1fr;
  column-gap: var(--gutter);
  align-items: baseline;
  padding-block: var(--space-sm);
}

.track__no {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5em;
  font-variant-numeric: tabular-nums;
}

.track__dot {
  color: var(--burgundy);
  font-size: 0.9em;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease-out);
}

.track__name {
  display: flex;
  align-items: center;
  gap: 0.6em;
  font-family: var(--font-serif);
  font-optical-sizing: auto;
  font-weight: 400;
  font-size: var(--fs-serif-m);
  line-height: 1.3;
  letter-spacing: 0;
  text-transform: uppercase;
  transition: color 0.6s var(--ease-out);
}

/* the small turning record beside each title: mobile only */
.track__vinyl {
  display: none;
  flex: none;
  width: 0.85em;
  height: 0.85em;
  border-radius: 50%;
  background: radial-gradient(circle closest-side, var(--cream) 0 9%, var(--burgundy) 11% 36%, #1c1512 38% 100%);
  animation: deck-spin 2.4s linear infinite;
}

.track__more {
  grid-column: 2;
  display: grid;
  grid-template-rows: 1fr;
}

.track__more-inner {
  min-height: 0;
  overflow: hidden;
}

.track__text {
  max-width: 46ch;
  padding-top: 0.6rem;
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--muted);
}

/* ---------- pinned: the playing track in full colour, its description open; the others stay
   legible and can be chosen (a click glides to them) ---------- */
.tracks--pinned .track__name {
  color: rgba(28, 21, 18, 0.42);
}

.tracks--pinned .track__row {
  cursor: pointer;
}

.tracks--pinned .track__title {
  display: inline-block;
  transition: transform 0.6s var(--ease-out);
}

.tracks--pinned .track:not(.is-active) .track__row:hover .track__name,
.tracks--pinned .track:not(.is-active) .track__row:focus-visible .track__name {
  color: rgba(28, 21, 18, 0.75);
}

.tracks--pinned .track:not(.is-active) .track__row:hover .track__title {
  transform: translateX(6px);
}

.tracks--pinned .track__row:focus-visible {
  outline: 1px solid var(--burgundy);
  outline-offset: 4px;
}

.tracks--pinned .track.is-active .track__no {
  color: var(--burgundy);
}

.tracks--pinned .track__more {
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.7s var(--ease-out);
}

.tracks--pinned .track.is-active .track__name {
  color: var(--ink);
}

.tracks--pinned .track.is-active .track__dot {
  opacity: 1;
}

.tracks--pinned .track.is-active .track__more {
  grid-template-rows: 1fr;
}

/* ---------- tablet and phone: no pin, no big record; the tracks stack ---------- */
@media (max-width: 1079px) {
  .tracks__stage {
    display: block;
  }
  .tracks__deck {
    display: none;
  }
  .track__vinyl {
    display: inline-block;
  }
  /* not pinned there is no playing dot: the titles start at the margin */
  .tracks:not(.tracks--pinned) .track__row {
    grid-template-columns: 1fr;
  }
  .tracks:not(.tracks--pinned) .track__no {
    display: none;
  }
  .tracks:not(.tracks--pinned) .track__more {
    grid-column: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .track__vinyl,
  .deck__record {
    animation: none;
  }
}
