/**
 * Content Protection CSS
 * Additional CSS layers to prevent content downloading
 */

/* When downloads are disabled, add SURGICAL protection layers - EXCLUDE EMBEDS */
body.downloads-disabled {
    /* CRITICAL: Disable pointer events on STATIC media only - NOT embeds */
    img:not([src*="youtube"]):not([src*="vimeo"]):not([src*="soundcloud"]):not([src*="spotify"]):not([src*="embed"]),
    video:not([src*="youtube"]):not([src*="vimeo"]):not([src*="soundcloud"]):not([src*="spotify"]):not([src*="embed"]),
    audio:not([src*="youtube"]):not([src*="vimeo"]):not([src*="soundcloud"]):not([src*="spotify"]):not([src*="embed"]),
    .thumbnail-container img:not([src*="youtube"]):not([src*="vimeo"]):not([src*="soundcloud"]):not([src*="spotify"]):not([src*="embed"]),
    .thumbnail-image:not([src*="youtube"]):not([src*="vimeo"]):not([src*="soundcloud"]):not([src*="spotify"]):not([src*="embed"]),
    [src$=".mp3"]:not([src*="embed"]),
    [src$=".mp4"]:not([src*="embed"]),
    [src$=".jpg"]:not([src*="youtube"]):not([src*="vimeo"]):not([src*="embed"]),
    [src$=".jpeg"]:not([src*="youtube"]):not([src*="vimeo"]):not([src*="embed"]),
    [src$=".png"]:not([src*="youtube"]):not([src*="vimeo"]):not([src*="embed"]),
    [src$=".gif"]:not([src*="youtube"]):not([src*="vimeo"]):not([src*="embed"]) {
        pointer-events: none !important;
        -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;
        -webkit-user-drag: none !important;
        -khtml-user-drag: none !important;
        -moz-user-drag: none !important;
        -o-user-drag: none !important;
    }

    /* ALLOW embed content to work normally */
    .embed-responsive iframe,
    .embed-responsive video,
    .embed-responsive img,
    iframe[src*="youtube"],
    iframe[src*="vimeo"],
    iframe[src*="soundcloud"],
    iframe[src*="spotify"],
    iframe[src*="embed"] {
        pointer-events: auto !important;
        -webkit-user-select: auto !important;
        -moz-user-select: auto !important;
        -ms-user-select: auto !important;
        user-select: auto !important;
        -webkit-touch-callout: default !important;
        -webkit-tap-highlight-color: initial !important;
        -webkit-user-drag: auto !important;
        -khtml-user-drag: auto !important;
        -moz-user-drag: auto !important;
        -o-user-drag: auto !important;
    }

    /* Override any existing pointer events - SURGICAL APPROACH */
    * {
        pointer-events: auto !important; /* Reset to allow other interactions */
    }
    
    /* Only disable static media, not embeds */
    img:not([src*="youtube"]):not([src*="vimeo"]):not([src*="soundcloud"]):not([src*="spotify"]):not([src*="embed"]),
    video:not([src*="youtube"]):not([src*="vimeo"]):not([src*="soundcloud"]):not([src*="spotify"]):not([src*="embed"]),
    audio:not([src*="youtube"]):not([src*="vimeo"]):not([src*="soundcloud"]):not([src*="spotify"]):not([src*="embed"]) {
        pointer-events: none !important;
    }

    /* Protection overlay styling - Smart overlay that allows controls but blocks downloads */
    .content-protection-overlay {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        z-index: 9999 !important;
        background-color: transparent !important;
        cursor: default !important;
        pointer-events: none !important; /* Allow clicks to pass through to controls */
        -webkit-user-select: none !important;
        -moz-user-select: none !important;
        -ms-user-select: none !important;
        user-select: none !important;
    }

    /* Special handling for video/audio controls */
    .content-protection-overlay:hover {
        cursor: not-allowed !important;
    }

    /* Ensure media controls remain accessible */
    video::-webkit-media-controls-panel,
    audio::-webkit-media-controls-panel {
        z-index: 10000 !important; /* Ensure controls are above overlay */
        position: relative !important;
    }

    /* Allow play button and controls to work */
    video::-webkit-media-controls-play-button,
    video::-webkit-media-controls-volume-slider,
    video::-webkit-media-controls-mute-button,
    video::-webkit-media-controls-timeline,
    video::-webkit-media-controls-current-time-display,
    video::-webkit-media-controls-time-remaining-display,
    audio::-webkit-media-controls-play-button,
    audio::-webkit-media-controls-volume-slider,
    audio::-webkit-media-controls-mute-button,
    audio::-webkit-media-controls-timeline,
    audio::-webkit-media-controls-current-time-display,
    audio::-webkit-media-controls-time-remaining-display {
        pointer-events: all !important;
        z-index: 10001 !important;
    }

    /* Minimal protection overlay styling */
    .minimal-protection-overlay {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        z-index: 9999 !important;
        background-color: transparent !important;
        cursor: default !important;
    }

    /* Enhanced browser control hiding */
    video::-webkit-media-controls-download-button,
    video::-webkit-media-controls-overflow-button,
    video::-webkit-media-controls-fullscreen-volume-minimize-button,
    audio::-webkit-media-controls-download-button,
    audio::-webkit-media-controls-overflow-button {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        width: 0 !important;
        height: 0 !important;
    }

    /* Firefox control hiding */
    video::-moz-media-controls-download-button,
    audio::-moz-media-controls-download-button {
        display: none !important;
    }

    /* Ensure media controls are fully functional */
    video::-webkit-media-controls-panel,
    audio::-webkit-media-controls-panel {
        pointer-events: all !important;
        z-index: 10000 !important;
    }

    /* Protected media styling */
    .protected-media {
        -webkit-user-select: none !important;
        -moz-user-select: none !important;
        -ms-user-select: none !important;
        user-select: none !important;
        -webkit-user-drag: none !important;
        -khtml-user-drag: none !important;
        -moz-user-drag: none !important;
        -o-user-drag: none !important;
        -webkit-touch-callout: none !important;
    }

    /* Hide download buttons completely */
    .download-button,
    a[download],
    button[download] {
        display: none !important;
    }

    /* Disable right-click cursor feedback */
    .protected-media {
        cursor: default !important;
    }

    /* Prevent image dragging */
    img {
        -webkit-user-drag: none !important;
        -khtml-user-drag: none !important;
        -moz-user-drag: none !important;
        -o-user-drag: none !important;
    }

    /* Audio player protection */
    audio::-webkit-media-controls-download-button,
    video::-webkit-media-controls-download-button {
        display: none !important;
    }

    /* Hide context menu on media elements */
    .media-element::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 9998;
        background: transparent;
    }

    /* Card protection for list views */
    .content-card {
        position: relative;
        
        img, video, audio {
            position: relative;
            z-index: 1;
        }
    }

    /* Thumbnail container protection */
    .thumbnail-container {
        position: relative;
        overflow: hidden;
        
        img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            display: block;
        }
    }

    /* SPECIFIC FIX FOR PHOTO SECTION - Higher specificity to override conflicts */
    body.downloads-disabled .photo-list .thumbnail-container,
    body.downloads-disabled .photo_list .thumbnail-container,
    body.downloads-disabled .photo-gallery .thumbnail-container,
    body.downloads-disabled .content-card .thumbnail-container {
        position: relative !important;
        overflow: hidden !important;
        width: 100% !important;
        height: 200px !important; /* Force exact height */
    }

    body.downloads-disabled .photo-list .thumbnail-container img,
    body.downloads-disabled .photo_list .thumbnail-container img,
    body.downloads-disabled .photo-gallery .thumbnail-container img,
    body.downloads-disabled .content-card .thumbnail-container img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
        object-position: center !important;
        display: block !important;
        max-width: none !important; /* Override max-width restrictions */
        max-height: none !important; /* Override max-height restrictions */
    }

    /* SPECIFIC FIX FOR AUDIO SECTION - Ensure audio thumbnails display properly */
    body.downloads-disabled .audio-list .thumbnail-container,
    body.downloads-disabled .audio_list .thumbnail-container,
    body.downloads-disabled .audio-gallery .thumbnail-container,
    body.downloads-disabled .content-card .thumbnail-container {
        position: relative !important;
        overflow: hidden !important;
        width: 100% !important;
        height: 200px !important; /* Force exact height like photos */
    }

    body.downloads-disabled .audio-list .thumbnail-container img,
    body.downloads-disabled .audio_list .thumbnail-container img,
    body.downloads-disabled .audio-gallery .thumbnail-container img,
    body.downloads-disabled .content-card .thumbnail-container img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
        object-position: center !important;
        display: block !important;
        max-width: none !important; /* Override max-width restrictions */
        max-height: none !important; /* Override max-height restrictions */
    }

    /* SPECIFIC FIX FOR VIDEO SECTION - Ensure video thumbnails display properly */
    body.downloads-disabled .video-list .thumbnail-container,
    body.downloads-disabled .video_list .thumbnail-container,
    body.downloads-disabled .video-gallery .thumbnail-container,
    body.downloads-disabled .content-card .thumbnail-container {
        position: relative !important;
        overflow: hidden !important;
        width: 100% !important;
        height: 200px !important; /* Force exact height like photos */
    }

    body.downloads-disabled .video-list .thumbnail-container img,
    body.downloads-disabled .video_list .thumbnail-container img,
    body.downloads-disabled .video-gallery .thumbnail-container img,
    body.downloads-disabled .content-card .thumbnail-container img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
        object-position: center !important;
        display: block !important;
        max-width: none !important; /* Override max-width restrictions */
        max-height: none !important; /* Override max-height restrictions */
    }

    /* Audio controls protection */
    audio::-webkit-media-controls-panel,
    video::-webkit-media-controls-panel {
        /* Custom styling to hide download options */
        filter: brightness(0.8);
    }

    /* Print protection */
    @media print {
        img.protected,
        video.protected,
        audio.protected {
            display: none !important;
        }
    }

    /* Mobile touch protection */
    @media (max-width: 768px) {
        .content-protection-overlay {
            min-height: 44px; /* Minimum touch target size */
        }
    }
}

    /* SURGICAL protection for embedded content - ALLOW EMBEDS */
.downloads-disabled {
    /* ALLOW normal selection on embed containers */
    .news-embed,
    .video-embed,
    .audio-embed,
    .photo-embed,
    .embed-responsive {
        -webkit-user-select: auto !important;
        -moz-user-select: auto !important;
        -ms-user-select: auto !important;
        user-select: auto !important;
        pointer-events: auto !important;
    }

    /* ALLOW YouTube and other embeds to work normally */
    iframe[src*="youtube"],
    iframe[src*="vimeo"],
    iframe[src*="soundcloud"],
    iframe[src*="spotify"],
    iframe[src*="dailymotion"],
    iframe[src*="embed"] {
        pointer-events: auto !important;
        -webkit-user-select: auto !important;
        -moz-user-select: auto !important;
        -ms-user-select: auto !important;
        user-select: auto !important;
    }

    /* Fallback for older browsers */
    .no-pointer-events {
        pointer-events: none !important;
    }
}

/* High specificity selectors for stubborn elements */
body.downloads-disabled {
    img[data-protection="enabled"],
    video[data-protection="enabled"],
    audio[data-protection="enabled"] {
        pointer-events: none !important;
        -webkit-user-select: none !important;
        -moz-user-select: none !important;
        -ms-user-select: none !important;
        user-select: none !important;
    }
}

/* Animation to indicate protected content */
@keyframes protectionPulse {
    0% { opacity: 0; }
    50% { opacity: 0.1; }
    100% { opacity: 0; }
}

.content-protection-indicator {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(255, 255, 255, 0.9);
    color: #666;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    pointer-events: none;
    z-index: 10000;
    animation: protectionPulse 2s infinite;
}
