:root {
  --bg: #231a19;
  --text: #ece5e1;
  --muted: #8d807c;
  --faint: #5f5552;
  --card: #2f2523;
  --bar-bg: rgba(255, 255, 255, 0.18);
  --bar-fill: #f2ece8;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 820px;
  margin: 0 auto;
  padding: clamp(32px, 10vh, 96px) 16px 48px;
}

/* ── text ─────────────────────────────────────────── */

.title {
  margin: 0 0 6px;
  font-size: clamp(22px, 4.2vw, 34px);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.title::before {
  content: "## ";
  color: var(--muted);
}

.subtitle {
  margin: 0 0 20px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  opacity: 0.85;
}

/* ── player card ──────────────────────────────────── */

.player {
  position: relative;
  display: flex;
  gap: 18px;
  align-items: stretch;
  padding: 14px;
  border-radius: var(--radius);
  overflow: hidden;
  isolation: isolate;
  background: var(--card);
  color: var(--text);
  text-decoration: none;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  animation: rise 0.5s ease both;
}
.player[hidden] { display: none; }

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* blurred album-art glow behind everything */
.ambient {
  position: absolute;
  inset: -40%;
  z-index: -2;
  background-size: cover;
  background-position: center;
  filter: blur(48px) saturate(1.5);
  opacity: 0.85;
  transition: opacity 0.6s ease, background-image 0.6s ease;
  animation: drift 24s ease-in-out infinite alternate;
}
.player::after {
  /* darken so text stays readable */
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(90deg, rgba(20, 14, 13, 0.55), rgba(20, 14, 13, 0.25));
}
body.no-ambient .ambient { opacity: 0; }

@keyframes drift {
  from { transform: rotate(0deg) scale(1); }
  to   { transform: rotate(14deg) scale(1.15); }
}
@media (prefers-reduced-motion: reduce) {
  .ambient, .player { animation: none; }
}

/* film grain */
.grain {
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: 0.18;
  pointer-events: none;
  background-image: 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='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

.art {
  flex: none;
  width: 100px;
  height: 100px;
  border-radius: 6px;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 2px 0;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.meta { min-width: 0; }

.track {
  font-size: 17px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.artist {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.artist .by { color: var(--muted); }
#artist {
  border-bottom: 1px dotted rgba(255, 255, 255, 0.35);
}

.logo {
  flex: none;
  width: 22px;
  height: 22px;
  color: var(--text);
  opacity: 0.9;
}

.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
}
.time {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 3.5ch;
}
.time:last-child { text-align: right; }
.play {
  width: 20px;
  height: 20px;
  color: var(--text);
}

.bar {
  margin-top: 8px;
  height: 4px;
  border-radius: 4px;
  background: var(--bar-bg);
  overflow: hidden;
}
.fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: var(--bar-fill);
  transition: width 0.25s linear;
}

/* Last.fm doesn't give a position, so the bar just shimmers */
.player.no-progress .time { visibility: hidden; }
.player.no-progress .fill {
  width: 35%;
  animation: shimmer 2.4s ease-in-out infinite;
}
@keyframes shimmer {
  from { transform: translateX(-100%); }
  to   { transform: translateX(290%); }
}

/* ── footnote ─────────────────────────────────────── */

.footnote {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--faint);
}
.footnote[hidden] { display: none; }

.toggle {
  flex: none;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.toggle:hover, .toggle:focus-visible { color: var(--muted); }

/* ── phones ───────────────────────────────────────── */

@media (max-width: 520px) {
  .player { gap: 12px; padding: 12px; }
  .art { width: 72px; height: 72px; }
  .track { font-size: 15px; }
  .footnote { flex-direction: column; align-items: flex-start; gap: 4px; }
}
