/**
 * Mad Origin Video Styling Enhancement - Frontend Styles
 * Applied to styled video widgets on the frontend
 */

/* Video Container Enhancements */
.mad-video-styled {
    position: relative;
}

/* Ensure videos maintain aspect ratio with rounded corners */
.mad-video-styled .sow-video-wrapper video,
.mad-video-styled .sow-video-wrapper iframe,
.mad-video-styled .sow-video-wrapper embed,
.mad-video-styled .sow-video-wrapper object {
    border-radius: inherit;
    max-width: 100%;
    height: auto;
}

/* Apply border-radius and overflow to fluid-width-video-wrapper */
.mad-video-styled .sow-video-wrapper .fluid-width-video-wrapper {
    border-radius: inherit;
    overflow: hidden;
}

/* Ensure proper video height and positioning */
.mad-video-styled .sow-video-wrapper .fluid-width-video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Responsive video container */
.mad-video-styled .sow-video-wrapper {
    position: relative;
    width: 100%;
    display: block;
}

/* Title styling base */
.mad-video-styled .widget-title {
    margin-top: 0;
    line-height: 1.2;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .mad-video-styled .sow-video-wrapper {
        /* Reduce hover effects on mobile for better performance */
        transition: none;
    }
    
    /* Disable hover effects on touch devices */
    .mad-video-styled .sow-video-wrapper:hover {
        transform: none !important;
        box-shadow: inherit !important;
    }
    
    .mad-video-styled .widget-title {
        font-size: 90%; /* Slightly smaller titles on mobile */
    }
    
    /* Ensure proper touch scrolling */
    .mad-video-styled {
        touch-action: manipulation;
    }
    
    /* Increase minimum touch targets */
    .mad-video-styled .sow-video-wrapper {
        min-height: 44px; /* iOS minimum touch target */
    }
}

@media (max-width: 480px) {
    .mad-video-styled .widget-title {
        font-size: 85%; /* Even smaller on very small screens */
    }
}

/* High DPI display optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .mad-video-styled .sow-video-wrapper {
        /* Enhanced shadows for retina displays */
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
}

/* Ensure video wrapper has relative positioning for overlay */
.mad-video-styled .sow-video-wrapper {
    position: relative;
}

/* Video Overlay Styles */
.mad-video-styled .mad-video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    cursor: pointer;
    border-radius: inherit;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    transition: opacity 0.3s ease;
}

/* Force border radius inheritance for overlay */
.mad-video-styled .sow-video-wrapper .mad-video-overlay {
    border-radius: inherit;
}

.mad-video-styled .mad-video-overlay:focus {
    outline: 2px solid rgba(255, 255, 255, 0.8);
    outline-offset: 2px;
}

.mad-video-styled .mad-overlay-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1em;
    padding: 2em;
    pointer-events: none;
    max-width: 90%;
    text-align: center;
    width: 100%;
    position: relative;
    z-index: 2; /* Top layer - content above box */
}

/* Content box wrapper */
.mad-video-styled .mad-overlay-content-box {
    position: relative;
    z-index: 1; /* Middle layer - box behind content */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* Cross-browser flexbox support */
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -webkit-flex-direction: column;
    -ms-flex-direction: column;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    -ms-flex-pack: center;
    /* Box sizing for consistent padding */
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    /* Smooth transitions */
    -webkit-transition: all 0.3s ease;
    -moz-transition: all 0.3s ease;
    -o-transition: all 0.3s ease;
    transition: all 0.3s ease;
}

/* When content box is disabled, ensure content has proper padding */
.mad-video-styled .mad-video-overlay[data-content-box="disabled"] .mad-overlay-content {
    padding: 2em;
}

/* Ensure text maintains proper contrast in content box */
.mad-video-styled .mad-overlay-content-box .mad-overlay-title,
.mad-video-styled .mad-overlay-content-box .mad-overlay-description {
    text-shadow: none; /* Remove any text shadows that might interfere with box styling */
    position: relative;
    z-index: 3; /* Ensure text is above everything */
}

/* High DPI optimization for content box borders */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .mad-video-styled .mad-overlay-content-box {
        /* Sharper borders on high DPI displays */
        border-style: solid;
    }
}

.mad-video-styled .mad-overlay-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mad-video-styled .mad-overlay-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5em;
    text-align: center;
    width: 100%;
}

.mad-video-styled .mad-overlay-title {
    margin: 0;
    line-height: 1.2;
    font-weight: bold;
}

.mad-video-styled .mad-overlay-description {
    margin: 0;
    line-height: 1.4;
    opacity: 0.9;
}

/* Mobile overlay optimizations */
@media (max-width: 768px) {
    .mad-video-styled .mad-video-overlay {
        /* Ensure proper touch targets */
        min-height: 44px;
        min-width: 44px;
        touch-action: manipulation;
        /* Reduce animations for better performance */
        transition: opacity 0.2s ease;
    }
    
    .mad-video-styled .mad-overlay-content {
        padding: 1.5em;
        gap: 0.75em;
        max-width: 95%;
    }
    
    .mad-video-styled .mad-overlay-title {
        font-size: 90%;
    }
    
    .mad-video-styled .mad-overlay-description {
        font-size: 85%;
    }
    
    .mad-video-styled .mad-overlay-icon {
        /* Scale down icons on smaller screens */
        font-size: 90%;
    }
    
    /* Content box mobile adjustments */
    .mad-video-styled .mad-overlay-content-box {
        max-width: 90%;
        padding: 1.5em;
    }
}

@media (max-width: 480px) {
    .mad-video-styled .mad-overlay-content {
        padding: 1em;
        gap: 0.5em;
        max-width: 98%;
    }
    
    .mad-video-styled .mad-overlay-title {
        font-size: 85%;
        line-height: 1.1;
    }
    
    .mad-video-styled .mad-overlay-description {
        font-size: 80%;
        line-height: 1.3;
    }
    
    .mad-video-styled .mad-overlay-icon {
        font-size: 85%;
    }
    
    /* Content box small screen adjustments */
    .mad-video-styled .mad-overlay-content-box {
        max-width: 95%;
        padding: 1em;
        /* Reduce border width on very small screens */
        border-width: 1px !important;
    }
}

/* Touch device specific optimizations */
@media (hover: none) and (pointer: coarse) {
    .mad-video-styled .mad-video-overlay {
        /* Remove hover effects on touch devices */
        transition: opacity 0.2s ease;
    }
    
    .mad-video-styled .mad-video-overlay:active {
        /* Provide visual feedback on touch */
        opacity: 0.8;
        transform: scale(0.98);
        transition: all 0.1s ease;
    }
}

/* Accessibility improvements */
.mad-video-styled .mad-video-overlay[aria-pressed="true"],
.mad-video-styled .mad-video-overlay:focus-visible {
    outline: 3px solid rgba(255, 255, 255, 0.8);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .mad-video-styled .mad-video-overlay {
        border: 2px solid;
    }
    
    .mad-video-styled .mad-overlay-title,
    .mad-video-styled .mad-overlay-description {
        text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .mad-video-styled .mad-video-overlay {
        transition: none;
    }
    
    .mad-video-styled .mad-video-overlay:active {
        transform: none;
    }
}