:root {
  --bg: #000;
  --card-bg: #181818;
  --text: #ffffff;
  --text-secondary: #b3b3b3;
  --accent: #1db954;
}

* {
  box-sizing: border-box;
}

/* NOTE: html itself must stay background-less. That keeps body's black
   background promoted to the canvas, painting BELOW the z-index:-1
   .art-background; a background on html makes body paint over the art. */

/* No page-level scrolling: the lyrics container scrolls internally */
html,
body {
  overflow: hidden;
}

body {
  font-family: "Special Elite";
  letter-spacing: 0.03em;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  max-height: 100vh;
  min-height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card {
  width: 100%;
  height: 100%;
}

.view[hidden] {
  display: none;
}

#login-view {
  text-align: center;
}

#login-view h1 {
  margin-top: 0;
}

.subtitle {
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.spotify-button {
  display: inline-block;
  background: var(--accent);
  color: #000;
  font-weight: 600;
  text-decoration: none;
  padding: 0.75rem 1.5rem;
  border-radius: 999px;
}

.now-playing {
  /*display: flex;*/
  display: none;
  gap: 1rem;
  align-items: center;
  font-family: system-ui, sans-serif;
  font-weight: 500;
  font-size: 1rem;
  line-height: 1.2rem;
    letter-spacing: 0em;
}

.album-art {
  width: 72px;
  height: 72px;
  border-radius: 6px;
  background: #333;
  object-fit: cover;
  flex-shrink: 0;
}

.track-info {
  flex: 1;
  min-width: 0;

}

.track-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-artist {
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.next-track-line {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 0.45rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.8;
}

/* Sits as a top border on the fixed .now-playing bar */
.progress-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: #404040;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: #fff;
}

.lyrics-container {
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  text-align: center;
  padding: 1vw 4vw;
  display: flex;
  flex-direction: column;
  font-size: 3vw;
  color: #666;
  opacity: 0;
  mix-blend-mode: screen;
  /* Duration must match LYRICS_FADE_MS in script.js */
  transition: opacity 0.6s ease;
}

/* Scrims */
.lyrics-container:after, .lyrics-container:before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    height: 15vw;
    background: linear-gradient(180deg, black, transparent);
    pointer-events: none;
}
.lyrics-container:after {
    background: linear-gradient(0deg, black, transparent);
    top: auto;
    bottom: 0;
}


.lyrics-container.visible {
  opacity: 1;
}

/* Center short content (placeholders) without justify-content: center,
   which puts overflowing lyrics in unreachable negative scroll space
   and breaks scrollIntoView. Auto margins collapse once content overflows. */
.lyrics-container > :first-child {
  margin-top: auto;
}

.lyrics-container > :last-child {
  margin-bottom: auto;
}

@keyframes fadeInOut {
  0%, 100% {
    opacity: 0; /* Fully hidden at the start and end */
  }
  50% {
    opacity: 1; /* Fully visible in the middle */
  }
}

.lyrics-placeholder {
  color: #666;
  animation: fadeInOut 2s ease-in-out infinite;
}
.lyrics-plain {
  display: none;
}

.lyrics-line {
  font-size: 6vw;
  padding: 3vw 0;
  color: #555;
  transition: color 0.2s ease;
  text-wrap: balance;
}
.lyrics-line:first-child { 
  margin-top: 38vh; 
}
.lyrics-line:last-child { 
  margin-bottom: 38vh; 
}

.lyrics-line.active {
  color: #fff;
  font-weight: 500;
}
.lyrics-line.after-active {
  color: #888;
}

/* Static message when a song has no usable (synced) lyrics */
.lyrics-unavailable {
  color: #666;
}

/* Intro progress bar shown when the first lyric starts >5s into the song */
.lyrics-intro {
  width: 24vw;
  height: 1.4vw;
  background: #444;
  border-radius: 5px;
  overflow: hidden;
  margin-left: auto;
  margin-right: auto;
  position: relative;
  margin-top: 2vw;
  margin-bottom: 2vw;
}
.lyrics-intro:after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: url(grunge-texture.jpg);
  background-size: 100%;
  mix-blend-mode: multiply;
  filter: contrast(1.5);
}

.lyrics-intro-fill {
  height: 100%;
  width: 0%;
  background: #444;
  transition: background 0.2s ease;
}
.active .lyrics-intro-fill {
  background: #fff;
}

.next-track {
  position: fixed;
  right: 2.5vw;
  bottom: 2.5vw;
  font-size: 1.6vw;
  line-height: 1.6em;
  font-family: "Special Elite";
  color: #fff;
  display: flex;
  flex-direction: column;
  z-index: 1;
  align-items: flex-end;
  gap: 0.7vw;
}

.next-track[hidden] {
  display: none;
}

.next-track-label {
  text-transform: uppercase;
  letter-spacing: 0.3em;
  opacity: 0.7;
  margin-right: -0.3em;
}
.next-track-name {
  font-size: 2.2vw;
  max-width: 40vw;
  text-align: right;
  text-wrap: balance;
}

.logout-button {
  display: none;
  margin: 1.5rem auto 0;
  background: transparent;
  border: 1px solid #404040;
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 0.5rem 1.25rem;
  cursor: pointer;
}

.logout-button:hover {
  border-color: var(--text-secondary);
  color: var(--text);
}

.explicit {
  position: absolute;
  top: 4vw;
  right: 4vw;
  width: 11vw;
  background: #fff;
  transform: rotate(6deg);
  cursor: pointer;
  z-index: 1;
}

/* Filter disabled state; .filter-enabled is toggled by script.js */
.explicit:not(.filter-enabled) {
  opacity: 0.35;
  filter: grayscale(1);
}

/* Full-screen album art behind the lyrics. The parent handles the
   active-lyrics dim; the two child layers double-buffer the crossfade
   between songs. */
.art-background {
  position: fixed;
  inset: 0;
  z-index: -1;
  /* Same speed as the .lyrics-container fade so the two swap in sync */
  transition: opacity 0.6s ease;
}

.art-background.dimmed {
  opacity: 0.17;
}

.art-background-layer {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 1s ease;
}

.art-background-layer.showing {
  opacity: 1;
}

/* Playback controls inside .now-playing */
.player-controls {
  display: flex;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
}

.player-button {
  background: transparent;
  border: none;
  color: #fff;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0.4rem;
  cursor: pointer;
}

.player-button svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

/* Play/pause icon swap; .playing is toggled by script.js */
.player-button .icon-pause {
  display: none;
}
.player-button.playing .icon-pause {
  display: block;
}
.player-button.playing .icon-play {
  display: none;
}

#play-pause-button {
  width: 3.4rem;
  height: 3.4rem;
}

/* Thumb-friendly portrait layout: controls pinned to the bottom,
   up-next moved to the top */
@media (orientation: portrait) {
  .now-playing {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    padding: 1rem 0.4rem calc(0.9rem + env(safe-area-inset-bottom)) 1rem;
    background: #000;
  }

}

/* Artist details shown when a song has no lyrics; mirrors .next-track */


.art-background:after {
  content: '';
  position: absolute;
  top: 60vh;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(0deg, #000000b5, transparent);
}

.artist-bio {
  position: fixed;
  left: 0;
  bottom: 0;
  z-index: 1;
  max-width: 60vw;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1.2vw;
  text-align: left;
  padding: 2.5vw;
  opacity: 1;
  transition: opacity 0.5s ease;
}

.artist-bio[hidden] {
  opacity: 0;
}

.artist-bio-image {
  width: 16vw;
  height: 16vw;
  object-fit: cover;
  border-radius: 50%;
  display: none;
}

.artist-bio-name {
  text-transform: uppercase;
  letter-spacing: 0.3em;
  opacity: 0.7;
  text-shadow: 0 1px 15px rgba(0,0,0,1);
  font-size: 1.5vw;
}

.artist-bio-text {
  font-size: 2vw;
  line-height: 1.15;
  text-shadow: 0 1px 25px rgba(0,0,0,1);
  /*color: #999;*/
  margin: 0;
}

.artist-bio-meta {
  font-size: 1.4vw;
  color: #777;
}

.artist-bio-source {
  font-size: 1.1vw;
  color: #555;
  display: none;
}

@media (orientation: portrait) {
  .lyrics-container {
    font-size: 7vw;
  }
  .lyrics-container:after, .lyrics-container:before {
    height: 65vw;
  }
  .lyrics-line {
    font-size: 9vw;
    padding: 6vw 0;
    /* Extends the scroll target area downward so scrollIntoView
       "center" lands the active line 20% of the viewport higher */
    scroll-margin-bottom: 40vh;
    scroll-margin-bottom: 40dvh;
  }
  .next-track {
    /* The now-playing bar carries up-next in portrait */
    display: none;
    padding: 6vw;
    left: 0;
    right: 0;
    bottom: 0;
    gap: 1.6vw;
    font-size: 4vw;
    line-height: 1.8rem;
    align-items: center;
  }
  .next-track-name {
    font-size: 6vw;
    text-align: center;
    max-width: none;
  }
  .artist-bio {
    display: none;
  }
  .explicit {
    width: 22vw;
    top: 6vw;
    right: 6vw;
  }
}