/* ===================================
   VIDEO ORIENTATION FIX FOR MOBILE
   Fixes sideways video display issue
   =================================== */

/* Force correct video orientation on mobile devices */
.tutorial-video video,
.product-video,
video {
    /* Fix orientation issues */
    -webkit-transform: rotate(0deg);
    transform: rotate(0deg);
    
    /* Ensure proper aspect ratio */
    object-fit: contain !important;
    
    /* Fix for iOS Safari */
    -webkit-video-playable-inline: true;
    playsinline: true;
    
    /* Prevent auto-rotation */
    image-orientation: from-image;
}

/* Mobile-specific video fixes */
@media (max-width: 768px) and (orientation: portrait) {
    .tutorial-video {
        position: relative;
        width: 100%;
        padding-bottom: 56.25%; /* 16:9 aspect ratio */
        height: 0;
        overflow: hidden;
    }
    
    .tutorial-video video,
    .tutorial-video iframe {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        
        /* Fix orientation */
        -webkit-transform: rotate(0deg) !important;
        transform: rotate(0deg) !important;
        
        /* Ensure correct display */
        object-fit: contain !important;
        max-width: 100%;
        max-height: 100%;
    }
    
    /* Product showcase videos on mobile */
    .product-video {
        -webkit-transform: rotate(0deg) !important;
        transform: rotate(0deg) !important;
        /* use contain to avoid stretching portrait videos */
        object-fit: contain !important;
        width: 100% !important;
        height: 100% !important;
        background: #000;
    }

    /* Quick view modal videos */
    .quick-view-modal video {
        -webkit-transform: rotate(0deg) !important;
        transform: rotate(0deg) !important;
        object-fit: contain !important;
        max-width: 100%;
        height: auto !important;
    }
}

/* Landscape mode on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .tutorial-video {
        position: relative;
        width: 100%;
        padding-bottom: 56.25%; /* 16:9 aspect ratio */
        height: 0;
        overflow: hidden;
    }
    
    .tutorial-video video,
    .tutorial-video iframe {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        object-fit: contain !important;
    }
}

/* iOS-specific fixes */
@supports (-webkit-touch-callout: none) {
    video {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
        -webkit-playsinline: true;
        playsinline: true;
    }
    
    .tutorial-video video {
        position: absolute !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        -webkit-transform: translate(-50%, -50%) !important;
        min-width: 100%;
        min-height: 100%;
        width: auto;
        height: auto;
        object-fit: contain !important;
    }
}

/* Android-specific fixes */
@media (max-width: 768px) {
    /* Force hardware acceleration */
    video {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
        will-change: transform;
    }
    
    /* Ensure videos maintain aspect ratio */
    .tutorial-video::before {
        content: "";
        display: block;
        padding-top: 56.25%; /* 16:9 aspect ratio */
    }
    
    .tutorial-video video {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        object-fit: contain;
    }
}

/* Fix for uploaded videos with wrong metadata */
video[data-rotation="90"],
video[data-rotation="270"] {
    transform: rotate(0deg) !important;
    -webkit-transform: rotate(0deg) !important;
}

/* Container fixes for proper video display */
.tutorial-card {
    overflow: visible !important;
}

.tutorial-video {
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Ensure YouTube embeds work correctly */
.youtube-wrapper {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 */
    height: 0;
    overflow: hidden;
}

.youtube-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* Fix for product card videos */
.product-card .product-video {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
    
    /* Prevent rotation */
    -webkit-transform: none !important;
    transform: none !important;
}

/* Add debug class for testing */
.video-debug {
    border: 2px solid red !important;
}

.video-debug::after {
    content: attr(data-orientation);
    position: absolute;
    top: 10px;
    left: 10px;
    background: red;
    color: white;
    padding: 5px;
    font-size: 12px;
    z-index: 1000;
}