/* Static FM — Music Player Component
   Replaces the Spotify embed iframe with SDK-powered controls.
   Designed by Claudia, 2026-03-23.

   States:
   1. Disconnected — "connect spotify" or "listen free" buttons
   2. Connected (Spotify) — full playback controls + volume
   3. Connected (Free) — same controls, soundcloud-backed
   4. Loading — tuning animation between tracks
*/

/* Player container — replaces .spotify-embed-container */
.music-player {
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 12px;
}

/* Provider badge */
.player-provider {
    font-family: 'Space Mono', monospace;
    font-size: 9px;
    letter-spacing: 2px;
    color: var(--text-dim);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.player-provider .provider-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--accent);
    animation: providerPulse 2s ease-in-out infinite;
}

@keyframes providerPulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* Track display — album art + info side by side */
.player-track {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.player-art {
    width: 56px;
    height: 56px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.03);
    flex-shrink: 0;
    overflow: hidden;
}

.player-art img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.3s;
}

.player-art img.loaded {
    opacity: 1;
}

.player-meta {
    flex: 1;
    min-width: 0;
}

.player-title {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.player-artist {
    font-size: 12px;
    font-weight: 300;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Progress bar */
.player-progress {
    margin-bottom: 12px;
}

.progress-bar {
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 2px;
    cursor: pointer;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s linear;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    right: -4px;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0;
    transition: opacity 0.2s;
}

.progress-bar:hover .progress-fill::after {
    opacity: 1;
}

.progress-times {
    display: flex;
    justify-content: space-between;
    font-family: 'Space Mono', monospace;
    font-size: 9px;
    color: var(--text-dim);
    margin-top: 4px;
}

/* Transport controls */
.player-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 12px;
}

.player-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    transition: color 0.2s;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.player-btn:hover {
    color: var(--text-primary);
}

.player-btn.play-pause {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 16px;
}

.player-btn.play-pause:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* Volume — sits alongside atmosphere slider */
.player-volume {
    display: flex;
    align-items: center;
    gap: 8px;
}

.volume-icon {
    font-size: 12px;
    color: var(--text-dim);
    cursor: pointer;
    transition: color 0.2s;
    flex-shrink: 0;
}

.volume-icon:hover {
    color: var(--text-secondary);
}

/* Disconnected state */
.player-connect {
    text-align: center;
    padding: 24px 16px;
}

.player-connect-title {
    font-family: 'Space Mono', monospace;
    font-size: 11px;
    letter-spacing: 2px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.connect-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.connect-btn {
    font-family: 'Space Mono', monospace;
    font-size: 10px;
    letter-spacing: 1px;
    padding: 16px 20px;
    min-height: 44px;
    box-sizing: border-box;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.connect-error {
    font-family: 'Space Mono', monospace;
    font-size: 9px;
    color: #c47a7a;
    margin-top: 8px;
    opacity: 0;
    transition: opacity 0.3s;
}

.connect-error.visible {
    opacity: 1;
}

.connect-btn.spotify {
    background: rgba(30, 215, 96, 0.1);
    border: 1px solid rgba(30, 215, 96, 0.2);
    color: #1ed760;
}

.connect-btn.spotify:hover {
    background: rgba(30, 215, 96, 0.15);
    border-color: rgba(30, 215, 96, 0.4);
}

.connect-btn.free {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
}

.connect-btn.free:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.connect-hint {
    font-size: 10px;
    color: var(--text-dim);
    margin-top: 12px;
}

/* Loading state */
.player-loading {
    text-align: center;
    padding: 20px;
}

.player-loading-text {
    font-family: 'Space Mono', monospace;
    font-size: 11px;
    letter-spacing: 3px;
    color: var(--text-secondary);
    animation: tuningPulse 2s ease-in-out infinite;
}

/* Mobile */
@media (max-width: 480px) {
    .player-track {
        gap: 12px;
    }

    .player-art {
        width: 48px;
        height: 48px;
    }

    .player-controls {
        gap: 16px;
    }

    .connect-buttons {
        flex-direction: column;
        align-items: center;
    }

    .connect-btn {
        width: 100%;
        max-width: 200px;
        text-align: center;
    }
}
