:root {
  --bg: #000;
  --fg: #f5f5f7;
  --muted: rgba(255, 255, 255, 0.56);
  --faint: rgba(255, 255, 255, 0.14);
  --ga: hsl(345 75% 58%); /* colour field, from the artwork */
  --gb: hsl(150 50% 60%); /* contrasting tag colour */
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --sans: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { background: var(--bg); }
body { margin: 0; color: var(--fg); background: transparent; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
  grid-template-columns: minmax(0, 1fr);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

.field {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  background: #000;
}

/* ---------- header: poster labels ---------- */

.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left));
}

.brand, .tag {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 12px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  white-space: nowrap;
}

.brand { background: #000; color: var(--fg); }

.tag {
  gap: 8px;
  letter-spacing: 0.14em;
  background: var(--gb);
  color: #000;
  font-variant-numeric: tabular-nums;
  transition: background-color 0.9s steps(6);
}
.tag .sep { width: 1px; height: 12px; background: rgba(0, 0, 0, 0.35); }

.dot { width: 7px; height: 7px; background: #000; opacity: calc(0.25 + 0.75 * var(--kick, 0)); }

/* ---------- stage + card ---------- */

.stage {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 14px max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}

.card {
  width: 100%;
  min-width: 0;
  max-width: 480px;
  padding: 16px;
  background: #000;
}

.head {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.art {
  position: relative;
  margin: 0;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--ga);
}
[data-state='playing'] .art { transform: scale(calc(1 + 0.012 * var(--kick, 0) + 0.01 * var(--bar, 0))); }
.art img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: auto;
}
.no-cover .art img { display: none; }
.fallback {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  font-weight: 900;
  font-size: 34px;
  letter-spacing: -0.06em;
  color: #000;
}
.no-cover .fallback { display: grid; }

.titles { min-width: 0; }

.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 6px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

.eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 10px; }
.eq i { width: 2px; height: 30%; background: var(--ga); }
/* heights set every frame from the beat (app.js); dimmer while not listening */
.eq { opacity: 0.45; transition: opacity 0.4s; }
[data-state='playing'] .eq { opacity: 1; }

h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.artist {
  margin: 4px 0 0;
  font-size: 15px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress { margin-top: 18px; }
.progress .track { height: 2px; background: var(--faint); overflow: hidden; }
.progress .track span {
  display: block;
  height: 100%;
  background: var(--fg);
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 0.25s linear;
}
.times {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin-top: 10px;
}

.play {
  position: relative;
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--fg);
  color: #000;
  cursor: pointer;
  transition: transform 0.25s var(--ease), opacity 0.3s;
}
.play:hover { transform: scale(1.05); }
.play:active { transform: scale(0.95); }
.play:focus-visible { outline: 2px solid var(--fg); outline-offset: 5px; }
.play:disabled { opacity: 0.3; cursor: default; transform: none; }
.play svg { grid-area: 1 / 1; width: 28px; height: 28px; fill: currentColor; }
.play .i-stop { display: none; width: 24px; height: 24px; }
[data-state='playing'] .play .i-play,
[data-state='loading'] .play .i-play { display: none; }
[data-state='playing'] .play .i-stop,
[data-state='loading'] .play .i-stop { display: block; }

.play .ring {
  position: absolute;
  inset: -7px;
  width: calc(100% + 14px);
  height: calc(100% + 14px);
  fill: none;
  stroke: var(--ga);
  stroke-width: 2;
  stroke-dasharray: 70 232;
  opacity: 0;
  transition: opacity 0.3s;
}
[data-state='loading'] .play .ring { opacity: 1; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.volume { display: none; align-items: center; gap: 10px; color: var(--muted); }
.volume svg { width: 20px; height: 20px; fill: currentColor; }
.volume .wave { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }

input[type='range'] {
  --v: 1;
  appearance: none;
  -webkit-appearance: none;
  width: 110px;
  height: 18px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
input[type='range']::-webkit-slider-runnable-track {
  height: 2px;
  background: linear-gradient(to right, var(--fg) calc(var(--v) * 100%), var(--faint) 0);
}
input[type='range']::-moz-range-track { height: 2px; background: var(--faint); }
input[type='range']::-moz-range-progress { height: 2px; background: var(--fg); }
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px;
  height: 10px;
  margin-top: -4px;
  background: var(--fg);
}
input[type='range']::-moz-range-thumb { width: 10px; height: 10px; border: 0; border-radius: 0; background: var(--fg); }
input[type='range']:focus-visible { outline: 2px solid var(--fg); outline-offset: 4px; }

.next {
  min-height: 1.4em;
  margin: 14px 0 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- desktop ---------- */

@media (hover: hover) and (pointer: fine) {
  .volume { display: inline-flex; }
}

@media (min-width: 900px) {
  .top { padding: 28px 32px 0; }
  .brand, .tag { height: 36px; padding: 0 14px; }

  .stage {
    align-items: center;
    justify-content: flex-end;
    padding: 28px clamp(32px, 6vw, 96px);
  }
  .card { width: 400px; padding: 20px; }
  .head { display: block; }
  .art { width: 100%; margin-bottom: 20px; }
  .fallback { font-size: 96px; }
  h1 { font-size: 30px; line-height: 1.08; letter-spacing: -0.03em; }
  .artist { font-size: 17px; margin-top: 6px; }
  .eyebrow { margin-bottom: 10px; }
  .progress { margin-top: 24px; }
  .controls { justify-content: flex-start; margin-top: 16px; }
  .play { width: 72px; height: 72px; }
  .next { text-align: left; margin-top: 18px; }
}

@media (min-width: 900px) and (max-height: 760px) {
  .art { width: 46%; float: left; margin: 0 16px 0 0; }
  .head { display: flow-root; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0.01ms !important; }
  [data-state='playing'] .art { transform: none; }
  .dot { opacity: 1; }
}
