/* Custom Audio Player Styles */
/* Modular component styling matching Bandcamp design with ThreeJS control panel aesthetic */
/* Mobile-first responsive design with theme support */

/* =================== THEME SYSTEM =================== */

/* Default (Dark) Theme */
.custom-audio-player {
    --background: #1a1a1a;
    --text: #ffffff;
    --text-secondary: #cccccc;
    --text-muted: #999999;
    --text-dim: #666666;
    --border: #333333;
    --border-light: #555555;
    --border-lighter: #666666;
    --bg-secondary: #2a2a2a;
    --bg-tertiary: #333333;
    --accent: #4a9eff;
    --accent-secondary: #00d4ff;
    --shadow: rgba(0, 0, 0, 0.3);
    --artwork-bg: #333333;
    --hover-bg: #333333;
    --active-bg: #444444;
    --progress-bg: #333333;
    --volume-bg: #333333;
    --scrollbar-track: #2a2a2a;
    --scrollbar-thumb: #555555;
    --scrollbar-thumb-hover: #666666;
}

/* Light Theme */
.custom-audio-player.theme-light {
    --background: #ffffff;
    --text: #333333;
    --text-secondary: #555555;
    --text-muted: #777777;
    --text-dim: #aaaaaa;
    --border: #e0e0e0;
    --border-light: #cccccc;
    --border-lighter: #bbbbbb;
    --bg-secondary: #f8f8f8;
    --bg-tertiary: #f0f0f0;
    --accent: #4a9eff;
    --accent-secondary: #00d4ff;
    --shadow: rgba(0, 0, 0, 0.15);
    --artwork-bg: #f0f0f0;
    --hover-bg: #f0f0f0;
    --active-bg: #e8e8e8;
    --progress-bg: #e0e0e0;
    --volume-bg: #e0e0e0;
    --scrollbar-track: #f0f0f0;
    --scrollbar-thumb: #cccccc;
    --scrollbar-thumb-hover: #bbbbbb;
}

/* Base player styles using CSS custom properties */
.custom-audio-player {
    width: 100%;
    max-width: 400px;
    background: var(--background);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    font-size: 14px;
    border-radius: 8px;
    box-shadow: 0 4px 12px var(--shadow);
    overflow: hidden;
    margin: 2% 0 2% 2%;
}

.player-artwork {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1; /* Maintains square aspect ratio on all screen sizes */
    background: var(--artwork-bg);
    overflow: hidden;
    margin: 0;
    padding: 0;
}

.player-artwork img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    margin: 0;
    padding: 0;
    border: none;
    vertical-align: top;
}

.player-info {
    padding: 16px 20px 12px;
    background: var(--background);
}

.player-artist {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
    line-height: 1.2;
}

.player-album {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 0;
    line-height: 1.2;
}

.player-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--background);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.transport-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-btn {
    background: transparent;
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    width: 44px;
    height: 44px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s ease;
    position: relative;
}

.control-btn.small {
    width: 35px;
    height: 35px;
    font-size: 13px;
}

.control-btn:hover {
    background: var(--hover-bg);
    border-color: var(--border-lighter);
}

.control-btn:active {
    background: var(--active-bg);
    transform: translateY(1px);
}

.control-btn.play-pause {
    width: 52px;
    font-size: 18px;
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.control-btn:disabled:hover {
    background: transparent;
    border-color: var(--border-light);
    transform: none;
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: auto;
    flex: 1;
    max-width: 200px;
}

.volume-slider {
    flex: 1;
    height: 4px;
    background: linear-gradient(to right, var(--text-muted) 0%, var(--text-muted) var(--volume-percent, 70%), var(--volume-bg) var(--volume-percent, 70%), var(--volume-bg) 100%);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--text-secondary);
    cursor: pointer;
    border: none;
}

.volume-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--text-secondary);
    cursor: pointer;
    border: none;
}

.volume-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    margin-left: 8px;
    user-select: none;
    width: 28px;
    height: 28px;
}

.volume-icon svg {
    width: 20px;
    height: 20px;
    display: block;
}

.volume-value {
    font-size: 11px;
    color: var(--text-muted);
    min-width: 32px;
    text-align: center;
    margin-left: 4px;
}

.progress-container {
    padding: 16px 20px;
    background: var(--background);
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--progress-bg);
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent) 0%, var(--accent-secondary) 100%);
    border-radius: 4px;
    width: 0%;
    transition: width 0.1s ease;
}

.progress-times {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

.track-list {
    background: var(--background);
    /* Default: auto-expand to fit all tracks */
    /* No max-height constraint by default */
}

.track-item {
    display: flex;
    align-items: center;
    padding: 8px 20px;
    cursor: pointer;
    border-bottom: 1px solid var(--bg-secondary);
    transition: background-color 0.2s ease;
}

.track-item:hover {
    background: var(--bg-secondary);
}

.track-item.current {
    background: var(--bg-tertiary);
    color: var(--accent);
}

.track-item:last-child {
    border-bottom: 1px solid var(--border);
}

.track-list::after {
    content: '';
    display: block;
    height: 12px;
}

.track-play-icon {
    font-size: 10px;
    color: var(--accent);
    width: 12px;
    text-align: center;
    margin-right: 6px;
}

.track-number {
    font-size: 12px;
    color: var(--text-dim);
    width: 24px;
    text-align: right;
    margin-right: 12px;
}

.track-item.current .track-number {
    color: var(--accent);
}

.track-title {
    flex: 1;
    font-size: 13px;
    line-height: 1.3;
}

.track-duration {
    font-size: 12px;
    color: var(--text-dim);
    margin-left: 12px;
}

.track-item.current .track-duration {
    color: var(--accent);
}

.loading-state {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--text-dim);
    font-size: 14px;
}

.error-state {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #ff6b6b;
    font-size: 14px;
    text-align: center;
    line-height: 1.4;
}

/* Enhanced mobile responsiveness */
@media (max-width: 480px) {
    .custom-audio-player {
        border-radius: 0;
        box-shadow: none;
        border-top: 1px solid #333;
        border-bottom: 1px solid #333;
    }
    
    .player-controls {
        gap: 4px;
        padding: 8px 12px;
        justify-content: space-between;
    }
    
    .control-btn {
        width: 36px;
        height: 36px;
        font-size: 12px;
        min-width: 36px; /* Prevent squishing */
    }
    
    .control-btn.play-pause {
        width: 44px;
        height: 44px;
        font-size: 16px;
        min-width: 44px;
    }
    
    .volume-control {
        gap: 4px;
        margin-left: 4px;
    }
    
    .volume-knob {
        width: 36px;
        height: 36px;
        min-width: 36px;
    }
    
    .volume-value {
        font-size: 10px;
        min-width: 28px;
    }
    
    .progress-container,
    .player-info {
        padding-left: 12px;
        padding-right: 12px;
    }
    
    .track-item {
        padding-left: 12px;
        padding-right: 12px;
        font-size: 13px;
    }
    
    .track-number {
        width: 20px;
        margin-right: 8px;
    }
    
    .track-duration {
        font-size: 11px;
        margin-left: 8px;
    }
    
    .player-artist {
        font-size: 16px;
    }
    
    .player-album {
        font-size: 14px;
    }
}

/* Extra small screens */
@media (max-width: 320px) {
    .player-controls {
        gap: 2px;
        padding: 6px 8px;
    }
    
    .control-btn {
        width: 32px;
        height: 32px;
        font-size: 11px;
        min-width: 32px;
    }
    
    .control-btn.play-pause {
        width: 40px;
        height: 40px;
        font-size: 14px;
        min-width: 40px;
    }
    
    .volume-knob {
        width: 32px;
        height: 32px;
        min-width: 32px;
    }
    
    .volume-value {
        display: none; /* Hide volume value on very small screens */
    }
    
    .progress-container,
    .player-info,
    .track-item {
        padding-left: 8px;
        padding-right: 8px;
    }
}

/* Large screens */
@media (min-width: 768px) {
    .custom-audio-player {
        max-width: 450px;
    }
    
    .player-controls {
        padding: 16px 24px;
        gap: 12px;
    }
    
    .control-btn {
        width: 48px;
        height: 48px;
        font-size: 16px;
    }
    
    .control-btn.play-pause {
        width: 56px;
        height: 56px;
        font-size: 20px;
    }
    
    .volume-knob {
        width: 48px;
        height: 48px;
    }
    
    .progress-container,
    .player-info {
        padding-left: 24px;
        padding-right: 24px;
    }
    
    .track-item {
        padding-left: 24px;
        padding-right: 24px;
    }
}

/* Accessibility improvements */
.control-btn:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.progress-bar:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.volume-knob:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.track-item:focus {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    background: var(--bg-secondary);
}

/* Custom scrollbar for track list */
.track-list::-webkit-scrollbar {
    width: 8px;
}

.track-list::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

.track-list::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 4px;
}

.track-list::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

/* Animation for play/pause button state changes */
.control-btn.play-pause .play-icon,
.control-btn.play-pause .pause-icon {
    transition: opacity 0.2s ease;
}

.control-btn.play-pause:not(.playing) .pause-icon {
    display: none;
}

.control-btn.play-pause.playing .play-icon {
    display: none;
}