/* Record Crate — a dark listening room; the records carry all the color.
   Floating controls are liquid glass; everything else stays matte. */

:root {
  color-scheme: dark;
  --bg: #0F1013;
  --ink: #F2F0EA;
  --ink-2: rgba(242, 240, 234, .55);
  --ink-3: rgba(242, 240, 234, .32);
  --pill-bg: rgba(255, 255, 255, .07);
  --player-ink: #F4F2EC;
  --font: system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI", Roboto,
          "Helvetica Neue", Arial, "Microsoft JhengHei", "Yu Gothic UI", "Malgun Gothic", sans-serif;
  /* fluid UI scale — chrome grows with viewport width so it reads bigger on wide screens */
  --ui:   clamp(13px, 1.25vw, 18px);
  --hbar: clamp(72px, 7.4vw, 106px);
  --ctrl: clamp(44px, 4.2vw, 60px);
  --ico:  clamp(20px, 1.9vw, 27px);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font-family: inherit; }
[hidden] { display: none !important; }
img { user-select: none; }

#app { position: fixed; inset: 0; }

/* room light: a cool glow from above, floor falling into shadow */
#app::before {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(110% 70% at 50% -12%, rgba(140, 150, 170, .10), transparent 60%),
    linear-gradient(rgba(0, 0, 0, 0) 62%, rgba(0, 0, 0, .42));
  pointer-events: none;
}

/* ---------- liquid glass (floating controls only) ---------- */
.segmented, .search.open, .player, .detail .detail-btn {
  background: linear-gradient(145deg, rgba(255, 255, 255, .13), rgba(255, 255, 255, .05));
  backdrop-filter: blur(24px) saturate(1.5);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .17),
    inset 0 0 0 1px rgba(255, 255, 255, .07),
    0 16px 40px -16px rgba(0, 0, 0, .6);
}

/* ---------- top bar ---------- */
.topbar {
  position: absolute; top: 0; left: 0; right: 0;
  height: var(--hbar);
  display: flex; align-items: center;
  gap: clamp(4px, .5vw, 10px);
  padding: 0 clamp(14px, 1.6vw, 28px);
  z-index: 40;
}
.topbar::before {
  content: "";
  position: absolute; inset: 0 0 auto; height: 130px;
  background: linear-gradient(rgba(6, 7, 9, .55), transparent);
  pointer-events: none; z-index: -1;
}
.brand {
  height: clamp(40px, 4.6vw, 64px); width: auto;
  margin-left: clamp(6px, .8vw, 14px);
  pointer-events: none; user-select: none;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, .5));
  opacity: 0; transition: opacity .5s ease;
}
.brand.ready, .brand-m.ready { opacity: 1; }

.icon-btn {
  width: var(--ctrl); height: var(--ctrl);
  display: grid; place-items: center;
  border: 0; background: transparent; color: inherit;
  border-radius: 50%;
  cursor: pointer;
  transition: background .2s, transform .15s;
  flex: 0 0 auto;
}
.icon-btn:hover { background: rgba(255, 255, 255, .09); }
.icon-btn:active { transform: scale(.9); }
.icon-btn svg { width: var(--ico); height: var(--ico); }

.segmented {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  border-radius: 999px;
  padding: 3px;
}
.segmented button {
  position: relative; z-index: 1;
  border: 0; background: none;
  font: 500 var(--ui)/1 var(--font);
  padding: .72em 1.4em;
  border-radius: 999px;
  color: var(--ink-2);
  cursor: pointer;
  transition: color .25s;
}
.segmented button[aria-selected="true"] { color: #fff; }
.segmented-thumb {
  position: absolute; top: 3px; bottom: 3px;
  background: linear-gradient(160deg, rgba(255, 255, 255, .22), rgba(255, 255, 255, .12));
  border-radius: 999px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 2px 8px rgba(0, 0, 0, .35);
  transition: left .32s cubic-bezier(.3, .8, .3, 1), width .32s cubic-bezier(.3, .8, .3, 1);
}

/* order toggle — a pill that flips newest↔oldest */
.sort-btn {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: clamp(6px, .7vw, 9px);
  height: var(--ctrl); padding: 0 clamp(13px, 1.4vw, 20px) 0 clamp(11px, 1.2vw, 16px);
  border: 0; border-radius: 999px;
  background: var(--pill-bg);
  color: var(--ink);
  font: 500 var(--ui)/1 var(--font);
  cursor: pointer;
  transition: background .2s, transform .15s;
}
.sort-btn:hover { background: rgba(255, 255, 255, .12); }
.sort-btn:active { transform: scale(.94); }
.sort-ico { width: var(--ico); height: var(--ico); transform-origin: 50% 50%; }
.sort-label { letter-spacing: .01em; white-space: nowrap; }

.search {
  margin-left: clamp(4px, .5vw, 8px);
  display: flex; align-items: center;
  border-radius: 999px;
  transition: background .25s;
}
.search input {
  width: 0; opacity: 0;
  border: 0; background: none; outline: none;
  font: 400 var(--ui)/1.2 var(--font);
  color: var(--ink);
  padding: 0;
  transition: width .32s cubic-bezier(.3, .8, .3, 1), opacity .2s, padding .32s;
}
.search input::placeholder { color: var(--ink-3); }
.search.open input { width: clamp(150px, 17vw, 240px); opacity: 1; padding: 0 2px 0 clamp(12px, 1.3vw, 18px); }

/* ---------- year filter + mobile logo (sits below the header, over the crate) ---------- */
.cratetop {
  position: absolute; top: var(--hbar); left: 0; right: 0;
  z-index: 35;
  display: flex; flex-direction: column; align-items: center;
  gap: clamp(10px, 1.4vw, 18px);
  padding: clamp(4px, 1vw, 14px) 12px 0;
  pointer-events: none;
  transition: opacity .45s ease;
}
.cratetop > * { pointer-events: auto; }
.brand-m {
  display: none; width: auto;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, .5));
  opacity: 0; transition: opacity .5s ease;
}
.yearbar {
  display: flex; align-items: center;
  gap: clamp(3px, .4vw, 7px);
  padding: clamp(3px, .35vw, 5px);
  border-radius: 999px;
  background: rgba(255, 255, 255, .06);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .09), inset 0 0 0 1px rgba(255, 255, 255, .05);
  max-width: calc(100vw - 20px);
  overflow-x: auto;
  scrollbar-width: none;
}
.yearbar::-webkit-scrollbar { display: none; }
.year-chip {
  flex: 0 0 auto;
  border: 0; background: none;
  color: var(--ink-2);
  font: 600 var(--ui)/1 var(--font);
  padding: .6em 1.05em;
  border-radius: 999px;
  cursor: pointer; white-space: nowrap;
  transition: color .2s, background .2s;
}
.year-chip:hover { color: var(--ink); }
.year-chip[aria-selected="true"] {
  color: #fff;
  background: linear-gradient(160deg, rgba(255, 255, 255, .22), rgba(255, 255, 255, .1));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2), 0 2px 8px rgba(0, 0, 0, .3);
}
/* the year filter is docked at the bottom of the crate, just above the player */
.yeardock {
  position: fixed; left: 50%;
  bottom: calc(clamp(16px, 2.2vw, 30px) + clamp(84px, 7.8vw, 112px) + clamp(12px, 1.6vw, 20px));
  transform: translateX(-50%);
  z-index: 35;
  display: flex; justify-content: center;
  max-width: calc(100vw - 20px);
  pointer-events: none;
  transition: opacity .45s ease;
}
.yeardock > * { pointer-events: auto; }

/* ---------- the crate ---------- */
.stage {
  position: absolute; inset: 0;
  cursor: grab;
  touch-action: pan-y;
  z-index: 10;
  /* keep the 3D slabs from compositing above sibling layers (detail/list views) */
  contain: paint;
}
.stage.dragging, .stage.dragging * { cursor: grabbing !important; }
.track { position: absolute; inset: 0; opacity: 0; }
#app:not(.is-loading) .track { opacity: 1; }

.item {
  position: absolute; left: 0; top: 50%;
  border: 0; background: none; padding: 0;
  cursor: pointer;
  perspective: 1700px;
  will-change: transform, visibility;
}
.item:focus { outline: none; }
.item:focus-visible { outline: 2px solid rgba(255, 255, 255, .85); outline-offset: 10px; border-radius: 6px; }

.lift { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; will-change: transform; }

.slab {
  position: absolute; inset: 0;
  transform-style: preserve-3d;
  transform-origin: left center;
  will-change: transform;
}
.face { position: absolute; inset: 0; backface-visibility: hidden; }
.face-front {
  overflow: hidden;
  /* square left edge butts flush against the spine; sit a hair forward to avoid z-fighting at the join */
  border-radius: 0 6px 6px 0;
  transform: translateZ(0.5px);
  background: #1B1D21;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .09);
}
.face-front img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
  pointer-events: none;
}
/* sleeve sheen + edge shading, kept quiet on dark */
.face-front::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  background:
    linear-gradient(100deg, rgba(255, 255, 255, .10), transparent 22%),
    linear-gradient(-85deg, rgba(0, 0, 0, .22), transparent 15%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06);
  pointer-events: none;
}

/* spine: faces the viewer (plane sits behind the cover's left edge) */
.spine {
  position: absolute; top: 0; bottom: 0; left: 0;
  width: var(--thick, 28px);
  transform-origin: left center;
  overflow: hidden;
  padding: 13px 2px;
  display: flex;
  justify-content: center;
  gap: 1px;
  box-shadow: inset -7px 0 9px -7px rgba(0, 0, 0, .45), inset 0 0 0 1px rgba(255, 255, 255, .05);
}
/* hinge the spine at the cover's left edge (z=0) and let it recede by --thick.
   the earlier translateX(-100%) recessed the whole panel behind the cover, opening a gap. */
.spine-latin { transform: rotateY(-90deg) rotate(180deg); }
.spine-cjk   { transform: rotateY(-90deg) translateX(-100%); }
.spine b, .spine span {
  display: block;
  writing-mode: vertical-rl;
  white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  max-height: 100%;
  line-height: 1.1;
}
/* fonts track the spine thickness so both columns stay legible on narrow (mobile) spines */
.spine b { font-weight: 700; font-size: min(11.5px, (var(--thick, 28px) - 5px) * 0.47); letter-spacing: .045em; }
.spine span { font-weight: 400; font-size: min(10px, (var(--thick, 28px) - 5px) * 0.38); opacity: .78; letter-spacing: .04em; }

.item-shadow {
  position: absolute; left: -8%; right: -26%; bottom: -8.5%;
  height: 13%;
  background: radial-gradient(48% 50% at 38% 50%, rgba(0, 0, 0, .65), rgba(0, 0, 0, 0) 74%);
  transform-origin: left center;
  will-change: transform, opacity;
  pointer-events: none;
}

/* ---------- shared: pills & rows ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1.5px solid color-mix(in srgb, currentColor 50%, transparent);
  background: transparent; color: inherit;
  border-radius: 999px;
  padding: 10px 26px;
  font: 600 13px/1 var(--font);
  cursor: pointer;
  transition: background .22s, color .22s, border-color .22s, transform .15s;
}
.pill svg { width: 13px; height: 13px; }
.pill:hover { background: var(--on-flood, var(--ink)); border-color: var(--on-flood, var(--ink)); color: var(--flood, var(--bg)); }
.pill:active { transform: scale(.96); }

.rows { list-style: none; margin: 0; padding: 0; }
.row {
  display: grid;
  grid-template-columns: 34px 1fr max-content;
  align-items: center; gap: 14px;
  width: 100%;
  border: 0; background: none; color: inherit;
  text-align: left;
  padding: 11px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .18s;
}
.row:hover { background: color-mix(in srgb, currentColor 8%, transparent); }
.row.playing { background: color-mix(in srgb, currentColor 12%, transparent); }
.row-num {
  position: relative;
  font: 500 12px/1 var(--font);
  opacity: .45;
  font-variant-numeric: tabular-nums;
  display: grid; place-items: center;
  width: 22px; height: 16px;
}
.row-num svg { width: 11px; height: 11px; display: none; }
.row-num .eq-bars { display: none; }
.row:hover .num-text { display: none; }
.row:hover .row-num svg { display: block; }
.row:hover .row-num { opacity: .9; }
.row.playing .num-text { display: none; }
.row.playing .row-num .eq-bars { display: flex; }
.row.playing .row-num { opacity: .9; }
.row.playing:hover .row-num .eq-bars { display: none; }
.row-main { min-width: 0; }
.row-title {
  font: 600 13.5px/1.3 var(--font);
  letter-spacing: -.005em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row-sub {
  display: block;
  font: 400 11px/1.3 var(--font);
  opacity: .55;
  margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row-album {
  font: 400 12px/1.3 var(--font);
  opacity: .5;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  justify-self: start;
  border: 0; background: none; color: inherit; padding: 0; cursor: pointer;
  text-align: left;
}
.row-album:hover { opacity: .85; text-decoration: underline; }
.row-dur { font: 400 12px/1 var(--font); opacity: .5; font-variant-numeric: tabular-nums; }
.rows-footer {
  text-align: center;
  font: 600 10px/1.6 var(--font);
  letter-spacing: .15em;
  text-transform: uppercase;
  opacity: .45;
  margin: 18px 0 0;
}

/* ---------- detail view ---------- */
.detail {
  position: fixed; inset: 0;
  z-index: 45;
  background: var(--flood, #333);
  color: var(--on-flood, #fff);
  will-change: clip-path;
  transform: translateZ(0);
}
.detail-btn {
  position: absolute; top: clamp(16px, 2vw, 28px);
  display: inline-flex; align-items: center; gap: clamp(7px, .8vw, 11px);
  height: var(--ctrl); padding: 0 clamp(16px, 1.7vw, 24px);
  border: 0; border-radius: 999px;
  color: inherit; text-decoration: none;
  font: 600 var(--ui)/1 var(--font);
  letter-spacing: .01em;
  cursor: pointer;
  z-index: 5;
  transition: transform .15s, filter .2s;
}
.detail-btn:hover { filter: brightness(1.2); }
.detail-btn:active { transform: scale(.94); }
.detail-btn svg { width: var(--ico); height: var(--ico); flex: 0 0 auto; }
.detail-back { left: clamp(16px, 2vw, 28px); }
.detail-spotify { right: clamp(16px, 2vw, 28px); }

.detail-inner {
  display: grid;
  grid-template-columns: minmax(320px, 44%) 1fr;
  height: 100%;
  padding: 68px clamp(28px, 6vw, 92px) 92px;
  gap: clamp(24px, 4.5vw, 76px);
  align-items: center;
}
.detail-left {
  display: flex; flex-direction: column;
  align-items: center; text-align: center;
}
.detail-art {
  width: min(46vh, 100%);
  aspect-ratio: 1;
  border-radius: 10px;
}
.detail-art img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  border-radius: inherit;
  /* shadow rides on the img so the empty slot is invisible while the cover flies in */
  box-shadow: 0 34px 80px -22px rgba(0, 0, 0, .55), 0 10px 26px rgba(0, 0, 0, .22);
}
#dTitle {
  font: 700 clamp(20px, 2.3vw, 29px)/1.15 var(--font);
  letter-spacing: -.02em;
  margin: 22px 0 0;
  max-width: 26ch;
}
#dArtist { font: 400 15px/1.3 var(--font); margin: 7px 0 0; opacity: .82; }
.meta {
  font: 600 10.5px/1 var(--font);
  letter-spacing: .15em;
  text-transform: uppercase;
  opacity: .5;
  margin: 12px 0 0;
}
.detail-actions { display: flex; gap: 12px; margin-top: 24px; }

.detail-right { min-width: 0; }
.detail-right .rows {
  max-height: min(68vh, 760px);
  overflow-y: auto;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(transparent, #000 20px, #000 calc(100% - 20px), transparent);
  mask-image: linear-gradient(transparent, #000 20px, #000 calc(100% - 20px), transparent);
}
.detail-right .rows::-webkit-scrollbar { display: none; }

/* ---------- playlist view ---------- */
.listview {
  position: absolute; inset: 0;
  z-index: 36; /* above the crate + year bar (35), below the header (40) */
  background: var(--bg);
  --flood: var(--bg);
  --on-flood: var(--ink);
  overflow-y: auto;
  padding: 96px clamp(20px, 12vw, 200px) 130px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .22) transparent;
}
.listview::-webkit-scrollbar { width: 8px; }
.listview::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .16); border-radius: 4px; }
.listview::-webkit-scrollbar-track { background: transparent; }
.list-head {
  display: flex; align-items: center; gap: 22px;
  margin-bottom: 26px;
  flex-wrap: wrap;
}
.list-head img {
  width: 112px; height: 112px;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 18px 44px -14px rgba(0, 0, 0, .6);
}
.list-head-text { min-width: 0; }
.list-head h1 {
  font: 700 clamp(20px, 2.6vw, 30px)/1.12 var(--font);
  letter-spacing: -.02em;
  margin: 0;
}
.list-sub { font: 400 13px/1.4 var(--font); color: var(--ink-2); margin: 7px 0 0; }
.list-actions { margin-left: auto; display: flex; gap: 10px; }
.listview .row { grid-template-columns: 30px 42px 1fr minmax(80px, .55fr) max-content; }
.row-thumb { width: 42px; height: 42px; border-radius: 8px; object-fit: cover; background: #1B1D21; }

/* ---------- player ---------- */
.player {
  position: fixed; left: 50%; bottom: clamp(16px, 2.2vw, 30px);
  transform: translateX(-50%);
  display: flex; align-items: center; gap: clamp(6px, .9vw, 13px);
  height: clamp(84px, 7.8vw, 112px);
  /* extra bottom padding lifts the row clear of the progress bar */
  padding: 0 clamp(12px, 1.4vw, 20px) clamp(12px, 1.3vw, 17px);
  border-radius: clamp(20px, 2vw, 28px);
  color: var(--player-ink);
  background: linear-gradient(150deg, rgba(48, 51, 58, .62), rgba(20, 22, 26, .55));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .16),
    inset 0 0 0 1px rgba(255, 255, 255, .07),
    0 28px 60px -18px rgba(0, 0, 0, .78);
  z-index: 60;
  width: min(660px, calc(100vw - clamp(20px, 4vw, 48px)));
}
.player .icon-btn { color: var(--player-ink); }
.player .icon-btn:hover { background: rgba(255, 255, 255, .1); }
.player-thumb {
  width: clamp(54px, 5.4vw, 74px); height: clamp(54px, 5.4vw, 74px);
  border-radius: clamp(11px, 1.1vw, 15px);
  object-fit: cover; background: #1B1D21; flex: 0 0 auto;
}
.player-titles {
  display: flex; flex-direction: column; gap: clamp(2px, .3vw, 5px);
  min-width: 0; flex: 1;
  padding: 0 clamp(4px, .7vw, 10px);
}
.player-titles span:first-child {
  font: 600 clamp(15px, 1.4vw, 19px)/1.25 var(--font);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.player-titles span:last-child {
  font: 400 clamp(12px, 1.1vw, 15px)/1.2 var(--font);
  opacity: .55;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#btnPlay .ic-pause { display: none; }
.player.playing #btnPlay .ic-play { display: none; }
.player.playing #btnPlay .ic-pause { display: block; }
.player-progress {
  position: absolute; left: clamp(20px, 2vw, 28px); right: clamp(20px, 2vw, 28px);
  bottom: clamp(9px, 1vw, 13px);
  height: clamp(2px, .25vw, 3px); border-radius: 3px;
  background: rgba(255, 255, 255, .13);
  overflow: hidden;
}
.player-progress i {
  display: block; height: 100%; width: 0;
  background: rgba(255, 255, 255, .65);
  border-radius: 2px;
}

/* equalizer bars */
.eq-bars { display: flex; align-items: flex-end; gap: 2px; height: 13px; width: 14px; }
.eq-bars i { flex: 1; background: currentColor; border-radius: 1px; height: 32%; }
.playing .eq-bars i, .row.playing .eq-bars i { animation: eq .9s ease-in-out infinite; }
.playing .eq-bars i:nth-child(2), .row.playing .eq-bars i:nth-child(2) { animation-duration: .68s; animation-delay: -.2s; }
.playing .eq-bars i:nth-child(3), .row.playing .eq-bars i:nth-child(3) { animation-duration: 1.05s; animation-delay: -.45s; }
@keyframes eq { 0%, 100% { height: 32%; } 50% { height: 96%; } }
.row .eq-bars { height: 11px; width: 13px; }

/* ---------- flight layer ---------- */
#flight { position: fixed; inset: 0; z-index: 70; pointer-events: none; }
.fly { position: absolute; perspective: 1700px; }
.fly .slab { position: absolute; inset: 0; }

/* ---------- loading ---------- */
.is-loading .topbar, .is-loading .player, .is-loading .cratetop, .is-loading .yeardock { opacity: 0; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .listview .row { grid-template-columns: 26px 42px 1fr max-content; }
  .row-album { display: none; }
  .listview { padding-inline: 16px; }
}
@media (max-width: 820px) {
  .detail { overflow-y: auto; }
  .detail-inner {
    grid-template-columns: 1fr;
    height: auto; min-height: 100%;
    align-items: start;
    padding: clamp(84px, 15vw, 124px) 20px 150px;
    gap: 30px;
  }
  .detail-art { width: min(58vw, 320px); }
  .detail-right .rows { max-height: none; mask-image: none; -webkit-mask-image: none; }
}
@media (max-width: 560px) {
  .brand { display: none; }                                   /* header logo hidden on phones… */
  .brand-m { display: block; height: clamp(34px, 10vw, 50px); } /* …and shown over the crate */
  .sort-label { display: none; }
  .sort-btn { padding: 0; width: var(--ctrl); justify-content: center; }
  .search.open input { width: clamp(92px, 32vw, 150px); }
}
@media (prefers-reduced-motion: reduce) {
  .eq-bars i { animation: none !important; }
  .segmented-thumb, .search input, .brand, .brand-m, .cratetop { transition: none; }
}
