/* =========================================================
   Max's Website — the Record Shelf
   loaded after style.css, which provides --px
   ========================================================= */

body.listening {
  overflow-x: clip;                      /* the rails run edge to edge */
  position: relative;
  min-height: 100vh;
  padding-bottom: 120px;                 /* room for the hi-fi */
  font-family: "Trebuchet MS", sans-serif;
  color: #e8e2d4;
  image-rendering: pixelated;
  background: #1c2541 url("assets/sprites/shelf-felt.png") repeat 0 0 /
    calc(48px * var(--px)) calc(48px * var(--px));
}

.shelf-head {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 26px 16px 0;
}
.back-tag {
  padding: 4px 12px;
  font: 700 13px "Trebuchet MS", sans-serif;
  color: #1c2541;
  text-decoration: none;
  background: #e8e2d4;
  border: 3px solid #0b0f1c;
  box-shadow: 3px 3px 0 #0b0f1c;
}
.back-tag:hover { background: #fff; }
.shelf-title {
  margin: 0;
  font: 700 clamp(22px, 3.4vw, 34px) Georgia, serif;
  letter-spacing: 3px;
  color: #f4d78a;
  text-shadow: 3px 3px 0 #0b0f1c;
}

/* ---------- the CDs, each on a string from the rail ---------- */
.cd-wall {
  position: relative;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr));
  justify-items: center;
  align-items: start;
  gap: 70px 34px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 80px 28px 40px;
}
/* a wooden picture rail above each row (placed by records.js) */
.row-rail {
  position: absolute;
  left: -100vw;
  right: -100vw;
  height: calc(16px * var(--px));
  background: url("assets/sprites/shelf-rail.png") repeat-x 0 0 /
    calc(32px * var(--px)) calc(16px * var(--px));
  pointer-events: none;
}
.record {
  --gap: 34px;                            /* matches RAIL_GAP in records.js */
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0;
  padding-top: var(--len, 40px);
  transform-origin: 50% calc(var(--gap) * -1 + 8px);
  animation: sway var(--sway, 5s) ease-in-out var(--delay, 0s) infinite alternate;
}
@keyframes sway {
  from { transform: rotate(calc(var(--tilt, 1.2deg) * -1)); }
  to   { transform: rotate(var(--tilt, 1.2deg)); }
}
/* the string runs from the rail down to the peg */
.record .string {
  position: absolute;
  top: calc(var(--gap) * -1 + 10px);
  left: calc(50% - 1px);
  width: 3px;
  height: calc(var(--len, 40px) + var(--gap) - 4px);
  background: #d8cdb0;
  box-shadow: 1px 0 0 rgba(0, 0, 0, 0.35);
}
.record .peg {
  position: relative;
  z-index: 2;
  width: calc(4px * var(--px));
  margin-top: -14px;
  margin-bottom: calc(-4px * var(--px));
}
.cd {
  position: relative;
  width: var(--cd, 230px);
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
  filter: drop-shadow(8px 10px 0 rgba(0, 0, 0, 0.4));
  transition: transform 0.15s;
}
.cd:hover, .cd:focus-visible { transform: scale(1.04) rotate(8deg); outline: none; }
.cd:focus-visible { filter: drop-shadow(0 0 0 #f4d78a) drop-shadow(8px 10px 0 rgba(0, 0, 0, 0.4)); }
/* the album art printed on the disc, with the hole in the middle */
.cd .art, .cd .blank {
  position: absolute;
  inset: 4%;
  width: 92%;
  height: 92%;
  border-radius: 50%;
  object-fit: cover;
  image-rendering: auto;
  -webkit-mask: radial-gradient(circle, transparent 0 15.5%, #000 16%);
          mask: radial-gradient(circle, transparent 0 15.5%, #000 16%);
}
.cd .blank { background: conic-gradient(#c9d3dc, #8fa1b3, #dfe6ec, #9aa9b8, #c9d3dc); }
.cd canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  pointer-events: none;
}
.record figcaption {
  max-width: var(--cd, 230px);
  margin-top: 12px;
  padding: 5px 12px 6px;
  text-align: center;
  color: #1c1405;
  background: #f4ecd2;
  border: 3px solid #0b0f1c;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.45);
  transform: rotate(var(--label, -1deg));
}
.record figcaption b { display: block; font: 700 15px Georgia, serif; }
.record figcaption span { font-size: 12px; color: #5c4517; }
.record.playing .cd { animation: none; }
.record.playing figcaption { background: #f4d78a; }

.shelf-empty {
  grid-column: 1 / -1;
  max-width: 600px;
  margin: 40px auto;
  padding: 20px 24px;
  font-size: 16px;
  line-height: 1.55;
  color: #1c1405;
  background: #f4ecd2;
  border: 3px solid #0b0f1c;
}
.shelf-empty code { background: #e8dcb9; padding: 0 4px; }

/* ---------- liner notes ---------- */
.liner {
  width: min(860px, 94vw);
  max-height: 90vh;
  padding: 0;
  color: #1c1405;
  background: #f4ecd2;
  border: 4px solid #0b0f1c;
  box-shadow: 10px 12px 0 rgba(0, 0, 0, 0.5);
}
.liner::backdrop { background: rgba(8, 11, 22, 0.8); }
.liner-inner { position: relative; display: flex; gap: 24px; padding: 24px; }
.liner-cover {
  flex: none;
  width: min(300px, 38vw);
  aspect-ratio: 1;
  object-fit: cover;
  border: 3px solid #0b0f1c;
  background: #1c2541;
  align-self: flex-start;
}
.liner-text { flex: 1; min-width: 0; }
.liner-artist { margin: 0; font-weight: 700; color: #8a5a2c; letter-spacing: 1px; text-transform: uppercase; font-size: 13px; }
.liner-title { margin: 2px 0 4px; font: 700 26px Georgia, serif; }
.liner-meta { margin: 0 0 12px; font-size: 13px; color: #5c4517; }
.liner-tracks { margin: 14px 0 0; padding: 0; list-style: none; max-height: 46vh; overflow-y: auto; }
.liner-tracks li { border-top: 2px dashed #d8cdb0; }
.liner-tracks button {
  display: flex;
  width: 100%;
  gap: 10px;
  padding: 7px 4px;
  font: 15px Georgia, serif;
  text-align: left;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}
.liner-tracks button:hover { background: #e8dcb9; }
.liner-tracks .n { width: 26px; color: #8a5a2c; font: 700 13px "Trebuchet MS", sans-serif; padding-top: 2px; }
.liner-tracks .t { flex: 1; }
.liner-tracks .d { color: #5c4517; font-size: 13px; }
.liner-tracks li.now button { background: #f4d78a; font-weight: 700; }
.liner-close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 34px;
  height: 34px;
  font: 700 22px "Trebuchet MS", sans-serif;
  color: #1c1405;
  background: #e8dcb9;
  border: 3px solid #0b0f1c;
  cursor: pointer;
}

/* ---------- the hi-fi bar ---------- */
.hifi {
  position: fixed;
  left: 50%;
  bottom: 12px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  width: min(1080px, calc(100% - 24px));
  padding: 10px 16px;
  transform: translateX(-50%);
  color: #f4ecd2;
  background: linear-gradient(180deg, #5c3a1a, #3d2410);
  border: 4px solid #0b0f1c;
  box-shadow: 0 0 0 3px #946234 inset, 6px 8px 0 rgba(0, 0, 0, 0.5);
}
.hifi[hidden] { display: none; }
.hifi-disc {
  flex: none;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid #0b0f1c;
  background: #9aa9b8;
}
.hifi-disc img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: auto;
  -webkit-mask: radial-gradient(circle, transparent 0 14%, #000 15%);
          mask: radial-gradient(circle, transparent 0 14%, #000 15%);
}
.hifi.spinning .hifi-disc { animation: spin 3s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.hifi-info { display: flex; flex-direction: column; min-width: 0; flex: 1 1 200px; }
.hifi-title { font: 700 16px Georgia, serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hifi-artist { font-size: 13px; color: #e8c48a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hifi-quality {
  align-self: flex-start;
  margin-top: 3px;
  padding: 0 6px;
  font: 700 11px "Trebuchet MS", sans-serif;
  letter-spacing: 0.5px;
  color: #0b0f1c;
  background: #7fd1a8;
  border: 2px solid #0b0f1c;
}
.hifi-quality:empty { display: none; }
.hifi-controls { display: flex; gap: 6px; }
.hifi-btn {
  display: grid;
  place-items: center;
  min-width: 36px;
  height: 32px;
  padding: 0 10px;
  font: 700 13px "Trebuchet MS", sans-serif;
  color: #3c2c10;
  background: linear-gradient(180deg, #f2d77e, #c79a3a);
  border: 3px solid #0b0f1c;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5);
  cursor: pointer;
}
.hifi-btn.big { min-width: 46px; height: 38px; }
.hifi-btn svg { width: 16px; height: 14px; }
.hifi-btn:hover { background: linear-gradient(180deg, #fbe58a, #e0b84a); }
.hifi-btn:active { transform: translate(2px, 2px); box-shadow: none; }
.hifi-seek { display: flex; align-items: center; gap: 8px; flex: 2 1 220px; font-size: 12px; font-variant-numeric: tabular-nums; }
.hifi-range { flex: 1; accent-color: #f4d78a; }
.hifi-vol { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #e8c48a; }
.hifi-vol input { width: 80px; accent-color: #f4d78a; }

@media (max-width: 760px) {
  .hifi { flex-wrap: wrap; gap: 8px 12px; }
  .hifi-seek { order: 5; flex-basis: 100%; }
  .hifi-vol { display: none; }
  .liner-inner { flex-direction: column; }
  .liner-cover { width: 100%; }
  body.listening { padding-bottom: 170px; }
}

/* ---------- the public shelf: Max's Spotify top five ---------- */
.shelf-note { max-width: 560px; margin: 10px auto 0; text-align: center; color: #f4ecd2; font-size: 15px; }
.shelf-note[hidden] { display: none; }
.record .rank {
  display: block;
  font: 700 13px Georgia, serif;
  font-style: normal;
  color: #8a5a2c;
  letter-spacing: 1px;
}
.liner-repeat, .liner-embed { display: none; }
.liner.spotify .liner-play, .liner.spotify .liner-tracks { display: none; }
.liner.spotify .liner-repeat { display: block; margin: 0 0 12px; font-size: 13px; font-style: italic; color: #5c4517; }
.liner.spotify .liner-embed { display: block; }
.liner-embed iframe { display: block; width: 100%; height: 352px; border: 0; border-radius: 12px; }
.liner-cover[hidden] { display: none; }
