/* ========================================
   Player Styles
   ======================================== */

:root {
    --player-accent: #fe2a47;
}

.player-wrapper {
    position: relative;
    background: var(--bg-primary);
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.player {
    position: relative;
    width: 100%;
    aspect-ratio: 9/16;
    max-width: 420px;
    background: #000;
    overflow: hidden;
}

.player video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    cursor: pointer;
}

/* Hide native video controls across browsers */
.player video::-webkit-media-controls,
.player video::-webkit-media-controls-enclosure,
.player video::-webkit-media-controls-panel,
.player video::-webkit-media-controls-play-button,
.player video::-webkit-media-controls-timeline,
.player video::-webkit-media-controls-current-time-display,
.player video::-webkit-media-controls-time-remaining-display,
.player video::-webkit-media-controls-volume-control,
.player video::-webkit-media-controls-fullscreen-button {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
}

/* --- Unmute overlay (mobile autoplay fallback) --- */
.player-unmute-overlay {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 8;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: rgba(0,0,0,0.65);
    border-radius: 20px;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.player-unmute-overlay.visible {
    opacity: 1;
    pointer-events: auto;
    animation: unmutePulse 2s ease-in-out 1;
}
.player-unmute-overlay svg {
    flex-shrink: 0;
}
@keyframes unmutePulse {
    0%   { transform: scale(0.9); opacity: 0; }
    20%  { transform: scale(1.05); opacity: 1; }
    40%  { transform: scale(1); }
    70%  { transform: scale(1.03); }
    100% { transform: scale(1); }
}

/* --- Play overlay --- */
.player-play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s ease;
}
.player-play-overlay.visible {
    opacity: 1;
}

/* --- Loading spinner --- */
.player-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 6;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.player-loading.visible {
    opacity: 1;
}
.player-loading-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(255,255,255,0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: playerSpin 0.8s linear infinite;
}
@keyframes playerSpin {
    to { transform: rotate(360deg); }
}
.player-play-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    cursor: pointer;
}
.player-play-overlay.visible .player-play-icon {
    animation: playIconPulse 0.6s ease forwards;
}
@keyframes playIconPulse {
    0%   { transform: scale(0.8); opacity: 0; }
    40%  { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1);   opacity: 1; }
}

/* --- Fullscreen episode paging transition --- */
.player-episode-transition {
    position: absolute;
    inset: 0;
    z-index: 4;
    pointer-events: none;
    background-color: #000;
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
    transform: translate3d(0, var(--episode-slide-in), 0);
    opacity: .92;
    transition: transform .42s cubic-bezier(.22, .61, .36, 1), opacity .42s ease;
    will-change: transform, opacity;
}
.player-episode-transition.is-active {
    transform: translate3d(0, 0, 0);
    opacity: 1;
}
.player-episode-transition.is-dragging {
    transition: none;
}

/* --- Controls bar --- */
.player-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}
.player-controls.visible {
    opacity: 1;
    pointer-events: auto;
}
.player-controls-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 8px 16px 30px;
    background: linear-gradient(transparent, rgba(0,0,0,0.75));
}

/* --- Progress bar --- */
.player-progress {
    width: 90%;
    margin: 0 auto;
    height: 4px;
    background: rgba(255,255,255,0.2);
    cursor: pointer;
    position: relative;
    border-radius: 2px;
    overflow: hidden;
    transition: height 0.15s ease;
    touch-action: none;
}
.player-progress:hover,
.player-progress:active {
    height: 8px;
}
.player-progress-buffered {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
}
.player-progress-played {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: var(--player-accent);
    border-radius: 2px;
}
.player-progress-thumb {
    position: absolute;
    top: 50%;
    width: 14px;
    height: 14px;
    background: var(--player-accent);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.15s ease;
    pointer-events: none;
    box-shadow: 0 0 4px rgba(0,0,0,0.4);
}
.player-progress:hover .player-progress-thumb,
.player-progress:active .player-progress-thumb {
    opacity: 1;
}
body.player-fullscreen .player-progress-thumb {
    width: 16px;
    height: 16px;
    opacity: 1;
}

/* --- Control buttons --- */
.player-btn {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.9;
    transition: opacity 0.2s;
    touch-action: manipulation;
    min-width: 36px;
    min-height: 36px;
    flex-shrink: 0;
}
.player-btn:hover { opacity: 1; }
.player-btn.disabled { opacity: 0.3; pointer-events: none; }
.player-btn.btn-next-ep { margin-left: -10px; }
.player-btn svg {
    flex-shrink: 0;
}
.player-time {
    color: rgba(255,255,255,0.9);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    margin: 0 2px;
}
.player-ep-indicator {
    color: rgba(255,255,255,0.7);
    font-size: 12px;
    white-space: nowrap;
    background: rgba(255,255,255,0.12);
    padding: 3px 10px;
    border-radius: 10px;
    margin: 0 2px;
}
.player-spacer { flex: 1; }
.player.hide-cursor { cursor: none; }

/* --- Native Fullscreen API (:fullscreen / -webkit-full-screen) --- */
.player:fullscreen,
.player:-webkit-full-screen {
    position: fixed !important;
    top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-width: none !important;
    max-height: none !important;
    aspect-ratio: auto !important;
    background: transparent !important;
    touch-action: none !important;
}
.player:fullscreen video,
.player:-webkit-full-screen video {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    background: transparent !important;
}

/* --- Fake fullscreen (iOS fallback via body class + inline styles) --- */
body.player-fullscreen {
    overflow: hidden !important;
    position: fixed;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    top: 0;
    left: 0;
    overscroll-behavior-x: none;
}
html.player-fullscreen {
    overflow: hidden !important;
    height: 100vh;
    height: 100dvh;
    background: transparent !important;
    overscroll-behavior-x: none;
}
body.player-fullscreen {
    background: transparent !important;
}
body.player-fullscreen .watch-page,
body.player-fullscreen .watch-layout,
body.player-fullscreen .player-wrapper {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-width: none;
    min-height: 0;
    margin: 0;
    background: transparent;
}
body.player-fullscreen .header,
body.player-fullscreen .watch-breadcrumb,
body.player-fullscreen .watch-cost-notice,
body.player-fullscreen .watch-vip-notice {
    display: none !important;
}
body.player-fullscreen .watch-left {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
body.player-fullscreen .player {
    position: fixed;
    inset: 0;
    max-width: none;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    aspect-ratio: auto;
    background: transparent;
}
body.player-fullscreen .player video {
    object-fit: cover;
    background: transparent;
}

/* --- Player lock overlay --- */
.player-wrapper.blurred.locked video { filter: blur(20px); pointer-events: none; }
.player-wrapper.locked .player { pointer-events: none; }
.player-wrapper.locked .player-lock-overlay { pointer-events: auto; }

.player-lock-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: rgba(0,0,0,0.65);
    z-index: 10;
}
.player-lock-icon {
    color: rgba(255,255,255,0.9);
}
.player-lock-text {
    color: rgba(255,255,255,0.9);
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    line-height: 1.5;
}
.player-unlock-btn {
    width: 240px;
    height: 48px;
    background: linear-gradient(90deg, #E52E2E 0%, #EB4C46 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.player-unlock-btn:active { opacity: 0.85; }

/* --- Responsive --- */
@media (max-width: 768px) {
    .player {
        max-width: 100%;
        aspect-ratio: 9/16;
        max-height: 50vh;
    }
    .player-controls-bar {
        padding: 8px 16px 6px;
    }
}
