/* =================================================================
   THE BOOT SCREEN - what the Portal shows before it can show anything
   (UI.Portal/wwwroot/index.html's #app, and App.razor while a session is
   restored; docs/claude/BlazorConventions.md "The boot screen", 2026-11-24).
   -----------------------------------------------------------------
   Kirk: "the green spinner with the % counter - sex that up to the max ...
   not make it look like a blazor app starting and instead loading like a
   real platform". It is the sign-in stage's night field, centred: the
   Listrak logo, the Converse wordmark, a typing indicator in the four
   moment families (a conversation platform "typing" while it loads), a
   thin meter filled by Blazor's own --blazor-load-percentage, and a status
   line. At 100% (the download done, .NET still starting) index.html's tiny
   script adds .is-starting and the meter keeps a moving sheen, so nothing
   ever looks frozen. Every class is boot-* and owned by THIS file alone.
   TOKENS ONLY, the whole file (Tests/ShellTokensOnlyTests). Reduced motion
   = still.
   ================================================================= */

/* Night behind the boot screen until a page arrives - never a white flash between the boot screen and the app. */
body:has(.boot):not(:has(#app > *)) {
    background: color-mix(in oklab, var(--theme-nav-background) 22%, black) !important;
}

.boot {
    --boot-night: color-mix(in oklab, var(--theme-nav-background) 22%, black);
    --boot-white: color-mix(in srgb, white 100%, transparent);
    --boot-ink: color-mix(in srgb, white 94%, transparent);
    --boot-ink-soft: color-mix(in srgb, white 62%, transparent);
    --boot-ink-faint: color-mix(in srgb, white 40%, transparent);
    --boot-track: color-mix(in srgb, white 12%, transparent);
    --boot-ease: cubic-bezier(.16, 1, .3, 1);
    position: fixed;
    inset: 0;
    z-index: 900;
    display: grid;
    place-items: center;
    overflow: hidden;
    background:
        radial-gradient(60% 55% at 22% 18%, color-mix(in oklab, var(--conv-ask) 40%, transparent), transparent 70%),
        radial-gradient(55% 60% at 82% 88%, color-mix(in oklab, var(--conv-flow) 34%, transparent), transparent 72%),
        var(--boot-night);
    color: var(--boot-ink);
    font-family: var(--theme-font);
}

/* The builder canvas's dot grid, fading out from the centre. */
.boot::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(color-mix(in srgb, white 10%, transparent) 1px, transparent 1.5px);
    background-size: 22px 22px;
    -webkit-mask-image: radial-gradient(closest-side at 50% 50%, transparent 30%, var(--boot-white) 100%);
    mask-image: radial-gradient(closest-side at 50% 50%, transparent 30%, var(--boot-white) 100%);
    pointer-events: none;
}

.boot-center {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 22px;
    padding: 24px;
    animation: boot-in 700ms var(--boot-ease) backwards;
}

.boot-mark {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.boot-listrak {
    display: block;
    width: 120px;
    height: auto;
}

.boot-word {
    margin: 0;
    color: var(--boot-ink);
    font-size: clamp(48px, 8vw, 80px);
    font-weight: 700;
    letter-spacing: -0.035em;
    line-height: .95;
}

/* A conversation platform "typing": the four moment families, in turn. */
.boot-typing {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 11px 16px;
    border-radius: 18px 18px 18px 6px;
    background: color-mix(in oklab, var(--boot-white) 8%, var(--boot-night));
    box-shadow: 0 8px 24px color-mix(in srgb, black 30%, transparent);
}

.boot-typing span {
    width: 8px;
    height: 8px;
    border-radius: var(--wf-radius-pill);
    animation: boot-dot 1.2s ease-in-out infinite;
}

.boot-typing span:nth-child(1) { background: color-mix(in oklab, var(--conv-ask) 70%, var(--boot-white)); }
.boot-typing span:nth-child(2) { background: color-mix(in oklab, var(--conv-say) 70%, var(--boot-white)); animation-delay: 150ms; }
.boot-typing span:nth-child(3) { background: color-mix(in oklab, var(--conv-act) 70%, var(--boot-white)); animation-delay: 300ms; }
.boot-typing span:nth-child(4) { background: color-mix(in oklab, var(--conv-flow) 70%, var(--boot-white)); animation-delay: 450ms; }

/* The meter: four segments, the four moment families, filling in turn from Blazor's own download percentage - loading moves
   through a conversation (ask 0-25%, say 25-50%, act 50-75%, flow 75-100%). A sheen crosses it the whole time. */
.boot-meter {
    position: relative;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    width: 232px;
    height: 4px;
}

.boot-seg {
    position: relative;
    overflow: hidden;
    border-radius: var(--wf-radius-pill);
    background: var(--boot-track);
}

.boot-seg > span {
    position: absolute;
    inset: 0 auto 0 0;
    width: clamp(0%, calc((var(--blazor-load-percentage, 0%) - var(--boot-from)) * 4), 100%);
    border-radius: inherit;
    background: var(--boot-hue);
    transition: width 240ms var(--boot-ease);
}

.boot-seg.is-ask { --boot-from: 0%; --boot-hue: color-mix(in oklab, var(--conv-ask) 72%, var(--boot-white)); }
.boot-seg.is-say { --boot-from: 25%; --boot-hue: color-mix(in oklab, var(--conv-say) 68%, var(--boot-white)); }
.boot-seg.is-act { --boot-from: 50%; --boot-hue: color-mix(in oklab, var(--conv-act) 70%, var(--boot-white)); }
.boot-seg.is-flow { --boot-from: 75%; --boot-hue: color-mix(in oklab, var(--conv-flow) 66%, var(--boot-white)); }

.boot.is-starting .boot-seg > span {
    width: 100%;
}

.boot-meter::after {
    content: "";
    position: absolute;
    inset: -2px 0;
    width: 30%;
    background: linear-gradient(90deg, transparent, color-mix(in srgb, white 45%, transparent), transparent);
    animation: boot-sheen 1.8s ease-in-out infinite;
    pointer-events: none;
}

/* THE HAND-OFF: the moment #app holds a page (the sign-in stage or the workspace), the boot screen dissolves into it -
   pure CSS, nothing that can stick. While a session is restored App.razor renders nothing, so the boot screen stays. */
/* A TRANSITION, not an animation: the end state (hidden, click-through) holds even where a browser runs no animation at all,
   so the boot layer can never stick over the app. */
.boot {
    transition: opacity 560ms var(--boot-ease), filter 560ms var(--boot-ease), transform 560ms var(--boot-ease), visibility 0s linear 560ms;
}

body:has(#app > *) .boot {
    visibility: hidden;
    opacity: 0;
    filter: blur(6px);
    transform: scale(1.02);
    pointer-events: none;
}

.boot-status {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin: 0;
    color: var(--boot-ink-soft);
    font-size: 13px;
    letter-spacing: .01em;
}

.boot-percent {
    color: var(--boot-ink-faint);
    font-variant-numeric: tabular-nums;
}

.boot-percent::after {
    content: var(--blazor-load-percentage-text, "");
}

.boot-status-starting {
    display: none;
}

.boot.is-starting .boot-status-loading,
.boot.is-starting .boot-percent {
    display: none;
}

.boot.is-starting .boot-status-starting {
    display: inline;
}

@keyframes boot-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}

@keyframes boot-dot {
    0%, 60%, 100% { transform: translateY(0); opacity: .55; }
    30% { transform: translateY(-5px); opacity: 1; }
}

@keyframes boot-sheen {
    from { transform: translateX(-110%); }
    to { transform: translateX(260%); }
}

@media (prefers-reduced-motion: reduce) {
    .boot-center,
    .boot-typing span {
        animation: none;
    }

    .boot-typing span {
        opacity: 1;
    }

    .boot-meter::after {
        display: none;
    }

    .boot {
        transition: none;
    }
}
