/**
 * Castaminofen — Premium mobile player + custom video controls
 */

.castbox-player-expanded-bg {
    display: none;
}

.castbox-player-expand {
    display: none;
}

.castbox-playback-speed-wrap {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 4px;
}

.castbox-playback-speed-label {
    font-size: 0.72rem;
    color: var(--cast-player-muted);
    font-weight: 600;
}

.castbox-playback-speed {
    border-radius: 8px;
    border: 1px solid var(--cast-player-border);
    background: transparent;
    color: var(--cast-player-text);
    padding: 4px 8px;
    font-size: 0.8rem;
    font-family: inherit;
}

.control-btn__label {
    font-size: 0.55rem;
    font-weight: 800;
    display: block;
    margin-top: -2px;
}

.castbox-play-pulse.is-playing {
    animation: castbox-play-pulse 1.6s ease-in-out infinite;
}

@keyframes castbox-play-pulse {
    0%, 100% { box-shadow: 0 4px 16px rgba(119, 108, 254, 0.35); }
    50% { box-shadow: 0 4px 28px rgba(119, 108, 254, 0.55); }
}

/* ——— Custom video controls ——— */
.castbox-video-loading {
    position: absolute;
    inset: 0;
    z-index: 3;
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
}

.castbox-video-loading::after {
    content: "";
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.25);
    border-top-color: #fff;
    animation: castbox-video-spin 0.8s linear infinite;
}

.castbox-video-loading[hidden] {
    display: none !important;
}

@keyframes castbox-video-spin {
    to { transform: rotate(360deg); }
}

.castbox-video-center-play {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 4;
    width: 64px;
    height: 64px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(6px);
    transition: opacity 0.25s ease, transform 0.2s ease;
}

.castbox-player-video {
    pointer-events: auto;
}

.castbox-video-controls {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.75));
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
}

.castbox-player-stage.castbox-video-controls--visible .castbox-video-controls,
.castbox-player-stage.castbox-video-controls--visible .castbox-video-center-play,
.castbox-player-stage:hover .castbox-video-controls {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.castbox-player-stage.castbox-video-controls--visible .castbox-video-center-play.is-playing {
    opacity: 0;
    pointer-events: none;
}

.castbox-video-timeline {
    height: 5px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    margin-bottom: 10px;
    cursor: pointer;
    position: relative;
}

.castbox-video-timeline__fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--cast-player-primary), var(--cast-player-accent));
    border-radius: inherit;
    pointer-events: none;
}

.castbox-video-controls__bar {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
}

.castbox-video-controls__spacer {
    flex: 1;
}

.castbox-video-ctrl-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.castbox-video-time {
    font-size: 0.72rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.castbox-video-time-sep {
    opacity: 0.6;
    font-size: 0.72rem;
}

.castbox-video-volume {
    width: 72px;
    accent-color: var(--cast-player-primary);
}

@media (max-width: 768px) {
    .castbox-sticky-player.is-active:not(.is-expanded) {
        bottom: 0;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.22);
        animation: castbox-mini-slide-in 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    }

    @keyframes castbox-mini-slide-in {
        from { transform: translateY(100%); opacity: 0.6; }
        to { transform: translateY(0); opacity: 1; }
    }

    .castbox-player-expand {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        width: 36px;
        height: 36px;
        border: none;
        border-radius: 50%;
        background: rgba(119, 108, 254, 0.15);
        color: var(--cast-player-primary);
        font-size: 0.85rem;
        cursor: pointer;
    }

    .castbox-player-mini-progress {
        cursor: pointer;
        height: 4px;
    }

    .castbox-sticky-player.is-expanded {
        background: #0a0a10;
    }

    .castbox-player-expanded-bg {
        display: block;
        position: absolute;
        inset: 0;
        z-index: 0;
        background-size: cover;
        background-position: center;
        filter: blur(48px) saturate(1.4);
        transform: scale(1.15);
        opacity: 0.55;
    }

    .castbox-player-expanded-bg::after {
        content: "";
        position: absolute;
        inset: 0;
        background: linear-gradient(180deg, rgba(10, 10, 16, 0.55) 0%, rgba(10, 10, 16, 0.92) 65%, #0a0a10 100%);
    }

    .castbox-sticky-player.is-expanded .castbox-player-expanded-art,
    .castbox-sticky-player.is-expanded .player-inner {
        position: relative;
        z-index: 1;
    }

    .castbox-sticky-player.is-expanded .castbox-playback-speed-wrap {
        display: flex;
    }

    .castbox-sticky-player.is-expanded .control-btn.play-pause {
        width: 72px;
        height: 72px;
        font-size: 1.35rem;
    }

    .castbox-sticky-player.is-expanded .progress-bar-wrapper {
        height: 8px;
    }

    .castbox-sticky-player.is-expanded .progress-handle {
        display: block;
        width: 14px;
        height: 14px;
    }

    body.castbox-player-active:has(#castbox-global-player.is-active:not(.is-expanded)) {
        padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    }

    .castbox-player-stage .castbox-player-video {
        max-height: 42vh;
    }

    .castbox-video-volume {
        display: none;
    }
}
