/* The Save to library button with the album sliding into the stack. A dark studio with a warm light and a fine grain,
   and in the middle the album card of a music app: the sleeve (a photograph painted on a canvas) with the record half
   out of it, the title, the Save to library button and the little stack of the library with its count. The card is
   drawn at one size (wide or narrow) and scaled to fit by script.js, so every pixel value here stays true. */
:root {
  --page: #09090b;            /* the studio */
  --haze: #2a1d16;            /* the warm light behind the card */
  --card: #131316;            /* the card */
  --card-deep: #0c0c0e;       /* the card at the bottom */
  --amber: #ffa45e;           /* the accent: the button disc, the saved light, the wave on the record */
  --amber-deep: #c2551f;      /* the accent in shadow */
  --vinyl: #0d0d0f;           /* the record */
  --ink: #f3f1ee;             /* the words */
  --muted: rgba(243, 241, 238, 0.52); /* the small lines */
  --line: rgba(255, 255, 255, 0.08);  /* the thin edges */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.sr,
.save__sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* the studio: a warm light behind the card, a cold one high up, and grain */
.stage {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 12px;
  overflow: hidden;
  background:
    radial-gradient(min(80vw, 760px) min(60vh, 440px) at 38% 52%, color-mix(in srgb, var(--haze) 95%, transparent), transparent 70%),
    radial-gradient(min(70vw, 620px) min(40vh, 300px) at 70% 0%, rgba(120, 140, 190, 0.08), transparent 70%),
    var(--page);
}

.stage::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.55;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 0.92 0 0 0 0 0.85 0 0 0 0.07 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 160px 160px;
}

/* the box that takes the scaled size of the card, so the stage can centre it */
.fit {
  position: relative;
  z-index: 1;
  width: 680px;
  height: 316px;
}

/* ---- the card, wide (the default) and narrow (.is-narrow, set by script.js) ---- */
.card {
  --sleeve: 236px;
  --disc: 222px;
  --peek: 106px;
  --pad: 40px;
  position: absolute;
  left: 0;
  top: 0;
  width: 680px;
  height: 316px;
  padding: var(--pad) 34px var(--pad) 40px;
  display: grid;
  grid-template-columns: calc(var(--sleeve) + var(--peek)) 1fr;
  column-gap: 34px;
  align-items: center;
  border-radius: 30px;
  transform-origin: 0 0;
  isolation: isolate;
  background: linear-gradient(180deg, var(--card), var(--card-deep));
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.05) inset,
    0 50px 90px -30px rgba(0, 0, 0, 0.85),
    0 22px 40px -18px rgba(0, 0, 0, 0.7),
    0 0 0 1px rgba(0, 0, 0, 0.6);
}

.card.is-narrow {
  --sleeve: 146px;
  --disc: 136px;
  --peek: 64px;
  width: 320px;
  height: 410px;
  padding: 22px 22px 22px;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr;
  row-gap: 18px;
  align-items: start;
  border-radius: 26px;
}

/* the edge of the card: light on top, gone at the bottom */
.card__edge {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.03) 40%, rgba(255, 255, 255, 0.01));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}

/* the warm light the sleeve throws on the card, brighter when the album is saved */
.card__light {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  pointer-events: none;
  z-index: -1;
}

.card__light::before {
  content: '';
  position: absolute;
  left: 4%;
  top: 30%;
  width: 70%;
  height: 90%;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--amber) 22%, transparent), transparent);
  filter: blur(20px);
}

/* ---- the sleeve and the record ---- */
.art {
  position: relative;
  width: calc(var(--sleeve) + var(--peek));
  height: var(--sleeve);
  justify-self: start;
}

.is-narrow .art {
  justify-self: center;
}

.vinyl {
  position: absolute;
  top: calc((var(--sleeve) - var(--disc)) / 2);
  left: calc(var(--sleeve) + var(--peek) - var(--disc));
  width: var(--disc);
  height: var(--disc);
  border-radius: 50%;
  box-shadow: 0 16px 30px -10px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.vinyl__disc {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  overflow: hidden;
  background: var(--vinyl);
}

/* the grooves: fine rings, a dead band between two songs, and the shiny lead-in at the edge */
.vinyl__grooves {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle, transparent 57%, rgba(255, 255, 255, 0.05) 57.6%, transparent 58.6%),
    radial-gradient(circle, transparent 79%, rgba(255, 255, 255, 0.045) 79.5%, transparent 80.6%),
    radial-gradient(circle, transparent 95%, rgba(255, 255, 255, 0.08) 96.5%, rgba(0, 0, 0, 0.6) 99%),
    repeating-radial-gradient(circle, #101012 0 1px, #18181b 1px 2px, #0e0e10 2px 3px),
    var(--vinyl);
}

.vinyl__label {
  position: absolute;
  left: 32%;
  top: 32%;
  width: 36%;
  height: 36%;
  border-radius: 50%;
}

/* the light on the record does not turn with it: two soft wedges, like a lamp over the turntable */
.vinyl__sheen {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  background: conic-gradient(from 20deg, transparent 0deg, rgba(255, 255, 255, 0.11) 24deg, transparent 52deg, transparent 180deg, rgba(255, 235, 220, 0.08) 206deg, transparent 236deg);
  -webkit-mask: radial-gradient(circle, transparent 34%, #000 35%, #000 97%, transparent 98%);
  mask: radial-gradient(circle, transparent 34%, #000 35%, #000 97%, transparent 98%);
}

/* the wave of light: a warm ring whose radius (--r) GSAP carries from the label to the edge */
.vinyl__wave {
  --r: 18%;
  --a: 0;
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  opacity: var(--a);
  mix-blend-mode: screen;
  background:
    radial-gradient(circle, transparent calc(var(--r) - 9%), color-mix(in srgb, var(--amber) 30%, transparent) calc(var(--r) - 3%), rgba(255, 236, 214, 0.75) var(--r), color-mix(in srgb, var(--amber) 22%, transparent) calc(var(--r) + 2.5%), transparent calc(var(--r) + 7%));
  -webkit-mask: repeating-radial-gradient(circle, #000 0 1px, rgba(0, 0, 0, 0.45) 1px 2px), radial-gradient(circle, transparent 34%, #000 35%);
  -webkit-mask-composite: source-in;
  mask: repeating-radial-gradient(circle, #000 0 1px, rgba(0, 0, 0, 0.45) 1px 2px), radial-gradient(circle, transparent 34%, #000 35%);
  mask-composite: intersect;
}

.vinyl__hole {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 3.4%;
  height: 3.4%;
  margin: -1.7% 0 0 -1.7%;
  border-radius: 50%;
  background: #050506;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.sleeve {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--sleeve);
  height: var(--sleeve);
  border-radius: 5px;
  overflow: hidden;
  background: #1a2230;
  box-shadow:
    0 30px 46px -18px rgba(0, 0, 0, 0.9),
    0 10px 18px -8px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(0, 0, 0, 0.5);
}

.sleeve__photo {
  display: block;
  width: 100%;
  height: 100%;
}

/* the cardboard of the sleeve: a light on the top edge, a worn spine on the right where the record comes out */
.sleeve__paper {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent 96%, rgba(0, 0, 0, 0.32)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 7%),
    linear-gradient(125deg, rgba(255, 255, 255, 0.07), transparent 40%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
}

/* ---- the words ---- */
.info {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 560;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.eyebrow__mark {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: var(--amber);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.eyebrow__sep {
  opacity: 0.6;
}

.title {
  margin: 0;
  font-size: 27px;
  line-height: 1.06;
  font-weight: 640;
  font-stretch: 96%;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meta {
  margin: 6px 0 22px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.is-narrow .eyebrow {
  margin-bottom: 7px;
}

.is-narrow .title {
  font-size: 24px;
}

.is-narrow .meta {
  margin: 4px 0 16px;
  font-size: 12.5px;
}

/* ---- the button ---- */
.save {
  appearance: none;
  border: 0;
  padding: 0;
  margin: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  border-radius: 999px;
  width: 100%;
  -webkit-tap-highlight-color: transparent;
}

.save:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--amber) 80%, white);
  outline-offset: 5px;
}

.save__body {
  --mx: 30%;
  --my: 50%;
  position: relative;
  display: block;
  height: 60px;
  border-radius: 999px;
  isolation: isolate;
  overflow: hidden;
  background:
    linear-gradient(180deg, #23232a, #16161b 60%, #121216),
    #16161b;
  box-shadow:
    0 14px 26px -12px rgba(0, 0, 0, 0.9),
    0 2px 4px rgba(0, 0, 0, 0.5);
}

.is-narrow .save__body {
  height: 56px;
}

/* the warm light that fills the button from the disc when the album is saved */
.save__fill {
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: 0;
  background:
    radial-gradient(120% 160% at 0% 50%, color-mix(in srgb, var(--amber) 34%, transparent), transparent 62%),
    linear-gradient(180deg, #2b2119, #1b1612);
}

/* the light under the pointer */
.save__light {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

.save__light-spot {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: radial-gradient(120px 80px at var(--mx) var(--my), rgba(255, 238, 222, 0.13), transparent 70%);
}

.save__sweep {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.save__sweep-band {
  position: absolute;
  top: -20%;
  left: 0;
  width: 34%;
  height: 140%;
  background: linear-gradient(90deg, transparent, rgba(255, 236, 216, 0.2) 45%, rgba(255, 255, 255, 0.32) 50%, rgba(255, 236, 216, 0.2) 55%, transparent);
}

.save__edge {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 -1px 0 rgba(0, 0, 0, 0.5),
    inset 0 0 0 1px rgba(255, 255, 255, 0.07);
}

.save__row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 100%;
  padding: 0 22px 0 9px;
}

.is-narrow .save__row {
  padding-left: 8px;
}

.save__icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background:
    radial-gradient(120% 120% at 30% 20%, #ffd2a8, var(--amber) 45%, var(--amber-deep));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset 0 -2px 3px rgba(120, 40, 0, 0.35),
    0 6px 14px -4px color-mix(in srgb, var(--amber-deep) 70%, transparent);
}

.is-narrow .save__icon {
  width: 40px;
  height: 40px;
}

.save__icon svg {
  width: 22px;
  height: 22px;
  overflow: visible;
  fill: none;
  stroke: #2a1406;
  stroke-width: 2.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.save__words {
  position: relative;
  display: grid;
  flex: 1;
  min-width: 0;
  height: 22px;
  overflow: hidden;
  font-size: 16px;
  line-height: 22px;
  font-weight: 600;
  font-stretch: 104%;
  letter-spacing: -0.005em;
  text-align: left;
}

.save__word {
  grid-area: 1 / 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- the library: the stack and the count ---- */
.lib {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
  padding-left: 4px;
}

.is-narrow .lib {
  margin-top: 14px;
}

.pile {
  position: relative;
  flex: none;
  width: 44px;
  height: 44px;
  margin-top: 8px;
}

.mini {
  position: absolute;
  inset: 0;
  border-radius: 4px;
  overflow: hidden;
  transform-origin: 50% 0%;
  box-shadow: 0 6px 10px -4px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(0, 0, 0, 0.5);
}

.mini canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* the albums further down the stack are in the shade of the one on top */
.mini__shade {
  position: absolute;
  inset: 0;
  background: #070708;
  opacity: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.mini::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.lib__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.lib__name {
  font-size: 11px;
  font-weight: 560;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.lib__count {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 17px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.lib__unit {
  font-weight: 450;
  color: rgba(243, 241, 238, 0.78);
}

/* the odometer: every digit is a column of two rounds of 0-9 behind a mask one line high */
.odo {
  display: inline-flex;
  height: 1.2em;
  line-height: 1.2em;
  overflow: hidden;
  -webkit-mask: linear-gradient(180deg, transparent, #000 22%, #000 78%, transparent);
  mask: linear-gradient(180deg, transparent, #000 22%, #000 78%, transparent);
}

.odo__d {
  display: block;
  width: 0.62em;
  text-align: center;
}

.odo__col {
  display: flex;
  flex-direction: column;
}

.odo__col span {
  display: block;
  height: 1.2em;
}

/* the words and the button stay above the copy of the sleeve while it flies */
.eyebrow,
.title,
.meta,
.save {
  position: relative;
  z-index: 6;
}

/* ---- the copy of the sleeve that flies into the stack ---- */
.ghost {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--sleeve);
  height: var(--sleeve);
  border-radius: 5px;
  overflow: hidden;
  visibility: hidden;
  transform-origin: 0 0;
  pointer-events: none;
  z-index: 5;
  box-shadow: 0 30px 50px -16px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(0, 0, 0, 0.4);
}

.ghost canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.ghost__shine {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: linear-gradient(125deg, transparent 30%, rgba(255, 240, 225, 0.35) 48%, transparent 62%);
}

@media (hover: hover) {
  .save:hover .save__icon {
    filter: brightness(1.05);
  }
}

@media (prefers-reduced-motion: reduce) {
  .save__sweep {
    display: none;
  }
}
