/* site-world.css: the site World backdrop (design SPEC v1 §1, §2, §4, §5). One fixed layer behind the page (z 0,
   content sits at z 1): the ground and CSS stars on ::before, the pre-rendered globe still on ::after (painted first,
   with or without script), and, on capable devices, site-world.js crossfades the live canvas over it. Composition is
   owned here, per variant and breakpoint: --sw-x, --sw-y (globe centre), --sw-r (body radius), --sw-dim, and
   --sw-mask (the landing's column scrim .84 -> .66 -> .26 -> 0 behind a text column, as a mask on the globe layers).
   The live globe reads the ::after box, so the still and the live frame agree to the pixel. The still is opaque on
   black and screened over the ground (light adds, black vanishes); the ground is cut out under the disc. Peach is
   light inside the globe only; no UI colour lives here. Regenerate the stills with tools/site-world-stills.mjs. */
.site-world {
  /* globe (text column left, form right): the planet behind the form, larger than it, partly off-screen.
     Tokens are viewport lengths (vw, vh), so the scrim lines up on the still's box and on the canvas alike. */
  --sw-x: 78vw; --sw-y: 58vh; --sw-r: calc(.575 * min(100vw, 100vh)); --sw-dim: 1;
  --sw-mask: linear-gradient(90deg, #00000029 26vw, #00000057 34vw, #000000bd 41vw, #000 46vw);
  position: fixed; top: 0; left: 0; right: 0; height: 100vh; height: 100lvh; z-index: 0;
  pointer-events: none; overflow: hidden; contain: strict; view-transition-name: site-world;
}
.site-world[data-site-world-place="left"] { --sw-x: 22vw; --sw-mask: linear-gradient(270deg, #00000029 26vw, #00000057 34vw, #000000bd 41vw, #000 46vw); }
.site-world::before, .site-world::after { content: ""; position: absolute; pointer-events: none; }
.site-world::before {
  inset: 0;
  background: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='293' height='293' fill='%23edf2f7'><circle cx='168' cy='80' r='.9' fill-opacity='.35'/><circle cx='40' cy='277' r='.55' fill-opacity='.6'/><circle cx='32' cy='262' r='.6' fill-opacity='.35'/><circle cx='47' cy='225' r='.9' fill-opacity='.35'/><circle cx='126' cy='49' r='.9' fill-opacity='.35'/><circle cx='66' cy='117' r='.55' fill-opacity='.8'/><circle cx='28' cy='116' r='.55' fill-opacity='.45'/><circle cx='151' cy='217' r='.6' fill-opacity='.35'/><circle cx='160' cy='289' r='.6' fill-opacity='.35'/><circle cx='99' cy='193' r='.55' fill-opacity='.35'/></svg>") 0 0 / 293px 293px,
    url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='211' height='211' fill='%23edf2f7'><circle cx='147' cy='18' r='.6' fill-opacity='.8'/><circle cx='177' cy='139' r='.9' fill-opacity='.6'/><circle cx='122' cy='152' r='.9' fill-opacity='.6'/><circle cx='79' cy='66' r='.6' fill-opacity='.45'/><circle cx='23' cy='150' r='.7' fill-opacity='.8'/><circle cx='90' cy='189' r='.9' fill-opacity='.6'/><circle cx='158' cy='21' r='.55' fill-opacity='.8'/></svg>") 61px 97px / 211px 211px,
    radial-gradient(circle at 50% 50%, #05070b 25vh, #08090a 100vh);
  -webkit-mask: radial-gradient(circle at var(--sw-x) var(--sw-y), #0000 calc(var(--sw-r) - 1px), #000 calc(var(--sw-r) + 1px));
  mask: radial-gradient(circle at var(--sw-x) var(--sw-y), #0000 calc(var(--sw-r) - 1px), #000 calc(var(--sw-r) + 1px));
  animation: sw-twinkle 4.6s ease-in-out 1.4s 4 alternate;
}
/* the still: a square 2.5 r wide, the globe's centre in its middle (horizon: the planet's top, 2 r wide) */
.site-world::after {
  left: calc(var(--sw-x) - 1.25 * var(--sw-r)); top: calc(var(--sw-y) - 1.25 * var(--sw-r));
  width: calc(2.5 * var(--sw-r)); height: calc(2.5 * var(--sw-r));
  background: url(/media/world/site-globe-v1-desktop.webp) center / 100% 100% no-repeat;
  background-image: image-set(url(/media/world/site-globe-v1-desktop.avif) type("image/avif"), url(/media/world/site-globe-v1-desktop.webp) type("image/webp"));
  mix-blend-mode: screen; opacity: var(--sw-dim); animation: sw-arrive 1.4s cubic-bezier(.16, 1, .3, 1) both;
}
.site-world > canvas { -webkit-mask: var(--sw-mask); mask: var(--sw-mask); }
.site-world::after { -webkit-mask: var(--sw-mask) calc(1.25 * var(--sw-r) - var(--sw-x)) 0 / 100vw 100% no-repeat; mask: var(--sw-mask) calc(1.25 * var(--sw-r) - var(--sw-x)) 0 / 100vw 100% no-repeat; }
.site-world > canvas { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; opacity: 0; transition: opacity 1s ease; }
.site-world[data-live] > canvas { opacity: 1; }
.site-world[data-live]::after { opacity: 0; transition: opacity 0s 1.1s; }
@keyframes sw-arrive { from { opacity: 0; transform: scale(.92); filter: brightness(.55); } }
@keyframes sw-twinkle { to { opacity: .72; } }

/* single-column layouts and phones: the globe in the top ~40% of the first screen, partly off the top edge; the
   page's main steps down to leave it room, then scrolls over it (the content brings its own glass) */
@media (max-width: 900px) {
  .site-world, .site-world[data-site-world-place] { --sw-x: 50vw; --sw-r: min(46vw, 24vh); --sw-y: calc(40vh - var(--sw-r)); --sw-mask: none; }
  .site-world::after { background-image: url(/media/world/site-globe-v1-phone.webp); background-image: image-set(url(/media/world/site-globe-v1-phone.avif) type("image/avif"), url(/media/world/site-globe-v1-phone.webp) type("image/webp")); }
  .site-world[data-site-world="globe"] ~ main { margin-top: max(0px, calc(40lvh - 112px)); }
}
/* horizon (reading pages): the planet's upper limb low in the viewport (its top at --sw-limb, which a page may set
   on <body> to share it with its own layout), the dawn line across the foot of the screen */
.site-world[data-site-world="horizon"] { --sw-x: 50vw; --sw-r: max(100vw, 130vh); --sw-y: calc(var(--sw-limb, 80vh) + var(--sw-r)); --sw-mask: none; }
.site-world[data-site-world="horizon"]::after {
  left: calc(var(--sw-x) - var(--sw-r)); top: calc(var(--sw-y) - 1.15 * var(--sw-r));
  width: calc(2 * var(--sw-r)); height: calc(.6 * var(--sw-r));
  background-image: url(/media/world/site-horizon-v1.webp);
  background-image: image-set(url(/media/world/site-horizon-v1.avif) type("image/avif"), url(/media/world/site-horizon-v1.webp) type("image/webp"));
}
/* quiet (app shells, internal pages): a small, distant globe in a corner */
.site-world[data-site-world="quiet"] { --sw-x: 88vw; --sw-y: 84vh; --sw-r: min(15vh, 11vw); --sw-dim: .55; --sw-mask: none; }
.site-world[data-site-world="quiet"]::after { background-image: url(/media/world/site-globe-v1-phone.webp); background-image: image-set(url(/media/world/site-globe-v1-phone.avif) type("image/avif"), url(/media/world/site-globe-v1-phone.webp) type("image/webp")); }
/* quiet, still only (internal tools: no module, nothing moves but the arrival): the globe holds the page's free top
   corner and scrolls away with the first screen, so tables, forms and running text never sit on it; the stars gather
   round it and fade out before the text (clean ground beyond). Pages place it with --sw-x, --sw-y and --sw-r. */
.site-world[data-site-world="quiet"][data-site-world-still] { position: absolute; view-transition-name: none; --sw-x: 91vw; --sw-y: 30vh; --sw-r: min(27vh, 17vw); --sw-dim: .8; }
.site-world[data-site-world="quiet"][data-site-world-still]::before {
  animation: none;
  -webkit-mask: radial-gradient(circle at var(--sw-x) var(--sw-y), #0000 calc(var(--sw-r) - 1px), #000 calc(var(--sw-r) + 1px), #000 calc(1.3 * var(--sw-r)), #0000 calc(2.1 * var(--sw-r)));
  mask: radial-gradient(circle at var(--sw-x) var(--sw-y), #0000 calc(var(--sw-r) - 1px), #000 calc(var(--sw-r) + 1px), #000 calc(1.3 * var(--sw-r)), #0000 calc(2.1 * var(--sw-r)));
}
.site-world[data-site-world="quiet"][data-site-world-still]::after { -webkit-mask: radial-gradient(closest-side, #000 90%, #0000); mask: radial-gradient(closest-side, #000 90%, #0000); background-image: image-set(url(/media/world/site-globe-v1-desktop.avif) type("image/avif"), url(/media/world/site-globe-v1-desktop.webp) type("image/webp")); }
@media (max-width: 900px) {
  .site-world[data-site-world="quiet"][data-site-world-still] { --sw-x: 84vw; --sw-y: 150px; --sw-r: 30vw; }
  .site-world[data-site-world="quiet"][data-site-world-still]::after { background-image: image-set(url(/media/world/site-globe-v1-phone.avif) type("image/avif"), url(/media/world/site-globe-v1-phone.webp) type("image/webp")); }
}
.site-world[data-site-world="off"] { display: none; }

/* cross-page continuity: the backdrop dissolves from one page's composition into the next */
@view-transition { navigation: auto; }
::view-transition-group(site-world) { animation-duration: .7s; }
/* In a glide the World's group stacks over the root, covering the page. Where the mount asks (the front door) the
   page's parts get groups of their own, for the glide only: named at rest, each would stop the glass blurring. */
:root:active-view-transition .site-world[data-site-world-lift] ~ * { view-transition-name: match-element; }
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  .site-world::before, .site-world::after { animation: none; }
  .site-world > canvas { display: none; }
}
@media (forced-colors: active), print { .site-world { display: none; } }
