/*
 * The boot screen (BootScreen.razor): the WebOne clip and one progress bar,
 * over the whole viewport, while a full load of the panel comes up.
 *
 * Painted by the builder (Site Builder 1141:3490 / 1141:5064) and, since
 * 2026-11-08, by every full load of the dashboard, whose own first paint was a
 * white page in the browser's default font. Its own sheet, linked on every
 * page, because it has to be dressed in the first paint and builder.css is
 * only linked by the builder.
 *
 * Light or dark from the scheme the shell's boot script stamps on <html>
 * before that paint (data-haya-scheme: the operator's choice, else the
 * product's default, else the machine's) — the same answer the panel is about
 * to draw itself in. The shell's colour tokens are not defined yet at this
 * point (it writes them once it has drawn), so the colours here are the
 * product theme's own canvases, written out.
 */

.pb-builder-loader {
    /* Light: the dashboard's canvas, and the bar in its brand blue. */
    --boot-bg: #f3f5fb;
    --boot-track: #e1e5ef;
    --boot-fill: linear-gradient(90deg, #a8d2f7 0%, #126fbe 100%);
    --boot-glow: #1b8fe5;
    --boot-stalled: linear-gradient(90deg, #f7d9a3 0%, #c97a16 100%);
    --boot-failed: linear-gradient(90deg, #f6b8b4 0%, #c8362f 100%);
    --boot-title: #3d3f52;
    --boot-text: #60627f;
    --boot-detail-bg: rgba(61, 63, 82, 0.06);
    --boot-detail-text: #60627f;
    --boot-retry-bg: #3d3f52;
    --boot-retry-text: #ffffff;
    --boot-retry-hover: #2b2d3c;
    --boot-focus: #126fbe;
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    background: var(--boot-bg);
}

:root[data-haya-scheme="dark"] .pb-builder-loader,
/* The screen on the way into the builder is dark whatever the panel's
   scheme (user request, 2026-11-10): the builder's chrome is black, so a
   light screen flashed white before it. The editor's own loader is on the
   way into the builder too; only the one leaving it keeps the scheme. */
.pb-builder-loader--builder,
.pb-builder-loader:not(.pb-builder-loader--boot):not(.pb-builder-loader--leaving) {
    /* Dark: black behind the builder, whose chrome is black; the dashboard's
       own dark canvas behind the dashboard, so the screen fades into it. */
    --boot-bg: #000000;
    --boot-track: #171717;
    --boot-fill: linear-gradient(90deg, #ffffff 0%, #2ea2f0 100%);
    --boot-glow: #1f81d6;
    --boot-stalled: linear-gradient(90deg, #ffffff 0%, #f5b942 100%);
    --boot-failed: linear-gradient(90deg, #ffffff 0%, #ef4444 100%);
    --boot-title: #ffffff;
    --boot-text: rgba(255, 255, 255, 0.72);
    --boot-detail-bg: rgba(255, 255, 255, 0.06);
    --boot-detail-text: rgba(255, 255, 255, 0.6);
    --boot-retry-bg: #ffffff;
    --boot-retry-text: #141414;
    --boot-retry-hover: #e6e6e6;
    --boot-focus: #4bc6ff;
}

    /* The screen on the way out of the builder is on its way to the
       dashboard, so it takes the dashboard's ground: black then navy was a
       visible jump between the two screens in dark mode. */
    :root[data-haya-scheme="dark"] .pb-builder-loader--dashboard,
    :root[data-haya-scheme="dark"] .pb-builder-loader--leaving {
        --boot-bg: #202028;
        --boot-track: #353546;
    }

/* One loading screen, not two. The static one stays up until the editor has
   its document (builder-loader.js adds .is-done and it fades); the editor's
   own loader underneath is only there to say "still waiting", so it stays
   invisible while the static one covers it. If the script never runs, the
   :has() rule still takes the screen down once the editor has drawn — and
   the dashboard's once the shell has. */
.pb-builder-loader--boot {
    transition: opacity .25s ease;
}

    .pb-builder-loader--boot.is-done,
    .pb-builder-host:has(.editor-shell):not(:has(.editor-shell > .pb-builder-loader)) > .pb-builder-loader--boot:not(.is-driven),
    body:has(.haya-shell) > .pb-builder-loader--dashboard:not(.is-driven) {
        opacity: 0;
        pointer-events: none;
    }

.pb-builder-host:has(.editor-shell):not(:has(.editor-shell > .pb-builder-loader)) > .pb-builder-loader--boot:not(.is-driven),
body:has(.haya-shell) > .pb-builder-loader--dashboard:not(.is-driven) {
    display: none;
}

.pb-builder-host:has(> .pb-builder-loader--boot:not(.is-done)) .editor-shell > .pb-builder-loader {
    visibility: hidden;
}

/* The clip at 250px square (user request, 2026-11-10: the 340px of
   2026-11-08 was too large), smaller only where the screen is narrower. */
.pb-builder-loader__content {
    --boot-stage: min(250px, 86vw);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.pb-builder-loader__logo-stage {
    display: grid;
    place-items: center;
    width: var(--boot-stage);
    aspect-ratio: 1;
}

/* Transparent (webone-loader-reverse-340: VP9 or HEVC with alpha), and its
   silver-and-blue logo reads on both grounds, so it is drawn as it is — no
   filter and no blending. */
.pb-builder-loader__video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* A reseller's logo in the clip's place (CMS-L4-28): one picture per
   ground, the one for the other scheme hidden, breathing gently so the
   screen still reads as working before the bar has moved. */
.pb-builder-loader__brand,
.pb-builder-loader__brand-name {
    max-width: 62%;
    max-height: 46%;
    object-fit: contain;
    animation: pb-boot-breathe 2.4s ease-in-out infinite;
}

.pb-builder-loader__brand--dark,
:root[data-haya-scheme="dark"] .pb-builder-loader__brand--light {
    display: none;
}

:root[data-haya-scheme="dark"] .pb-builder-loader__brand--dark {
    display: block;
}

.pb-builder-loader__brand-name {
    max-height: none;
    color: var(--boot-title);
    font-size: 28px;
    font-weight: 700;
    text-align: center;
    overflow-wrap: anywhere;
}

@keyframes pb-boot-breathe {
    0%, 100% { opacity: .55; transform: scale(.97); }
    50% { opacity: 1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .pb-builder-loader__brand,
    .pb-builder-loader__brand-name {
        animation: none;
    }
}

/* The bar as it was. Pulled up, because the clip's logo ends at 72% of its
   height and the rest of the square is transparent: without this the bar sat
   a hundred pixels below the logo, reading as a separate thing. */
.pb-builder-loader__track {
    position: relative;
    display: block;
    width: 248px;
    height: 4px;
    margin-block-start: calc(var(--boot-stage) * -0.2);
    overflow: visible;
    border-radius: 12px;
    background: var(--boot-track);
}

.pb-builder-loader__fill {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: var(--boot-fill);
    transform: scaleX(var(--pb-load, .02));
    transform-origin: left center;
    transition: transform .35s ease-out;
}

.pb-builder-loader__glow {
    position: absolute;
    top: -2px;
    left: 0;
    width: 4px;
    height: 8px;
    border-radius: 12px;
    background: var(--boot-glow);
    filter: blur(4px);
    transform: translateX(calc(var(--pb-load, .02) * 244px));
    transition: transform .35s ease-out;
}

/* Leaving the builder for the dashboard (EditorHeader): the next page has
   not answered yet and nothing on this one can say how far it has got, so
   the bar walks a first stretch and waits there. The dashboard's own screen
   picks up from the same point (builder-loader.js, "carry"), so the bar
   never goes backwards across the two pages. Above everything the editor
   draws — Theo's layer and the drag curtains sit in the billions. */
.pb-builder-loader--leaving {
    z-index: 2147483600;
}

.pb-builder-loader--leaving .pb-builder-loader__fill {
    animation: pb-boot-leave-fill 3s cubic-bezier(.2, .7, .3, 1) forwards;
}

.pb-builder-loader--leaving .pb-builder-loader__glow {
    animation: pb-boot-leave-glow 3s cubic-bezier(.2, .7, .3, 1) forwards;
}

@keyframes pb-boot-leave-fill {
    from { transform: scaleX(.04); }
    to { transform: scaleX(.3); }
}

@keyframes pb-boot-leave-glow {
    from { transform: translateX(calc(.04 * 244px)); }
    to { transform: translateX(calc(.3 * 244px)); }
}

.pb-builder-loader__sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* The honest half of the loader (user test B03/I09): what the screen says when
   the bar has stood still for thirty seconds, or the runtime failed to start.
   Hidden until builder-loader.js marks the screen troubled; the words are
   rendered by the page in the operator's language and only revealed here.
   The font is named here because on the dashboard nothing else has named one
   yet: the shell writes its font once it has drawn. */
.pb-builder-loader__trouble {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    max-width: min(440px, calc(100vw - 48px));
    margin-block-start: 8px;
    text-align: center;
    color: var(--boot-text);
    font-family: var(--font-sans, IRANYekanXVF, "Segoe UI", Tahoma, sans-serif);
    font-size: 13px;
    line-height: 1.7;
}

.pb-builder-loader--boot.is-troubled .pb-builder-loader__trouble {
    display: flex;
}

/* A stalled bar is amber: a wait, not yet a failure. A failed one is red. */
.pb-builder-loader--boot.is-stalled .pb-builder-loader__fill {
    background: var(--boot-stalled);
}

.pb-builder-loader--boot.is-failed .pb-builder-loader__fill {
    background: var(--boot-failed);
}

.pb-builder-loader--boot.is-troubled .pb-builder-loader__glow {
    display: none;
}

.pb-builder-loader__trouble-title {
    color: var(--boot-title);
    font-size: 14px;
    font-weight: 600;
}

.pb-builder-loader__trouble-hint {
    margin: 0;
}

/* The error's own words: small, monospaced, left to right whatever the
   panel's direction, and only when there are any ([hidden] otherwise — the
   rule below must not set display, or [hidden] would stop working). */
.pb-builder-loader__trouble-detail:not([hidden]) {
    display: block;
    max-width: 100%;
    padding: 6px 10px;
    border-radius: 6px;
    background: var(--boot-detail-bg);
    color: var(--boot-detail-text);
    font-family: ui-monospace, monospace;
    font-size: 11px;
    line-height: 1.6;
    overflow-wrap: anywhere;
    text-align: start;
}

.pb-builder-loader__retry {
    margin-block-start: 4px;
    height: 36px;
    padding: 0 18px;
    border: 0;
    border-radius: 8px;
    background: var(--boot-retry-bg);
    color: var(--boot-retry-text);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

    .pb-builder-loader__retry:hover {
        background: var(--boot-retry-hover);
    }

    .pb-builder-loader__retry:focus-visible {
        outline: 2px solid var(--boot-focus);
        outline-offset: 2px;
    }

@media (prefers-reduced-motion: reduce) {
    .pb-builder-loader__fill,
    .pb-builder-loader__glow,
    .pb-builder-loader--boot { transition: none; }

    .pb-builder-loader--leaving .pb-builder-loader__fill,
    .pb-builder-loader--leaving .pb-builder-loader__glow { animation: none; }
}
