/* =============================================================
   Sign-in splash — the Synexus One mark building and scattering twice
   while the workspace loads, then handing over to it.

   Shown from the moment Sign in is submitted (Account/Login) until the
   first workspace page is ready (Views/Shared/_SplashScreen.cshtml has the
   markup and the script that decides when). The motion is the brand
   reference exactly, played twice: the six blocks of the logo fly in one
   after another, nudge outwards once, then blur and scatter out; they come
   back in, nudge, and scatter out again (two 4.5s cycles), with the stage
   floating in a slow 3D sway over a pulsing glow.

   The wordmark is timed to the blocks on the same 9s timeline: it rises in
   as the first block lands (0.675s-1.35s) and fades out with the final
   scatter (7.875s-8.55s, the blocks' own easing). The canvas then dissolves
   into the page underneath (the script in _SplashScreen.cshtml), or, if the
   page is not ready by the second scatter, the mark holds assembled until it
   is and then scatters.

   The page after sign-in continues exactly where the login page left off:
   the layout head records when Sign in was pressed and the splash script
   sets every animation's clock to that, so the navigation does not jump.
   Only transform, opacity and filter animate, on composited layers.

   Colours follow the theme: the logo's blue, lilac, mint and pink blocks on
   the app's soft tinted canvas in light themes and on the dark canvas in
   dark, with the wordmark's "Synexus" in the theme's text colour and "One"
   in the brand's light blue.

   Under prefers-reduced-motion, or the in-app preference, the mark simply
   stands assembled and the splash fades out.
   ============================================================= */

.synx-splash {
    --blue: #84c0ff;
    --purple: #e2d6ff;
    --green: #b3f9d3;
    --pink: #f8ceea;
    --square-size: 110px;
    --small-square: 80px;
    --gap: 14px;
    --border-radius: 4px;
    --splash-text: #0b0d12;
    --splash-muted: rgba(15, 23, 42, .45);
    --splash-one: #8fc3fb;
    --splash-block-shadow: 0 8px 25px rgba(37, 99, 235, .16);
    --splash-canvas:
        radial-gradient(ellipse at top left, #e6efff 0%, transparent 48%),
        radial-gradient(ellipse at top right, #f7eaf4 0%, transparent 42%),
        radial-gradient(ellipse at bottom left, #edf5f0 0%, transparent 38%),
        #f5f6f8;

    position: fixed;
    inset: 0;
    z-index: 3000;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: var(--splash-canvas);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    opacity: 1;
    contain: layout paint;
}

/* Sign in pressed: the canvas eases in rather than cutting in. The page
   after sign-in picks it up already in view. */
.synx-splash-on:not(.synx-splash-continue) .synx-splash {
    animation: splash-canvas-in 240ms ease-out both;
}

[data-bs-theme="dark"] .synx-splash,
body.dark .synx-splash {
    --splash-text: #f1f5f9;
    --splash-muted: rgba(255, 255, 255, .4);
    --splash-block-shadow: 0 8px 25px rgba(0, 0, 0, .5);
    --splash-canvas: #050507;
}

.synx-splash-on .synx-splash {
    display: flex;
}

/* Ambient glow container */
.synx-splash-stage {
    position: relative;
    width: 420px;
    height: 420px;
    display: flex;
    justify-content: center;
    align-items: center;
    perspective: 1000px;
}

.synx-splash-glow {
    position: absolute;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(132, 192, 255, .15) 0%, rgba(248, 206, 234, .15) 50%, transparent 70%);
    filter: blur(40px);
    animation: splash-pulse-glow 4s ease-in-out var(--splash-offset, 0ms) infinite alternate;
}

.synx-splash-mark {
    position: relative;
    width: 320px;
    height: 320px;
    transform-style: preserve-3d;
    animation: splash-container-float 4s ease-in-out var(--splash-offset, 0ms) infinite;
}

.splash-block {
    position: absolute;
    border-radius: var(--border-radius);
    box-shadow: var(--splash-block-shadow);
    transform-origin: center center;
    backface-visibility: hidden;
    will-change: transform, opacity, filter;
}

/* ---- Exact geometric placements ---- */
.splash-block.b-tl {
    width: var(--square-size);
    height: var(--square-size);
    background-color: var(--blue);
    left: 0;
    top: 0;
    animation: splash-tl 4.5s cubic-bezier(.77, 0, .175, 1) var(--splash-offset, 0ms) 2 both;
}

.splash-block.b-tr {
    width: var(--square-size);
    height: var(--square-size);
    background-color: var(--purple);
    left: calc(var(--square-size) + var(--gap));
    top: 0;
    animation: splash-tr 4.5s cubic-bezier(.77, 0, .175, 1) var(--splash-offset, 0ms) 2 both;
}

.splash-block.b-bl {
    width: var(--square-size);
    height: var(--square-size);
    background-color: var(--green);
    left: 0;
    top: calc(var(--square-size) + var(--gap));
    animation: splash-bl 4.5s cubic-bezier(.77, 0, .175, 1) var(--splash-offset, 0ms) 2 both;
}

.splash-block.b-br {
    width: var(--square-size);
    height: var(--square-size);
    background-color: var(--pink);
    left: calc(var(--square-size) + var(--gap));
    top: calc(var(--square-size) + var(--gap));
    animation: splash-br 4.5s cubic-bezier(.77, 0, .175, 1) var(--splash-offset, 0ms) 2 both;
}

.splash-block.b-r {
    width: var(--small-square);
    height: var(--small-square);
    background-color: var(--blue);
    left: calc(var(--square-size) * 2 + var(--gap) * 2);
    top: calc(var(--square-size) * .75);
    animation: splash-fr 4.5s cubic-bezier(.77, 0, .175, 1) var(--splash-offset, 0ms) 2 both;
}

.splash-block.b-b {
    width: var(--small-square);
    height: var(--small-square);
    background-color: var(--purple);
    left: calc(var(--square-size) * .75);
    top: calc(var(--square-size) * 2 + var(--gap) * 2);
    animation: splash-fb 4.5s cubic-bezier(.77, 0, .175, 1) var(--splash-offset, 0ms) 2 both;
}

/* ---- Wordmark, under the mark ---- */
.synx-splash-wordmark {
    margin-top: -12px;
    font-family: var(--font-family-base, 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif);
    font-size: 52px;
    font-weight: 500;
    line-height: 1;
    letter-spacing: -.02em;
    color: var(--splash-text);
    will-change: transform, opacity;
    animation: splash-word 9s linear var(--splash-offset, 0ms) 1 both;
}

    .synx-splash-wordmark .one {
        color: var(--splash-one);
    }

/* ---- Status text: on the wordmark's timeline, pulsing inside it ---- */
.synx-splash-status {
    position: absolute;
    bottom: 40px;
    color: var(--splash-muted);
    font-size: 12px;
    letter-spacing: 4px;
    text-transform: uppercase;
    animation: splash-word 9s linear var(--splash-offset, 0ms) 1 both;
}

    .synx-splash-status > span {
        display: inline-block;
        animation: splash-text-pulse 2s ease-in-out var(--splash-offset, 0ms) infinite;
    }

/* ---- Leaving: the mark and wordmark have already gone with the final
   scatter; the canvas dissolves into the page underneath. ---- */
.synx-splash.is-leaving {
    opacity: 0;
    pointer-events: none;
    transition: opacity 420ms cubic-bezier(.4, 0, .2, 1);
}

/* Small screens keep the same composition, scaled to fit. */
@media (max-width: 520px), (max-height: 640px) {
    .synx-splash-stage { scale: .62; margin: -80px 0; }
    .synx-splash-wordmark { font-size: 39px; margin-top: 0; }
}

/* ---- Keyframes (the brand reference, unchanged) ---- */
@keyframes splash-tl {
    0% { transform: translate(-180px, -180px) scale(0) rotate(-45deg); opacity: 0; filter: blur(10px); }
    15% { transform: translate(0, 0) scale(1) rotate(0deg); opacity: 1; filter: blur(0px); }
    35% { transform: translate(0, 0) scale(1); }
    45% { transform: translate(-3px, -3px) scale(1.02); }
    55% { transform: translate(0, 0) scale(1); }
    75% { transform: translate(0, 0) scale(1); opacity: 1; }
    90%, 100% { transform: translate(-120px, 120px) scale(.2) rotate(90deg); opacity: 0; filter: blur(12px); }
}

@keyframes splash-tr {
    0% { transform: translate(180px, -180px) scale(0) rotate(45deg); opacity: 0; filter: blur(10px); }
    18% { transform: translate(0, 0) scale(1) rotate(0deg); opacity: 1; filter: blur(0px); }
    38% { transform: translate(0, 0) scale(1); }
    48% { transform: translate(3px, -3px) scale(1.02); }
    58% { transform: translate(0, 0) scale(1); }
    75% { transform: translate(0, 0) scale(1); opacity: 1; }
    90%, 100% { transform: translate(120px, -120px) scale(.2) rotate(-90deg); opacity: 0; filter: blur(12px); }
}

@keyframes splash-bl {
    0% { transform: translate(-180px, 180px) scale(0) rotate(-45deg); opacity: 0; filter: blur(10px); }
    21% { transform: translate(0, 0) scale(1) rotate(0deg); opacity: 1; filter: blur(0px); }
    41% { transform: translate(0, 0) scale(1); }
    51% { transform: translate(-3px, 3px) scale(1.02); }
    61% { transform: translate(0, 0) scale(1); }
    75% { transform: translate(0, 0) scale(1); opacity: 1; }
    90%, 100% { transform: translate(-120px, -120px) scale(.2) rotate(90deg); opacity: 0; filter: blur(12px); }
}

@keyframes splash-br {
    0% { transform: translate(180px, 180px) scale(0) rotate(45deg); opacity: 0; filter: blur(10px); }
    24% { transform: translate(0, 0) scale(1) rotate(0deg); opacity: 1; filter: blur(0px); }
    44% { transform: translate(0, 0) scale(1); }
    54% { transform: translate(3px, 3px) scale(1.02); }
    64% { transform: translate(0, 0) scale(1); }
    75% { transform: translate(0, 0) scale(1); opacity: 1; }
    90%, 100% { transform: translate(120px, 120px) scale(.2) rotate(-90deg); opacity: 0; filter: blur(12px); }
}

@keyframes splash-fr {
    0% { transform: translate(220px, 0) scale(0) rotate(90deg); opacity: 0; filter: blur(10px); }
    27% { transform: translate(0, 0) scale(1) rotate(0deg); opacity: 1; filter: blur(0px); }
    47% { transform: translate(6px, 0) scale(1.05); }
    57% { transform: translate(0, 0) scale(1); }
    75% { transform: translate(0, 0) scale(1); opacity: 1; }
    90%, 100% { transform: translate(180px, 60px) scale(0) rotate(180deg); opacity: 0; filter: blur(15px); }
}

@keyframes splash-fb {
    0% { transform: translate(0, 220px) scale(0) rotate(-90deg); opacity: 0; filter: blur(10px); }
    30% { transform: translate(0, 0) scale(1) rotate(0deg); opacity: 1; filter: blur(0px); }
    50% { transform: translate(0, 6px) scale(1.05); }
    60% { transform: translate(0, 0) scale(1); }
    75% { transform: translate(0, 0) scale(1); opacity: 1; }
    90%, 100% { transform: translate(-60px, 180px) scale(0) rotate(-180deg); opacity: 0; filter: blur(15px); }
}

@keyframes splash-container-float {
    0%, 100% { transform: rotateX(0deg) rotateY(0deg) translateY(0px); }
    50% { transform: rotateX(6deg) rotateY(-6deg) translateY(-8px); }
}

@keyframes splash-pulse-glow {
    0% { transform: scale(.85); opacity: .4; }
    100% { transform: scale(1.2); opacity: .8; }
}

/* The wordmark's 9s envelope (two 4.5s block cycles): in from 7.5% to 15%
   as the first block lands, out from 87.5% to 95% with the final scatter. */
@keyframes splash-word {
    0%, 7.5% { opacity: 0; transform: translateY(10px); animation-timing-function: cubic-bezier(.2, .8, .2, 1); }
    15% { opacity: 1; transform: translateY(0); }
    87.5% { opacity: 1; transform: translateY(0); animation-timing-function: cubic-bezier(.77, 0, .175, 1); }
    95%, 100% { opacity: 0; transform: translateY(-6px); }
}

@keyframes splash-canvas-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes splash-text-pulse {
    0%, 100% { opacity: .3; }
    50% { opacity: .8; }
}

/* ---- Reduced motion: the OS setting or the in-app preference ---- */
@media (prefers-reduced-motion: reduce) {
    .synx-splash,
    .synx-splash :is(.splash-block, .synx-splash-mark, .synx-splash-glow, .synx-splash-wordmark, .synx-splash-status, .synx-splash-status > span) {
        animation: none !important;
    }

    .synx-splash.is-leaving { transition-duration: 200ms; }
}

:is([data-reduce-animations="true"], .reduce-motion) .synx-splash,
:is([data-reduce-animations="true"], .reduce-motion) .synx-splash :is(.splash-block, .synx-splash-mark, .synx-splash-glow, .synx-splash-wordmark, .synx-splash-status, .synx-splash-status > span) {
    animation: none !important;
}
