@layer properties, theme, base, components, utilities;

/* /w/connect in a journey browser (bootstrap/surface.js `data-boot-wait`): until the app draws into #app, the words the
   journey's held paper says (door/JourneyDoor.tsx HOLD_WAIT), where it says them. On a 4G link the main bundle takes ~3 s
   before anything of the app paints (prod 11-06), and that stretch read as a dead page. Gone with the app's first render.
   Here rather than in a file of its own: this sheet already blocks the first paint, so it costs no request. */
html[data-boot-wait] #app:empty::after {
  content: "Finding your way in\2026";
  position: fixed;
  top: 42dvh;
  left: 0;
  right: 0;
  text-align: center;
  font: 400 14px/20px system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #6b665f;
  animation: boot-wait-in 400ms 200ms both, boot-wait-pulse 1.4s 600ms ease-in-out infinite alternate;
}
/* The light journey (bootstrap/surface.js: `data-boot-wait="dark"` where the journey last wore dark): until the app paints, the
   paper the wait and the page it opens onto wear (journey.css --journey-paper; door/JourneyDoor.tsx JourneyDoorWait) and the
   words in the held paper's tone (FlowerWait's label on the light palette). Kept over the cold load's empty journey placeholder
   (routes/w.connect.tsx JourneyWait, `data-journey-wait`, empty) until the door's own note paints in the same place, never a
   blank white frame between them (item 11's reviewer, 11-06). Only while #app is empty or holds that placeholder: anything else
   the app paints (an error page, a redirect, another route) takes the words and the paper away. Rules of their own: a browser
   without :has() keeps the rule above. */
html[data-boot-wait]:not([data-boot-wait="dark"]) #app:empty::after { color: #b34700; }
html[data-boot-wait]:not([data-boot-wait="dark"]):has(#app:empty) { background: #f5f3e6; }
html[data-boot-wait]:not([data-boot-wait="dark"]):has(#app [data-journey-wait]:empty) { background: #f5f3e6; }
html[data-boot-wait]:not([data-boot-wait="dark"]) #app [data-journey-wait]:empty { background: #f5f3e6 !important; }
/* and under the journey's paper frames while they mount (the door's chunk swapping in, before the page has set its palette on
   <html>): the body's default ground showed for a frame between two paper ones (item 11's second reviewer, 11-06, a second tab) */
html[data-boot-wait]:not([data-boot-wait="dark"]):has(#app:empty, #app [data-journey-wait]:empty, #app .journey-root[data-oc-paper]) body { background: #f5f3e6; }
/* The dark journey (`data-boot-wait="dark"`: a browser whose door was last marked dark, journey.door.light "0" = petal classic's
   dark ground): the same cases on the ground its first dark frame has. That is the app's dark `data-theme="dessn"` --background
   = --surface-chrome = --gray-800 #262729 (packages/ui-tokens/src/tokens.css; the dark wait, routes/w.connect.tsx JourneyWait,
   paints var(--background), and first-frame/ground.css holds the same #262729 on the shell), and the words in its
   --muted-foreground (--gray-300 #b1b2b6) rather than the light journey's orange. Without them the body's light default showed
   until the app painted (prod 11-10: ~28 s on slow 4G, CPU 4x). */
html[data-boot-wait="dark"] #app:empty::after { color: #b1b2b6; }
html[data-boot-wait="dark"]:has(#app:empty) { background: #262729; }
html[data-boot-wait="dark"]:has(#app [data-journey-wait]:empty) { background: #262729; }
html[data-boot-wait="dark"] #app [data-journey-wait]:empty { background: #262729 !important; }
html[data-boot-wait="dark"]:has(#app:empty, #app [data-journey-wait]:empty, #app .journey-root[data-oc-paper]) body { background: #262729; }
html[data-boot-wait] #app:has([data-journey-wait]:empty)::after {
  content: "Finding your way in\2026";
  position: fixed;
  top: 42dvh;
  left: 0;
  right: 0;
  text-align: center;
  font: 400 14px/20px system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #6b665f;
  animation: boot-wait-pulse 1.4s 600ms ease-in-out infinite alternate;
}
html[data-boot-wait]:not([data-boot-wait="dark"]) #app:has([data-journey-wait]:empty)::after { color: #b34700; }
html[data-boot-wait="dark"] #app:has([data-journey-wait]:empty)::after { color: #b1b2b6; }
/* /login holding a stored session (bootstrap/surface.js `data-boot-login-wait`): until the app draws, the words and ground of the
   wait it draws next (components/auth/SignInWait.tsx) and of /w/connect's after it ("Opening your projects"), never a blank page
   (sign-in walk 11-15, F3). Gone with the app's first drawing: an #app holding only the toaster's empty <section> draws nothing
   yet (car-signin's +10 on prod, 11-16, 4b: the words went with #app:empty while the page stayed blank until the wait), and its
   ground over the palette the app's first styles set on the page (that frame was the light door's beige). One :has() level:
   a nested :has() is invalid and drops the whole rule. */
html[data-boot-login-wait]:not(:has(#app > :not(section))),
html[data-boot-login-wait]:not(:has(#app > :not(section))) body { background: #fcfcfc !important; }
html[data-boot-login-wait]:not(:has(#app > :not(section))) #app::after {
  content: "Opening your projects";
  position: fixed;
  top: 50dvh;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  text-align: center;
  /* where SignInWait's words sit, beside its 20 px flower and 6 px gap, so they don't move when the app draws */
  text-indent: 26px;
  font: 400 14px/20px system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #b34700;
  animation: boot-wait-in 400ms 200ms both, boot-wait-pulse 1.4s 600ms ease-in-out infinite alternate;
}
@keyframes boot-wait-in { from { opacity: 0; } }
@keyframes boot-wait-pulse { to { opacity: 0.55; } }
@media (prefers-reduced-motion: reduce) {
  html[data-boot-wait] #app:empty::after,
  html[data-boot-login-wait]:not(:has(#app > :not(section))) #app::after { animation: none; }
}
