@use "../../../dev" as *;
@use "../../../variables" as *;
// ============================================================================
// Media | Video
// ============================================================================

// Basic SCSS for Video Elements
// ----------------------------------------------------------------------------
// This basic example styles the <video> element to maintain aspect ratio, add
// a border, and ensure it's responsive.

/// Basic video element styling.
///
/// Ensures responsiveness and adds a subtle border and shadow for distinction.
/// Customizes video controls on hover.
video {
    max-width: 100%; // Ensure responsiveness
    height: auto; // Maintain aspect ratio
    border: q(1) solid #ddd; // Add a light border for distinction
    box-shadow: 0 q(2) q(4) rgba(0, 0, 0, 0.1); // Optional: Add a subtle shadow for depth

    // Customizing the video controls
    &:hover::controls {
        background: rgba(
            0,
            0,
            0,
            0.75
        ); // Darken controls on hover for better visibility
        color: var(
            --surface_primary
        ); // Change control icons/text color to white for contrast
    }
}

/// Wrapper for video elements.
///
/// Ensures the video occupies the full height and width of its container.
.video_wrapper {
    height: 100%;
    overflow: hidden;
    position: absolute;
    width: 100%;

    // position: relative;
    // padding-bottom: 56.25%;
    // /* 16:9 */
    // padding-top: q(25);
    // height: 0;

    // background-color: var(--color_text_primary);
    // height: auto;
    // left: 50%;
    // min-height: 100%;
    // min-width: 100%;
    // position: absolute;
    // top: 50%;
    // -ms-transform: translate(-50%, -50%);
    // -webkit-transform: translate(-50%, -50%);
    // transform: translate(-50%, -50%);
    // -moz-transform: translate(-50%, -50%);
    // -o-transform: translate(-50%, -50%);
    // width: auto;
    // z-index: -3;

    iframe {
        // height: 100%;
        // left: 0;
        // position: absolute;
        // top: -q(4) !important;
        // width: 100%;

        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }
}

/// Background overlay for videos.
///
/// This overlay is semi-transparent and covers the entire video area, useful for adding effects or messages.
.video-background {
}

.htms-video {
}

.video-wrapper iframe {
}

.video-background {
    position: absolute;
    height: 100%;
    width: 100%;
    z-index: 1;
    top: 0;
    background: rgba(67, 67, 67, 0.5);
}

// Advanced SCSS with Mixins for Responsive Aspect Ratios
// ----------------------------------------------------------------------------
// For a more advanced and flexible approach, especially for maintaining
// specific aspect ratios (like 16:9), you can use SCSS mixins.

/// Mixin for maintaining aspect ratio for elements.
///
/// This mixin is especially useful for video containers to ensure that they maintain a specific aspect ratio.
///
/// @param {Number} $width - The width part of the aspect ratio.
/// @param {Number} $height - The height part of the aspect ratio.
@mixin video-aspect-ratio($width, $height) {
    position: relative;
    &:before {
        display: block;
        content: "";
        width: 100%;
        padding-top: calc($height / $width) * 100%;
    }
    > .video-content {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }
}

/// Container for videos, ensuring a 16:9 aspect ratio.
///
/// Applies the aspect-ratio mixin for consistent sizing across different devices.
.video-container {
    @include video-aspect-ratio(16, 9); // 16:9 aspect ratio

    video {
        position: absolute;
        width: 100%;
        height: 100%;
        border: none; // Remove border for this approach
    }
}

// Styling Video Overlays and Custom Controls
// ----------------------------------------------------------------------------
// If you're implementing custom controls or overlays (like play buttons or
// progress bars), SCSS can help you manage their styles cohesively.

/// Styling for video overlays, typically used for play buttons or video captions.
///
/// This overlay is semi-transparent and centered within the video container.
/// It becomes visible on hover or when the video is paused.
.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.5); // Semi-transparent overlay
    color: var(--color_surface_primary);
    font-size: q(32);
    cursor: pointer;

    // Hide by default and show on video hover or pause
    opacity: 0;
    transition: opacity 0.3s ease;
    video:hover + &,
    video:pause + & {
        opacity: 1;
    }
}

/// Custom controls for video playback.
///
/// These controls are positioned at the bottom of the video and styled with a semi-transparent background.
.custom-controls {
    position: absolute;
    bottom: 0;
    width: 100%;
    padding: q(10);
    background: rgba(0, 0, 0, 0.7); // Semi-transparent background for controls
    color: var(--color_surface_primary);
    display: flex;
    justify-content: space-between;

    .play-button,
    .volume-control,
    .full-screen-button {
        cursor: pointer;
    }
}

// Responsive Video Embeds
// ----------------------------------------------------------------------------
// For embedded videos (like from YouTube or Vimeo), ensuring responsiveness
// while maintaining aspect ratio is crucial.

/// Ensures embedded videos maintain responsiveness and aspect ratio.
///
/// Particularly useful for video embeds from platforms like YouTube or Vimeo.
.embed-responsive {
    @include video-aspect-ratio(
        16,
        9
    ); // 16:9 aspect ratio for embedded videos

    iframe,
    object,
    embed {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }
}
