/**
 * Video Player Styles
 * Full-screen video player with custom HUD controls
 */

/* Player Modal Container */
.player-modal {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 1000;
    display: none;
    flex-direction: column;
}

.player-modal.active {
    display: flex;
}

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

/* Portrait Mode: Video top, info bottom */
.player-modal.portrait .video-wrapper {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    position: relative;
    flex-shrink: 0;
}

.player-modal.portrait .player-info-panel {
    flex: 1;
    background: var(--bg-primary);
    padding: 16px;
    padding-bottom: calc(var(--safe-bottom) + 16px);
    overflow-y: auto;
}

/* Landscape Mode: Fullscreen */
.player-modal.landscape .video-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
}

.player-modal.landscape .player-info-panel {
    display: none;
}

/* Video Element */
.video-element {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

/* Hide browser's native remote playback overlay button */
video::-internal-media-controls-overlay-cast-button,
video::-webkit-media-controls-overlay-enclosure,
video::-webkit-media-controls-enclosure {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
}

.video-element::-internal-media-controls-overlay-cast-button {
    display: none !important;
}

/* Video Loader */
.video-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    z-index: 15;
}

.video-loader.active {
    display: block;
}

/* Cursor hidden when HUD hidden */
.video-wrapper.cursor-hidden {
    cursor: none;
}

/* ===== PLAYER HUD ===== */
.player-hud {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 1;
    transition: opacity var(--transition-slow) ease;
}

.player-hud > * {
    pointer-events: auto;
}

.player-hud.hidden {
    opacity: 0;
    pointer-events: none;
}

.player-hud.hidden > * {
    pointer-events: none;
}

/* HUD Top Bar */
.hud-top {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 10px 12px;
    padding-top: calc(var(--safe-top) + 10px);
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.8) 0%, transparent 100%);
    display: flex;
    align-items: center;
    gap: 12px;
}

.player-modal.landscape .hud-top {
    padding-left: max(12px, var(--safe-left));
    padding-right: max(12px, var(--safe-right));
}

.hud-back {
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.hud-back svg {
    width: 24px;
    height: 24px;
}

.hud-title {
    flex: 1;
}

.hud-ep-num {
    font-size: 0.7rem;
    color: var(--accent);
    font-weight: 600;
}

.hud-ep-title {
    font-size: 0.85rem;
    font-weight: 500;
}

/* HUD Center (not used currently but kept for potential features) */
.hud-center {
    display: none;
}

/* Play/Pause Indicator (YouTube-style animated) */
.play-pause-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    width: 80px;
    height: 80px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: none;
}

.play-pause-indicator svg {
    width: 40px;
    height: 40px;
    fill: #fff;
}

.play-pause-indicator.show {
    animation: playPausePop 0.5s ease-out forwards;
}

@keyframes playPausePop {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    30% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.1);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Speed Indicator (2x) */
.speed-indicator {
    position: absolute;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    padding: 10px 18px;
    border-radius: 20px;
    font-size: 0.95rem;
    font-weight: 500;
    display: none;
    align-items: center;
    gap: 4px;
    z-index: 20;
    pointer-events: none;
    letter-spacing: 0.5px;
}

.speed-indicator svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
    opacity: 0.9;
}

/* HUD Bottom Bar */
.hud-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px;
    padding-bottom: calc(var(--safe-bottom) + 12px);
    background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, transparent 100%);
}

.player-modal.landscape .hud-bottom {
    padding-left: max(12px, var(--safe-left));
    padding-right: max(12px, var(--safe-right));
}

/* Seek Container */
.seek-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    position: relative;
}

.seek-time {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    min-width: 40px;
    display: none;
}

.seek-time.right {
    text-align: right;
    display: none;
}

/* Seek Bar */
.seek-bar-wrapper {
    flex: 1;
    height: 36px;
    display: flex;
    align-items: center;
    cursor: pointer;
    touch-action: none;
    position: relative;
}

.seek-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 2px;
    position: relative;
    transition: height 0.1s;
}

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

/* Seek Preview Tooltip */
.seek-preview-tooltip {
    position: absolute;
    bottom: 100%;
    left: 0;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.1s;
    margin-bottom: 8px;
    z-index: 30;
}

.seek-bar-wrapper:hover .seek-preview-tooltip {
    opacity: 1;
}

.seek-buffered {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 2px;
}

.seek-progress {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
}

.seek-handle {
    position: absolute;
    top: 50%;
    width: 14px;
    height: 14px;
    background: var(--accent);
    border-radius: var(--radius-full);
    transform: translate(-50%, -50%);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* HUD Bottom Row */
.hud-bottom-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    overflow: visible;
    flex-wrap: nowrap;
}

.hud-btn-group {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.hud-btn-group.left {
    gap: 0;
    flex-shrink: 1;
    min-width: 0;
}

.hud-btn-group.right {
    gap: 4px;
    flex-shrink: 0;
}

/* Mobile Portrait Adjustments */
@media (max-width: 600px) {
    .player-modal.portrait .volume-control .volume-slider-wrapper {
        display: none !important;
    }

    .player-modal.portrait .hud-btn {
        width: 34px;
        height: 34px;
    }

    .player-modal.portrait .hud-btn svg {
        width: 18px;
        height: 18px;
    }

    .player-modal.portrait .time-display {
        font-size: 0.65rem;
        padding: 4px 6px;
        margin-left: 2px;
    }

    .player-modal.portrait .hud-btn-group.right {
        gap: 0;
    }

    .player-modal.portrait .hud-bottom {
        padding: 8px;
        padding-bottom: calc(var(--safe-bottom) + 8px);
    }

    .player-modal.portrait .seek-container {
        margin-bottom: 4px;
    }
}

/* Very small screens: hide time display in portrait */
@media (max-width: 380px) {
    .player-modal.portrait .time-display {
        display: none;
    }
}

/* HUD Button */
.hud-btn {
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: var(--radius-full);
}

.hud-btn:active {
    background: rgba(255, 255, 255, 0.1);
}

.hud-btn svg {
    width: 22px;
    height: 22px;
}

/* Cast Button Styles */
.cast-btn.connected {
    color: var(--accent);
}

.cast-btn.connecting {
    animation: cast-pulse 1.5s ease-in-out infinite;
}

@keyframes cast-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.4;
    }
}

/* Hide Google's native Cast button */
google-cast-launcher {
    display: none !important;
}

/* Cast Status Overlay */
.cast-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.cast-overlay.active {
    display: flex;
}

.cast-overlay-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    color: var(--accent);
}

.cast-overlay-icon svg {
    width: 100%;
    height: 100%;
}

.cast-overlay-text {
    font-size: 1.1rem;
    color: var(--text-secondary);
    text-align: center;
}

.cast-overlay-device {
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 4px;
}

/* Volume Control (YouTube-style horizontal slider) */
.volume-control {
    display: flex;
    align-items: center;
    position: relative;
}

.volume-slider-wrapper {
    width: 0;
    overflow: hidden;
    transition: width var(--transition-normal) ease;
    display: flex;
    align-items: center;
}

.volume-control:hover .volume-slider-wrapper,
.volume-control.dragging .volume-slider-wrapper {
    width: 62px;
}

.volume-slider {
    width: 52px;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    position: relative;
    cursor: pointer;
    margin-left: 4px;
    margin-right: 6px;
}

.volume-slider:hover {
    height: 6px;
}

.volume-slider-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: #fff;
    border-radius: 2px;
    pointer-events: none;
}

.volume-slider-handle {
    position: absolute;
    top: 50%;
    width: 12px;
    height: 12px;
    background: #fff;
    border-radius: var(--radius-full);
    transform: translate(-50%, -50%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.1s;
}

.volume-control:hover .volume-slider-handle,
.volume-control.dragging .volume-slider-handle {
    opacity: 1;
}

/* Time Display (YouTube-style) */
.time-display {
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 4px;
    user-select: none;
    white-space: nowrap;
    margin-left: 4px;
}

.time-display:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Double-tap Feedback */
.tap-feedback {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-primary);
    font-size: 0.75rem;
    font-weight: 600;
    pointer-events: none;
    z-index: 20;
}

.tap-feedback.left {
    left: 15%;
}

.tap-feedback.right {
    right: 15%;
}

.tap-feedback.show {
    display: flex;
    animation: tapFade 0.5s ease-out forwards;
}

.tap-feedback svg {
    width: 36px;
    height: 36px;
}

@keyframes tapFade {
    0% {
        opacity: 0;
        transform: translateY(-50%) scale(0.8);
    }
    30% {
        opacity: 1;
        transform: translateY(-50%) scale(1.1);
    }
    100% {
        opacity: 0;
        transform: translateY(-50%) scale(1);
    }
}

/* ===== PORTRAIT INFO PANEL ===== */
.info-panel-header {
    margin-bottom: 16px;
}

.info-panel-ep {
    font-size: 0.7rem;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 4px;
}

.info-panel-title {
    font-family: var(--font-display);
    font-size: 1.4rem;
    letter-spacing: 0.02em;
}

.info-panel-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.info-panel-actions .btn {
    flex: 1;
    height: 42px;
    font-size: 0.85rem;
}

.info-panel-episodes h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

/* Mini Episode List */
.mini-episode-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mini-ep-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    cursor: pointer;
}

.mini-ep-item.active {
    background: rgba(255, 107, 0, 0.15);
    border: 1px solid rgba(255, 107, 0, 0.3);
}

.mini-ep-num {
    font-family: var(--font-display);
    font-size: 1.2rem;
    color: var(--accent);
    width: 30px;
}

.mini-ep-info {
    flex: 1;
}

.mini-ep-title {
    font-size: 0.8rem;
    font-weight: 500;
}

.mini-ep-duration {
    font-size: 0.7rem;
    color: var(--text-muted);
}
