:root {
  color-scheme: dark;
  --ink: #f8f2e8;
  --muted: #c8bdb1;
  --yellow: #f5bd57;
  --edge: rgba(255, 255, 255, .16);
}

* { box-sizing: border-box; }
html { min-width: 300px; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 0%, #4e2146 0, transparent 29rem),
    linear-gradient(135deg, #100d16, #24121e 55%, #0e121a);
  font-family: Georgia, 'Times New Roman', serif;
}
button { font: inherit; }

/* Page shell and heading */
.wrap { width: min(1160px, calc(100% - 2.5rem)); margin: auto; padding: 4.5rem 0 5rem; }
header { margin-bottom: 2.5rem; text-align: center; }
.eyebrow {
  margin: 0 0 .75rem;
  color: var(--yellow);
  font: 600 .75rem/1.2 system-ui, sans-serif;
  letter-spacing: .18em;
  text-transform: uppercase;
}
h1 { margin: 0; font-size: clamp(2.5rem, 7vw, 5.5rem); font-weight: 400; letter-spacing: -.055em; }
.subtitle { max-width: 38rem; margin: 1rem auto 0; color: var(--muted); font: 1rem/1.6 system-ui, sans-serif; }

/* Draggable circular carousel with camera-facing album sleeves */
.carousel-viewport {
  --radius: clamp(330px, 42vw, 520px);
  position: relative;
  width: 100%;
  height: clamp(510px, 62vw, 660px);
  overflow: hidden;
  perspective: 1300px;
  cursor: grab;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.carousel-viewport.is-carousel-dragging { cursor: grabbing; }
.carousel-viewport img {
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}
.carousel-track {
  --carousel-rotation: 0deg;
  position: absolute;
  inset: 0;
  transform: translateZ(calc(0px - var(--radius))) rotateY(var(--carousel-rotation));
  transform-style: preserve-3d;
  transition: transform .72s cubic-bezier(.2, .8, .25, 1);
}
.song-card {
  position: absolute;
  left: 50%;
  top: 50%;
  width: clamp(245px, 28vw, 330px);
  min-width: 0;
  transform: translate(-50%, -50%) rotateY(var(--slot-angle)) translateZ(var(--radius));
  transform-style: preserve-3d;
}
.song-card:focus-visible { outline: none; }
.player-stack {
  position: relative;
  display: grid;
  grid-template-rows: 35.5% 64.5%;
  width: 100%;
  aspect-ratio: 1 / 1.55;
  filter: brightness(.58) saturate(.72);
  isolation: isolate;
  transform: rotateY(var(--counter-angle));
  transform-style: preserve-3d;
  transition: transform .72s cubic-bezier(.2, .8, .25, 1), filter .35s, opacity .35s;
}
.song-card.is-active .player-stack { filter: none; }
.song-card:focus-visible .sleeve { outline: 3px solid var(--yellow); outline-offset: 5px; }
.carousel-viewport.is-carousel-dragging .carousel-track,
.carousel-viewport.is-carousel-dragging .player-stack { transition: none; }
.carousel-help {
  position: absolute;
  z-index: 20;
  right: 0;
  bottom: .25rem;
  left: 0;
  margin: 0;
  color: rgba(255, 255, 255, .48);
  font: 700 .65rem/1.2 system-ui, sans-serif;
  letter-spacing: .12em;
  text-align: center;
  pointer-events: none;
}

/* Outer wrapper slides and drags. Children keep independent rotations. */
.record-drawer {
  --drag-x: 0px;
  --drag-y: 0px;
  --lift: 0%;
  position: relative;
  z-index: 1;
  grid-area: 2 / 1;
  align-self: start;
  justify-self: center;
  width: 90%;
  aspect-ratio: 1;
  margin-top: 2%;
  border: 0;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  cursor: grab;
  touch-action: none;
  transform: translate3d(var(--drag-x), calc(var(--lift) + var(--drag-y)), 0);
  transition: transform .62s cubic-bezier(.2, .85, .25, 1);
  user-select: none;
  -webkit-user-select: none;
}
.song-card.is-active:hover .record-drawer,
.song-card.is-raised .record-drawer,
.song-card.is-playing .record-drawer,
.song-card.is-cueing .record-drawer { --lift: -60%; }
.song-card.is-dismissed .record-drawer { --lift: 0%; }
.song-card.is-dragging .record-drawer { cursor: grabbing; transition: none; }
.record-drawer:focus-visible { outline: 3px solid var(--yellow); outline-offset: 5px; }
.record-drawer::before {
  content: '';
  position: absolute;
  z-index: 0;
  right: 8%;
  bottom: -7%;
  left: 8%;
  height: 22%;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, .48) 0%, rgba(0, 0, 0, .2) 45%, rgba(0, 0, 0, 0) 76%);
  filter: blur(5px);
  transform: scaleY(.42);
  transform-origin: center;
  pointer-events: none;
}

/* Vinyl artwork, spinning label, and spindle hole */
.vinyl-vector,
.record-label,
.spindle-hole { pointer-events: none; }
.vinyl-vector {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 1.1rem 1rem rgba(0, 0, 0, .48));
  transform: rotate(-5deg);
}
.record-label {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 50%;
  width: 31%;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, .7);
  border-radius: 50%;
  background: radial-gradient(circle, #d8a94e, #7f274a);
  transform: translate(-50%, -50%);
}
.record-label img { display: block; width: 100%; height: 100%; object-fit: cover; }
.spindle-hole {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 50%;
  width: 3.2%;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 50%;
  background: #020202;
  box-shadow: inset 0 0 3px #000, 0 0 2px rgba(255, 255, 255, .3);
  transform: translate(-50%, -50%);
}

/*
 * Start motion while the needle drops and keep the same animation running
 * when audio begins. Reusing one animation avoids a visible reset or jump.
 */
.song-card:is(.is-cueing, .is-playing) .vinyl-vector {
  animation: groove-wobble 1.333s ease-in-out alternate infinite;
}
.song-card:is(.is-cueing, .is-playing) .record-label {
  animation: label-spin 1.53846s linear infinite;
}
@keyframes groove-wobble { from { transform: rotate(-5deg); } to { transform: rotate(5deg); } }
@keyframes label-spin { to { transform: translate(-50%, -50%) rotate(360deg); } }

/* Gesture feedback shown only while dragging */
.drag-hint {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: 11%;
  opacity: 0;
  padding: .35rem .6rem;
  border-radius: 999px;
  color: #15100a;
  background: var(--yellow);
  font: 800 .65rem/1 system-ui, sans-serif;
  letter-spacing: .08em;
  transform: translateX(-50%);
  transition: opacity .15s;
  white-space: nowrap;
}
.song-card.is-dragging .drag-hint { opacity: 1; }

/* Three-dimensional sleeve and front cover */
.sleeve-scene {
  position: relative;
  z-index: 2;
  grid-area: 2 / 1;
  width: 100%;
  aspect-ratio: 1;
  perspective: 1200px;
}
.sleeve {
  position: absolute;
  inset: 0;
  border-radius: .85rem;
  box-shadow: 0 1.5rem 3rem rgba(0, 0, 0, .38);
  transform-style: preserve-3d;
  transition: transform .72s cubic-bezier(.2, .75, .25, 1);
}
.song-card.is-flipped .sleeve { transform: rotateY(-180deg); }
.sleeve-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border: 1px solid var(--edge);
  border-radius: .85rem;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.sleeve-front { background: #1f1824; }
.cover-surface {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  cursor: pointer;
}
.cover-art { display: block; width: 100%; height: 100%; object-fit: contain; background: #17131a; }
.cover-placeholder {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  color: rgba(255, 255, 255, .52);
  background: radial-gradient(circle at 40% 35%, #6b315c, #181523 65%);
  font-size: 1.2rem;
  font-style: italic;
}
.front-title {
  position: absolute;
  inset: auto 0 0;
  padding: 1.8rem 1rem .75rem;
  color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, .78));
  font: 600 clamp(.82rem, 2vw, 1.05rem)/1.2 system-ui, sans-serif;
  letter-spacing: .015em;
  text-shadow: 0 1px 4px #000;
}
.play-button {
  position: absolute;
  z-index: 5;
  top: 1rem;
  right: 1rem;
  display: grid;
  width: 2.8rem;
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .42);
  border-radius: 50%;
  opacity: .2;
  color: #17110a;
  background: rgba(245, 189, 87, .9);
  box-shadow: 0 .4rem 1rem rgba(0, 0, 0, .35);
  cursor: pointer;
  transition: opacity .25s, background .2s, transform .2s;
}
.sleeve-front:hover .play-button,
.play-button:focus-visible { opacity: 1; }
.play-button:hover,
.play-button:focus-visible { background: var(--yellow); transform: scale(1.08); }
.play-symbol::before { content: '▶'; display: block; margin-left: .12em; font: 900 1rem/1 system-ui, sans-serif; }
.song-card.is-cueing .play-symbol::before { content: '…'; margin: 0; }
.song-card.is-playing .play-symbol::before { content: 'Ⅱ'; margin: 0; letter-spacing: -.18em; }


/* Vertical control attached to sleeve edge */
.lyrics-tab,
.front-tab {
  position: absolute;
  z-index: 4;
  right: 0;
  top: 50%;
  width: 7.4rem;
  border: 0;
  border-radius: .45rem .45rem 0 0;
  padding: .55rem .7rem;
  color: rgba(245, 189, 87, .4);
  background: rgba(0, 0, 0, .2);
  cursor: pointer;
  font: 800 .7rem/1 system-ui, sans-serif;
  letter-spacing: .12em;
  transform: translate(44%, -50%) rotate(-90deg);
  transition: color .2s, background .2s;
}
.lyrics-tab:hover,
.lyrics-tab:focus-visible,
.front-tab:hover,
.front-tab:focus-visible { color: rgb(245, 189, 87); background: rgba(0, 0, 0, .5); }

/* Lyrics side of sleeve */
.sleeve-back {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  padding: 1rem;
  color: #18151a;
  background: #e8e2d9;
  transform: rotateY(180deg);
}
.back-heading { display: flex; align-items: start; justify-content: space-between; gap: .75rem; }
.back-title { margin: 0; font: 700 clamp(1.15rem, 3vw, 1.55rem)/1.1 Georgia, serif; }
.lyrics-window {
  flex: 1;
  min-height: 0;
  overflow: auto;
  margin: 0;
  border: 1px solid #c4beb6;
  border-radius: .45rem;
  padding: .9rem;
  color: #111;
  background: #fff;
  box-shadow: inset 0 1px 5px rgba(0, 0, 0, .12);
  font: clamp(.72rem, 2vw, .9rem)/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
}
.no-lyrics { color: #625b63; font-style: italic; }
audio[hidden] { display: none; }

/* Empty library and responsive/accessibility states */
.empty {
  padding: 3.5rem 1.5rem;
  border: 1px dashed var(--edge);
  border-radius: 1rem;
  color: var(--muted);
  text-align: center;
  font: 1rem/1.6 system-ui, sans-serif;
}
code { color: var(--yellow); }

@media (max-width: 620px) {
  .wrap { width: min(92vw, 430px); padding-top: 3rem; }
  .carousel-viewport { --radius: 285px; height: 570px; }
  .song-card { width: min(78vw, 310px); }
  .carousel-help { font-size: .56rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
  .song-card:is(.is-cueing, .is-playing) .vinyl-vector,
  .song-card:is(.is-cueing, .is-playing) .record-label { animation: none; }
}
