/* Music gallery (music.html). Builds on css/site.css tokens. Mobile first. */
.page-music {
  --mp-h: 0px;            /* set by JS to the player's height while it is visible */
  --mp-bg: rgba(10, 13, 19, 0.96);
  --mp-text: #e6ebf5;
  --mp-dim: #8f9bb0;
}
.page-music main { padding-bottom: calc(var(--mp-h) + 1rem); }
.page-music .site-footer { margin-bottom: var(--mp-h); }

.music-hero .music-stats {
  color: var(--mp-dim);
  font-weight: 600;
  letter-spacing: 0.02em;
  margin: 0.75rem 0 0;
}
.music-hero .btn { min-height: 44px; }

/* ---------- toolbar ---------- */
.music-library { padding-bottom: 2rem; }
.music-toolbar { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 0.9rem; }
@media (min-width: 576px) {
  .music-toolbar { flex-direction: row; }
  .music-search { flex: 1 1 auto; }
  .music-sort { flex: 0 0 13rem; }
}
.music-search, .music-sort {
  background-color: var(--da-elevated);
  border: 1px solid var(--bs-border-color);
  color: var(--mp-text);
  min-height: 44px;
}
.music-search:focus, .music-sort:focus { border-color: var(--da-accent); box-shadow: 0 0 0 0.2rem rgba(59, 158, 255, 0.25); background-color: var(--da-elevated); color: #fff; }

.music-chips {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  padding: 0.15rem 0 0.6rem;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
.music-chip {
  flex: 0 0 auto;
  border: 1px solid var(--bs-border-color);
  background: var(--da-elevated);
  color: var(--bs-body-color);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  min-height: 36px;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.music-chip small { opacity: 0.6; font-weight: 500; margin-left: 0.2rem; }
.music-chip:hover { border-color: var(--da-border); color: #fff; }
.music-chip[aria-pressed="true"] { background: var(--da-accent-2); border-color: var(--da-accent); color: #fff; }
.music-chip:focus-visible, .album-card:focus-visible, .track-row:focus-visible, .mp-btn:focus-visible, .mp-thumb:focus-visible {
  outline: 2px solid var(--da-accent);
  outline-offset: 2px;
}

.music-count { color: var(--mp-dim); font-size: 0.85rem; margin: 0.2rem 0 0.8rem; }
.music-empty { text-align: center; color: var(--mp-dim); padding: 3rem 0; }

/* ---------- grid ---------- */
.album-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}
@media (min-width: 576px) { .album-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; } }
@media (min-width: 992px) { .album-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.25rem; } }
@media (min-width: 1200px) { .album-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

.album-card {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0;
  border: 1px solid var(--bs-border-color);
  border-radius: 0.8rem;
  background: var(--da-elevated);
  color: inherit;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  content-visibility: auto;
  contain-intrinsic-size: auto 300px;
}
.album-card:hover { transform: translateY(-3px); border-color: var(--da-accent); box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45); }
.album-card.is-playing { border-color: var(--da-accent); box-shadow: 0 0 0 1px var(--da-accent) inset; }
.album-card .cov { display: block; position: relative; aspect-ratio: 1 / 1; background: #0a0d12; }
.cov img, .album-art img, .mp-thumb img, .cov-ph { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.cov-ph {
  display: flex; align-items: center; justify-content: center;
  color: rgba(255, 255, 255, 0.92);
  font-weight: 900;
  font-size: clamp(1.8rem, 8vw, 3.6rem);
  letter-spacing: 0.04em;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.45);
  user-select: none;
}
.album-card .card-body { padding: 0.65rem 0.75rem 0.8rem; }
.album-card .t { font-weight: 700; font-size: 0.95rem; line-height: 1.25; overflow-wrap: anywhere; color: #fff; display: block; }
.album-card .a { font-size: 0.8rem; color: var(--da-accent); font-weight: 600; display: block; margin-top: 0.15rem; }
.album-card .m { font-size: 0.75rem; color: var(--mp-dim); display: block; margin-top: 0.2rem; }
.album-card .hit { font-size: 0.72rem; color: #ffd166; display: block; margin-top: 0.25rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.album-card .eq-badge { position: absolute; right: 0.5rem; bottom: 0.5rem; background: rgba(8, 10, 14, 0.8); border-radius: 0.5rem; padding: 0.25rem 0.4rem; }

/* ---------- album view ---------- */
.album-view { max-width: 920px; margin: 0 auto; }
.album-back { margin-bottom: 1rem; min-height: 40px; }
.album-head { display: flex; flex-direction: column; gap: 1.1rem; align-items: center; text-align: center; }
.album-art { position: relative; width: min(100%, 320px); aspect-ratio: 1 / 1; border-radius: 0.9rem; overflow: hidden; box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55); background: #0a0d12; flex: 0 0 auto; }
.album-artist { color: var(--da-accent); font-weight: 700; margin: 0; letter-spacing: 0.04em; text-transform: uppercase; font-size: 0.85rem; }
.album-info h2 { font-weight: 900; font-size: clamp(1.6rem, 6vw, 2.6rem); line-height: 1.1; margin: 0.25rem 0 0.5rem; overflow-wrap: anywhere; outline: none; }
.album-meta { color: var(--mp-dim); margin: 0 0 1rem; }
.album-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; justify-content: center; }
.album-actions .btn { min-height: 44px; }
@media (min-width: 640px) {
  .album-head { flex-direction: row; align-items: flex-end; text-align: left; gap: 1.75rem; }
  .album-actions { justify-content: flex-start; }
}
.album-desc { margin: 1.5rem 0 1rem; max-width: 70ch; line-height: 1.65; }
.album-desc p { margin: 0 0 0.9rem; }

.track-list { list-style: none; margin: 1.25rem 0 0; padding: 0; border-top: 1px solid var(--bs-border-color); }
.track-list li { border-bottom: 1px solid var(--bs-border-color); }
.track-row {
  display: flex; align-items: center; gap: 0.75rem;
  width: 100%; min-height: 48px;
  padding: 0.55rem 0.5rem;
  background: transparent; border: 0; color: inherit; text-align: left; cursor: pointer;
  border-radius: 0.4rem;
}
.track-row:hover { background: rgba(59, 158, 255, 0.08); }
.track-row .n { flex: 0 0 2rem; text-align: right; color: var(--mp-dim); font-variant-numeric: tabular-nums; font-size: 0.85rem; display: flex; justify-content: flex-end; align-items: center; }
.track-row .tt { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.track-row .tt small { display: block; color: var(--mp-dim); font-size: 0.78rem; }
.track-li { display: flex; align-items: center; }
.track-li .track-row { flex: 1 1 auto; min-width: 0; }
.track-row .tt { text-overflow: ellipsis; }
.track-row .d { flex: 0 0 auto; color: var(--mp-dim); font-variant-numeric: tabular-nums; font-size: 0.85rem; }
.track-row .pp { flex: 0 0 auto; width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: var(--da-accent); border: 1px solid var(--bs-border-color); }
.track-row .pp svg { width: 16px; height: 16px; fill: currentColor; }
.track-row.is-current { background: rgba(59, 158, 255, 0.14); }
.track-row.is-current .tt { color: #fff; font-weight: 700; }
.track-row.is-current .pp { background: var(--da-accent-2); color: #fff; border-color: var(--da-accent); }

/* equalizer bars */
.eq { display: inline-flex; gap: 2px; align-items: flex-end; height: 14px; }
.eq i { width: 3px; background: var(--da-accent); height: 40%; border-radius: 1px; animation: eq 0.9s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: -0.3s; }
.eq i:nth-child(3) { animation-delay: -0.6s; }
.eq.is-paused i { animation-play-state: paused; }
@keyframes eq { 0%, 100% { height: 25%; } 50% { height: 100%; } }

/* placeholder gradient + cover in album view */
.album-art .cov-ph { font-size: clamp(3rem, 18vw, 6rem); }

/* ---------- toast ---------- */
.music-toast {
  position: fixed; left: 50%; bottom: calc(var(--mp-h) + 1rem); transform: translate(-50%, 20px);
  background: #1b2433; color: #fff; border: 1px solid var(--da-border); border-radius: 0.6rem;
  padding: 0.6rem 1rem; z-index: 1045; max-width: min(92vw, 28rem); font-size: 0.9rem;
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease, transform 0.2s ease;
}
.music-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- player bar ---------- */
.music-player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
  background: var(--mp-bg);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--da-border);
  color: var(--mp-text);
  padding: 0.5rem 0.75rem calc(0.5rem + env(safe-area-inset-bottom, 0px));
  display: flex; flex-wrap: wrap; align-items: center; column-gap: 0.4rem; row-gap: 0.1rem;
}
.music-player[hidden] { display: none; }
.mp-now { order: 1; flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: 0.6rem; }
.mp-thumb { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 0.4rem; overflow: hidden; padding: 0; border: 0; background: #0a0d12; position: relative; cursor: pointer; }
.mp-thumb .cov-ph { font-size: 1rem; }
.mp-text { min-width: 0; }
.mp-title { font-weight: 700; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-sub { font-size: 0.75rem; color: var(--mp-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.mp-controls, .mp-seek { display: contents; }
.mp-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent; color: var(--mp-text);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; flex: 0 0 auto;
}
.mp-btn svg { width: 22px; height: 22px; fill: currentColor; display: block; }
.mp-btn:hover { background: rgba(255, 255, 255, 0.08); }
.mp-btn.mp-sm svg { width: 19px; height: 19px; }
.mp-btn.mp-sm { color: var(--mp-dim); }
.mp-btn.mp-sm[aria-pressed="true"] { color: var(--da-accent); }
.mp-btn.mp-play { background: #fff; color: #0b1018; width: 46px; height: 46px; }
.mp-btn.mp-play:hover { background: #dbe8ff; }
#mpPrev { order: 2; } #mpPlay { order: 3; } #mpNext { order: 4; }
.music-player::before { content: ""; order: 5; flex: 0 0 100%; height: 0; }
#mpShuffle { order: 6; } #mpRepeat { order: 10; }
#mpElapsed { order: 7; } #mpSeek { order: 8; } #mpTotal { order: 9; }
.mp-time { font-size: 0.72rem; color: var(--mp-dim); font-variant-numeric: tabular-nums; min-width: 2.4rem; text-align: center; }
.mp-vol { display: none; }
#mpSeek { flex: 1 1 0; min-width: 0; }

.music-player input[type="range"] {
  -webkit-appearance: none; appearance: none; background: transparent; height: 24px; cursor: pointer; margin: 0;
  --pct: 0%;
}
.music-player input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--da-accent) var(--pct), rgba(255, 255, 255, 0.18) var(--pct)); }
.music-player input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.18); }
.music-player input[type="range"]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--da-accent); }
.music-player input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: #fff; margin-top: -5px; border: 0; }
.music-player input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 0; }
.music-player input[type="range"]:focus-visible { outline: 2px solid var(--da-accent); outline-offset: 2px; border-radius: 4px; }

@media (min-width: 768px) {
  .music-player {
    left: var(--da-rail-current, 0px);
    transition: left 0.22s ease;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, 1fr);
    grid-template-areas: "now ctrl vol" "now seek vol";
    column-gap: 1rem; row-gap: 0;
    padding: 0.6rem 1.25rem calc(0.6rem + env(safe-area-inset-bottom, 0px));
  }
  .music-player::before { display: none; }
  .mp-now { grid-area: now; order: 0; }
  .mp-thumb { width: 56px; height: 56px; }
  .mp-controls { grid-area: ctrl; display: flex; justify-content: center; align-items: center; gap: 0.35rem; }
  .mp-seek { grid-area: seek; display: flex; align-items: center; gap: 0.5rem; }
  .mp-controls > *, .mp-seek > * { order: 0 !important; }
  /* visual order inside controls: shuffle, prev, play, next, repeat (DOM order) */
  .mp-vol { grid-area: vol; display: flex; align-items: center; justify-content: flex-end; gap: 0.25rem; }
  #mpVol { width: 110px; }
}

@media (prefers-reduced-motion: reduce) {
  .album-card, .music-toast, .music-player { transition: none; }
  .album-card:hover { transform: none; }
  .eq i { animation: none; height: 70%; }
}

/* download buttons */
.track-li .dl, #mpDl {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--mp-dim); text-decoration: none;
}
.track-li .dl svg, #mpDl svg { width: 20px; height: 20px; fill: currentColor; }
.track-li .dl:hover, #mpDl:hover { background: rgba(59, 158, 255, 0.14); color: var(--da-accent); }
.track-li .dl:focus-visible, #mpDl:focus-visible { outline: 2px solid var(--da-accent); outline-offset: 2px; }
#mpDl[hidden] { display: none; }
#mpDl { order: 11; }
@media (max-width: 400px) { .track-row { gap: 0.5rem; } .track-row .n { flex-basis: 1.4rem; } }
@media (min-width: 768px) { #mpDl { order: 0; } }
.music-unsupported { color: #ffd166; text-align: center; padding: 0.5rem 1rem; }

/* share + artist */
.track-li .shr, #mpShare { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent; display: inline-flex; align-items: center; justify-content: center; color: var(--mp-dim); cursor: pointer; padding: 0; }
.track-li .shr svg, #mpShare svg { width: 19px; height: 19px; fill: currentColor; }
.track-li .shr:hover, #mpShare:hover { background: rgba(59, 158, 255, 0.14); color: var(--da-accent); }
.track-li .shr:focus-visible, #mpShare:focus-visible, .artist-link:focus-visible { outline: 2px solid var(--da-accent); outline-offset: 2px; }
#mpShare { order: 12; }
@media (min-width: 768px) { #mpShare { order: 0; } }
.album-share { min-width: 44px; min-height: 44px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.album-share svg { width: 20px; height: 20px; fill: currentColor; }
.artist-link { color: inherit; text-decoration: underline dotted; }
.artist-link:hover { color: #fff; }
.album-prompt { margin: 1rem 0 0; padding: 0.6rem 0.9rem; border: 1px solid var(--da-accent); border-radius: 0.6rem; background: rgba(59, 158, 255, 0.1); display: flex; gap: 0.75rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.album-prompt[hidden] { display: none; }
.track-li.is-target { outline: 2px solid var(--da-accent); outline-offset: -2px; border-radius: 0.4rem; }
.artist-view { max-width: 1100px; }
.artist-view h2 { font-weight: 900; font-size: clamp(1.8rem, 7vw, 3rem); margin: 0.2rem 0 0.4rem; outline: none; overflow-wrap: anywhere; }
.artist-h { font-size: 1.1rem; font-weight: 800; margin: 1.75rem 0 0.8rem; }
.music-chip { text-decoration: none; display: inline-flex; align-items: center; }
@media (max-width: 767px) { .music-player .mp-btn.mp-sm, .music-player #mpDl, .music-player #mpShare { width: 40px; height: 44px; } }
