/**
 * Creative Loading Screen Styles
 * E-Video Theme Loading Screen Component
 */

/* Loading Screen Container */
.e-video-loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: #ffffff;
    transition: opacity 0.5s ease-out, visibility 0.5s ease-out;
    
    /* Mobile performance optimizations */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-perspective: 1000px;
    perspective: 1000px;
    transform: translate3d(0, 0, 0);
    
    /* Prevent unwanted interactions on mobile */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    
    /* Ensure full coverage on mobile browsers */
    min-height: 100vh;
    min-height: -webkit-fill-available;
}

.e-video-loading-screen.fade-out {
    opacity: 0;
    visibility: hidden;
}

/* Loading Content Container */
.e-video-loading-content {
    text-align: center;
    padding: 20px;
    max-width: 90%;
    
    /* Hardware acceleration for mobile */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    will-change: transform;
}

/* Loading Logo */
.e-video-loading-logo {
    max-width: 100%;
    height: auto;
    margin-bottom: 20px;
    display: block;
    
    /* Image optimization for mobile */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    
    /* Hardware acceleration */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    will-change: transform;
}

/* Mobile-specific logo sizing */
@media (max-width: 768px) {
    [data-mobile="true"] .e-video-loading-logo {
        /* The actual size will be set via inline styles by JavaScript */
        /* This ensures the mobile-specific size is applied */
        max-width: 100% !important;
    }
}

/* Loading Text */
.e-video-loading-text {
    font-size: 16px;
    font-weight: 500;
    margin-top: 15px;
    color: #333333;
    font-family: inherit;
    
    /* Better text rendering on mobile */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    
    /* Prevent text selection */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Animation: Pulse */
.e-video-loading-logo.pulse {
    animation: pulseAnimation 1.5s ease-in-out infinite;
}

@keyframes pulseAnimation {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.7;
    }
}

/* Animation: Spin */
.e-video-loading-logo.spin {
    animation: spinAnimation 2s linear infinite;
}

@keyframes spinAnimation {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Animation: Bounce */
.e-video-loading-logo.bounce {
    animation: bounceAnimation 1s ease-in-out infinite;
}

@keyframes bounceAnimation {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-20px);
    }
    60% {
        transform: translateY(-10px);
    }
}

/* Animation: Fade */
.e-video-loading-logo.fade {
    animation: fadeAnimation 2s ease-in-out infinite;
}

@keyframes fadeAnimation {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.3;
    }
}

/* Animation: Scale */
.e-video-loading-logo.scale {
    animation: scaleAnimation 1.5s ease-in-out infinite;
}

@keyframes scaleAnimation {
    0%, 100% {
        transform: scale(1);
    }
    25% {
        transform: scale(1.2);
    }
    75% {
        transform: scale(0.8);
    }
}

/* Loading Spinner (fallback when no logo) */
.e-video-loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spinAnimation 1s linear infinite;
    margin-bottom: 20px;
}

/* Responsive Design */
/* Large tablets and small desktops */
@media (max-width: 1024px) {
    .e-video-loading-content {
        padding: 30px 20px;
    }
    
    .e-video-loading-logo {
        max-width: 100px;
    }
    
    .e-video-loading-text {
        font-size: 15px;
        line-height: 1.4;
    }
}

/* Standard tablets */
@media (max-width: 768px) {
    .e-video-loading-content {
        padding: 25px 15px;
        max-width: 90%;
    }
    
    .e-video-loading-logo {
        max-width: 80px;
        margin-bottom: 15px;
    }
    
    .e-video-loading-text {
        font-size: 14px;
        line-height: 1.5;
        margin-top: 12px;
        padding: 0 10px;
    }
    
    .e-video-loading-progress {
        width: 150px;
        height: 4px;
        margin-top: 15px;
    }
    
    .e-video-loading-spinner {
        width: 50px;
        height: 50px;
        border-width: 3px;
    }
    
    /* Reduce animation intensity on tablets */
    @keyframes bounceAnimation {
        0%, 20%, 50%, 80%, 100% {
            transform: translateY(0);
        }
        40% {
            transform: translateY(-15px);
        }
        60% {
            transform: translateY(-8px);
        }
    }
}

/* Mobile landscape */
@media (max-width: 640px) and (orientation: landscape) {
    .e-video-loading-screen {
        padding: 10px;
    }
    
    .e-video-loading-content {
        padding: 15px 10px;
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 15px;
        max-width: 95%;
    }
    
    .e-video-loading-logo {
        max-width: 60px;
        margin-bottom: 0;
        flex-shrink: 0;
    }
    
    .e-video-loading-text {
        font-size: 13px;
        margin-top: 0;
        text-align: left;
    }
    
    .e-video-loading-progress {
        width: 120px;
        margin-top: 0;
    }
}

/* Standard mobile phones */
@media (max-width: 480px) {
    .e-video-loading-screen {
        padding: 15px;
    }
    
    .e-video-loading-content {
        padding: 20px 15px;
        max-width: 95%;
        min-height: auto;
    }
    
    .e-video-loading-logo {
        max-width: 60px;
        margin-bottom: 12px;
    }
    
    .e-video-loading-text {
        font-size: 13px;
        line-height: 1.6;
        margin-top: 10px;
        padding: 0 5px;
        word-wrap: break-word;
        hyphens: auto;
    }
    
    .e-video-loading-progress {
        width: 120px;
        height: 3px;
        margin-top: 12px;
    }
    
    .e-video-loading-spinner {
        width: 40px;
        height: 40px;
        border-width: 3px;
        margin-bottom: 15px;
    }
    
    /* Gentler animations for mobile */
    @keyframes pulseAnimation {
        0%, 100% {
            transform: scale(1);
            opacity: 1;
        }
        50% {
            transform: scale(1.05);
            opacity: 0.8;
        }
    }
    
    @keyframes bounceAnimation {
        0%, 20%, 50%, 80%, 100% {
            transform: translateY(0);
        }
        40% {
            transform: translateY(-10px);
        }
        60% {
            transform: translateY(-5px);
        }
    }
    
    @keyframes scaleAnimation {
        0%, 100% {
            transform: scale(1);
        }
        25% {
            transform: scale(1.1);
        }
        75% {
            transform: scale(0.9);
        }
    }
}

/* Small mobile phones */
@media (max-width: 375px) {
    .e-video-loading-content {
        padding: 15px 10px;
    }
    
    .e-video-loading-logo {
        max-width: 50px;
    }
    
    .e-video-loading-text {
        font-size: 12px;
        line-height: 1.7;
        margin-top: 8px;
    }
    
    .e-video-loading-progress {
        width: 100px;
        height: 3px;
        margin-top: 10px;
    }
    
    .e-video-loading-spinner {
        width: 35px;
        height: 35px;
        border-width: 2px;
    }
}

/* Very small screens */
@media (max-width: 320px) {
    .e-video-loading-content {
        padding: 10px 8px;
    }
    
    .e-video-loading-logo {
        max-width: 45px;
    }
    
    .e-video-loading-text {
        font-size: 11px;
        margin-top: 6px;
    }
    
    .e-video-loading-progress {
        width: 90px;
        margin-top: 8px;
    }
    
    .e-video-loading-spinner {
        width: 30px;
        height: 30px;
        border-width: 2px;
    }
}

/* High DPI displays (Retina) */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .e-video-loading-logo {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .e-video-loading-screen {
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
        -webkit-touch-callout: none;
        -webkit-tap-highlight-color: transparent;
    }
    
    /* Disable pointer events to prevent accidental taps */
    .e-video-loading-content * {
        pointer-events: none;
    }
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    .e-video-loading-screen {
        /* Fix for iOS Safari viewport issues */
        min-height: -webkit-fill-available;
        min-height: 100dvh;
    }
    
    /* Prevent zoom on double tap */
    .e-video-loading-content {
        touch-action: manipulation;
    }
}

/* Performance optimizations for older mobile devices */
@media (max-width: 480px) and (max-device-width: 480px) {
    /* Reduce complexity for older devices */
    .e-video-loading-logo.bounce,
    .e-video-loading-logo.scale {
        animation-name: pulseAnimation;
    }
    
    /* Simplify progress bar on very small screens */
    .e-video-loading-progress-bar {
        background: #007bff;
    }
}

/* Connection-aware loading optimizations */
@media (max-width: 768px) {
    /* Reduce animation frequency on mobile to save battery */
    .e-video-loading-logo {
        animation-duration: 2s;
    }
    
    .e-video-loading-spinner {
        animation-duration: 1.5s;
    }
    
    .e-video-loading-progress-bar {
        animation-duration: 2.5s;
    }
}

/* Mobile-specific loading states */
.e-video-loading-screen[data-mobile="true"] {
    /* Enhanced mobile styles */
    contain: layout style paint;
    isolation: isolate;
}

.e-video-loading-screen[data-mobile="true"] .e-video-loading-content {
    /* Optimize layout containment */
    contain: layout style;
}

/* Landscape mobile optimizations */
@media (max-height: 500px) and (orientation: landscape) {
    .e-video-loading-content {
        padding: 10px 15px;
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        gap: 15px;
        max-width: 95%;
    }
    
    .e-video-loading-logo {
        margin-bottom: 0;
        flex-shrink: 0;
    }
    
    .e-video-loading-text {
        margin-top: 0;
        text-align: left;
        flex-grow: 1;
    }
    
    .e-video-loading-progress {
        margin-top: 0;
        align-self: flex-end;
    }
}

/* Ultra-wide mobile screens */
@media (min-aspect-ratio: 18/9) and (max-width: 480px) {
    .e-video-loading-content {
        flex-direction: row;
        max-width: 80%;
        gap: 20px;
    }
    
    .e-video-loading-logo {
        margin-bottom: 0;
        max-width: 50px;
    }
    
    .e-video-loading-text {
        margin-top: 0;
        text-align: left;
        font-size: 12px;
    }
}

/* Battery optimization for mobile */
@media (max-width: 768px) and (prefers-reduced-motion: no-preference) {
    /* Pause animations when page is not visible to save battery */
    .e-video-loading-screen:not(.page-visible) .e-video-loading-logo,
    .e-video-loading-screen:not(.page-visible) .e-video-loading-spinner,
    .e-video-loading-screen:not(.page-visible) .e-video-loading-progress-bar {
        animation-play-state: paused;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .e-video-loading-screen {
        background-color: #1a1a1a;
    }
    
    .e-video-loading-text {
        color: #ffffff;
    }
    
    .e-video-loading-spinner {
        border-color: #333333;
        border-top-color: #007bff;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .e-video-loading-logo,
    .e-video-loading-spinner,
    .e-video-loading-progress-bar {
        animation: none;
    }
    
    .e-video-loading-screen {
        transition: none;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .e-video-loading-screen {
        background-color: #000000;
    }
    
    .e-video-loading-text {
        color: #ffffff;
        font-weight: bold;
    }
    
    .e-video-loading-spinner {
        border-color: #ffffff;
        border-top-color: #ffff00;
    }
}
