/* =============================================================================================================
   Site background (Owen, 2026-11-27): one fixed layer behind every page. Dark monotone with green, no gray or white.
   4 large soft radial blobs (2 on phones) drift across each other on transforms only, plus a 3% grain to stop
   banding. Markup: the <div class="site-bg"> in src/layouts/Site.astro. Pause when the tab is hidden: src/scripts/fx.ts.

   CHANGE THE COLOURS HERE, and only here.
   Rule: nothing in the background may end up lighter than #1d2027 (relative luminance 0.0144), so text stays
   readable. The blob strengths below (--bg-*-a) were tuned and measured so the brightest overlap stays under that.
   ============================================================================================================= */
:root {
  --bg-base:    #0B0D11;  /* the canvas everything sits on */
  --bg-shadow:  #07080A;  /* deepest shadow: the vignette at the edges */
  --bg-green:   #0D1A12;  /* dark green blob */
  --bg-depth:   #10261A;  /* green depth blob */
  --bg-lift:    #1A1D23;  /* the "lighter" direction: the site's surface colour, never gray or white */
  --bg-bloom:   183, 243, 74; /* accent bloom: brand lime #b7f34a as r,g,b ... */
  --bg-bloom-a: .06;          /* ... at 6% */
  /* how strong each blob is at its centre (0 to 1): tuned so overlaps stay darker than #1d2027 */
  --bg-green-a: .9;
  --bg-depth-a: .62;
  --bg-lift-a:  .55;
  /* one full drift cycle per blob (desktop); phones run 1.6x slower */
  --bg-speed: 1;
}

/* the page itself shows the canvas; the layer sits behind all content */
html { background: var(--bg-base); }
body { background: transparent; }
.site-bg { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; background: var(--bg-base); contain: strict; }
.site-bg__blob { position: absolute; border-radius: 50%; will-change: transform; animation-timing-function: ease-in-out; animation-iteration-count: infinite; animation-direction: alternate; }
/* each blob is a radial gradient that fades to nothing: soft edges with no filter: blur() (cheap, stays at 60fps) */
.site-bg__blob--green { width: 95vmax; height: 95vmax; left: -30vmax; top: -35vmax;
  background: radial-gradient(closest-side, rgb(13 26 18 / var(--bg-green-a)), rgb(13 26 18 / calc(var(--bg-green-a) * .55)) 45%, transparent 100%);
  animation-name: bg-drift-a; animation-duration: calc(42s * var(--bg-speed)); }
.site-bg__blob--depth { width: 80vmax; height: 80vmax; right: -28vmax; top: 20vh;
  background: radial-gradient(closest-side, rgb(16 38 26 / var(--bg-depth-a)), rgb(16 38 26 / calc(var(--bg-depth-a) * .5)) 45%, transparent 100%);
  animation-name: bg-drift-b; animation-duration: calc(38s * var(--bg-speed)); }
.site-bg__blob--lift { width: 70vmax; height: 70vmax; left: -15vmax; bottom: -40vmax;
  background: radial-gradient(closest-side, rgb(26 29 35 / var(--bg-lift-a)), rgb(26 29 35 / calc(var(--bg-lift-a) * .45)) 45%, transparent 100%);
  animation-name: bg-drift-c; animation-duration: calc(34s * var(--bg-speed)); }
.site-bg__blob--bloom { width: 60vmax; height: 60vmax; right: -8vmax; top: -22vmax;
  background: radial-gradient(closest-side, rgb(var(--bg-bloom) / var(--bg-bloom-a)), rgb(var(--bg-bloom) / calc(var(--bg-bloom-a) * .45)) 40%, transparent 100%);
  animation-name: bg-drift-d; animation-duration: calc(45s * var(--bg-speed)); }
/* deepest shadow round the edges, so the blobs never read as a flat wash */
.site-bg__vignette { position: absolute; inset: 0; background: radial-gradient(120% 90% at 50% 40%, transparent 55%, var(--bg-shadow) 100%); }
/* 3% grain: a tiny SVG noise tile, static (moving grain costs frames and reads as flicker) */
.site-bg__grain { position: absolute; inset: -50%; opacity: .03;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 160px 160px; }

/* continuous, slow drift: transforms only, no colour change, no scale pulsing */
@keyframes bg-drift-a { 0% { transform: translate3d(0, 0, 0); } 50% { transform: translate3d(18vw, 12vh, 0); } 100% { transform: translate3d(32vw, -4vh, 0); } }
@keyframes bg-drift-b { 0% { transform: translate3d(0, 0, 0); } 50% { transform: translate3d(-22vw, 18vh, 0); } 100% { transform: translate3d(-8vw, 34vh, 0); } }
@keyframes bg-drift-c { 0% { transform: translate3d(0, 0, 0); } 50% { transform: translate3d(26vw, -16vh, 0); } 100% { transform: translate3d(48vw, -6vh, 0); } }
@keyframes bg-drift-d { 0% { transform: translate3d(0, 0, 0); } 50% { transform: translate3d(-18vw, 14vh, 0); } 100% { transform: translate3d(-34vw, 4vh, 0); } }

/* sections that used to paint their own solid colour now let the background through */
.marquee, .hero, main > section, footer.closing { background-color: transparent !important; }
/* the "surface" bands keep their lighter feel as a see-through tint of the surface colour */
.ground-surface { background: rgb(26 29 35 / .42) !important; }

/* phones: 2 blobs (green + lime bloom), even slower, for battery */
@media (max-width: 767px) {
  :root { --bg-speed: 1.6; }
  .site-bg__blob--depth, .site-bg__blob--lift { display: none; }
  .site-bg__blob--green { width: 140vmax; height: 140vmax; left: -60vmax; top: -40vmax; }
  .site-bg__blob--bloom { width: 110vmax; height: 110vmax; right: -50vmax; top: -30vmax; }
}
/* tab hidden: stop (fx.ts sets the class) */
.site-bg.is-paused .site-bg__blob { animation-play-state: paused; }
/* reduced motion: the same gradient, standing still */
@media (prefers-reduced-motion: reduce) { .site-bg__blob { animation: none; } }
