/* Player Container */
.player-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    box-sizing: border-box;
    width: min(calc(100% - 40px), 600px);
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: clamp(10px, 3vw, 20px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    z-index: 1000;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.3s ease;
    --glow-color: rgba(255, 255, 255, 0.37);
    box-shadow: 0 8px 32px 0 var(--glow-color);
    will-change: transform;
}

.player-container.dragging {
    transition: none !important;
    will-change: transform;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    cursor: grabbing;
}

/* Player Controls */
.player-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    justify-content: flex-start;
}

.player-button {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    width: clamp(32px, 5vw, 40px);
    aspect-ratio: 1;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid transparent;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

.player-button:hover,
.player-button.active {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
    border-color: var(--glow-color);
    box-shadow: 0 0 15px var(--glow-color);
}

.player-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.player-button svg {
    width: clamp(16px, 2.5vw, 20px);
    height: clamp(16px, 2.5vw, 20px);
    fill: white;
    filter: drop-shadow(0 0 2px var(--glow-color));
}

.play-button {
    width: clamp(40px, 6vw, 50px);
    aspect-ratio: 1;
}

.play-button svg {
    width: clamp(20px, 3vw, 24px);
    height: clamp(20px, 3vw, 24px);
}

/* Now Playing Section */
.now-playing {
    text-align: center;
    color: white;
    margin: 10px 0;
    position: relative;
    overflow: hidden;
    height: 24px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 10px;
    /* Fade out edges */
    mask-image: linear-gradient(to right, transparent, black 20px, black calc(100% - 20px), transparent);
    -webkit-mask-image: linear-gradient(to right, transparent, black 20px, black calc(100% - 20px), transparent);
}

.scroll-text {
    white-space: nowrap;
    position: relative;
    display: inline-block;
    font-size: 16px;
    color: white;
    text-shadow: 0 0 10px var(--glow-color);
    will-change: transform;
}

/* Scrolling mode */
.scroll-text.marquee {
    display: flex;
    width: max-content;
    /* Ensure transform uses full content width */
    position: absolute;
    /* Take out of flow to avoid parent centering */
    left: 0;
    /* Start from the left edge */
    height: 100%;
    /* Ensure vertical alignment */
    align-items: center;
    /* Center text vertically */
    /* gap removed, using padding on spans for correct 50% calculation */
}

.scroll-text.marquee span {
    padding-right: 50px;
    /* Space between the original and the duplicate */
    flex-shrink: 0;
    /* Prevent shrinking */
}

@keyframes scrollText {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-50%);
        /* Move by half the width (one full copy + padding) */
    }
}

/* Only animate if text is longer than container */
.scroll-text:hover {
    animation-play-state: paused;
}

/* Loading Spinner */
.loading-spinner {
    display: none;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    animation: fadeIn 0.3s ease;
}

.loading-spinner svg {
    width: 100%;
    height: 100%;
    color: var(--glow-color, rgba(255, 255, 255, 0.8));
    filter: drop-shadow(0 0 5px var(--glow-color));
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Keyboard Shortcut Feedback */
.keyboard-feedback {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: white;
    padding: 20px 40px;
    border-radius: 20px;
    font-size: 24px;
    font-weight: 500;
    z-index: 10000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 8px 32px 0 var(--glow-color, rgba(255, 255, 255, 0.37));
    text-align: center;
    white-space: pre-line;
    text-shadow: 0 0 10px var(--glow-color, rgba(255, 255, 255, 0.6));
}

.keyboard-feedback.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.keyboard-feedback.help-mode {
    font-size: 16px;
    padding: 30px 40px;
    max-width: 400px;
    line-height: 1.8;
    text-align: left;
    font-family: 'Courier New', monospace;
    border-color: var(--glow-color, rgba(255, 255, 255, 0.3));
}

/* Time Display */
.time-display {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.8);
    margin-left: 10px;
    text-shadow: 0 0 5px var(--glow-color);
    font-family: 'Inter', monospace;
    min-width: 45px;
    text-align: center;
}

/* Volume Control */
.volume-control {
    display: flex;
    align-items: center;
    gap: 5px;
    flex: 0 1 auto;
    min-width: clamp(80px, 15vw, 100px);
    max-width: clamp(100px, 20vw, 150px);
    padding: 0 5px;
    margin-right: auto;
}

.volume-button {
    padding: 5px;
    width: 30px;
    height: 30px;
}

.volume-button svg {
    width: 20px;
    height: 20px;
}

.volume-control input[type="range"] {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    cursor: pointer;
    transition: height 0.2s ease;
    min-width: clamp(40px, 10vw, 80px);
}

.volume-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: var(--glow-color, rgba(255, 255, 255, 0.37));
    border-radius: 50%;
    box-shadow: 0 0 10px var(--glow-color, rgba(255, 255, 255, 0.37));
    cursor: pointer;
    transition: all 0.2s ease;
}

.volume-control input[type="range"]::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: var(--glow-color, rgba(255, 255, 255, 0.37));
    border: none;
    border-radius: 50%;
    box-shadow: 0 0 10px var(--glow-color, rgba(255, 255, 255, 0.37));
    cursor: pointer;
    transition: all 0.2s ease;
}

.volume-control input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 15px var(--glow-color, rgba(255, 255, 255, 0.37));
}

.volume-control input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 15px var(--glow-color, rgba(255, 255, 255, 0.37));
}

.volume-control svg {
    filter: drop-shadow(0 0 2px var(--glow-color));
}

/* Progress Bar */
.progress-container {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    width: 100%;
}

.seek-bar {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to right,
            var(--glow-color, rgba(255, 255, 255, 0.3)) 0%,
            var(--glow-color, rgba(255, 255, 255, 0.3)) var(--buffer-width, 0%),
            rgba(255, 255, 255, 0.1) var(--buffer-width, 0%),
            rgba(255, 255, 255, 0.1) 100%);
    border-radius: 2px;
    cursor: pointer;
    transition: height 0.2s ease;
    position: relative;
    --buffer-width: 0%;
}

.seek-bar:hover {
    height: 6px;
}

.seek-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: var(--glow-color, rgba(255, 255, 255, 0.37));
    border-radius: 50%;
    box-shadow: 0 0 10px var(--glow-color, rgba(255, 255, 255, 0.37));
    cursor: pointer;
    transition: all 0.2s ease;
}

.seek-bar::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: var(--glow-color, rgba(255, 255, 255, 0.37));
    border: none;
    border-radius: 50%;
    box-shadow: 0 0 10px var(--glow-color, rgba(255, 255, 255, 0.37));
    cursor: pointer;
    transition: all 0.2s ease;
}

.seek-bar::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 15px var(--glow-color, rgba(255, 255, 255, 0.37));
}

.seek-bar::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 15px var(--glow-color, rgba(255, 255, 255, 0.37));
}

/* Desktop: wrapper divs are invisible — children participate in the flex row as normal */
.controls-primary,
.controls-secondary {
    display: contents;
}

/* Responsive Design */
@media (max-width: 600px) {
    .player-container {
        width: calc(100% - 40px);
        padding: 10px 12px;
        bottom: 12px;
    }

    /* Stack into two rows: secondary on top, primary on bottom */
    .player-controls {
        flex-direction: column-reverse;
        gap: 6px;
        padding: 6px;
        align-items: stretch;
    }

    .controls-primary,
    .controls-secondary {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        width: 100%;
    }

    /* Give the volume slider room to breathe */
    .controls-primary .volume-control {
        flex: 1;
        min-width: 0;
        max-width: none;
        margin-right: 0;
    }

    /* Secondary buttons slightly smaller to keep the row tidy */
    .controls-secondary .player-button {
        width: 32px;
        height: 32px;
    }

    .controls-secondary .player-button svg {
        width: 15px;
        height: 15px;
    }

    .play-button {
        width: 44px;
        height: 44px;
    }
}

/* ============================================ */
/* Drive Mode (mobile / coarse-pointer only)    */
/* ============================================ */

.drive-toggle {
    display: none;
    position: absolute;
    top: -18px;
    right: 18px;
    height: 36px;
    padding: 0 14px 0 12px;
    border: 1px solid transparent;
    border-radius: 18px;
    background:
        linear-gradient(135deg, rgba(11, 6, 27, 0.95), rgba(7, 3, 18, 0.95)) padding-box,
        linear-gradient(140deg, rgba(0, 255, 255, 0.55), rgba(128, 0, 255, 0.6)) border-box;
    color: white;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.02em;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4), 0 0 14px rgba(0, 255, 255, 0.18);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    z-index: 5;
    transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.drive-toggle svg {
    width: 18px;
    height: 18px;
    fill: white;
    filter: drop-shadow(0 0 3px rgba(0, 255, 255, 0.55));
}

.drive-toggle:active {
    transform: scale(0.96);
}

.drive-toggle.active {
    background:
        linear-gradient(135deg, rgba(0, 255, 255, 0.18), rgba(128, 0, 255, 0.22)) padding-box,
        linear-gradient(140deg, rgba(0, 255, 255, 0.85), rgba(128, 0, 255, 0.85)) border-box;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45), 0 0 20px rgba(0, 255, 255, 0.4);
}

.player-drive-controls {
    display: none;
    align-items: center;
    justify-content: space-around;
    gap: 8px;
    padding: 8px 4px 4px;
    width: 100%;
}

.drive-button {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.18);
    width: clamp(72px, 22vw, 96px);
    aspect-ratio: 1;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.15s ease, background 0.2s ease;
    padding: 0;
}

.drive-button:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.22);
}

.drive-button svg {
    width: 38%;
    height: 38%;
    fill: white;
    filter: drop-shadow(0 0 3px var(--glow-color));
}

.drive-play-button {
    width: clamp(96px, 30vw, 128px);
    background:
        linear-gradient(135deg, rgba(0, 255, 255, 0.18), rgba(128, 0, 255, 0.25)) padding-box,
        linear-gradient(140deg, rgba(0, 255, 255, 0.55), rgba(128, 0, 255, 0.6)) border-box;
    border: 1px solid transparent;
    box-shadow: 0 0 22px rgba(0, 255, 255, 0.22);
}

.player-container.drive-mode .now-playing {
    height: 32px;
    margin: 14px 0 8px;
}

.player-container.drive-mode .scroll-text {
    font-size: 17px;
}

@media (hover: none) and (pointer: coarse), (max-width: 600px) {
    .drive-toggle {
        display: inline-flex;
    }

    .player-container.drive-mode .player-controls {
        display: none;
    }

    .player-container.drive-mode .player-drive-controls {
        display: flex;
    }
}

/* Always keep the toggle reachable while drive mode is active, so a
   viewport change (rotate, devtools resize) cannot hide the only way out. */
.player-container.drive-mode .drive-toggle {
    display: inline-flex;
}

/* Visible focus rings for keyboard / switch-control users. */
.drive-toggle:focus-visible,
.drive-button:focus-visible {
    outline: 2px solid rgba(0, 255, 255, 0.85);
    outline-offset: 3px;
    box-shadow: 0 0 0 4px rgba(0, 255, 255, 0.18);
}