/* Music page (bgm.php): the player and the track list. Tokens, panels and buttons come from css/character.css;
   everything here is scoped under .bg and prefixed bg-. */

.bg { display: grid; gap: 14px; align-content: start; }
.bg > * { min-width: 0; }
.bg > #top-banner:empty { display: none; }

/* ── Head ──────────────────────────────────────────────────────── */
.bg-head { display: grid; gap: 8px; }
.bg-crumb { margin: 12px 0 0; color: var(--acc2); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; }
.bg-h1 { display: inline-block; justify-self: start; margin-bottom: 4px; }
.bg-lead { max-width: 76ch; margin: 0; color: var(--text-2); font-size: 0.92rem; }
.bg-nojs { margin: 0; color: var(--text-2); font-size: 0.9rem; }

/* ── Player: stays in view while the list scrolls ──────────────── */
.bg-player {
    position: sticky;
    top: 8px;
    z-index: 20;
    display: grid;
    gap: 10px;
    border-color: color-mix(in srgb, var(--acc2) 45%, transparent);
    background:
        radial-gradient(circle, rgba(255, 255, 255, 0.05) 1px, transparent 1.4px) 0 0 / 10px 10px,
        linear-gradient(135deg, #1c1640, #101a34 60%);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
.bg-now { display: flex; align-items: center; gap: 12px; min-width: 0; }
.bg-now-txt { flex: 1 1 auto; min-width: 0; }
.bg-now-g { margin: 0; color: var(--acc2); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; }
.cd-jp .bg-now-g { letter-spacing: 0; }
.bg-now-t { margin: 0; overflow: hidden; color: #fff; font: 400 clamp(1.05rem, 3.4vw, 1.45rem)/1.2 var(--font-display); text-overflow: ellipsis; white-space: nowrap; }
.bg-ctl { display: flex; flex: none; align-items: center; gap: 8px; }

.bg-btn {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 40px;
    height: 40px;
    padding: 0 10px;
    border: 2px solid #05080f;
    border-radius: 999px;
    background: #24305a;
    color: #fff;
    font: 700 0.82rem/1 var(--font-body);
    box-shadow: 2px 2px 0 #05080f;
    cursor: pointer;
    transition: background 0.15s, translate 0.1s, box-shadow 0.1s;
}
.bg-btn:hover { background: #33427a; }
.bg-btn:active { translate: 1px 1px; box-shadow: 1px 1px 0 #05080f; }
.bg-btn:focus-visible, .bg-play:focus-visible, .bg-wave:focus-visible, .bg-vol input:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.bg-main { width: 56px; height: 56px; min-width: 56px; padding: 0; background: var(--gold); color: #0b0f1a; box-shadow: 3px 3px 0 #05080f; }
.bg-main:hover { background: #ffe07d; }
.bg-loop[aria-pressed="true"] { background: var(--acc); color: var(--acc-ink); }
.bg-loop[aria-pressed="false"] { color: var(--text-3); }
.bg-loop[aria-pressed="false"] span { text-decoration: line-through; }

/* play / pause / loading faces of the two kinds of play button */
.bg-ic-play, .bg-ic-pause, .bg-eq, .bg-spin { display: none; line-height: 0; }
.bg-main .bg-ic-play { display: inline-block; translate: 1px 0; }
.bg-player[data-state="playing"] .bg-main .bg-ic-play, .bg-player[data-state="loading"] .bg-main .bg-ic-play { display: none; }
.bg-player[data-state="playing"] .bg-main .bg-ic-pause { display: inline-block; }
.bg-player[data-state="loading"] .bg-spin {
    display: inline-block;
    width: 22px;
    height: 22px;
    border: 3px solid rgba(11, 15, 26, 0.25);
    border-top-color: #0b0f1a;
    border-radius: 50%;
    animation: bg-spin 0.8s linear infinite;
}
@keyframes bg-spin { to { rotate: 360deg; } }

.bg-vol { display: inline-flex; align-items: center; gap: 6px; margin: 0; color: var(--text-2); }
.bg-vol input { width: 92px; accent-color: var(--acc2); cursor: pointer; }

.bg-wave {
    position: relative;
    height: 72px;
    border: 2px solid #05080f;
    border-radius: 10px;
    background: rgba(5, 8, 15, 0.55);
    cursor: pointer;
    touch-action: none;       /* a drag on the bar seeks, it does not scroll */
    overflow: hidden;
}
.bg-wave canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.bg-time { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; color: var(--text-2); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.bg-loopnote { overflow: hidden; color: var(--text-3); font-size: 0.76rem; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.bg-msg { min-height: 1.3em; margin: -4px 0 0; color: var(--text-3); font-size: 0.8rem; }

/* ── Track list ────────────────────────────────────────────────── */
.bg-count { margin-left: 6px; color: var(--text-3); font: 600 0.78rem/1 var(--font-body); letter-spacing: 0; vertical-align: middle; }
.bg-list { display: grid; gap: 6px; margin: 12px 0 0; padding: 0; list-style: none; }
.bg-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 4px 12px;
    padding: 8px 12px 8px 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    background: rgba(10, 22, 40, 0.55);
    cursor: pointer;
    scroll-margin-top: calc(var(--bg-player-h, 250px) + 20px);   /* an #anchor lands below the sticky player (js sets its height) */
    transition: background 0.15s, border-color 0.15s;
}
.bg-row:hover { border-color: color-mix(in srgb, var(--acc2) 45%, transparent); background: rgba(124, 58, 237, 0.14); }
.bg-row.is-current { border-color: var(--acc2); background: rgba(124, 58, 237, 0.24); }
.bg-play {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 2px solid #05080f;
    border-radius: 50%;
    background: #fff;
    color: #0b0f1a;
    box-shadow: 2px 2px 0 #05080f;
    cursor: pointer;
}
.bg-play .bg-ic-play { display: inline-block; translate: 1px 0; }
.bg-row.is-current .bg-play { background: var(--gold); }
.bg-row.is-playing .bg-ic-play, .bg-row.is-loading .bg-ic-play { display: none; }
.bg-row.is-playing .bg-eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 16px; }
.bg-eq i { width: 3px; height: 100%; border-radius: 1px; background: #0b0f1a; transform-origin: 50% 100%; animation: bg-eq 0.9s ease-in-out infinite; }
.bg-eq i:nth-child(2) { animation-delay: -0.3s; }
.bg-eq i:nth-child(3) { animation-delay: -0.6s; }
@keyframes bg-eq { 0%, 100% { scale: 1 0.3; } 50% { scale: 1 1; } }
.bg-row.is-loading .bg-play::after {
    content: '';
    width: 16px;
    height: 16px;
    border: 3px solid rgba(11, 15, 26, 0.25);
    border-top-color: #0b0f1a;
    border-radius: 50%;
    animation: bg-spin 0.8s linear infinite;
}
.bg-row-txt { display: grid; gap: 1px; min-width: 0; }
.bg-row-t { color: #fff; font: 400 1.02rem/1.25 var(--font-display); letter-spacing: 0.3px; }
.cd-jp .bg-row-t { letter-spacing: 0; }
.bg-row-u { color: var(--text-2); font-size: 0.8rem; line-height: 1.4; }
.bg-row-meta { display: grid; justify-items: end; gap: 3px; color: var(--text-2); font-size: 0.82rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bg-tag { padding: 1px 7px; border: 1px solid color-mix(in srgb, var(--acc2) 55%, transparent); border-radius: 999px; color: var(--acc2); font-size: 0.66rem; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; }
.bg-tag-once { border-color: rgba(255, 255, 255, 0.18); color: var(--text-3); }
.bg-native { grid-column: 1 / -1; width: 100%; height: 36px; margin-top: 4px; }

/* ── About ─────────────────────────────────────────────────────── */
.bg-facts { display: grid; gap: 10px; margin: 12px 0 0; }
.bg-facts > div { display: grid; gap: 2px 14px; }
.bg-facts dt { color: var(--acc2); font-size: 0.76rem; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; }
.bg-facts dd { margin: 0; color: var(--text-2); font-size: 0.9rem; }
@media (min-width: 700px) { .bg-facts > div { grid-template-columns: 150px minmax(0, 1fr); align-items: baseline; } }

/* ── Phones ────────────────────────────────────────────────────── */
@media (max-width: 620px) {
    .bg-player { top: 4px; gap: 8px; padding: 12px; }
    .bg-now { flex-wrap: wrap; gap: 8px 10px; }
    .bg-now-txt { flex: 1 1 0; }
    .bg-ctl { flex: 1 1 100%; justify-content: space-between; }
    .bg-main { width: 48px; height: 48px; min-width: 48px; }
    .bg-vol input { width: 76px; }
    .bg-wave { height: 54px; }
    .bg-loopnote { display: none; }
    .bg-row { gap: 4px 10px; padding: 8px 10px 8px 8px; }
    .bg-row-u { font-size: 0.76rem; }
}
@media (prefers-reduced-motion: reduce) {
    .bg-eq i, .bg-spin, .bg-row.is-loading .bg-play::after { animation: none; }
    .bg-btn, .bg-row { transition: none; }
}
