:root {
  --ink:        rgba(248, 246, 242, 0.95);
  --ink-muted:  rgba(248, 246, 242, 0.52);
  --glass:      rgba(17, 17, 22, 0.32);
  --glass-edge: rgba(255, 255, 255, 0.16);
  --glass-lift: rgba(255, 255, 255, 0.14);
  --ring-track: rgba(255, 255, 255, 0.20);
  --ring-fill:  rgba(255, 247, 234, 0.92);
  --ground:     #0b0b0f;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--ground);
}

body {
  font-family: "Archivo", ui-sans-serif, system-ui, -apple-system, "Helvetica Neue", sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* ---- the artwork: one static image, edge to edge, no motion of any kind ---- */
#stage {
  position: fixed;
  inset: 0;
  background-color: var(--ground);
  background-repeat: no-repeat;
  background-position: center center;
  background-size: cover;
}

/* the looping clip sits inside the stage and fills it the same way a
   background-size: cover image would */
.clip {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border: 0;
  pointer-events: none;
}

.clip[hidden] { display: none; }

/* ---- change the background ---- */
.background {
  position: fixed;
  right: 44px;
  bottom: 44px;
  width: 44px;
  height: 44px;
  border: 1px solid var(--glass-edge);
  border-radius: 999px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(26px) saturate(150%);
  backdrop-filter: blur(26px) saturate(150%);
  box-shadow:
    0 10px 40px rgba(0, 0, 0, 0.30),
    inset 0 1px 0 var(--glass-lift);
  opacity: 0.82;
}

.background:hover { opacity: 1; }
.background svg { width: 18px; height: 18px; }
.background[hidden] { display: none; }

/* ---- the player ---- */
.player {
  position: fixed;
  left: 50%;
  bottom: 44px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  width: min(420px, calc(100vw - 48px));
  padding: 10px 22px 10px 12px;
  border: 1px solid var(--glass-edge);
  border-radius: 999px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(26px) saturate(150%);
  backdrop-filter: blur(26px) saturate(150%);
  box-shadow:
    0 10px 40px rgba(0, 0, 0, 0.30),
    inset 0 1px 0 var(--glass-lift);
}

.controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: none;
}

button {
  display: grid;
  place-items: center;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  cursor: pointer;
  border-radius: 999px;
  opacity: 0.72;
  touch-action: manipulation;
  transition: transform 0.08s ease, opacity 0.12s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button:hover { opacity: 1; }
button:active { transform: scale(0.85); opacity: 1; transition: transform 0.04s ease; }
button:focus-visible {
  outline: 1px solid rgba(255, 255, 255, 0.7);
  outline-offset: 3px;
  opacity: 1;
}

.skip { width: 34px; height: 34px; }
.skip svg { width: 15px; height: 15px; }

.play-slot {
  position: relative;
  width: 46px;
  height: 46px;
  flex: none;
}

.ring {
  position: absolute;
  inset: 0;
  transform: rotate(-90deg);
  pointer-events: none;
}

.ring circle { fill: none; stroke-width: 1.5; }
.ring .track { stroke: var(--ring-track); }
.ring .fill  { stroke: var(--ring-fill); stroke-linecap: round; }

#play {
  position: absolute;
  inset: 0;
  opacity: 0.9;
}
#play:hover { opacity: 1; }
#play svg { width: 17px; height: 17px; margin-left: 1px; }
#play[data-state="playing"] svg { margin-left: 0; }

.divider {
  width: 1px;
  height: 26px;
  flex: none;
  background: linear-gradient(
    to bottom,
    transparent,
    rgba(255, 255, 255, 0.20),
    transparent
  );
}

.meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.title {
  font-family: "Newsreader", ui-serif, Georgia, serif;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: 0.005em;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Marquee scroll for titles that overflow the pill */
.title.marquee {
  text-overflow: clip;
  animation: title-scroll 12s linear infinite;
  padding-right: 3em;
}

@keyframes title-scroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.artist {
  font-size: 9.5px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


@media (max-width: 520px) {
  .player { bottom: 28px; gap: 10px; padding: 9px 18px 9px 10px; }
  .title { font-size: 15px; }
  .background { right: 20px; bottom: 28px; width: 40px; height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  /* someone who has asked their system for less movement gets the poster
     frame instead of the clip */
  .clip { display: none; }
}

/* ---- status line, used while connecting or when something needs saying ---- */
.player[data-state="notice"] .title { font-style: italic; color: var(--ink-muted); }

/* Loading / buffering state — spin the ring and pulse the button */
@keyframes ring-spin {
  to { stroke-dashoffset: 0; }
}

@keyframes pulse-opacity {
  0%, 100% { opacity: 0.55; }
  50%       { opacity: 1; }
}

.player[data-state="loading"] .ring .fill {
  stroke-dashoffset: 0;
  stroke-dasharray: 6 134;
  animation: ring-spin 1.1s linear infinite;
  stroke-linecap: round;
}

#play[data-state="loading"] {
  animation: pulse-opacity 1.2s ease-in-out infinite;
  pointer-events: none;
}

/* each still sits in its own layer, painted once, so changing artwork is
   only a change of which layer is visible */
.plate {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  pointer-events: none;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  will-change: opacity;
  transform: translateZ(0);
  transition: opacity 0.6s ease;
}

.plate.on { opacity: 1; }


/* ---- theme toggle (bottom-left corner) ---- */
.theme-toggle {
  position: fixed;
  left: 44px;
  bottom: 44px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 16px 0 12px;
  height: 44px;
  border: 1px solid var(--glass-edge);
  border-radius: 999px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(26px) saturate(150%);
  backdrop-filter: blur(26px) saturate(150%);
  box-shadow:
    0 10px 40px rgba(0, 0, 0, 0.30),
    inset 0 1px 0 var(--glass-lift);
  opacity: 0.80;
  color: var(--ink);
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.theme-toggle:hover { opacity: 1; }

.theme-toggle-label {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
  white-space: nowrap;
}

.theme-toggle:hover .theme-toggle-label {
  color: var(--ink);
}

.theme-icon {
  width: 15px;
  height: 15px;
  flex: none;
  opacity: 0.8;
}

@media (max-width: 520px) {
  .theme-toggle { left: 20px; bottom: 28px; height: 40px; padding: 0 14px 0 10px; }
}

/* ---- PWA install button (appears above the theme toggle when available) ---- */
.install-btn {
  position: fixed;
  left: 44px;
  bottom: 100px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 16px 0 12px;
  height: 44px;
  border: 1px solid var(--glass-edge);
  border-radius: 999px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(26px) saturate(150%);
  backdrop-filter: blur(26px) saturate(150%);
  box-shadow:
    0 10px 40px rgba(0, 0, 0, 0.30),
    inset 0 1px 0 var(--glass-lift);
  opacity: 0.80;
  color: var(--ink);
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.install-btn:hover { opacity: 1; }
.install-btn[hidden] { display: none; }

.install-label {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
  white-space: nowrap;
}

.install-btn:hover .install-label { color: var(--ink); }

@media (max-width: 520px) {
  .install-btn { left: 20px; bottom: 84px; height: 40px; padding: 0 14px 0 10px; }
}
