/**
 * MX Video Scroll CSS
 */

/* Container styles */
.mx-video-scroll-container {
    position: relative;
    overflow: hidden;
    display: block;
    width: 100%;
    cursor: pointer;
    aspect-ratio: 16/9;
    max-height: 100vh;
}

/* Placeholder image styles */
.mx-video-scroll-placeholder {
    width: 100%;
    display: block;
    position: relative;
    z-index: 1;
    aspect-ratio: 16/9;
    overflow: hidden;
}

.mx-video-scroll-placeholder img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    object-position: center center;
}

/* Video container styles */
.mx-video-scroll-video {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    display: none;
    z-index: 3;
}

.mx-video-scroll-video iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* Play button styles */
.mx-video-play-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 20px;
    transition: all 0.3s ease;
    z-index: 4; /* Increased z-index to ensure it stays above other elements */
    pointer-events: auto; /* Ensure it remains clickable */
    margin: 0; /* Reset any margins that might affect positioning */
    padding: 0; /* Reset any padding that might affect positioning */
}

.mx-video-play-button:hover {
    background-color: rgba(0, 0, 0, 0.9);
    transform: translate(-50%, -50%) scale(1.1);
}

/* Ensure play button stays centered during all animation states */
.mx-reveal .mx-video-play-button {
    transform: translate(-50%, -50%); /* Reinforce centering during animation */
}

.mx-reveal .mx-video-play-button:hover {
    transform: translate(-50%, -50%) scale(1.1); /* Maintain hover effect with centering */
}

/* Overlay styles */
.mx-video-scroll-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #4054b2;
    transform: translateX(0);
    transition: transform 0.8s ease;
    z-index: 5; /* Overlay above all content */
    pointer-events: none; /* Prevent overlay from blocking clicks */
}

/* Error message styles */
.mx-video-scroll-error {
    padding: 20px;
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    text-align: center;
}

/* Reveal animation classes - added via JavaScript */

/* Right direction (default) */
.mx-video-scroll-container[data-direction="right"].mx-reveal .mx-video-scroll-overlay {
    transform: translateX(100%);
}

/* Left direction */
.mx-video-scroll-container[data-direction="left"] .mx-video-scroll-overlay {
    left: auto;
    right: 0;
}

.mx-video-scroll-container[data-direction="left"][data-effect="slide"] .mx-video-scroll-overlay {
    /* Ensure correct starting position for smooth slide */
    transform: translateX(101%);
}

.mx-video-scroll-container[data-direction="left"].mx-reveal .mx-video-scroll-overlay {
    transform: translateX(-100%);
}

/* Zoom effect (ease-in-out) */
.mx-video-scroll-container[data-effect="zoom"] .mx-video-scroll-overlay {
    transform-origin: center;
    transform: scale(0);
    transition: transform 0.4s ease-in;
    opacity: 0.7;
}

.mx-video-scroll-container[data-effect="zoom"].mx-reveal .mx-video-scroll-overlay {
    transform: scale(2);
    opacity: 0;
    transition: transform 0.6s ease-out, opacity 0.6s ease-out;
}

/* Elastic slide effect (default) */
/* Smooth slide effect (no bounce) */
.mx-video-scroll-container[data-effect="slide"] .mx-video-scroll-overlay {
    transform: translateX(-101%);
    animation: none;
    transition: transform 0.5s ease-in-out;
}

/* Right direction slide animation */
.mx-video-scroll-container[data-direction="right"][data-effect="slide"].mx-reveal .mx-video-scroll-overlay {
    transform: translateX(101%);
}

/* Left direction slide animation */
.mx-video-scroll-container[data-direction="left"][data-effect="slide"].mx-reveal .mx-video-scroll-overlay {
    transform: translateX(-101%);
}

/* Keyframes for right direction elastic slide */
@keyframes slideRightElastic {
    0% { transform: translateX(-101%); } /* Start off-screen left */
    40% { transform: translateX(0); } /* Move into place */
    60% { transform: translateX(0); } /* Hold briefly */
    75% { transform: translateX(90%); } /* Start sliding out */
    85% { transform: translateX(85%); } /* Elastic effect */
    100% { transform: translateX(101%); } /* Final position off-screen right */
}

/* Keyframes for left direction elastic slide */
@keyframes slideLeftElastic {
    0% { transform: translateX(101%); } /* Start off-screen right */
    40% { transform: translateX(0); } /* Move into place */
    60% { transform: translateX(0); } /* Hold briefly */
    75% { transform: translateX(-90%); } /* Start sliding out */
    85% { transform: translateX(-85%); } /* Elastic effect */
    100% { transform: translateX(-101%); } /* Final position off-screen left */
}

/* Video loaded state - hide placeholder, show video */
.mx-video-scroll-container.video-loaded .mx-video-scroll-placeholder {
    opacity: 0;
    pointer-events: none;
    position: absolute;
}

.mx-video-scroll-container.video-loaded .mx-video-scroll-video {
    display: block !important;
    z-index: 3;
}

/* Hide any iframe that is a direct child of the container */
.mx-video-scroll-container > iframe:not([data-mx-video-scroll]),
.mx-video-scroll-placeholder > iframe {
    display: none !important;
}

/* Ensure proper positioning with nested iframes */
.mx-video-scroll-placeholder {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Ensure play button is a child of the main container */
.mx-video-scroll-container .mx-video-play-button {
    /* Position relative to the main container */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .mx-video-play-button {
        width: 50px;
        height: 50px;
        font-size: 16px;
    }
}
