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

:root {
  --bg:         #0a0a0f;
  --surface:    #16213e;
  --card:       #1a1a2e;
  --card-hover: #1e1e38;
  --border:     rgba(255,255,255,.08);
  --accent:     #8b5cf6;
  --accent-dim: rgba(139,92,246,.25);
  --text-1:     #f3f4f6;
  --text-2:     #9ca3af;
  --text-3:     #6b7280;
  --radius:     12px;
  --player-h:   72px;
}

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text-1);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  min-height: 100dvh;
  line-height: 1.5;
}

img { display: block; max-width: 100%; }

button { cursor: pointer; border: none; background: none; color: inherit; font: inherit; }

/* ── Header ───────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(10,10,15,.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 1.5rem;
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}

.site-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -.025em;
  color: var(--text-1);
}

.site-subtitle {
  font-size: .8125rem;
  color: var(--text-3);
  margin-top: .125rem;
}

.track-count {
  font-size: .75rem;
  color: var(--text-3);
  white-space: nowrap;
}

/* ── Genre bar ────────────────────────────────────────────── */
.genre-bar {
  border-bottom: 1px solid var(--border);
  padding: .625rem 1.5rem;
}

.genre-chips {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  gap: .5rem;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.genre-chips::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  padding: .3125rem .875rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 500;
  background: rgba(255,255,255,.08);
  color: var(--text-2);
  transition: background .15s, color .15s;
}

.chip:hover { background: rgba(255,255,255,.14); color: var(--text-1); }

.chip.active {
  background: var(--accent);
  color: #fff;
}

/* ── Main grid ────────────────────────────────────────────── */
.main-content {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  padding-bottom: calc(var(--player-h) + 2rem);
}

.track-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1.25rem;
}

/* ── Track card ───────────────────────────────────────────── */
.track-card {
  display: flex;
  flex-direction: column;
}

.cover-wrap {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card);
  cursor: pointer;
  outline: 2px solid transparent;
  outline-offset: 2px;
  transition: outline-color .15s;
}

.cover-wrap:focus-visible { outline-color: var(--accent); }

.cover-wrap.active { outline-color: var(--accent); }

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

.cover-placeholder {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #4c1d95 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.cover-placeholder svg {
  width: 40%;
  height: 40%;
  opacity: .3;
}

.cover-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .18s;
}

.cover-wrap:hover .cover-overlay { background: rgba(0,0,0,.45); }

.cover-wrap.active .cover-overlay { background: rgba(0,0,0,.15); }

.play-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255,255,255,.92);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #111;
  transform: scale(.85);
  opacity: 0;
  transition: transform .18s, opacity .18s;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
}

.cover-wrap:hover .play-circle,
.cover-wrap.active .play-circle {
  opacity: 1;
  transform: scale(1);
}

.play-circle svg { width: 20px; height: 20px; }

/* push play icon slightly right for optical centering */
.play-circle .icon-play { transform: translateX(2px); }

.track-info { margin-top: .5rem; padding: 0 .125rem; }

.track-title {
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-artist {
  font-size: .75rem;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: .125rem;
}

.track-meta {
  display: flex;
  align-items: center;
  gap: .375rem;
  margin-top: .375rem;
  flex-wrap: nowrap;
}

.genre-tag {
  font-size: .6875rem;
  background: rgba(255,255,255,.09);
  color: var(--text-2);
  padding: .125rem .5rem;
  border-radius: 999px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 7rem;
}

.duration {
  font-size: .6875rem;
  color: var(--text-3);
  white-space: nowrap;
}

.lyrics-btn {
  font-size: .6875rem;
  color: var(--text-3);
  margin-left: auto;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color .15s;
  white-space: nowrap;
}

.lyrics-btn:hover { color: var(--text-2); }

.lyrics-panel {
  margin-top: .5rem;
  max-height: 180px;
  overflow-y: auto;
  background: rgba(255,255,255,.04);
  border-radius: 8px;
  padding: .75rem;
  font-size: .75rem;
  line-height: 1.6;
  color: var(--text-2);
  white-space: pre-wrap;
  scrollbar-width: thin;
  scrollbar-color: var(--text-3) transparent;
}

/* ── Skeleton loading ─────────────────────────────────────── */
.skeleton {
  animation: pulse 1.5s ease-in-out infinite;
  background: var(--card);
  border-radius: var(--radius);
}

.skeleton-cover {
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
}

.skeleton-line {
  height: .75rem;
  border-radius: 4px;
  margin-top: .5rem;
}

.skeleton-line.w-3q { width: 75%; }
.skeleton-line.w-half { width: 50%; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .4; }
}

/* ── Empty / error state ──────────────────────────────────── */
.state-message {
  grid-column: 1 / -1;
  text-align: center;
  padding: 5rem 1rem;
  color: var(--text-3);
  font-size: .9375rem;
}

/* ── Player bar ───────────────────────────────────────────── */
.player-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--player-h);
  background: rgba(10,10,15,.96);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  z-index: 20;
  display: flex;
  align-items: center;
}

.player-bar[hidden] { display: none; }

.player-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
}

.player-cover-wrap {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
  background: var(--card);
}

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

.player-cover-placeholder {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #1e1b4b, #4c1d95);
  display: none;
}

.player-meta {
  min-width: 0;
  flex: 0 0 140px;
  display: flex;
  flex-direction: column;
}

.player-title {
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-artist {
  font-size: .75rem;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.play-btn {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #fff;
  color: #111;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, transform .1s;
}

.play-btn:hover { background: #e5e7eb; transform: scale(1.05); }
.play-btn:active { transform: scale(.95); }

.play-btn svg { width: 18px; height: 18px; }
.play-btn .icon-play { transform: translateX(2px); }

/* Player bar icon toggle */
.play-btn .icon-pause { display: none; }

body.playing .play-btn .icon-play  { display: none; }
body.playing .play-btn .icon-pause { display: block; }

/* Card overlay: show pause icon when this card is the active playing track */
.cover-wrap.playing .play-circle .icon-play  { display: none; }
.cover-wrap.playing .play-circle .icon-pause { display: block; }

.scrubber-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: .625rem;
  min-width: 0;
}

.time-label {
  font-size: .6875rem;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  width: 2.5rem;
}

#time-current { text-align: right; }
#time-total   { text-align: left; }

.scrubber {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,.15);
  outline: none;
  cursor: pointer;
  min-width: 0;
}

.scrubber::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.scrubber::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  cursor: pointer;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 640px) {
  .player-meta { flex: 0 0 100px; }
  .track-grid  { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 1rem; }
  .site-header { padding: 1rem; }
  .main-content { padding: 1.25rem 1rem calc(var(--player-h) + 1.5rem); }
}

@media (max-width: 400px) {
  .player-meta { display: none; }
  .track-grid  { grid-template-columns: repeat(2, 1fr); }
}
