/* ============================================
   Vibes — Apple Music Light Mode
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', sans-serif;
  background: #FFFFFF;
  color: #000000;
  min-height: 100vh;
  padding: 0 16px;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.25);
}

/* --- Layout Container --- */
.header,
.search-section,
.empty-state,
.song-section,
.vibe-section,
.loading-state,
.error-state {
  max-width: 900px;
  margin: 0 auto;
}

/* --- Header --- */
.header {
  padding: 48px 0 8px;
  text-align: center;
}

.header-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: fit-content;
  margin: 0 auto;
  cursor: pointer;
  user-select: none;
  transition: opacity 150ms ease;
}

.header-brand:hover {
  opacity: 0.65;
}

.header-icon {
  width: 32px;
  height: 32px;
  color: #FC3C44;
}

.header-title {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.1;
}

.header-subtitle {
  margin-top: 6px;
  font-size: 15px;
  font-weight: 400;
  color: rgba(60, 60, 67, 0.6);
}

/* --- Search --- */
.search-section {
  padding: 24px 0 16px;
  position: relative;
}

.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: rgba(60, 60, 67, 0.3);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 44px;
  padding: 0 44px 0 42px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 400;
  color: #000000;
  background: #F2F2F7;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 12px;
  outline: none;
  transition: border-color 200ms ease, background 200ms ease;
}

.search-input::placeholder {
  color: rgba(60, 60, 67, 0.3);
}

.search-input:focus {
  border-color: rgba(0, 0, 0, 0.12);
  background: #E5E5EA;
}

.search-clear {
  position: absolute;
  right: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: none;
  border: none;
  color: rgba(60, 60, 67, 0.3);
  cursor: pointer;
  border-radius: 50%;
  transition: color 200ms ease;
}

.search-clear:hover {
  color: rgba(60, 60, 67, 0.6);
}

/* --- Search Results Dropdown --- */
.search-results {
  position: absolute;
  top: calc(24px + 44px + 6px);
  left: 0;
  right: 0;
  background: #F2F2F7;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 12px;
  overflow: hidden;
  z-index: 100;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 200ms ease;
}

.search-result-item:hover {
  background: rgba(0, 0, 0, 0.04);
}

.search-message {
  font-size: 14px;
  color: rgba(60, 60, 67, 0.6);
  cursor: default;
  justify-content: center;
}

.search-message:hover {
  background: transparent;
}

.search-result-item + .search-result-item {
  border-top: 1px solid rgba(60, 60, 67, 0.12);
}

.search-result-art {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.search-result-info {
  min-width: 0;
  flex: 1;
}

.search-result-badge {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: #FC3C44;
  background: rgba(252, 60, 68, 0.1);
  padding: 3px 8px;
  border-radius: 6px;
}

.search-result-track {
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-artist {
  font-size: 13px;
  font-weight: 400;
  color: rgba(60, 60, 67, 0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Empty State --- */
.empty-state {
  padding: 80px 0;
  text-align: center;
}

.empty-icon {
  color: rgba(60, 60, 67, 0.3);
  margin-bottom: 16px;
}

.empty-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 6px;
}

.empty-subtitle {
  font-size: 15px;
  font-weight: 400;
  color: rgba(60, 60, 67, 0.6);
}

/* --- Song Card --- */
.song-section {
  padding: 8px 0 0;
}

.song-card {
  background: #F2F2F7;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 12px;
  padding: 20px;
}

.song-card-inner {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.album-art {
  width: 120px;
  height: 120px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
}

.song-meta {
  min-width: 0;
  flex: 1;
  padding-top: 4px;
}

.track-name {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.4px;
  line-height: 1.2;
  margin-bottom: 4px;
}

.artist-name {
  font-size: 16px;
  font-weight: 500;
  color: #FC3C44;
  margin-bottom: 2px;
}

.album-name {
  font-size: 14px;
  font-weight: 400;
  color: rgba(60, 60, 67, 0.6);
}

/* --- Player Container --- */
.player-container {
  margin-top: 16px;
}

.player-container iframe {
  width: 100%;
  height: 175px;
  border: none;
  border-radius: 10px;
}

/* Full-album embed: taller so the tracklist + play controls show. */
.player-container.album-embed iframe {
  height: 450px;
}

/* --- Vibe Scroll (Apple Music lyrics style) --- */
.vibe-section {
  padding: 24px 0 48px;
}

.vibe-scroll {
  padding: 24px 0;
}

/* --- Vibe Line --- */
.vibe-line {
  padding: 12px 0;
  opacity: 0;
  transform: translateY(8px);
  animation: vibeIn 300ms ease forwards;
}

.vibe-lyric {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.3px;
  color: #000000;
  cursor: pointer;
  transition: color 200ms ease;
}

.vibe-line:hover .vibe-lyric {
  color: rgba(60, 60, 67, 0.8);
}

.vibe-translation {
  display: grid;
  grid-template-rows: 0fr;
  margin-top: 0;
  opacity: 0;
  /* Animate real content height (no clip, no max-height jank) on Apple's lyric easing curve. */
  transition: grid-template-rows 340ms cubic-bezier(0.32, 0.72, 0, 1), opacity 240ms ease, margin-top 240ms ease;
}

.vibe-translation-inner {
  min-height: 0;
  overflow: hidden;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  color: rgba(60, 60, 67, 0.6);
}

.vibe-line.active .vibe-translation,
.vibe-line.revealed .vibe-translation {
  grid-template-rows: 1fr;
  opacity: 1;
  margin-top: 8px;
}

.vibe-line.active .vibe-lyric {
  color: #FC3C44;
}

/* Dimmed state — when any line is active, dim the others */
.vibe-scroll.has-active .vibe-line:not(.active) .vibe-lyric {
  color: rgba(60, 60, 67, 0.2);
}

/* --- Play-Along (self-driven clock) --- */
.play-along-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 4px 0 20px;
}

.play-album-btn {
  background: rgba(60, 60, 67, 0.1);
  color: #FC3C44;
}

.play-album-btn:hover {
  background: rgba(60, 60, 67, 0.16);
}

.album-progress {
  font-size: 13px;
  font-weight: 500;
  color: rgba(60, 60, 67, 0.6);
}

.play-along-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 18px 0 13px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: #FFFFFF;
  background: #FC3C44;
  border: none;
  border-radius: 19px;
  cursor: pointer;
  transition: transform 150ms ease, background 200ms ease;
}

.play-along-btn:hover { background: #E62F37; }
.play-along-btn:active { transform: scale(0.96); }

.play-along-btn.is-playing {
  background: rgba(60, 60, 67, 0.1);
  color: #FC3C44;
}

.pa-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* The lit line glows; the rest dim. The .revealed reveal is shared with .active above. */
.vibe-line.lit .vibe-lyric {
  color: #FC3C44;
}

.vibe-scroll.playing .vibe-line:not(.lit) .vibe-lyric {
  color: rgba(60, 60, 67, 0.2);
}

/* --- Section Markers --- */
.vibe-line.section-marker {
  padding: 24px 0 8px;
}

.vibe-line.section-marker .vibe-lyric {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: rgba(60, 60, 67, 0.3);
  cursor: default;
}

/* --- The Bottom Line Summary Card --- */
.vibe-summary-card {
  margin-top: 32px;
  padding: 24px;
  background: #F2F2F7;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 16px;
  opacity: 0;
  transform: translateY(8px);
  animation: vibeIn 400ms ease forwards;
}

.vibe-summary-label {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #FC3C44;
  margin-bottom: 10px;
}

.vibe-summary-text {
  font-size: 18px;
  font-weight: 500;
  line-height: 1.5;
  color: #000000;
}

/* --- Liner Notes (album finale) — a record-sleeve close to the whole listen --- */
.liner-notes-card {
  margin-top: 48px;
  padding: 28px;
  background: #000000;
  border: none;
}

.liner-notes-card .vibe-summary-label {
  color: #FC3C44;
}

.liner-notes-card .vibe-summary-text {
  color: #FFFFFF;
  font-size: 19px;
  font-weight: 500;
}

@keyframes vibeIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Loading State --- */
.loading-state {
  padding: 48px 0;
  text-align: center;
}

.loading-indicator {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.loading-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #FC3C44;
  animation: pulse 1.2s ease-in-out infinite;
}

.loading-text {
  font-size: 15px;
  font-weight: 500;
  color: rgba(60, 60, 67, 0.6);
}

@keyframes pulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.1); }
}

/* --- Error State --- */
.error-state {
  padding: 32px 0;
  text-align: center;
}

.error-message {
  font-size: 15px;
  font-weight: 400;
  color: rgba(60, 60, 67, 0.6);
}

/* --- Responsive --- */
@media (max-width: 640px) {
  .header {
    padding: 32px 0 8px;
  }

  .header-title {
    font-size: 28px;
  }

  .song-card-inner {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .album-art {
    width: 180px;
    height: 180px;
  }

  .vibe-lyric {
    font-size: 20px;
  }

  .vibe-translation-inner {
    font-size: 15px;
  }

  .vibe-summary-text {
    font-size: 16px;
  }
}

/* ============================================
   Album-color flood — Apple-style immersive view (scoped to body.flooded)
   ============================================ */
.flood-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0;
  transition: opacity 600ms ease;
  pointer-events: none;
}

body.flooded {
  background: #060606;
  color: #FFFFFF;
}
body.flooded .flood-bg { opacity: 1; }

/* Header */
body.flooded .header-title { color: #FFFFFF; }
body.flooded .header-subtitle { color: rgba(255, 255, 255, 0.6); }

/* Search bar (stays visible above a song) */
body.flooded .search-input {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.16);
  color: #FFFFFF;
}
body.flooded .search-input::placeholder { color: rgba(255, 255, 255, 0.4); }
body.flooded .search-input:focus { background: rgba(255, 255, 255, 0.16); }
body.flooded .search-icon { color: rgba(255, 255, 255, 0.4); }

/* Search results dropdown */
body.flooded .search-results { background: #1C1C1E; border-color: rgba(255, 255, 255, 0.12); }
body.flooded .search-result-track { color: #FFFFFF; }
body.flooded .search-result-item:hover { background: rgba(255, 255, 255, 0.06); }
body.flooded .search-result-item + .search-result-item { border-top-color: rgba(255, 255, 255, 0.08); }

/* Song card — frosted glass over the flood */
body.flooded .song-card {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}
body.flooded .track-name { color: #FFFFFF; }
body.flooded .album-name { color: rgba(255, 255, 255, 0.6); }

/* Lyrics + decodes */
body.flooded .vibe-lyric { color: #FFFFFF; }
body.flooded .vibe-line:hover .vibe-lyric { color: rgba(255, 255, 255, 0.8); }
body.flooded .vibe-translation-inner { color: rgba(255, 255, 255, 0.72); }
body.flooded .vibe-line.active .vibe-lyric,
body.flooded .vibe-line.lit .vibe-lyric { color: #FFFFFF; }
body.flooded .vibe-scroll.has-active .vibe-line:not(.active) .vibe-lyric,
body.flooded .vibe-scroll.playing .vibe-line:not(.lit) .vibe-lyric {
  color: rgba(255, 255, 255, 0.32);
}

/* Summary card */
body.flooded .vibe-summary-card {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
}
body.flooded .vibe-summary-text { color: #FFFFFF; }

/* Controls */
body.flooded .album-progress { color: rgba(255, 255, 255, 0.6); }
body.flooded .play-album-btn { background: rgba(255, 255, 255, 0.16); }
body.flooded .play-album-btn:hover { background: rgba(255, 255, 255, 0.24); }
body.flooded .play-along-btn.is-playing { background: rgba(255, 255, 255, 0.18); }

/* Scrollbar */
body.flooded ::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); }
