/* Application splash. Loaded in the head so it is render-blocking: the overlay
   is painted before any page content and covers it until splash.js hides it.
   Same splash as aem-labs.com. The splash-in keyframes are the liquid-splash
   motion from css/motion/liquid-motion.css. */

.splash {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: clamp(16px, 2vw, 24px);
    background: var(--sand);
    color: var(--charcoal);
    /* Failsafe: if splash.js never runs the overlay still gets out of the way. */
    animation: splash-failsafe 0.01s linear 8s forwards;
}

.splash[hidden] {
    display: none;
}

/* Set by the head script once this tab has already shown the splash. */
html.splash-seen .splash {
    display: none;
}

html.splash-seen:has(.splash:not([hidden])) {
    overflow: visible;
}

/* One fade on the whole overlay. The logo and bar have no exit of their own. */
.splash.is-leaving {
    animation: splash-fade 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    pointer-events: none;
}

html:has(.splash:not([hidden])) {
    overflow: hidden;
}

.splash img {
    width: clamp(56px, 6vw, 72px);
    height: auto;
    animation: splash-in 1.5s cubic-bezier(0.22, 1, 0.36, 1) 0.1s both;
}

.splash span {
    width: clamp(96px, 10vw, 128px);
    height: 1px;
    background: rgba(var(--charcoal-rgb), 0.14);
    overflow: hidden;
}

.splash span::after {
    content: "";
    display: block;
    height: 100%;
    background: var(--rust);
    transform: scaleX(0);
    transform-origin: left;
    /* Runs for the 2 second minimum, matching splash.js. */
    animation: splash-progress 2s cubic-bezier(0.65, 0, 0.35, 1) forwards;
}

@keyframes splash-in {
    0% {
        opacity: 0;
        filter: blur(8px);
        transform: translate3d(0, 10px, 0) scale(0.88);
    }

    58% {
        opacity: 1;
        filter: blur(0);
        transform: translate3d(0, -2px, 0) scale(1.008);
    }

    100% {
        opacity: 1;
        filter: blur(0);
        transform: translate3d(0, 0, 0) scale(1);
    }
}

@keyframes splash-progress {
    to {
        transform: scaleX(1);
    }
}

@keyframes splash-fade {
    to {
        opacity: 0;
    }
}

@keyframes splash-failsafe {
    to {
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .splash img {
        animation: none;
    }

    .splash span::after {
        animation-duration: 0.01s;
        transform: scaleX(1);
    }

    .splash.is-leaving {
        animation-duration: 0.01s;
    }
}
