/* ─── Music page — Deezer-inspired layout ──────────────────────────
   Structure:
     .musicPage
       .musicTopBar          ← search + tag pills + sort/set dropdowns
       .musicBody
         .musicGallery       ← left sidebar, scrollable track list
         .currentTrackCard   ← center card (cover + info + comments)
   ──────────────────────────────────────────────────────────────── */

@keyframes musicFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Page wrapper ─────────────────────────────────────────────── */
.musicPage {
  --nav-offset: clamp(60px, 8vh, 96px);
  --page-pad:   clamp(12px, 2vw, 24px);
  --sidebar-w:  clamp(220px, 26vw, 320px);
  --card-h:     clamp(420px, 68vh, 720px);

  display: flex;
  flex-direction: column;
  gap: var(--page-pad);
  width: 80vw;
  margin: 2em auto ;
  animation: musicFadeIn 0.3s ease-out;
}

/* ── Top bar ──────────────────────────────────────────────────── */
.musicTopBar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(0,0,0,0.25);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 30px;
  border: 0.5px solid rgba(255,255,255,0.1);
  flex-wrap: nowrap;
}

.musicTopBar form {
  display: contents;
}

.musicSearchInput {
  background: rgba(255,255,255,0.08);
  border: 2px solid rgba(255,255,255,0.15);
  border-radius: 20px;
  padding: 6px 14px;
  color: #fff;
  font-size: 13px;
  outline: none;
  width: clamp(100px, 16vw, 200px);
  flex-shrink: 0;
  font-family: inherit;
}

.musicSearchInput::placeholder { color: rgba(255,255,255,0.35); }
.musicSearchInput:focus { border-color: rgba(255,255,255,0.35); }

.musicTagBar {
  display: flex;
  gap: 6px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 2px 0;
}

.musicTagBar::-webkit-scrollbar { display: none; }

.musicTagBar a,
.musicTagBar span {
  background: rgba(255,255,255,0.07);
  border: 0.5px solid rgba(255,255,255,0.14);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.musicTagBar a:hover,
.musicTagBar span:hover {
  background: rgba(255,255,255,0.14);
  color: #fff;
}

.musicTagBar a.active {
  background: rgba(255,255,255,0.22);
  color: #fff;
  border-color: rgba(255,255,255,0.3);
}

.musicTopSelect {
  background: rgba(255,255,255,0.07);
  border: 0.5px solid rgba(255,255,255,0.14);
  border-radius: 20px;
  padding: 5px 12px;
  color: rgba(255,255,255,0.7);
  font-size: 12px;
  outline: none;
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.musicTopSelect option { background: #222; }

#musicSearchBtn {
  background: rgba(255,255,255,0.1);
  border: 0.5px solid rgba(255,255,255,0.2);
  border-radius: 20px;
  padding: 5px 14px;
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
  transition: background 0.15s;
}

#musicSearchBtn:hover { background: rgba(255,255,255,0.18); }

.musicFavFilterBtn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.musicFavFilterBtn img { width: 20px; height: 20px; }

/* ── Body (sidebar + card) ────────────────────────────────────── */
.musicBody {
  display: flex;
  gap: var(--page-pad);
  height: var(--card-h);
  min-height: 0;
}

/* ── Sidebar track list ───────────────────────────────────────── */
.musicGallery {
  width: var(--sidebar-w);
  flex-shrink: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  background: rgba(0,0,0,0.22);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 20px;
  border: 0.5px solid rgba(255,255,255,0.08);
  padding: 8px 0;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.2) transparent;
}

.musicGallery::-webkit-scrollbar { width: 4px; }
.musicGallery::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 4px; }

.trackItem {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
  border-radius: 0;
}

.trackItem:hover { background: rgba(255,255,255,0.07); }

.trackItem.active {
  background: rgba(255,255,255,0.12);
}

.trackItem.active .trackTitle {
  color: #fff;
}

.coverContainer {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 6px;
  overflow: hidden;
}

.cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.trackInfo {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.trackTitle {
  font-size: 16px;
  color: rgba(255,255,255,0.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}

.trackArtist {
  font-size: 14px;
  color: rgba(255,255,255,0.4);
  margin: 0;
}

.favoriteIcon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  object-fit: contain;
}

#noTracks {
  text-align: center;
  color: rgba(255,255,255,0.4);
  font-size: 13px;
  padding: 40px 16px;
}

/* ── Current track card ───────────────────────────────────────── */
.currentTrackCard {
  flex: 1;
  min-width: 0;
  height: 100%;
  border-radius: 20px;
  border: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  box-sizing: border-box;
  /* Background image set via JS on data-background-url */
  background-color: rgba(0,0,0,0.3);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* Dark overlay so content stays readable over background image */
.currentTrackCard::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(0,0,0,0.45) 0%,
    rgba(0,0,0,0.25) 40%,
    rgba(0,0,0,0.65) 100%
  );
  z-index: 0;
  pointer-events: none;
}

/* Content sits above both pseudo-elements */
.currentTrackContent {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: clamp(16px, 2.5vw, 28px) clamp(16px, 2.5vw, 32px) 12px;
  position: relative;
  z-index: 1;
  box-sizing: border-box;
}

/* Cover — large, centered, square */
.currentCoverContainer {
  flex-shrink: 0;
  width: 450px;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  background: rgba(255,255,255,0.06);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.currentCover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
  display: block;
}

/* Play button overlay on cover */
.playButton {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.35);
  opacity: 0;
  transition: opacity 0.2s;
  cursor: pointer;
  border: none;
  padding: 0;
  margin: 0;
}

.currentTrackCard.has-track .currentCoverContainer:hover .playButton,
.currentTrackCard.has-track .playButton.is-playing {
  opacity: 1;
}

.playButton img {
  width: 48px;
  height: 48px;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.6));
}

/* Info below cover — centered */
.currentInfo {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

#currentTitle {
  font-size: clamp(16px, 2.2vw, 24px);
  color: #fff;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

#currentArtist {
  font-size: 16px;
  color: rgba(255,255,255);
  margin: 0;
}

#currentDescription {
  font-size: 12px;
  color: rgba(255,255,255,0.4);
  line-height: 1.5;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 90%;
}

#currentTags { margin: 0; }

#tagList {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: center;
}

#tagList span {
  background: rgba(255,255,255,0.1);
  border: 0.5px solid rgba(255,255,255,0.18);
  color: rgb(255, 255, 255);
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s;
}

#tagList span:hover { background: rgba(255,255,255,0.2); }

/* Vote + favorite row */
.voteSection {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
}

#voteButton {
  width: 24px;
  height: 24px;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s, transform 0.15s;
  background: none;
  border: none;
  padding: 0;
}

#voteButton:hover { opacity: 1; transform: scale(1.15); }
#voteButton.voted { opacity: 1; }

#voteCount {
  font-size: 13px;
  color: rgba(255,255,255,0.6);
}

.favoriteButton {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  transition: transform 0.15s;
}

.favoriteButton:hover { transform: scale(1.15); }
.favoriteButton img { width: 20px; height: 20px; }

/* ── Comments slide-up drawer ─────────────────────────────────── */
.commentsSection {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  background: rgba(10,10,10,0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 0.5px solid rgba(255,255,255,0.1);
  border-radius: 0 0 20px 20px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s cubic-bezier(0.4,0,0.2,1);
  display: flex;
  flex-direction: column;
}

.commentsSection.open {
  max-height: 65%;
}

#commentsHeader {
  font-size: 14px;
  color: rgba(255,255,255,0.7);
  padding: 12px 20px 8px;
  margin: 0;
  border-bottom: 0.5px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.commentsList {
  flex: 1;
  overflow-y: auto;
  padding: 10px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.2) transparent;
}

.comment {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.comment-author {
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  font-weight: 500;
}

.comment-time {
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  cursor: pointer;
}

.comment-time:hover { color: rgba(255,255,255,0.7); }

.comment-text {
  font-size: 13px;
  color: rgba(255,255,255,0.8);
  margin: 0;
  line-height: 1.4;
}

.no-comments,
.loading-comments,
.comments-error {
  font-size: 13px;
  color: rgba(255,255,255,0.35);
  text-align: center;
  padding: 16px 0;
}

#commentForm {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-top: 0.5px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

#commentContent {
  flex: 1;
  background: rgba(255,255,255,0.08);
  border: 0.5px solid rgba(255,255,255,0.15);
  border-radius: 16px;
  padding: 7px 14px;
  color: #fff;
  font-size: 13px;
  font-family: inherit;
  resize: none;
  height: 34px;
  outline: none;
  line-height: 1.4;
}

#commentContent:focus { border-color: rgba(255,255,255,0.3); }

#commentForm button {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}

#commentForm button:hover { background: rgba(255,255,255,0.22); }

#commentLoginRequired {
  font-size: 13px;
  color: rgba(255,255,255,0.5);
  text-align: center;
  padding: 10px 16px;
}

#commentLoginRequired a {
  color: #fff;
  text-decoration: underline;
}

/* ── Comments toggle button ───────────────────────────────────── */
.toggleCommentsButton {
  position: absolute;
  bottom: 14px;
  right: 16px;
  z-index: 11;
  width: 28px;
  height: 28px;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s, transform 0.3s;
  filter: invert(1);
}

.toggleCommentsButton:hover { opacity: 0.9; }

.commentsSection.open ~ .toggleCommentsButton,
.currentTrackCard:has(.commentsSection.open) .toggleCommentsButton {
  transform: rotate(180deg);
  opacity: 0.8;
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 900px) {
  .musicBody {
    flex-direction: column;
    height: auto;
  }

  .musicGallery {
    width: 100%;
    height: clamp(200px, 35vh, 300px);
  }

  .currentTrackCard {
    height: clamp(380px, 60vh, 560px);
  }

  .currentTrackContent {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 20px;
  }

  .currentCoverContainer {
    width: clamp(120px, 45vw, 180px);
  }

  #currentDescription { display: none; }

  #tagList { justify-content: center; }
  .voteSection { justify-content: center; }
}

@media (max-width: 600px) {
  .musicTopBar {
    flex-wrap: wrap;
    gap: 8px;
  }

  .musicSearchInput { width: 100%; }
  .musicTagBar { order: 3; width: 100%; }
}
