/* ============================================================
   Secret Door — synced lyrics experience
   Palette: deep night violets / indigo / soft moonlight
   ============================================================ */

:root {
  --bg: #07050d;
  --ink: #f3ecff;
  --muted: rgba(243, 236, 255, 0.42);
  --dim: rgba(243, 236, 255, 0.16);
  --accent: #c8a8ff;
  --accent-2: #7b6bff;
  --glow: rgba(168, 140, 255, 0.55);
  --card: rgba(255, 255, 255, 0.04);
  --card-edge: rgba(255, 255, 255, 0.10);
  --display: "Clash Display", system-ui, -apple-system, "Segoe UI", sans-serif;
  --sans: "Satoshi", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  position: relative;
}

/* ---------- Ambient aurora background ---------- */
.aurora {
  position: fixed;
  inset: -20vmax;
  z-index: 0;
  filter: blur(60px) saturate(135%);
  pointer-events: none;
}
.blob {
  position: absolute;
  border-radius: 50%;
  opacity: 0.55;
  mix-blend-mode: screen;
  will-change: transform;
}
.blob--a {
  width: 55vmax; height: 55vmax;
  background: radial-gradient(circle at 30% 30%, #6a3cff, transparent 62%);
  top: -10vmax; left: -8vmax;
  animation: drift-a 22s ease-in-out infinite alternate;
}
.blob--b {
  width: 48vmax; height: 48vmax;
  background: radial-gradient(circle at 60% 40%, #ff5fa2, transparent 60%);
  bottom: -12vmax; right: -6vmax;
  animation: drift-b 26s ease-in-out infinite alternate;
}
.blob--c {
  width: 42vmax; height: 42vmax;
  background: radial-gradient(circle at 50% 50%, #18b6c9, transparent 62%);
  top: 30%; left: 35%;
  animation: drift-c 30s ease-in-out infinite alternate;
}
@keyframes drift-a { to { transform: translate(14vmax, 8vmax) scale(1.15); } }
@keyframes drift-b { to { transform: translate(-12vmax, -6vmax) scale(1.1); } }
@keyframes drift-c { to { transform: translate(6vmax, -10vmax) scale(0.9); } }

#particles {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

/* subtle film grain for texture */
.grain {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0.05;
  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='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- Enter overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1.4rem;
  background: radial-gradient(circle at 50% 45%, rgba(10, 6, 20, 0.35), rgba(5, 3, 11, 0.85));
  backdrop-filter: blur(8px);
  transition: opacity 0.9s ease, visibility 0.9s;
}
.overlay.hidden { opacity: 0; visibility: hidden; }

.enter {
  position: relative;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: radial-gradient(circle at 50% 40%, rgba(200, 168, 255, 0.18), rgba(123, 107, 255, 0.05));
  color: var(--ink);
  display: grid;
  place-items: center;
  transition: transform 0.4s cubic-bezier(.2,.9,.3,1.4);
}
.enter:hover { transform: scale(1.06); }
.enter:active { transform: scale(0.97); }
.enter__ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(200, 168, 255, 0.5);
  box-shadow: 0 0 60px var(--glow), inset 0 0 30px rgba(200, 168, 255, 0.25);
  animation: pulse 2.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.12); opacity: 0.25; }
}
.enter__icon { font-size: 1.6rem; margin-left: 4px; opacity: 0.95; }
.enter__label {
  position: absolute;
  bottom: 30px;
  font-family: var(--sans);
  font-size: 0.62rem;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  opacity: 0.55;
}
.overlay__hint {
  font-size: 0.72rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Stage layout ---------- */
.stage {
  position: relative;
  z-index: 10;
  height: 100dvh;
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(1.4rem, 4vw, 3rem) clamp(1.2rem, 5vw, 2.4rem) 1.6rem;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: clamp(1.2rem, 3vw, 2rem);
}

/* ---------- Now playing header ---------- */
.now-playing {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 3vw, 1.6rem);
}
.art {
  position: relative;
  width: clamp(86px, 22vw, 128px);
  aspect-ratio: 1;
  flex: none;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(74, 30, 120, 0.55), 0 0 0 1px var(--card-edge);
  background: linear-gradient(135deg, #2a1a52, #120a26);
}
.art__disc {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    repeating-radial-gradient(circle at 50% 50%, rgba(255,255,255,0.04) 0 2px, transparent 2px 5px),
    radial-gradient(circle at 50% 50%, #3a2568, #0d0720 70%);
  opacity: 0;
  transition: opacity 0.6s ease;
}
.art img {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.8s ease;
}
.art img.loaded { opacity: 1; }
/* gentle breathing glow while playing (no tumbling square) */
.art.playing { animation: artbreath 4.5s ease-in-out infinite; }
@keyframes artbreath {
  0%, 100% {
    box-shadow: 0 18px 50px rgba(74, 30, 120, 0.55), 0 0 0 1px var(--card-edge),
                0 0 22px rgba(168, 140, 255, 0.25);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 22px 64px rgba(120, 60, 200, 0.7), 0 0 0 1px var(--card-edge),
                0 0 46px rgba(168, 140, 255, 0.55);
    transform: scale(1.025);
  }
}

.meta { min-width: 0; }
.eyebrow {
  display: flex;
  align-items: center;
  gap: 0.6em;
  font-size: 0.64rem;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0.8;
  margin-bottom: 0.45rem;
}
.eq {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 11px;
}
.eq i {
  width: 2.5px;
  height: 25%;
  border-radius: 2px;
  background: var(--accent);
  transition: height 0.3s ease;
}
.stage.playing .eq i { animation: eq 0.9s ease-in-out infinite; }
.eq i:nth-child(1) { animation-duration: 0.85s; }
.eq i:nth-child(2) { animation-duration: 1.15s; }
.eq i:nth-child(3) { animation-duration: 0.7s; }
.eq i:nth-child(4) { animation-duration: 1s; }
@keyframes eq {
  0%, 100% { height: 25%; }
  50% { height: 100%; }
}
.title {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(2.1rem, 7.5vw, 3.2rem);
  line-height: 0.96;
  letter-spacing: -0.02em;
  text-shadow: 0 4px 40px rgba(168, 140, 255, 0.35);
}
.artist {
  margin-top: 0.4rem;
  font-size: 0.92rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.progress {
  margin-top: 0.9rem;
  height: 3px;
  width: min(240px, 60%);
  border-radius: 99px;
  background: var(--dim);
  overflow: hidden;
}
.progress__bar {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  box-shadow: 0 0 12px var(--glow);
  transition: width 0.25s linear;
}

/* ---------- Lyrics ---------- */
.lyrics-viewport {
  position: relative;
  min-height: 0; /* allow the 1fr grid track to clip instead of growing to content */
  overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 16%, #000 84%, transparent);
          mask-image: linear-gradient(180deg, transparent, #000 16%, #000 84%, transparent);
}
.lyrics {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65em;
  padding-block: 40vh;
  /* horizontal room so a scaled-up active line can't run off the edge */
  padding-inline: clamp(0.75rem, 5vw, 2.5rem);
  text-align: center;
  transition: transform 0.6s cubic-bezier(.22,.61,.36,1);
  will-change: transform;
}
.lyric-line {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(1.3rem, 4.6vw, 1.95rem);
  line-height: 1.22;
  letter-spacing: -0.01em;
  max-width: 100%;
  overflow-wrap: break-word;
  color: var(--ink);
  opacity: 0.18;
  filter: blur(0.6px);
  transform: scale(0.92);
  transition: opacity 0.5s ease, transform 0.5s cubic-bezier(.2,.8,.3,1.2),
              filter 0.5s ease, color 0.5s ease, text-shadow 0.5s ease;
}
.lyric-line.active {
  opacity: 1;
  font-weight: 600;
  filter: blur(0);
  transform: scale(1.03);
  color: #fff;
  text-shadow: 0 0 26px rgba(200, 168, 255, 0.55);
}
.lyric-line--instrumental { letter-spacing: 0.5em; opacity: 0.22; }
.lyric-line--instrumental.active { letter-spacing: 0.5em; }
.lyric-line--status {
  opacity: 0.5;
  filter: none;
  transform: none;
  font-size: 1.1rem;
  color: var(--muted);
}
.lyric-line--plain { cursor: default; }

/* ---------- Player / Spotify embed ---------- */
.player {
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 16px;
  padding: 8px;
  backdrop-filter: blur(14px);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.4);
}
#spotify-embed iframe { border-radius: 10px; display: block; }

/* ---------- Lyrics sync control ---------- */
.sync {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 2px 6px 10px;
  font-family: var(--sans);
}
.sync__label {
  font-size: 0.6rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: auto;
}
.sync__btn {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 1px solid var(--card-edge);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease, border-color 0.2s ease;
}
.sync__btn:hover { background: rgba(200, 168, 255, 0.18); border-color: rgba(200, 168, 255, 0.5); }
.sync__btn:active { transform: scale(0.92); }
.sync__val {
  min-width: 4.2ch;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: 0.8rem;
  color: var(--accent);
  letter-spacing: 0.02em;
}
.sync__reset {
  margin-left: 0.2rem;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.2s ease;
}
.sync__reset:hover { color: var(--ink); }

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  .now-playing { gap: 1rem; }
  .lyrics { gap: 0.5em; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .blob, .enter__ring, .art.playing { animation: none !important; }
  .lyrics, .lyric-line, .progress__bar { transition-duration: 0.15s; }
  #particles { display: none; }
}
