/* ===== Mini music player (musicplayer.js), top left of the board =====
   It takes the other players' cards' place, as wide as their column, and
   moves the column down by its height (.has-music on the viewport). */

.music-player {
    --mp-h: 2.375rem;
    position: absolute;
    top: 0.75rem;
    left: var(--gutter);
    z-index: 22;
    display: flex;
    align-items: center;
    width: 12.25rem;
    height: var(--mp-h);
    border: 1px solid var(--border-light);
    border-radius: 999px;
    background: var(--glass);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    color: var(--text);
    box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.25);
    cursor: default;
    transition: width 0.2s ease;
}

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

.board-viewport.has-music .hud-others { top: calc(0.75rem + 2.375rem + 0.375rem); }

/* The cover: folds and opens the player. */
.mp-art {
    position: relative;
    flex: none;
    width: calc(var(--mp-h) - 2px);
    height: calc(var(--mp-h) - 2px);
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--bg-panel);
    color: var(--accent);
    cursor: pointer;
    overflow: hidden;
    display: grid;
    place-items: center;
}
.mp-art:hover, .mp-art:focus-visible { box-shadow: 0 0 0 2px var(--accent); outline: none; }
.mp-note svg { width: 1.125rem; height: 1.125rem; fill: currentColor; display: block; }
.mp-art > * { pointer-events: none; }
.mp-cover { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.mp-cover[hidden] { display: none; }
.music-player.has-cover .mp-note { visibility: hidden; }

/* Three bars bouncing over the cover while it plays. */
.mp-eq {
    position: absolute;
    left: 50%;
    bottom: 0.25rem;
    transform: translateX(-50%);
    display: none;
    align-items: flex-end;
    gap: 0.09rem;
    height: 0.6rem;
    padding: 0.08rem 0.14rem;
    border-radius: 0.15rem;
    background: rgba(0, 0, 0, 0.55);
}
.mp-eq i { display: block; width: 0.13rem; height: 100%; background: var(--reach); transform-origin: bottom; animation: mp-eq 0.9s ease-in-out infinite alternate; }
.mp-eq i:nth-child(2) { animation-delay: -0.3s; animation-duration: 0.7s; }
.mp-eq i:nth-child(3) { animation-delay: -0.6s; animation-duration: 1.1s; }
.music-player.is-playing .mp-eq { display: flex; }

@keyframes mp-eq {
    from { transform: scaleY(0.25); }
    to { transform: scaleY(1); }
}

.mp-body {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    gap: 0.0625rem;
    padding: 0 0.25rem 0 0.4375rem;
}

.mp-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.2;
    mask-image: linear-gradient(90deg, #000 85%, transparent);
    -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent);
}
.mp-title-text { display: inline-block; white-space: nowrap; }
.mp-title:not(.is-long) { mask-image: none; -webkit-mask-image: none; }
.mp-title:not(.is-long) .mp-title-text { max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
.mp-title.is-long .mp-title-text { animation: mp-marquee var(--mp-scroll, 10s) ease-in-out infinite alternate; }
.music-player.is-paused .mp-title, .music-player.is-muted .mp-title { color: var(--text-muted); }

/* Hold at each end, glide between. */
@keyframes mp-marquee {
    0%, 15% { transform: translateX(0); }
    85%, 100% { transform: translateX(var(--mp-shift, 0)); }
}

.mp-btn {
    flex: none;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    display: grid;
    place-items: center;
}
.mp-btn svg { width: 1rem; height: 1rem; fill: currentColor; display: block; pointer-events: none; }
.mp-btn:hover { background: var(--accent-dim); color: var(--accent); }
.mp-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.mp-mute[aria-pressed="true"] { color: var(--danger); }

/* Folded: only the cover. */
.music-player.is-collapsed { width: var(--mp-h); }
.music-player.is-collapsed .mp-body { display: none; }

@media (max-width: 768px) {
    /* Phones: above the avatars' column, as round as they are, clear of a
       two-line hint. */
    .music-player { --mp-h: 2.75rem; top: 3.5rem; left: 0.5rem; width: min(17rem, calc(100% - 1rem)); }
    .board-viewport.has-music .hud-others { top: calc(3.5rem + 2.75rem + 0.5rem); }
    /* Opened on purpose: over the centre prompt (40), under battles (50). */
    .music-player:not(.is-collapsed) { z-index: 41; }
    .mp-btn { width: 2.125rem; height: 2.125rem; }
    .mp-btn svg { width: 1.125rem; height: 1.125rem; }
    .mp-title { font-size: 0.8rem; }
}

@media (prefers-reduced-motion: reduce) {
    .mp-eq i { animation: none; transform: scaleY(0.7); }
    .mp-title.is-long .mp-title-text { animation: none; }
    .mp-title.is-long { mask-image: none; -webkit-mask-image: none; }
    .mp-title.is-long .mp-title-text { max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
    .music-player { transition: none; }
}
