/* Render-blocking, same-origin (CSP-safe) rules that must apply before the app's global stylesheet
   arrives. Prerendered routes (/, /privacy, /terms, /contact) already contain real content:
   anonymous visitors see it immediately instead of the boot screen, while a likely-signed-in
   visitor (see session-hint.js) keeps the boot screen and never sees the marketing page flash
   before the redirect into the app. boot-splash.ts clears both markers once the app has rendered. */
html[data-prerendered]:not([data-session]) .cofo-boot {
  display: none;
}
html[data-prerendered][data-session] app-root {
  visibility: hidden;
}
/* The prerendered landing page, contact and blog pages are light (`data-light` is set by session-hint.js for `/`, `/contact` and `/blog*`;
   /privacy and /terms are dark and must not be painted light). Without this the canvas and the full-height <body> are
   dark (the app's surface tokens and the shell's color-scheme) until the page's own styles arrive,
   which showed as a dark flash before the first content. Same colour as the page's own
   background, so there is nothing to swap; the global 200 ms colour transition is switched off so
   the light colour is there on the very first frame. */
html[data-prerendered][data-light]:not([data-session]),
html[data-prerendered][data-light]:not([data-session]) body {
  background-color: #f8f9fc;
  color-scheme: light;
  transition: none;
}

/* /login is client rendered and light: session-hint.js marks it before first paint and the login
   screen removes the marker when it is left, so the rest of the app is not painted light. */
html[data-light-page],
html[data-light-page] body {
  background-color: #f8f9fc;
  color-scheme: light;
  transition: none;
}

/* The prerendered page is kept on screen while the app bootstraps (see boot-splash.ts): the
   original <app-root> stays exactly where it is (#cofo-prerender-snapshot, never re-parented or
   re-styled, so the browser's first paint of it remains the LCP) and the app boots into a sibling
   <app-root data-prerender-host> laid over the same box, behind it. Shown at half scale while
   hidden: Chrome records the size of an element when it first paints, so the live hero text,
   which is a new element, does not become a bigger, much later LCP candidate under the snapshot.
   Scaling is paint-only, so the live layout (and its height) is the real one.

   The scale is tiny (2%) rather than half: layout shifts are scored by the area they move, and the
   live app keeps settling (fonts, async content) while it waits behind the snapshot. At 50% those
   invisible shifts counted (mobile CLS 0.017 from the host alone); at 2% they are negligible.
   Parking the host off screen instead was tried and rejected: nothing is recorded at first paint,
   so the live hero becomes a second, later LCP candidate at the swap. */
#cofo-prerender-snapshot {
  pointer-events: none;
  user-select: none;
}
app-root[data-prerender-host] {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: -1;
  pointer-events: none;
  transform: scale(0.02);
  transform-origin: 0 0;
}
