/* Shared Loader CSS for Shell and Game */

/* The main container covering the screen */
#appLoader,
#shellLoader {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #030918;
    z-index: 2000;
    /* Shell might override to 9999 inline if needed, but 2000 is base */
    transition: opacity 0.35s ease;
    overflow: hidden;
    pointer-events: none;
    opacity: 0;
}

/* State: Visible */
body.app-loading #appLoader,
#shellLoader.visible {
    opacity: 1;
    pointer-events: auto;
}

/* State: Hidden */
body:not(.app-loading) #appLoader,
#shellLoader.hidden {
    opacity: 0;
    pointer-events: none;
}

/* The Visual Card / Full Screen Container */
.loader-visual,
.shell-loader-visual {
    position: relative;
    overflow: hidden;
    background: #010916;
    /* Default to Desktop Image */
    background-image: url('../icons/Launchscreen_RallyeApp_Desktop.png');
    background-size: cover;
    background-position: center center;

    /* Full Screen Mode (Default for Shell & Modern Game) */
    width: 100%;
    height: 100%;
    max-width: none;
    border-radius: 0;
    box-shadow: none;
}

/* Progress Bar Container */
.loader-visual__progress,
.shell-loader-progress {
    position: absolute;
    left: 12%;
    right: 12%;
    bottom: clamp(20px, 10%, 56px);
    height: 14px;
    border-radius: 999px;
    background: rgba(3, 9, 24, .65);
    border: 1px solid rgba(255, 255, 255, .25);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
    overflow: hidden;
}

/* Progress Bar Fill */
/* Progress Bar Fill */
.loader-visual__progress-fill,
.shell-loader-fill {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    width: 100%;
    transform-origin: left;
    background: linear-gradient(90deg, #34d399 0%, #22d3ee 45%, #818cf8 100%);
    filter: drop-shadow(0 4px 12px rgba(34, 211, 238, .35));

    /* Default Indeterminate State (GPU Optimized) */
    animation: loader-indeterminate 1.5s cubic-bezier(0.65, 0.815, 0.735, 0.395) infinite;
}

/* Determinate State (if needed later, use scaleX) */
.loader-visual__progress-fill.determinate {
    animation: none;
    transform: scaleX(var(--progress-scale, 0));
}

/* Optimized Keyframes */
@keyframes loader-indeterminate {
    0% {
        transform: translateX(-100%) scaleX(0.2);
    }

    50% {
        transform: translateX(0%) scaleX(0.5);
    }

    100% {
        transform: translateX(100%) scaleX(0.2);
    }
}

/* Mobile Adjustments */
@media (max-width: 480px) {

    .loader-visual,
    .shell-loader-visual {
        width: 100%;
        height: 100%;
        max-width: none;
        border-radius: 0;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {

    #appLoader,
    #shellLoader {
        transition: none;
    }

    .loader-visual__progress-fill,
    .shell-loader-fill {
        animation: none;
        transform: none;
        width: 100%;
    }
}