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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: var(--accent); }
button, input { font: inherit; }
[hidden] { display: none !important; }

:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 30;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--gold-400);
  color: var(--maroon-900);
  font-weight: 700;
  text-decoration: none;
}
.skip-link:focus { top: 12px; }

/* ---------- Scene background ---------- */
.scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: var(--maroon-900);
}
.scene-layer {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 1.2s ease;
}
.scene-layer.is-visible { opacity: 1; }
.scene-layer svg { display: block; width: 100%; height: 100%; }

.scene-shade {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(180deg,
    rgba(22, 8, 4, 0.4) 0%,
    rgba(22, 8, 4, 0) 26%,
    rgba(22, 8, 4, 0.12) 62%,
    rgba(22, 8, 4, 0.72) 100%);
}

/* ---------- Top bar ---------- */
.topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--topbar-h);
  padding: max(10px, env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right)) 10px max(var(--gutter), env(safe-area-inset-left));
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--text);
  text-decoration: none;
}
.brand-mark {
  width: 38px;
  height: 38px;
  flex: none;
  filter: drop-shadow(0 2px 8px rgba(240, 138, 36, 0.55));
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name {
  font-family: var(--font-display);
  font-size: 1.4rem;
  line-height: 1.1;
  color: var(--gold-300);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
}
.brand-tag {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
}

.topnav { display: flex; gap: 6px; flex: none; }
.navlink {
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: rgba(30, 12, 6, 0.4);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s ease;
}
.navlink:hover { background: rgba(30, 12, 6, 0.65); }

/* ---------- Hero & player deck ---------- */
main { position: relative; z-index: 2; }

.hero {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: calc(var(--topbar-h) + 22px) var(--gutter) 28px;
}

.deck {
  width: min(100%, 520px);
  display: grid;
  gap: 14px;
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--glass-border);
  background: var(--glass);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: var(--shadow-lg);
}

/* The YouTube player must stay visible and at least 200×200 px. */
.screen {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 200px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #0b0503;
  border: 1px solid rgba(233, 193, 96, 0.2);
}
.screen-mount { position: absolute; inset: 0; }
.screen-mount iframe,
.screen-mount video { display: block; width: 100%; height: 100%; border: 0; }

.screen-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 58%, rgba(246, 168, 69, 0.28), transparent 62%),
    #140704;
  pointer-events: none;
}
.screen-empty svg {
  width: 72px;
  height: 72px;
  filter: drop-shadow(0 4px 18px rgba(240, 138, 36, 0.6));
}
.deck[data-media="youtube"] .screen-empty,
.deck[data-media="file"] .screen-empty { display: none; }

/* Song picture, shown when playing audio files */
.screen-cover {
  position: absolute;
  inset: 0;
  display: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform-origin: 50% 60%;
}
.deck[data-media="file"] .screen-cover { display: block; }
.deck[data-media="file"][data-status="playing"] .screen-cover {
  animation: slow-zoom 24s ease-in-out infinite alternate;
}
@keyframes slow-zoom { from { transform: scale(1); } to { transform: scale(1.08); } }

.deck-info { text-align: center; }
.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.track-title {
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.4rem, 4.6vw, 1.9rem);
  line-height: 1.2;
  color: var(--cream-100);
  overflow-wrap: anywhere;
}
.track-meta {
  margin: 2px 0 0;
  min-height: 1.4em;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Progress */
.progress {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
}
.time {
  min-width: 3.4ch;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

/* Range inputs (seek + volume) */
.range {
  --fill: 0%;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 24px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
.range:disabled { cursor: default; opacity: 0.5; }
.range::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--accent) var(--fill), rgba(255, 247, 232, 0.18) var(--fill));
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--gold-300);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
}
.range::-moz-range-track { height: 6px; border-radius: 999px; background: rgba(255, 247, 232, 0.18); }
.range::-moz-range-progress { height: 6px; border-radius: 999px; background: var(--accent); }
.range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 50%;
  background: var(--gold-300);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
}
.range:focus-visible { box-shadow: none; }
.range:focus-visible::-webkit-slider-thumb { box-shadow: var(--focus-ring); }
.range:focus-visible::-moz-range-thumb { box-shadow: var(--focus-ring); }

/* Buttons */
.btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.icon { width: 44px; height: 44px; }
.btn.icon svg { width: 22px; height: 22px; }
.btn.small { width: 38px; height: 38px; }
.btn.small svg { width: 20px; height: 20px; }
.btn.icon:not(:disabled):hover { background: rgba(255, 247, 232, 0.1); }
.btn:not(:disabled):active { transform: scale(0.94); }

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 3vw, 18px);
}

.btn.toggle { color: var(--text-faint); }
.btn.toggle[aria-pressed="true"],
.btn.repeat[data-mode="all"],
.btn.repeat[data-mode="one"] { color: var(--accent); }
.btn.toggle[aria-pressed="true"]::after,
.btn.repeat[data-mode="all"]::after,
.btn.repeat[data-mode="one"]::after {
  content: "";
  position: absolute;
  bottom: 4px;
  left: 50%;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: currentColor;
}
.repeat-one {
  position: absolute;
  top: 5px;
  right: 4px;
  display: none;
  width: 14px;
  height: 14px;
  place-items: center;
  border-radius: 999px;
  background: var(--accent);
  color: var(--maroon-900);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}
.btn.repeat[data-mode="one"] .repeat-one { display: grid; }

.btn.play {
  width: 66px;
  height: 66px;
  background: linear-gradient(145deg, var(--gold-300), var(--saffron-500));
  color: var(--maroon-900);
  box-shadow: 0 8px 24px rgba(240, 138, 36, 0.45);
}
.btn.play svg { width: 30px; height: 30px; }
.btn.play:not(:disabled):hover { box-shadow: 0 10px 30px rgba(240, 138, 36, 0.6); }
.btn.play .i-pause { display: none; }
.deck[data-status="playing"] .btn.play .i-play { display: none; }
.deck[data-status="playing"] .btn.play .i-pause { display: block; }
.deck[data-status="loading"] .btn.play svg { opacity: 0.35; }
.deck[data-status="loading"] .btn.play::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: var(--gold-300);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.deck-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 247, 232, 0.06);
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}
.chip svg { width: 18px; height: 18px; }
.chip:hover { background: rgba(255, 247, 232, 0.13); }
.chip[aria-expanded="true"] { background: var(--gold-400); color: var(--maroon-900); border-color: var(--gold-400); }
.chip:disabled { opacity: 0.45; cursor: default; }

.volume {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  justify-content: flex-end;
  min-width: 120px;
}
.volume .range { width: min(130px, 100%); }
.volume .i-muted { display: none; }
.volume.is-muted .i-vol { display: none; }
.volume.is-muted .i-muted { display: block; }
/* Phones control volume with their own buttons. */
@media (hover: none) and (pointer: coarse) {
  .volume .range { display: none; }
  .volume { min-width: 0; }
}

.deck-credit {
  margin: 0;
  color: var(--text-faint);
  font-size: 0.78rem;
  text-align: center;
}

/* Live listener count */
.live-count {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 5px 12px 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: rgba(30, 12, 6, 0.55);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: var(--cream-100);
  font-size: 0.85rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.live-dot {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #5fd38a;
}
.live-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #5fd38a;
  animation: live-pulse 1.8s ease-out infinite;
}
@keyframes live-pulse { from { transform: scale(1); opacity: 0.7; } to { transform: scale(2.8); opacity: 0; } }

/* Scene picker */
.scene-picker {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
.scene-opt {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px 6px 7px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: rgba(30, 12, 6, 0.5);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}
.scene-opt:hover { background: rgba(30, 12, 6, 0.75); }
.scene-opt[aria-checked="true"] { background: var(--gold-400); border-color: var(--gold-400); color: var(--maroon-900); }
.scene-swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(255, 247, 232, 0.5);
  background: var(--swatch);
}

/* ---------- Content sections ---------- */
.content {
  position: relative;
  background: var(--maroon-900);
}
.content::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -140px;
  height: 140px;
  background: linear-gradient(180deg, rgba(30, 11, 6, 0), var(--maroon-900));
  pointer-events: none;
}

.section {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 36px var(--gutter);
}
.section-title {
  margin: 0 0 16px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.5rem, 4vw, 2rem);
  color: var(--gold-300);
}

.songlist {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.song-btn {
  width: 100%;
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 247, 232, 0.04);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.song-btn:hover { background: rgba(255, 247, 232, 0.08); border-color: var(--glass-border); }
.song-num {
  display: grid;
  place-items: center;
  height: 22px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.song-text { min-width: 0; }
.song-title { display: block; font-weight: 600; overflow-wrap: anywhere; }
.song-cat { display: block; color: var(--text-faint); font-size: 0.82rem; }
.song-go { width: 22px; height: 22px; color: var(--accent); }
.song.is-current .song-btn { border-color: var(--accent); background: rgba(246, 168, 69, 0.12); }

/* Little equaliser shown on the playing song */
.eq { display: none; gap: 3px; align-items: end; height: 16px; }
.eq span { width: 3px; border-radius: 2px; background: var(--accent); animation: eq 1s ease-in-out infinite; }
.eq span:nth-child(2) { animation-delay: -0.35s; }
.eq span:nth-child(3) { animation-delay: -0.7s; }
@keyframes eq { 0%, 100% { height: 4px; } 50% { height: 16px; } }
.song.is-current.is-playing .eq { display: flex; }
.song.is-current.is-playing .num-text { display: none; }

.empty-note { color: var(--text-muted); }

.about p { max-width: 65ch; color: rgba(255, 247, 232, 0.84); }
.faq-q { margin: 24px 0 4px; font-size: 1.05rem; color: var(--cream-100); }
.about .jai { font-family: var(--font-display); font-size: 1.3rem; color: var(--gold-300); }

.footer {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 24px var(--gutter) max(40px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  color: var(--text-faint);
  font-size: 0.85rem;
  text-align: center;
}
.footer p { margin: 4px 0; }
.footer-links a { margin: 0 8px; }

/* ---------- Lyrics panel ---------- */
.lyrics {
  position: fixed;
  z-index: 10;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--glass-border);
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform 0.35s ease;
}
.lyrics.is-open { transform: none; }
.lyrics-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 14px 20px;
  border-bottom: 1px solid var(--line);
}
.lyrics-title {
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.3rem;
  line-height: 1.25;
  color: var(--gold-300);
}
.lyrics-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 20px 36px;
  color: var(--cream-100);
  font-size: 1.12rem;
  line-height: 1.9;
  text-align: center;
  white-space: pre-line;
  overscroll-behavior: contain;
}
.lyrics-body .muted { color: var(--text-muted); white-space: normal; }

@media (max-width: 640px) {
  .lyrics {
    top: auto;
    left: 0;
    height: 72vh;
    height: 72svh;
    width: 100%;
    border-left: 0;
    border-top: 1px solid var(--glass-border);
    border-radius: 22px 22px 0 0;
    transform: translateY(100%);
  }
  .lyrics-body { padding-bottom: max(36px, env(safe-area-inset-bottom)); }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: var(--maroon-800);
  color: var(--text);
  font-size: 0.92rem;
  text-align: center;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translate(-50%, 16px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Small screens ---------- */
@media (max-width: 420px) {
  .brand-tag { display: none; }
  .navlink { padding: 6px 11px; }
  .deck { padding: 12px; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .scene * { animation: none !important; }
}
