/* ============================================================
   Mood Radio — every mood is just a palette swap on these vars
   ============================================================ */
:root {
  --ink: #f6ece0;
  --muted: rgb(246 236 224 / 0.58);
  --line: rgb(246 236 224 / 0.14);
  --card: rgb(255 255 255 / 0.05);
  --card-hi: rgb(255 255 255 / 0.09);
  --bg-a: #17110c;
  --bg-b: #2a1a0f;
  --glow-a: #f2a43a;
  --glow-b: #4fb0a0;
  --accent: #f2a43a;
  --accent-ink: #1a1206;
  --art-opacity: 0.32;
  --wash: 0.82;
  --display: "Fraunces", ui-serif, Georgia, serif;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 20px;
  --shadow: 0 30px 70px -25px rgb(0 0 0 / 0.75);
}

html[data-mood="saloon"] {
  --bg-a: #17110c; --bg-b: #2c1a0e;
  --glow-a: #f2a43a; --glow-b: #4fb0a0;
  --accent: #f5b13f; --accent-ink: #1a1206;
}
html[data-mood="roadtrip"] {
  --bg-a: #0b1220; --bg-b: #1d2f4d;
  --glow-a: #ff7a45; --glow-b: #4d8bd6;
  --accent: #ff8a52; --accent-ink: #170a04;
  --ink: #eaf1ff; --muted: rgb(234 241 255 / 0.6);
  --line: rgb(234 241 255 / 0.14);
}
html[data-mood="relax"] {
  --bg-a: #08090f; --bg-b: #1d1233;
  --glow-a: #c9a227; --glow-b: #6a4bb0;
  --accent: #d8b348; --accent-ink: #15100a;
  --ink: #ece9f5; --muted: rgb(236 233 245 / 0.58);
  --line: rgb(236 233 245 / 0.12);
  --art-opacity: 0.26;
}
html[data-mood="morning"] {
  --bg-a: #fdf6ea; --bg-b: #f6e2c6;
  --glow-a: #e79a35; --glow-b: #cfd9a0;
  --accent: #c2661b; --accent-ink: #fff6ea;
  --ink: #2b2015; --muted: rgb(43 32 21 / 0.62);
  --line: rgb(43 32 21 / 0.16);
  --card: rgb(255 255 255 / 0.45);
  --card-hi: rgb(255 255 255 / 0.7);
  --art-opacity: 0.2;
  --wash: 0.88;
  --shadow: 0 26px 60px -28px rgb(90 60 20 / 0.55);
}
html[data-mood="retro"] {
  --bg-a: #191108; --bg-b: #3d2415;
  --glow-a: #e0b15a; --glow-b: #a8422b;
  --accent: #e3b45f; --accent-ink: #1d1305;
  --ink: #f4e8d5; --muted: rgb(244 232 213 / 0.6);
}

*, *::before, *::after { box-sizing: border-box; }

/* display:grid on .player would otherwise win against the hidden attribute */
[hidden] { display: none !important; }

body {
  margin: 0;
  overflow-x: hidden; /* the backdrop deliberately overflows; the page must not */
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg-a);
  -webkit-font-smoothing: antialiased;
  transition: color 0.6s ease, background-color 0.6s ease;
}

.sr {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- backdrop ---------- */
.backdrop { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: var(--bg-a); }
.backdrop__art {
  position: absolute; inset: -12%;
  background-size: cover; background-position: center;
  filter: blur(70px) saturate(1.5);
  opacity: var(--art-opacity);
  transform: scale(1.15);
  transition: background-image 0.8s ease, opacity 0.8s ease;
}
.backdrop__wash {
  position: absolute; inset: 0;
  background:
    radial-gradient(60% 55% at 15% 10%, color-mix(in srgb, var(--glow-a) 42%, transparent), transparent 70%),
    radial-gradient(55% 50% at 85% 85%, color-mix(in srgb, var(--glow-b) 38%, transparent), transparent 70%),
    linear-gradient(160deg, var(--bg-a), var(--bg-b));
  opacity: var(--wash);
  transition: opacity 0.6s ease;
  animation: drift 26s ease-in-out infinite alternate;
}
@keyframes drift {
  from { background-position: 0% 0%, 100% 100%, 0 0; }
  to   { background-position: 12% 8%, 88% 92%, 0 0; }
}
.backdrop__grain {
  position: absolute; inset: 0; opacity: 0.16; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- shell ---------- */
.shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: clamp(20px, 4vw, 46px) clamp(18px, 4vw, 40px) 24px;
}

/* ---------- mood picker ---------- */
.picker {
  min-height: min(86dvh, 780px);
  display: flex; flex-direction: column; justify-content: center;
  gap: clamp(26px, 4vw, 44px);
}
.eyebrow {
  margin: 0 0 14px;
  font-size: 0.74rem; letter-spacing: 0.34em; text-transform: uppercase;
  color: var(--accent); font-weight: 600;
}
.picker__title {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2.6rem, 7.4vw, 5.1rem);
  line-height: 0.98;
  letter-spacing: -0.02em;
}
.picker__title em { font-style: italic; font-weight: 800; color: var(--accent); }
.picker__sub { margin: 18px 0 0; color: var(--muted); font-size: 1.05rem; max-width: 40ch; }
.picker__foot { margin: 0; color: var(--muted); font-size: 0.85rem; }

.moods {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}
.mood {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: flex-end; gap: 6px;
  min-height: 190px; padding: 20px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card);
  backdrop-filter: blur(14px);
  color: inherit; text-align: left; font: inherit; cursor: pointer;
  transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1), background 0.35s ease, border-color 0.35s ease;
}
.mood::after {
  content: ""; position: absolute; inset: 0; opacity: 0.5;
  background: radial-gradient(120% 90% at 50% -20%, var(--m-a), transparent 68%);
  transition: opacity 0.35s ease;
}
.mood:hover, .mood:focus-visible {
  transform: translateY(-6px);
  background: var(--card-hi);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  outline: none;
}
.mood:hover::after, .mood:focus-visible::after { opacity: 0.85; }
.mood__icon { position: relative; font-size: 1.7rem; line-height: 1; margin-bottom: auto; }
.mood__name { position: relative; font-family: var(--display); font-size: 1.5rem; font-weight: 600; letter-spacing: -0.01em; }
.mood__line { position: relative; margin: 0; color: var(--muted); font-size: 0.85rem; line-height: 1.45; }
.mood__count { position: relative; font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); }

/* ---------- player ---------- */
.player {
  display: grid;
  grid-template-columns: minmax(0, 1.62fr) minmax(280px, 0.8fr);
  grid-template-areas: "rail rail" "stage queue";
  gap: clamp(20px, 3vw, 36px);
  align-items: start;
}
.rail { grid-area: rail; min-width: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.rail__btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card);
  color: var(--muted); font: inherit; font-size: 0.9rem; font-weight: 500;
  cursor: pointer; transition: all 0.25s ease;
}
.rail__btn:hover { color: var(--ink); border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.rail__btn[aria-current="true"] {
  background: var(--accent); color: var(--accent-ink);
  border-color: transparent; font-weight: 600;
}

.stage {
  grid-area: stage; min-width: 0;
  display: grid; grid-template-columns: minmax(0, 290px) minmax(0, 1fr);
  gap: clamp(20px, 3vw, 34px);
  align-items: center;
}
.cover {
  position: relative; aspect-ratio: 1; width: 100%;
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.cover img {
  position: relative; z-index: 2;
  width: 100%; height: 100%; object-fit: cover;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--line);
}
/* the record peeking out from behind the sleeve - it must not reach far enough
   right to sit on top of the now-playing text */
.cover__spin {
  position: absolute; z-index: 1; inset: 9% -26% 9% auto;
  aspect-ratio: 1; height: 82%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--accent) 85%, #000) 0 7%, #100c08 7.5% 12%, transparent 12.5%),
    repeating-radial-gradient(circle at 50% 50%, #17110d 0 2px, #241a12 2px 4px);
  box-shadow: var(--shadow);
  transition: transform 0.6s ease;
}
body.is-playing .cover__spin { animation: spin 5.5s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.cover.is-loading img { opacity: 0.85; }

/* keeps the spinning record from ever painting over the copy beside it */
.stage__now { position: relative; z-index: 2; min-width: 0; }

.now__mood {
  margin: 0 0 10px;
  font-size: 0.72rem; letter-spacing: 0.3em; text-transform: uppercase;
  color: var(--accent); font-weight: 600;
}
.now__title {
  margin: 0;
  font-family: var(--display); font-weight: 600;
  font-size: clamp(1.6rem, 3.4vw, 2.6rem); line-height: 1.08; letter-spacing: -0.02em;
}
.now__title, .now__artist, .now__album {
  display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden;
}
.now__title { -webkit-line-clamp: 2; overflow-wrap: anywhere; }
.now__artist { margin: 10px 0 0; font-size: 1.02rem; font-weight: 500; -webkit-line-clamp: 1; }
.now__album { margin: 4px 0 0; color: var(--muted); font-size: 0.88rem; -webkit-line-clamp: 1; }

.now__src {
  display: inline-block; margin-top: 12px;
  color: var(--muted); font-size: 0.78rem; text-decoration: none;
  border-bottom: 1px solid var(--line); padding-bottom: 2px;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.now__src:hover { color: var(--accent); border-color: var(--accent); }

.scrub { display: flex; align-items: center; gap: 12px; margin: 20px 0 18px; }
.scrub__t {
  flex: 0 0 auto; min-width: 46px;
  font-variant-numeric: tabular-nums; font-size: 0.78rem; color: var(--muted);
}
.scrub__t:last-child { text-align: right; }
.scrub__bar {
  position: relative; flex: 1; height: 22px; cursor: pointer;
  display: flex; align-items: center;
}
.scrub__bar::before {
  content: ""; position: absolute; left: 0; right: 0; height: 4px;
  border-radius: 999px; background: var(--line);
}
.scrub__fill {
  position: absolute; left: 0; height: 4px; width: 0;
  border-radius: 999px; background: var(--accent);
}
.scrub__knob {
  position: absolute; left: 0; width: 12px; height: 12px; margin-left: -6px;
  border-radius: 50%; background: var(--accent);
  opacity: 0; transition: opacity 0.2s ease;
}
.scrub__bar:hover .scrub__knob, .scrub__bar:focus-visible .scrub__knob { opacity: 1; }
.scrub__bar:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; border-radius: 4px; }

.controls { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.btn {
  flex: none;
  display: inline-grid; place-items: center;
  width: 42px; height: 42px; padding: 0;
  border-radius: 50%; border: 1px solid var(--line);
  background: var(--card); color: var(--ink);
  cursor: pointer; transition: all 0.2s ease;
}
.btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; }
.btn:hover { background: var(--card-hi); border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.btn--play {
  width: 60px; height: 60px;
  background: var(--accent); color: var(--accent-ink); border-color: transparent;
}
.btn--play svg { width: 24px; height: 24px; fill: currentColor; stroke: none; }
.btn--play:hover { background: var(--accent); filter: brightness(1.08); transform: scale(1.04); }
.btn[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }
.ico-pause, .ico-mute { display: none; }
body.is-playing .ico-play { display: none; }
body.is-playing .ico-pause { display: block; }
body.is-muted .ico-vol { display: none; }
body.is-muted .ico-mute { display: block; }

.vol { display: flex; align-items: center; gap: 8px; margin-left: auto; }
#volume {
  width: 76px; height: 4px; appearance: none; -webkit-appearance: none;
  background: var(--line); border-radius: 999px; cursor: pointer;
}
#volume::-webkit-slider-thumb {
  -webkit-appearance: none; width: 13px; height: 13px;
  border-radius: 50%; background: var(--accent); border: none;
}
#volume::-moz-range-thumb { width: 13px; height: 13px; border: none; border-radius: 50%; background: var(--accent); }

.hint { margin: 16px 0 0; min-height: 1.2em; font-size: 0.82rem; color: var(--muted); }

/* ---------- queue ---------- */
.queue {
  grid-area: queue; min-width: 0;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); backdrop-filter: blur(14px);
  padding: 18px 8px 10px 18px;
}
.queue__head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding-right: 10px; }
.queue__head h3 { margin: 0; font-family: var(--display); font-size: 1.1rem; font-weight: 600; }
.queue__count { font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.queue__list {
  list-style: none; margin: 12px 0 0; padding: 0 8px 0 0;
  max-height: min(52dvh, 430px); overflow-y: auto; scrollbar-width: thin;
}
.queue__list::-webkit-scrollbar { width: 6px; }
.queue__list::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; }
.row {
  display: grid; grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center; gap: 12px;
  width: 100%; padding: 9px 10px;
  border: 0; border-radius: 12px; background: none;
  color: inherit; font: inherit; text-align: left; cursor: pointer;
  transition: background 0.2s ease;
}
.row:hover { background: var(--card-hi); }
.row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.row__n { font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.row__t { min-width: 0; }
.row__title { display: block; font-size: 0.9rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row__artist { display: block; font-size: 0.76rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row__d { font-size: 0.74rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.row[aria-current="true"] .row__title { color: var(--accent); }
.row[aria-current="true"] .row__n { color: var(--accent); }
.row.is-dead { opacity: 0.4; }

/* ---------- misc ---------- */
/* the YouTube API replaces this div with the iframe itself, keeping the id */
#yt {
  position: absolute; inset: 0; z-index: 0;
  width: 100% !important; height: 100% !important;
  opacity: 0; pointer-events: none; border: 0;
  border-radius: var(--radius);
}
.credits {
  padding: 10px clamp(18px, 4vw, 40px) 22px;
  text-align: center; font-size: 0.76rem; color: var(--muted);
}

@media (max-width: 900px) {
  .player { grid-template-columns: minmax(0, 1fr); grid-template-areas: "rail" "stage" "queue"; }
  /* a wrapped rail pushes the player down the page - let it swipe instead */
  .rail {
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
    margin-inline: calc(-1 * clamp(18px, 4vw, 40px));
    padding-inline: clamp(18px, 4vw, 40px);
  }
  .rail::-webkit-scrollbar { display: none; }
  .rail__btn { flex: none; }
  .stage { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .cover { max-width: 260px; }
  .cover__spin { display: none; }
  .scrub { margin: 22px 0 16px; }
  .controls { justify-content: center; }
  .vol { margin-left: 0; }
  .queue__list { max-height: 46dvh; }
}
@media (max-width: 560px) {
  .moods { grid-template-columns: 1fr 1fr; }
  .mood { min-height: 150px; padding: 16px; }
  .mood__name { font-size: 1.25rem; }
  .mood__line { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0.01ms !important; }
}
