/* =========================================================
   Avishay's Realm: music page
   (loads after style.css and reuses its variables)
   ========================================================= */

.page-music { --player-h: 74px; padding-bottom: var(--player-h); }

/* ---------- Category cards ---------- */

.categories { padding: 22px 0 6px; }
.categories .section-head { margin-bottom: 22px; }

.cat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}

.cat-card {
  position: relative;
  aspect-ratio: 2.45 / 1;
  display: flex;
  align-items: flex-end;
  gap: 16px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  isolation: isolate;
  text-align: left;
  transition: border-color 0.3s, box-shadow 0.3s, transform 0.3s;
}
.cat-card .cat-art {
  position: absolute;
  inset: 0;
  z-index: -2;
  transition: transform 0.6s ease;
}
.cat-card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(0deg, rgba(8, 6, 20, 0.88) 0%, rgba(8, 6, 20, 0.45) 50%, rgba(8, 6, 20, 0.05) 100%);
}
.cat-card:hover { border-color: rgba(157, 125, 245, 0.5); transform: translateY(-2px); }
.cat-card:hover .cat-art { transform: scale(1.05); }
.cat-card[aria-selected="true"] {
  border: 2px solid var(--accent-strong);
  box-shadow: 0 0 0 1px rgba(185, 160, 255, 0.25), 0 0 28px var(--accent-glow);
}

.cat-icon { flex: none; color: #fff; }
.cat-icon svg { width: 30px; height: 30px; }
.cat-text { display: flex; flex-direction: column; min-width: 0; text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6); }
.cat-name { font-size: 1rem; font-weight: 500; line-height: 1.3; }
.cat-count { font-size: 0.82rem; color: #d6d1ee; }


/* Category artwork: a real image when set in music-data.js, otherwise a placeholder gradient */
.cat-art { background-size: cover; background-position: center; }
.cat-art--cinematic {
  background-color: #1b2a52;
  background-image:
    radial-gradient(ellipse at 70% 15%, rgba(255, 255, 255, 0.35), transparent 35%),
    radial-gradient(ellipse at 30% 110%, rgba(70, 160, 110, 0.65), transparent 55%),
    linear-gradient(180deg, #3d5fa8 0%, #5a7cc4 40%, #2e5a6a 75%, #1b2a3a 100%);
}
.cat-art--retro {
  background-color: #2a1062;
  background-image:
    repeating-linear-gradient(0deg, rgba(255, 90, 220, 0.16) 0 1px, transparent 1px 22px),
    repeating-linear-gradient(90deg, rgba(90, 220, 255, 0.12) 0 1px, transparent 1px 22px),
    radial-gradient(circle at 72% 40%, rgba(255, 70, 170, 0.75), transparent 22%),
    radial-gradient(ellipse at 75% 105%, rgba(255, 70, 200, 0.55), transparent 55%),
    linear-gradient(160deg, #150f45, #2a1062 55%, #0e0a2a);
}
.cat-art--casual {
  background-color: #4fa3c8;
  background-image:
    radial-gradient(circle at 78% 28%, rgba(255, 240, 180, 0.7), transparent 20%),
    radial-gradient(ellipse at 50% 120%, rgba(120, 190, 80, 0.85), transparent 55%),
    linear-gradient(180deg, #4fa3dc 0%, #8fcbe8 50%, #6fae5a 80%, #3f7a3a 100%);
}
.cat-art--rock {
  background-color: #3a0f1e;
  background-image:
    radial-gradient(ellipse at 65% 35%, rgba(255, 80, 60, 0.7), transparent 40%),
    radial-gradient(ellipse at 20% 0%, rgba(200, 40, 90, 0.6), transparent 55%),
    linear-gradient(180deg, #7a1c2e 0%, #4a1230 50%, #1a0a16 100%);
}

/* ---------- Track list ---------- */

.library { padding: 28px 0 52px; }

.list-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}
.list-icon { color: var(--accent-strong); }
.list-icon svg { width: 30px; height: 30px; }
.list-head h2 {
  font-size: clamp(1.4rem, 1.85vw, 1.75rem);
  font-weight: 400;
  white-space: nowrap;
  outline: none;
}
.list-count { color: var(--text-muted); white-space: nowrap; }

.track-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.row {
  display: grid;
  grid-template-columns: 40px minmax(140px, 1.1fr) 52px minmax(160px, 2.4fr);
  align-items: center;
  gap: 20px;
  padding: 9px 20px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.row:hover { background: rgba(157, 125, 245, 0.06); border-color: rgba(157, 125, 245, 0.3); }
.row.is-current { background: rgba(157, 125, 245, 0.09); border-color: rgba(157, 125, 245, 0.55); }
.row.is-current .row-title { color: var(--accent-strong); }

.row .play { background: transparent; }
.row.is-playing .play { background: var(--accent); border-color: var(--accent); }
.row.is-playing .play::before {
  left: 50%;
  width: 12px; height: 15px;
  border: 0;
  background: linear-gradient(90deg, #fff 0 35%, transparent 35% 65%, #fff 65% 100%);
}

.row-title {
  font-size: 0.98rem;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-dur { color: var(--text-muted); font-variant-numeric: tabular-nums; text-align: right; }

.wave {
  position: relative;
  height: 34px;
  cursor: pointer;
  touch-action: none;
}
.wave svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.wave-base { fill: rgba(157, 125, 245, 0.38); transition: fill 0.2s; }
.wave-played {
  fill: var(--accent-strong);
  clip-path: inset(0 calc(100% - var(--p, 0%)) 0 0);
}
.row:hover .wave-base { fill: rgba(157, 125, 245, 0.55); }

/* ---------- Player bar ---------- */

.player {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 60;
  height: var(--player-h);
  display: grid;
  grid-template-columns: minmax(200px, 1fr) auto minmax(260px, 1.4fr) auto;
  align-items: center;
  gap: 30px;
  padding: 0 clamp(16px, 3vw, 48px);
  background: rgba(14, 12, 30, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.35);
}

.player-now { display: flex; align-items: center; gap: 16px; min-width: 0; }
.player-thumb {
  flex: none;
  width: 60px;
  height: 48px;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.player-meta { min-width: 0; }
.player-title { font-size: 0.98rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-cat { font-size: 0.85rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.player-controls { display: flex; align-items: center; gap: 16px; }

.pbtn--toggle[aria-pressed="true"],
.pbtn--toggle[data-mode="all"],
.pbtn--toggle[data-mode="one"] { color: var(--accent-strong); }
.pbtn--toggle[aria-pressed="true"]::after,
.pbtn--toggle[data-mode="all"]::after,
.pbtn--toggle[data-mode="one"]::after {
  /* small "on" dot */
  content: "";
  position: absolute;
  bottom: 2px;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--accent-strong);
}
.repeat-one {
  display: none;
  position: absolute;
  top: 6px; right: 5px;
  font-size: 0.6rem;
  font-weight: 600;
  line-height: 1;
}
.pbtn--toggle[data-mode="one"] .repeat-one { display: block; }

.pbtn--main {
  width: 48px;
  height: 48px;
  color: #fff;
  border: 2px solid var(--accent);
  background: rgba(157, 125, 245, 0.16);
  box-shadow: 0 0 22px var(--accent-glow);
}
.pbtn--main:hover { background: rgba(157, 125, 245, 0.3); color: #fff; transform: scale(1.05); }
.pbtn--main svg { width: 21px; height: 21px; }
.i-pause { display: none; }
.player.is-playing .i-play { display: none; }
.player.is-playing .i-pause { display: block; }

.player-progress { display: flex; align-items: center; gap: 16px; min-width: 0; }
.player-progress .range { flex: 1; min-width: 0; }
.player-time { font-size: 0.85rem; color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.player-volume { display: flex; align-items: center; gap: 8px; }
.player-volume .range { width: 96px; }
/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 1200px) {
  .cat-grid { gap: 16px; }
  .cat-card { padding: 14px 16px; gap: 12px; }
  .cat-icon svg { width: 30px; height: 30px; }
  .cat-name { font-size: 1rem; }
  .player { gap: 24px; grid-template-columns: minmax(180px, 1fr) auto minmax(200px, 1.2fr) auto; }
  .player-volume .range { width: 80px; }
}

@media (max-width: 960px) {
  .cat-grid { grid-template-columns: repeat(2, 1fr); }
  .cat-card { aspect-ratio: 2.8 / 1; }
  .row { grid-template-columns: 44px minmax(120px, 1fr) 50px minmax(120px, 1.4fr); gap: 16px; padding: 10px 16px; }
  .player { grid-template-columns: minmax(0, 1fr) auto minmax(160px, 1fr); }
  .player-volume { display: none; }
}

@media (max-width: 640px) {
  .page-music { --player-h: 70px; }


  .cat-grid { gap: 10px; }
  .cat-card { aspect-ratio: 1.45 / 1; flex-direction: column; align-items: flex-start; justify-content: flex-end; gap: 6px; padding: 12px; }
  .cat-icon svg { width: 24px; height: 24px; }
  .cat-name { font-size: 0.92rem; }
  .cat-count { font-size: 0.8rem; }

  .list-head { gap: 12px; }
  .list-icon svg { width: 24px; height: 24px; }
  .list-head h2 { font-size: 1.15rem; white-space: normal; line-height: 1.3; }
  .list-head .rule { display: none; }
  .list-count { margin-left: auto; font-size: 0.9rem; }

  .row { grid-template-columns: 40px 1fr auto; gap: 14px; padding: 10px 14px; }
  .row .play { width: 40px; height: 40px; }
  .row .wave { display: none; }
  .row-title { font-size: 1rem; }

  /* Compact player: now playing + play/next, thin seek bar along the top edge */
  .player {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    padding: 0 12px;
  }
  .player-thumb { width: 48px; height: 48px; }
  .player-title { font-size: 0.98rem; }
  .player-controls { gap: 4px; }
  #p-shuffle, #p-repeat { display: none; }
  .pbtn--main { width: 44px; height: 44px; }
  .player-progress { position: absolute; left: 0; right: 0; top: -9px; }
  .player-time { display: none; }
  /* thin edge-to-edge bar; the handle only appears while dragging */
  .player-progress .range::-webkit-slider-runnable-track { height: 3px; border-radius: 0; }
  .player-progress .range::-webkit-slider-thumb { width: 12px; height: 12px; margin-top: -4.5px; opacity: 0; transition: opacity 0.2s; }
  .player-progress .range:active::-webkit-slider-thumb { opacity: 1; }
  .player-progress .range::-moz-range-track,
  .player-progress .range::-moz-range-progress { height: 3px; border-radius: 0; }
  .player-progress .range::-moz-range-thumb { opacity: 0; }
  .player-progress .range:active::-moz-range-thumb { opacity: 1; }
}

/* Keep toasts above the player bar */
.page-music .toast { bottom: calc(var(--player-h) + 16px); }
