/* ============================================================
   VALHALLA OTAKU — Music Player (Manga Edition)
   ============================================================ */

.music-player {
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 10px 18px;
    background: var(--ash);
    border: 3px solid var(--ink-line);
    box-shadow: 6px 6px 0 var(--ink-line);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    max-width: 450px;
    border-radius: 0; /* Boîte rigide façon case de manga */
}

.music-player::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(var(--dot-color) 1px, transparent 1.3px);
    background-size: 4px 4px;
    opacity: 0.3;
    pointer-events: none;
    z-index: 0;
}

.music-player > * {
    position: relative;
    z-index: 1;
}

/* Minimize logic */
.minimize-btn {
    background: var(--stone);
    border: 2px solid var(--ink-line);
    color: var(--dust);
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 2px 5px;
    box-shadow: 2px 2px 0 var(--ink-line);
}

.minimize-btn:hover {
    color: var(--parchment);
    transform: translate(-1px, -1px);
    box-shadow: 3px 3px 0 var(--ink-line);
}

.minimize-btn:active {
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0 var(--ink-line);
}

.music-player.minimized {
    padding: 10px 15px;
    max-width: 100px;
}

.music-player.minimized .music-info,
.music-player.minimized .player-controls {
    display: none;
}

/* Keep visualizer visible even when minimized to show playing state */
.music-player.minimized .visualizer {
    display: flex;
}

.music-player:hover {
    transform: translate(-2px, -2px);
    box-shadow: 8px 8px 0 var(--ink-line);
}

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

.player-btn {
    background: var(--stone);
    border: 2px solid var(--ink-line);
    color: var(--dust);
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    width: 32px;
    height: 32px;
    box-shadow: 2px 2px 0 var(--ink-line);
}

#play-pause-btn {
    width: 40px;
    height: 40px;
    font-size: 1.3rem;
    background: var(--gold);
    color: var(--ink);
    border: 2px solid var(--ink-line);
}

.player-btn:hover {
    transform: translate(-1px, -1px);
    box-shadow: 3px 3px 0 var(--ink-line);
    color: var(--parchment);
}

#play-pause-btn:hover {
    color: var(--ink);
}

.player-btn:active {
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0 var(--ink-line);
}

.music-info {
    display: flex;
    flex-direction: column;
    min-width: 100px;
    max-width: 150px;
    gap: 4px;
}

.track-name {
    font-family: var(--font-title);
    font-size: 0.8rem;
    color: var(--gold);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 700;
    text-shadow: 1px 1px 0 var(--ink-line);
}
html[data-theme="light"] .track-name { text-shadow: none; color: var(--ink-line); }

.track-status {
    font-family: var(--font-accent);
    font-size: 0.6rem;
    color: var(--dust);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    background: var(--ink);
    padding: 2px 4px;
    display: inline-block;
    align-self: flex-start;
    border: 2px solid var(--ink-line);
}
html[data-theme="light"] .track-status { color: var(--parchment); }

.track-status.loading {
    animation: loading-pulse 1.5s infinite ease-in-out;
}

@keyframes loading-pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Visualizer */
.visualizer {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 12px;
}

.bar {
    width: 3px;
    background: var(--ink-line);
    transition: height 0.2s ease;
    height: 3px;
}

.playing .bar {
    animation: bounce 1.2s infinite steps(4, end);
}

.playing .bar:nth-child(2) { animation-delay: 0.2s; }
.playing .bar:nth-child(3) { animation-delay: 0.4s; }
.playing .bar:nth-child(4) { animation-delay: 0.6s; }

@keyframes bounce {
    0%, 100% { height: 3px; }
    50% { height: 12px; }
}

/* Volume control */
.volume-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 0;
    opacity: 0;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.music-player:not(.minimized):hover .volume-wrapper,
.volume-wrapper.force-show {
    width: 80px;
    opacity: 1;
    margin-left: 5px;
    pointer-events: auto;
}

.volume-slider {
    width: 70px;
    height: 6px;
    -webkit-appearance: none;
    background: var(--stone);
    border: 2px solid var(--ink-line);
    outline: none;
    cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--gold);
    border: 2px solid var(--ink-line);
    border-radius: 0; /* Bouton curseur carré */
}

/* Responsive fixes */
@media (max-width: 600px) {
    .music-player {
        bottom: 100px;
        right: 15px;
        left: 15px;
        max-width: none;
        padding: 10px 12px;
        justify-content: space-between;
    }

    .music-player.minimized {
        left: auto;
        width: auto;
        max-width: 80px;
        bottom: 150px;
    }

    .music-info {
        min-width: 0;
        flex: 1;
        margin: 0 10px;
    }

    .track-name {
        max-width: 120px;
    }

    .player-btn {
        width: 30px;
        height: 30px;
        font-size: 1rem;
    }

    #play-pause-btn {
        width: 36px;
        height: 36px;
    }

    .volume-wrapper.force-show {
        position: absolute;
        bottom: 70px;
        right: -3px;
        background: var(--ash);
        padding: 10px;
        border: 3px solid var(--ink-line);
        box-shadow: 6px 6px 0 var(--ink-line);
        width: 120px;
        height: 40px;
        justify-content: center;
    }
}
