/* Mobile Video Controls Fix */

/* General mobile video improvements */
@media (max-width: 768px) {
    /* Ensure video containers are properly sized */
    .video-container, .bunny-video-wrapper, .embed-responsive {
        position: relative !important;
        width: 100% !important;
        height: auto !important;
        min-height: 200px !important;
        overflow: visible !important;
        background: #000 !important;
        border-radius: 8px !important;
    }

/* Course promo video: avoid persistent centered overlay button/dimming; use only native controls bar */
#course-promo-video::-webkit-media-controls-overlay-play-button,
#course-promo-video::-webkit-media-controls-start-playback-button {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
}

    /* Fix iframe videos */
    .video-container iframe,
    .bunny-video-wrapper iframe,
    .embed-responsive iframe {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        border: none !important;
        pointer-events: auto !important;
        touch-action: manipulation !important;
        -webkit-overflow-scrolling: touch !important;
        z-index: 1 !important;
    }

    /* Fix HTML5 video elements */
    video {
        width: 100% !important;
        height: auto !important;
        max-width: 100% !important;
        display: block !important;
        pointer-events: auto !important;
        touch-action: manipulation !important;
        -webkit-playsinline: true !important;
        -webkit-appearance: none !important;
        background: #000 !important;
        border-radius: 8px !important;
    }

    /* Ensure video controls are visible and touchable */
    video::-webkit-media-controls-panel {
        display: flex !important;
        opacity: 1 !important;
        background: rgba(0, 0, 0, 0.8) !important;
        border-radius: 0 0 8px 8px !important;
    }

    /* Course promo video: reduce perceived dimming from controls overlay */
    #course-promo-video::-webkit-media-controls-enclosure,
    #course-promo-video::-webkit-media-controls-panel {
        background: transparent !important;
    }

    /* Show play/pause button on mobile */
    video::-webkit-media-controls-play-button {
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
    }

    video::-webkit-media-controls-start-playback-button {
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
    }

    /* Show play/pause controls */
    video:not(#course-promo-video)::-webkit-media-controls-overlay-play-button {
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
    }

    /* Course promo video: avoid persistent centered overlay button/dimming; use only native controls bar */
    #course-promo-video::-webkit-media-controls-overlay-play-button,
    #course-promo-video::-webkit-media-controls-start-playback-button {
        display: none !important;
        opacity: 0 !important;
        visibility: hidden !important;
    }

    /* Custom play button overlay for better mobile experience */
    .video-play-overlay {
        position: absolute !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        background: rgba(0, 0, 0, 0.7) !important;
        color: white !important;
        border: none !important;
        border-radius: 50% !important;
        width: 80px !important;
        height: 80px !important;
        font-size: 24px !important;
        cursor: pointer !important;
        z-index: 10 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        transition: all 0.3s ease !important;
        pointer-events: auto !important;
        touch-action: manipulation !important;
    }

    .video-play-overlay:hover {
        background: rgba(0, 0, 0, 0.9) !important;
        transform: translate(-50%, -50%) scale(1.1) !important;
    }

    .video-play-overlay.hidden {
        display: none !important;
    }

    /* Fix for Bunny.net videos */
    .bunny-video-wrapper {
        padding-bottom: 56.25% !important; /* 16:9 aspect ratio */
        height: 0 !important;
        position: relative !important;
        overflow: hidden !important;
        background: #000 !important;
    }

    /* Ensure touch events work properly */
    .video-container,
    .bunny-video-wrapper,
    .embed-responsive,
    video,
    iframe {
        -webkit-user-select: none !important;
        -moz-user-select: none !important;
        -ms-user-select: none !important;
        user-select: none !important;
        -webkit-touch-callout: none !important;
        -webkit-tap-highlight-color: transparent !important;
    }

    /* Remove any overlays that might block touch events */
    .video-container::before,
    .video-container::after,
    .bunny-video-wrapper::before,
    .bunny-video-wrapper::after {
        display: none !important;
    }
}

/* Tablet specific fixes */
@media (min-width: 769px) and (max-width: 1024px) {
    .video-container iframe,
    .bunny-video-wrapper iframe,
    video {
        pointer-events: auto !important;
        touch-action: manipulation !important;
    }
}

/* Force show controls on touch devices */
@media (hover: none) and (pointer: coarse) {
    video {
        controls: true !important;
    }

    /* Course promo video: avoid persistent centered overlay button/dimming; use only native controls bar */
    #course-promo-video::-webkit-media-controls-overlay-play-button,
    #course-promo-video::-webkit-media-controls-start-playback-button {
        display: none !important;
        opacity: 0 !important;
        visibility: hidden !important;
    }

    video::-webkit-media-controls {
        display: flex !important;
        opacity: 1 !important;
    }

    video::-webkit-media-controls-panel {
        display: flex !important;
        opacity: 1 !important;
    }

    /* Course promo video: reduce perceived dimming from controls overlay */
    #course-promo-video::-webkit-media-controls-enclosure,
    #course-promo-video::-webkit-media-controls-panel {
        background: transparent !important;
    }
}

/* iOS specific fixes */
@supports (-webkit-appearance: none) {
    @media (max-width: 768px) {
        video {
            -webkit-appearance: none !important;
            -webkit-playsinline: true !important;
        }

        video::-webkit-media-controls {
            -webkit-appearance: media-controls-panel !important;
            display: flex !important;
        }

        video::-webkit-media-controls-panel {
            -webkit-appearance: media-controls-panel !important;
            display: flex !important;
        }
    }
}
