/* The loader (TEST-SPEC NFR-013). Its own small file, loaded first, so it paints before anything else has
   arrived; a separate file so a strict Content-Security-Policy needs no exception for it.
   The logo is the tachometer (DECISIONS R1-13), drawn on a 64-unit grid (as ui/mark), here at 120 px:
   1 unit = 1.875 px. Its needle sweeps across the whole dial in 0.36 s, lighting it as it passes, and the
   dial stays lit; the needle then returns to rest at its swing's own pace and swings there until the first
   screen is ready (boot.js fades the loader out). The loader may leave as soon as the sweep has lit the dial.
   Everything that moves is an HTML box animating transform or opacity, which the browser's compositor runs
   on its own thread, so it stays smooth while the app's script downloads and starts: on a phone's
   high-density screen Chrome runs an SVG element's transform on the main thread. So the lit arc is not a
   stroke's dash: it is two layers clipped to the dial's shape (the dial, then the red zone), each lit by
   conic wedges that turn with the needle. The wedge shapes, the clip shapes and every keyframe come from
   bin/logo-export, in the generated block at the end. */

/* In the theme the app loads into (NFR-035): boot.js has already set the saved choice on <html>, so the
   same selectors as brrm.css pick it, falling back to the system's. */
#br-loader {
  position: fixed; inset: 0; z-index: 10000; display: grid; place-items: center; transition: opacity 200ms ease;
  background: #F4F4F4; --br-mark-arc: #111111; --br-mark-red: #E60023; --br-mark-ink: #111111;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #br-loader { background: #111111; --br-mark-arc: #FFFFFF; --br-mark-red: #E60023; --br-mark-ink: #FFFFFF; }
}
:root[data-theme="dark"] #br-loader { background: #111111; --br-mark-arc: #FFFFFF; --br-mark-red: #E60023; --br-mark-ink: #FFFFFF; }
/* The installed app (NFR-043): Industrial Black in both themes, as the phone's launch screen (the manifest's
   background_color) that comes just before it, so the still logo there passes straight into this one. */
:root[data-installed] #br-loader { background: #111111; --br-mark-arc: #FFFFFF; --br-mark-red: #E60023; --br-mark-ink: #FFFFFF; }
#br-loader.br-loader--out { opacity: 0; pointer-events: none; }
/* Nothing inside the loader transitions: brrm.css, which arrives later, gives every svg a colour and fill
   transition for hovering, and its new text colour would start one here, off the compositor. */
#br-loader * { transition: none; }

.br-loader__art { position: relative; width: 120px; height: 120px; }
.br-loader__art > * { position: absolute; }
.br-loader__track, .br-loader__hub { left: 0; top: 0; width: 120px; height: 120px; overflow: visible; }
/* The unlit dial: the arcs at a fifth of their colour. */
.br-loader__track path { fill: none; stroke-width: 6; stroke-linecap: round; stroke-opacity: .2; }
.br-loader__track .br-loader__t { stroke: var(--br-mark-arc); }
.br-loader__track .br-loader__r { stroke: var(--br-mark-red); }

/* The lit layers and the needle are 120 px boxes centred on the dial's centre (their top is generated), so
   a wedge or the needle turns about the centre of its box. */
.br-loader__lit, .br-loader__needle { left: 0; width: 120px; height: 120px; }
.br-loader__wedge { position: absolute; inset: 0; will-change: transform; }
/* A wedge is 130 degrees ending at its box's top: turned to the needle's angle, it lights from the needle back
   past the start of the dial, its tail in the dial's gap where the clip hides it. The first (a) stops halfway
   at the top, the second (b) goes on to the end, so together they light the whole dial and stay. */
.br-loader__lit--t .br-loader__wedge { background: conic-gradient(from 230deg, var(--br-mark-arc) 0deg 129.5deg, transparent 130deg); }
.br-loader__lit--r .br-loader__wedge { background: conic-gradient(from 230deg, var(--br-mark-red) 0deg 129.5deg, transparent 130deg); }
.br-loader__wa { animation: br-ld-wa .36s linear both; }
.br-loader__wb { animation: br-ld-wb .36s linear both; }
.br-loader__wr { animation: br-ld-wr .36s linear both; }
/* The red zone's round end, lit as the needle reaches it. */
.br-loader__cap { border-radius: 50%; background: var(--br-mark-red); opacity: 0; will-change: opacity; animation: br-ld-cap .36s linear both; }

/* The needle: its box makes the pass (sweep and return), the box inside it the swing after it. */
.br-loader__needle { will-change: transform; animation: br-needle 3.36s linear both; }
.br-loader__swing { position: absolute; inset: 0; will-change: transform; animation: br-ld-swing .9s cubic-bezier(.37, 0, .63, 1) 3.36s infinite alternate both; }
.br-loader__swing svg { display: block; width: 100%; height: 100%; overflow: visible; }
.br-loader__swing path { fill: none; stroke: var(--br-mark-ink); stroke-width: 5; stroke-linecap: round; }
.br-loader__hub circle { fill: none; stroke: var(--br-mark-ink); stroke-width: 3.5; }

/* The hand-off from Android's launch screen (NFR-045). Phones since about 2020 draw that screen from the
   maskable icon, whose badge is the launch screen's own deep space, so it shows the still logo alone, at the
   icon's 0.72 scale: on a 240 dp icon 0.72 x 240 / 120 = 1.44x the loader's, its centre (the grid's) on the
   screen's. The loader's first frame is that picture, lit and at rest, and it eases down to its own size
   while the needle starts its swing. boot.js sets data-handoff only in the app installed on Android. */
.br-loader__from { position: relative; }
:root[data-handoff] .br-loader__from { transform-origin: 60px 60px; will-change: transform; animation: br-ld-handoff .36s cubic-bezier(.4, 0, .2, 1) both; }
:root[data-handoff] .br-loader__wedge, :root[data-handoff] .br-loader__cap, :root[data-handoff] .br-loader__needle { animation: none; }
:root[data-handoff] .br-loader__swing { animation-delay: 0s; }
@keyframes br-ld-handoff { from { transform: scale(1.44); } to { transform: none; } }

/* The name under the logo, letter by letter while the app loads (R2-51, NFR-056): each letter its own HTML box that
   fades and rises on the compositor, the four within the needle's sweep and a little after. It hangs under the logo
   without moving it, so the logo stays on the screen's centre and the hand-off above still lines up. */
.br-loader__word { position: absolute; left: 50%; top: calc(100% + 14px); display: flex; transform: translateX(-50%); color: var(--br-mark-ink); }
.br-loader__letter { display: block; opacity: 0; transform: translateY(8px); animation: br-ld-letter .2s cubic-bezier(.2, .8, .2, 1) forwards; }
.br-loader__letter svg { display: block; fill: currentColor; }
.br-loader__letter:nth-child(1) { animation-delay: .04s; }
.br-loader__letter:nth-child(2) { animation-delay: .12s; }
.br-loader__letter:nth-child(3) { animation-delay: .2s; }
.br-loader__letter:nth-child(4) { animation-delay: .28s; }
@keyframes br-ld-letter { to { opacity: 1; transform: none; } }

/* Reduced motion, and the hand-off's still logo: the dial lit and the needle at rest. */
:root[data-handoff] .br-loader__wa { transform: rotate(0deg); }
:root[data-handoff] .br-loader__wb, :root[data-handoff] .br-loader__wr { transform: rotate(120deg); }
:root[data-handoff] .br-loader__wr, :root[data-handoff] .br-loader__cap { opacity: 1; }
:root[data-handoff] .br-loader__needle { transform: rotate(100deg); }
@media (prefers-reduced-motion: reduce) {
  #br-loader * { animation: none !important; }
  #br-loader .br-loader__wa { transform: rotate(0deg); }
  #br-loader .br-loader__wb, #br-loader .br-loader__wr { transform: rotate(120deg); }
  #br-loader .br-loader__wr, #br-loader .br-loader__cap { opacity: 1; }
  #br-loader .br-loader__needle { transform: rotate(100deg); }
  #br-loader .br-loader__letter { opacity: 1; transform: none; }
}

/* The navbar logo's pass as the loader leaves (NFR-014) draws the SVG mark of ui/mark with br-needle,
   br-lit-t and br-lit-r below (brrm.css runs them). */

/* --- generated by bin/logo-export: do not edit by hand --- */
/* The pass: 360 ms of sweep and 3000 ms of return, 3360 ms in all; the swing is 6 degrees every 900 ms. */
.br-loader__lit, .br-loader__needle { top: 11.25px; }
.br-loader__lit--t { clip-path: path('M 16.157 85.312 A 50.625 50.625 0 1 1 108.664 46.046 A 5.625 5.625 0 0 1 97.85 49.147 A 39.375 39.375 0 1 0 25.9 79.688 A 5.625 5.625 0 0 1 16.157 85.312 Z'); }
.br-loader__lit--r { clip-path: path('M 110.132 52.954 A 50.625 50.625 0 0 1 103.843 85.312 L 94.1 79.688 A 39.375 39.375 0 0 0 98.992 54.52 A 5.625 5.625 0 0 1 110.132 52.954 Z'); }
.br-loader__cap { left: 93.346px; top: 88.125px; width: 11.25px; height: 11.25px; }
@keyframes br-needle {
  0% { transform: rotate(-120deg); }
  0.893% { transform: rotate(-119.444deg); }
  1.786% { transform: rotate(-115.556deg); }
  2.679% { transform: rotate(-105deg); }
  3.571% { transform: rotate(-84.444deg); }
  4.464% { transform: rotate(-50.556deg); }
  5.357% { transform: rotate(0deg); }
  6.25% { transform: rotate(50.556deg); }
  6.823% { transform: rotate(74deg); }
  7.063% { transform: rotate(82deg); }
  7.143% { transform: rotate(84.444deg); }
  8.036% { transform: rotate(105deg); }
  8.929% { transform: rotate(115.556deg); }
  9.821% { transform: rotate(119.444deg); }
  10.714% { transform: rotate(120deg); animation-timing-function: cubic-bezier(.37,0,.63,1); }
  100% { transform: rotate(100deg); }
}
@keyframes br-ld-wa {
  0% { transform: rotate(-120deg); }
  8.333% { transform: rotate(-119.444deg); }
  16.667% { transform: rotate(-115.556deg); }
  25% { transform: rotate(-105deg); }
  33.333% { transform: rotate(-84.444deg); }
  41.667% { transform: rotate(-50.556deg); }
  50% { transform: rotate(0deg); }
  100% { transform: rotate(0deg); }
}
@keyframes br-ld-wb {
  0% { transform: rotate(-120deg); }
  8.333% { transform: rotate(-119.444deg); }
  16.667% { transform: rotate(-115.556deg); }
  25% { transform: rotate(-105deg); }
  33.333% { transform: rotate(-84.444deg); }
  41.667% { transform: rotate(-50.556deg); }
  50% { transform: rotate(0deg); }
  58.333% { transform: rotate(50.556deg); }
  63.679% { transform: rotate(74deg); }
  65.92% { transform: rotate(82deg); }
  66.667% { transform: rotate(84.444deg); }
  75% { transform: rotate(105deg); }
  83.333% { transform: rotate(115.556deg); }
  91.667% { transform: rotate(119.444deg); }
  100% { transform: rotate(120deg); }
}
@keyframes br-ld-wr {
  0% { transform: rotate(-120deg); opacity: 0; }
  8.333% { transform: rotate(-119.444deg); opacity: 0; }
  16.667% { transform: rotate(-115.556deg); opacity: 0; }
  25% { transform: rotate(-105deg); opacity: 0; }
  33.333% { transform: rotate(-84.444deg); opacity: 0; }
  41.667% { transform: rotate(-50.556deg); opacity: 0; }
  50% { transform: rotate(0deg); opacity: 1; }
  58.333% { transform: rotate(50.556deg); opacity: 1; }
  63.679% { transform: rotate(74deg); opacity: 1; }
  65.92% { transform: rotate(82deg); opacity: 1; }
  66.667% { transform: rotate(84.444deg); opacity: 1; }
  75% { transform: rotate(105deg); opacity: 1; }
  83.333% { transform: rotate(115.556deg); opacity: 1; }
  91.667% { transform: rotate(119.444deg); opacity: 1; }
  100% { transform: rotate(120deg); opacity: 1; }
}
@keyframes br-ld-cap {
  0% { opacity: 0; }
  99.9% { opacity: 0; }
  100% { opacity: 1; }
}
@keyframes br-ld-swing {
  0% { transform: none; }
  100% { transform: rotate(-6deg); }
}
@keyframes br-lit-t {
  0% { stroke-dashoffset: 100; opacity: 0; }
  0.893% { stroke-dashoffset: 99.714; opacity: 1; }
  1.786% { stroke-dashoffset: 97.709; opacity: 1; }
  2.679% { stroke-dashoffset: 92.268; opacity: 1; }
  3.571% { stroke-dashoffset: 81.672; opacity: 1; }
  4.464% { stroke-dashoffset: 64.204; opacity: 1; }
  5.357% { stroke-dashoffset: 38.144; opacity: 1; }
  6.25% { stroke-dashoffset: 12.085; opacity: 1; }
  6.823% { stroke-dashoffset: 0; opacity: 1; }
  7.063% { stroke-dashoffset: 0; opacity: 1; }
  7.143% { stroke-dashoffset: 0; opacity: 1; }
  8.036% { stroke-dashoffset: 0; opacity: 1; }
  8.929% { stroke-dashoffset: 0; opacity: 1; }
  9.821% { stroke-dashoffset: 0; opacity: 1; }
  10.714% { stroke-dashoffset: 0; opacity: 1; }
  100% { stroke-dashoffset: 0; opacity: 1; }
}
@keyframes br-lit-r {
  0% { stroke-dashoffset: 100; opacity: 0; }
  0.893% { stroke-dashoffset: 100; opacity: 0; }
  1.786% { stroke-dashoffset: 100; opacity: 0; }
  2.679% { stroke-dashoffset: 100; opacity: 0; }
  3.571% { stroke-dashoffset: 100; opacity: 0; }
  4.464% { stroke-dashoffset: 100; opacity: 0; }
  5.357% { stroke-dashoffset: 100; opacity: 0; }
  6.25% { stroke-dashoffset: 100; opacity: 0; }
  6.823% { stroke-dashoffset: 100; opacity: 0; }
  7.063% { stroke-dashoffset: 100; opacity: 0; }
  7.143% { stroke-dashoffset: 93.567; opacity: 1; }
  8.036% { stroke-dashoffset: 39.474; opacity: 1; }
  8.929% { stroke-dashoffset: 11.696; opacity: 1; }
  9.821% { stroke-dashoffset: 1.462; opacity: 1; }
  10.714% { stroke-dashoffset: 0; opacity: 1; }
  100% { stroke-dashoffset: 0; opacity: 1; }
}
/* --- end of generated --- */
