/* GH #5181 — THE BOOT PROGRESS BAR: what the page shows while the wasm payload downloads.

   Before this, nothing was painted between the page's first byte and the head's first frame — on a
   cold load, a blank canvas for as long as the download took. The owner's rulings (2026-10-12):

     3. A SMALL bar, CENTRED in the page, one inch wide, with NO percentage text.
     4. Once the bar is complete it PULSES its opacity between 40% and 100% until the head's first
        frame.
     5. It shows NOTHING unless loading takes longer than about 300 ms, so a cached load never
        flashes it.

   WIDTH: the loader writes `--blazor-load-percentage` (a percentage, `${loaded / total * 100}%`) on
   the root element's inline style while the boot resources download, and custom properties
   inherit, so the fill's `width: var(...)` tracks the download with no script and no polling. The
   loader's second, quoted-string property is not read anywhere: there is no text (ruling 3).

   `1in` IS A CSS INCH, i.e. 96 CSS px, and NOT a measured physical inch: nothing on this page can
   measure the display before the head boots, and every engine fixes the CSS inch at 96 px.

   COMPLETE: "the value is 100%" is not a selector, so `ttr-boot.js` marks the root
   `ttr-boot-loaded` when it is (`watchBootProgress`), and the pulse keys on that class. What is still
   owed at 100% is the runtime's start and the head's own boot up to its first DOM, which on this
   head is seconds; the pulse is what the visitor sees in that gap.

   FIRST FRAME: the bar is hidden by the head's first DOM. Every boot path mounts its first element
   into `#shell-root` (the shell, the user picker, a sign-in refusal) or, under `?mode=smoke`, into
   `#stage`, and both are EMPTY in index.html, so `:not(:empty) ~` hides the bar the moment the head
   owns the page — no script, and nothing the head has to remember to call. The bar is therefore
   AFTER both elements in the document, which the sibling combinator needs.

   THE 300 ms GATE, KEYED ON THE DOWNLOAD (GH #5181 fix round): the bar starts transparent and a
   zero-length reveal animation, DELAYED by `--boot-progress-delay`, makes it opaque — and the moment
   the download completes, `ttr-boot-loaded` PAUSES that animation where it stands. Paused inside its
   delay it never fires, so a download that completes inside the delay never shows the bar, however
   long the runtime then takes to start (about a second on a cached load, which is what the gate
   exists for). Paused after it fired, its fill holds the bar opaque. So the rule is ruling 5's as
   written: the bar shows only when the download is still running when the delay ends. Timed on the
   page alone, a cached download done in 250 ms still revealed a COMPLETE bar at 300 ms and pulsed it
   until the first element (review 1945 finding 1; cdp-lifecycle's P2p reads this, the reveal's own
   state included, since a blocked main thread hides the paint from a sampler).

   THE PULSE RUNS ON THE FILL, not on the bar, so it cannot touch the bar's opacity, which is the
   reveal's alone; a pulse there would show a bar the paused reveal is keeping hidden. Complete, the
   fill covers the track, and the track is cleared so the fill's opacity is the whole bar's, as a
   pulse of the bar's own opacity would be.

   REDUCED MOTION (UxOne/CLAUDE.md §20's gate, which the rulings do not state): under
   `prefers-reduced-motion: reduce` the completed bar holds steady at full opacity instead of
   pulsing. The reveal still happens; it is a step, not motion.

   COLOURS: this paints before any skin is elected, so no skin token is read (`--ttr-*` is the
   head's, and absent here). The canvas behind it is the renderer stylesheet's pre-boot `#E9E9EC`
   whatever the colour scheme, and then whatever the elected skin stamps, light or dark — so one
   mid-tone grey is used, at about 3.7:1 against both #E9E9EC and a #1C1C1E dark canvas, rather than
   a pair keyed on `prefers-color-scheme` that would be wrong on the light pre-boot canvas in a
   dark-scheme browser.

   PLACEMENT: centred in the window. The desktop simulation frame (Docs/187 C4) centres the
   simulated screen in the same window, so a tab that becomes a framed phone keeps the bar at the
   screen's centre too. Under `?log=1` it sits half the strip's height below the shell's centre;
   that posture is diagnostic.

   ROOT §28 DOES NOT REACH THIS: no generator runs before the head boots, so there is no
   declaration this bar could be produced from. It is static markup in index.html and this file
   for that reason, and it is gone before the generator's first output paints. */

#ttr-boot-progress {
    --boot-progress-delay: 300ms;
    position: fixed;
    left: 50%;
    top: 50%;
    width: 1in;
    height: 4px;
    margin: -2px 0 0 -0.5in;
    border-radius: 2px;
    overflow: hidden;
    background: rgba(128, 128, 136, 0.28);
    pointer-events: none;
    opacity: 0;
    animation: ttr-boot-progress-reveal 0s linear var(--boot-progress-delay) forwards;
}

#ttr-boot-progress > .ttr-boot-progress-fill {
    width: var(--blazor-load-percentage, 0%);
    height: 100%;
    background: #76767F;
}

html.ttr-boot-loaded #ttr-boot-progress {
    animation-play-state: paused;
    background: transparent;
}

html.ttr-boot-loaded #ttr-boot-progress > .ttr-boot-progress-fill {
    animation: ttr-boot-progress-pulse 0.9s ease-in-out infinite alternate;
}

@media (prefers-reduced-motion: reduce) {
    html.ttr-boot-loaded #ttr-boot-progress > .ttr-boot-progress-fill {
        animation: none;
    }
}

#shell-root:not(:empty) ~ #ttr-boot-progress,
#stage:not(:empty) ~ #ttr-boot-progress,
html.ttr-boot-failed #ttr-boot-progress {
    display: none;
}

/* GH #5286 — A BOOT THAT FAILS BEFORE ITS FIRST ELEMENT: the bar above is hidden and this sentence
   takes its place. `ttr-boot.js`'s `failBoot` marks the root `ttr-boot-failed` and appends the one
   `#ttr-boot-failed` element, and ONLY when the boot has failed before the head drew anything, so
   until then the page holds no text of ours (WebBootProgressBarTests states that exception). The
   words are the page's own static English: no caption registry exists before the head boots, and
   root §28 does not reach this page (the header above says why); what would retire them is a caption
   table shipped before the runtime.

   COLOURS: the bar's mid-tone grey, for the bar's reason (one colour right on the light pre-boot
   canvas whatever the scheme, and on a dark canvas a skin may already have stamped). No single grey
   reaches 4.5:1 against both #E9E9EC and #1C1C1E — the best any one grey can do is 3.75:1 each
   way — so the text is set LARGE (24 px), where WCAG 2.x AA asks 3:1, which #76767F meets against
   both: 3.71:1 on #E9E9EC and 3.78:1 on #1C1C1E (WCAG relative luminance, computed 2026-10-13). */
#ttr-boot-failed {
    position: fixed;
    left: 0;
    right: 0;
    top: 50%;
    margin: 0;
    padding: 0 16px;
    transform: translateY(-50%);
    text-align: center;
    font: 24px/1.3 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: #76767F;
}

@keyframes ttr-boot-progress-reveal {
    to { opacity: 1; }
}

@keyframes ttr-boot-progress-pulse {
    from { opacity: 1; }
    to { opacity: 0.4; }
}
