/**
* Player attached to the bottom of the page — CastBox + palette Castaminofen
 */
:root {
    --cast-player-primary: #776CFE;
    --cast-player-accent: #00EA99;
    --cast-player-bg: rgba(255, 255, 255, 0.97);
    --cast-player-border: #E5E7EB;
    --cast-player-text: #111827;
    --cast-player-muted: #6B7280;
    --cast-player-progress-bg: #E5E7EB;
}

body.dark-mode,
body.bb-dark-mode,
html[data-castory-theme="dark"] body {
    --cast-player-bg: rgba(26, 29, 41, 0.98);
    --cast-player-border: #2D3748;
    --cast-player-text: #F3F4F6;
    --cast-player-muted: #9CA3AF;
    --cast-player-progress-bg: #4A5568;
}

html[data-castory-theme="light"] body {
    --cast-player-bg: rgba(255, 255, 255, 0.97);
    --cast-player-border: #E5E7EB;
    --cast-player-text: #111827;
    --cast-player-muted: #6B7280;
    --cast-player-progress-bg: #E5E7EB;
}

.castbox-sticky-player {
    position: fixed;
    bottom: -150px;
    left: 0;
    right: 0;
    background: var(--cast-player-bg);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--cast-player-border);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.12);
    padding: 16px 20px;
    z-index: 99990;
    transition: bottom 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.castbox-sticky-player.is-active {
    bottom: 0;
    visibility: visible;
    pointer-events: auto;
}

.castbox-sticky-player:not(.is-active) {
    visibility: hidden;
    pointer-events: none;
}

.castbox-sticky-player.is-active.is-audio-mode,
.castbox-sticky-player.is-active:not(.is-video-mode):not(.is-expanded) {
    background: var(--cast-player-glass, rgba(26, 29, 41, 0.58));
    backdrop-filter: blur(22px) saturate(160%);
    -webkit-backdrop-filter: blur(22px) saturate(160%);
    border-top: 1px solid var(--cast-player-glass-border, rgba(255, 255, 255, 0.1));
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.2);
}

.castbox-sticky-player.is-active.is-audio-mode .control-btn.play-pause {
    background: linear-gradient(135deg, var(--cast-player-primary), var(--cast-hover, #a03cff));
    box-shadow: 0 4px 16px rgba(119, 108, 254, 0.35);
}

.castbox-sticky-player.is-active.is-audio-mode .progress-bar-fill {
    background: linear-gradient(90deg, var(--cast-player-primary), var(--cast-player-accent));
}

.castbox-sticky-player .player-inner {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.castbox-sticky-player .player-track-info {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 30%;
    min-width: 0;
}

.castbox-sticky-player .player-thumbnail {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

.castbox-sticky-player .player-text {
    overflow: hidden;
    min-width: 0;
}

.castbox-sticky-player .player-track-title {
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--cast-player-text);
}

.castbox-sticky-player .player-track-podcast {
    font-size: 0.8rem;
    color: var(--cast-player-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.castbox-sticky-player .player-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 50%;
    flex: 1;
}

.castbox-sticky-player .control-buttons {
    display: flex;
    align-items: center;
    gap: 20px;
}

.castbox-sticky-player .control-btn {
    font-size: 1.2rem;
    color: var(--cast-player-muted);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}

.castbox-sticky-player .control-btn.play-pause {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--cast-player-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.castbox-sticky-player .control-btn.play-pause:hover {
    background: #A03CFF;
}

.castbox-sticky-player .progress-container {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.castbox-sticky-player .time-display {
    font-size: 0.75rem;
    color: var(--cast-player-muted);
    min-width: 35px;
}

.castbox-sticky-player .progress-bar-wrapper {
    flex-grow: 1;
    height: 6px;
    background: var(--cast-player-progress-bg);
    border-radius: 3px;
    position: relative;
    cursor: pointer;
}

.castbox-sticky-player .progress-bar-fill {
    height: 100%;
    background: var(--cast-player-primary);
    border-radius: 3px;
    width: 0%;
    position: relative;
    pointer-events: none;
}

.castbox-sticky-player .progress-handle {
    width: 12px;
    height: 12px;
    background: var(--cast-player-primary);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 0;
    transform: translate(-50%, -50%);
    display: none;
    pointer-events: none;
}

.castbox-sticky-player .progress-bar-wrapper:hover .progress-handle {
    display: block;
}

.castbox-sticky-player .player-volume {
    width: 20%;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.castbox-sticky-player .volume-slider {
    width: 80px;
    accent-color: var(--cast-player-primary);
}

#castbox-audio-element {
    display: none;
}

/* ——— Backdrop + extended mobile mode ——— */
.castbox-player-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 99989;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.castbox-player-backdrop.is-visible {
    opacity: 1;
    visibility: visible;
}

.castbox-player-drag-handle {
    display: none;
}

.castbox-player-mini-progress {
    display: none;
}

.castbox-player-expanded-art {
    display: none;
}

.castbox-player-mini-play {
    display: none;
}

.castbox-player-mode-badge {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--cast-player-primary);
    margin-bottom: 2px;
}

.castbox-player-close {
    display: none;
}

.castbox-player-dismiss {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 10px;
    left: 12px;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: var(--cast-player-progress-bg);
    color: var(--cast-player-text);
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    z-index: 3;
}

.castbox-player-stage {
    position: relative;
    width: 100%;
    max-width: 960px;
    margin: 0 auto 12px;
}

.castbox-video-close {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
}

.castbox-video-fullscreen {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 0.95rem;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
}

.castbox-fullscreen-btn {
    display: none;
}

.castbox-sticky-player.is-video-mode .castbox-fullscreen-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.castbox-player-stage:fullscreen,
.castbox-player-stage:-webkit-full-screen {
    width: 100vw;
    height: 100vh;
    max-width: none;
    margin: 0;
    padding: 0;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.castbox-player-stage:fullscreen .castbox-player-video,
.castbox-player-stage:-webkit-full-screen .castbox-player-video {
    width: 100%;
    height: 100%;
    max-width: 100vw;
    max-height: 100vh;
    min-height: 0;
    border-radius: 0;
    object-fit: contain;
}

.castbox-player-stage:fullscreen .castbox-video-close,
.castbox-player-stage:fullscreen .castbox-video-fullscreen,
.castbox-player-stage:-webkit-full-screen .castbox-video-close,
.castbox-player-stage:-webkit-full-screen .castbox-video-fullscreen {
    z-index: 5;
}

.castbox-fullscreen-hint {
    position: absolute;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    z-index: 6;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    backdrop-filter: blur(8px);
    animation: castbox-fs-hint-in 0.35s ease;
    max-width: calc(100% - 32px);
}

.castbox-fullscreen-hint[hidden] {
    display: none !important;
}

.castbox-fullscreen-hint__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
}

.castbox-fullscreen-hint__btn:hover {
    background: rgba(255, 255, 255, 0.28);
}

@keyframes castbox-fs-hint-in {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

body.castbox-player-video-fullscreen .castbox-sticky-player {
    z-index: 2147483646;
}

.castbox-mode-switch {
    display: flex;
    gap: 8px;
    align-items: center;
}

.castbox-mode-switch__btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--cast-player-border);
    background: transparent;
    color: var(--cast-player-muted);
    cursor: pointer;
}

.castbox-mode-switch__btn.is-active {
    background: var(--cast-player-primary);
    border-color: var(--cast-player-primary);
    color: #fff;
}

.castbox-player-video {
    width: 100%;
    max-height: 120px;
    border-radius: 12px;
    background: #000;
    display: block;
}

/* ——— desktop video mode ——— */
.castbox-sticky-player.is-video-mode {
    padding-top: 12px;
}

.castbox-sticky-player.is-video-mode .castbox-player-video {
    max-height: min(56vh, 520px);
    min-height: 280px;
}

.castbox-sticky-player.is-video-mode .player-track-info {
    display: none;
}

.castbox-sticky-player.is-video-mode .player-inner {
    max-width: 960px;
}

.castbox-sticky-player.is-audio-mode #castbox-player-stage {
    display: none !important;
}

.castbox-sticky-player.is-video-mode .castbox-mode-switch {
    display: flex !important;
}

body.castbox-player-active.castbox-player-has-video:has(#castbox-global-player.is-active) {
    padding-bottom: 160px;
}

@media (min-width: 769px) {
    body.castbox-player-active.castbox-player-has-video {
        padding-bottom: calc(min(56vh, 520px) + 120px);
    }
}

body.castbox-player-expanded {
    overflow: hidden;
}

@media (max-width: 768px) {
    .castbox-player-mini-progress {
        display: block;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 3px;
        background: rgba(255, 255, 255, 0.12);
        z-index: 4;
    }

    .castbox-player-mini-progress span {
        display: block;
        height: 100%;
        width: 0%;
        background: linear-gradient(90deg, var(--cast-player-primary), var(--cast-player-accent));
        transition: width 0.15s linear;
    }

    .castbox-sticky-player.is-active:not(.is-expanded) {
        padding: 0 12px 10px;
    }

    .castbox-sticky-player .player-inner {
        flex-wrap: nowrap;
        align-items: center;
        gap: 10px;
        padding-top: 6px;
    }

    .castbox-sticky-player:not(.is-expanded) .player-track-info {
        flex: 1;
        width: auto;
        min-width: 0;
        justify-content: flex-start;
        cursor: pointer;
    }

    .castbox-sticky-player:not(.is-expanded) .player-thumbnail {
        width: 42px;
        height: 42px;
        border-radius: 8px;
    }

    .castbox-sticky-player:not(.is-expanded) .player-track-podcast,
    .castbox-sticky-player:not(.is-expanded) .castbox-player-mode-badge {
        display: none;
    }

    .castbox-sticky-player:not(.is-expanded) .player-controls,
    .castbox-sticky-player:not(.is-expanded) .castbox-mode-switch,
    .castbox-sticky-player:not(.is-expanded) .castbox-player-drag-handle {
        display: none !important;
    }

    .castbox-player-mini-play {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        width: 40px;
        height: 40px;
        border: none;
        border-radius: 50%;
        background: var(--cast-player-primary);
        color: #fff;
        font-size: 0.95rem;
        cursor: pointer;
    }

    .castbox-sticky-player.is-expanded .castbox-player-mini-play {
        display: none;
    }

    .castbox-sticky-player .player-volume {
        display: none;
    }

    .castbox-player-drag-handle {
        display: none;
    }

    .castbox-player-close {
        display: flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        top: 14px;
        left: 14px;
        width: 36px;
        height: 36px;
        border: none;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.12);
        color: #fff;
        font-size: 1.4rem;
        line-height: 1;
        cursor: pointer;
        z-index: 6;
    }

    .castbox-player-dismiss {
        display: none;
    }

    .castbox-sticky-player .player-track-info {
        cursor: pointer;
    }

    .castbox-sticky-player.is-expanded {
        position: fixed;
        inset: 0;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        max-height: none;
        height: 100%;
        overflow-y: auto;
        border-radius: 0;
        padding: calc(12px + env(safe-area-inset-top, 0px)) 20px calc(24px + env(safe-area-inset-bottom, 0px));
        box-shadow: none;
        display: flex;
        flex-direction: column;
        background: linear-gradient(180deg, #12121a 0%, #0a0a10 100%);
        border-top: none;
    }

    .castbox-sticky-player.is-expanded .castbox-player-mini-progress {
        display: none;
    }

    .castbox-sticky-player.is-expanded .castbox-player-expanded-art {
        display: flex;
        flex: 1;
        align-items: center;
        justify-content: center;
        padding: 56px 0 20px;
        min-height: 0;
    }

    .castbox-sticky-player.is-expanded #castbox-player-artwork {
        width: min(72vw, 320px);
        height: min(72vw, 320px);
        object-fit: cover;
        border-radius: 18px;
        box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
    }

    .castbox-sticky-player.is-expanded .player-inner {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
        width: 100%;
        max-width: 480px;
        margin: 0 auto;
        padding-top: 0;
    }

    .castbox-sticky-player.is-expanded .player-track-info {
        width: 100%;
        justify-content: center;
        text-align: center;
        flex-direction: column;
        padding-top: 0;
    }

    .castbox-sticky-player.is-expanded .player-thumbnail {
        display: none;
    }

    .castbox-sticky-player.is-expanded .player-text {
        text-align: center;
    }

    .castbox-sticky-player.is-expanded .player-track-title {
        font-size: 1.15rem;
        white-space: normal;
        line-height: 1.35;
    }

    .castbox-sticky-player.is-expanded .player-track-podcast,
    .castbox-sticky-player.is-expanded .castbox-player-mode-badge {
        display: block;
    }

    .castbox-sticky-player.is-expanded .player-controls {
        display: flex;
        width: 100%;
    }

    .castbox-sticky-player.is-expanded .control-btn.play-pause {
        width: 64px;
        height: 64px;
        font-size: 1.25rem;
    }

    .castbox-sticky-player.is-expanded .castbox-player-video {
        max-height: 42vh;
        border-radius: 12px;
    }

    .castbox-sticky-player.is-expanded.has-video #castbox-player-stage {
        display: block !important;
    }

    body.castbox-player-active:has(#castbox-global-player.is-active:not(.is-expanded)) {
        padding-bottom: 58px;
    }

    body.castbox-player-expanded.castbox-player-active {
        padding-bottom: 0;
    }
}
