/* shader-ground: the part's ground, alive. This file gives the part its still background, one per preset, made from
   the same tokens the shader mixes: it is what shows before the script runs, without WebGL, and in the skills' own
   Chrome (--disable-gpu). effect.js lays the canvas over it and fades it in.
   Every rule sits in :where(), so any rule of the page wins. */

:where([data-fx~="shader-ground"]) {
  /* knobs */
  --ground-base: var(--fx-ground);                 /* the color the lights lie on: the part's own ground, found by fx.js */
  --ground-c1: var(--c-brand, #2456e6);            /* the first light */
  --ground-c2: var(--c-accent, #e6682a);           /* the second */
  --ground-c3: var(--c-brand-light, #cfd8ff);      /* the third */
  --ground-mix: 0.5;       /* 0 to 1: how much of the lights lies on the ground (times the site's --fx-energy) */
  --ground-speed: 1;       /* times the site's --fx-pace */
  --ground-scale: 1;       /* the size of the pattern: under 1 larger shapes, over 1 smaller */
  --ground-pointer: 0.6;   /* 0 to 1: how much it leans to the mouse; 0 for none */
  --ground-grain: 0.06;    /* 0 to 0.2: the still grain over it; 0 for none */
  --ground-contrast: 4.5;  /* the contrast the part's text keeps on the strongest light; 3 for display type alone */
  --ground-clear: none;    /* left | right | top | bottom: the side where the words are; the far side takes the full mix */
  --ground-levels: 14;     /* contour: how many level lines */
  --ground-line: 1.25;     /* contour: a line's width in px */
  --ground-cell: 14;       /* halftone: the dots' pitch in px */
  /* the mix after the script has checked the text's contrast; until then, the knob */
  --_m: calc(var(--_mix, var(--ground-mix)) * 100%);
  position: relative;
  isolation: isolate;
}
:where([data-fx~="shader-ground"]) > :where(.fx-gl, .fx-ground-grain) { z-index: -1; }
:where(.fx-ground-grain) {
  position: absolute; inset: 0; pointer-events: none; opacity: var(--ground-grain); mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 1'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* The still grounds. */
:where([data-fx~="shader-ground"]:not([data-fx-preset]), [data-fx~="shader-ground"][data-fx-preset="aurora"]) {
  background-image:
    radial-gradient(90% 70% at 18% 6%, color-mix(in srgb, var(--ground-c1) var(--_m), transparent), transparent 70%),
    radial-gradient(70% 60% at 88% 34%, color-mix(in srgb, var(--ground-c2) calc(var(--_m) * 0.7), transparent), transparent 72%),
    radial-gradient(80% 60% at 58% 104%, color-mix(in srgb, var(--ground-c3) calc(var(--_m) * 0.55), transparent), transparent 70%);
}
:where([data-fx~="shader-ground"][data-fx-preset="mesh"]) {
  --ground-mix: 0.6;
  --ground-speed: 0.8;
  background-image:
    radial-gradient(46% 62% at 26% 30%, color-mix(in srgb, var(--ground-c1) var(--_m), transparent), transparent 100%),
    radial-gradient(42% 58% at 76% 66%, color-mix(in srgb, var(--ground-c2) calc(var(--_m) * 0.85), transparent), transparent 100%),
    radial-gradient(40% 50% at 56% 12%, color-mix(in srgb, var(--ground-c3) calc(var(--_m) * 0.8), transparent), transparent 100%);
}
:where([data-fx~="shader-ground"][data-fx-preset="beam"]) {
  --ground-mix: 0.7;
  background-image:
    radial-gradient(34% 40% at 16% -8%, color-mix(in srgb, var(--ground-c2) calc(var(--_m) * 0.6), transparent), transparent 100%),
    conic-gradient(from 118deg at 16% -22%, transparent 0deg, color-mix(in srgb, var(--ground-c1) calc(var(--_m) * 0.75), transparent) 12deg, transparent 26deg, color-mix(in srgb, var(--ground-c3) calc(var(--_m) * 0.4), transparent) 38deg, transparent 50deg, color-mix(in srgb, var(--ground-c1) calc(var(--_m) * 0.5), transparent) 60deg, transparent 74deg),
    radial-gradient(110% 120% at 16% -22%, color-mix(in srgb, var(--ground-c1) calc(var(--_m) * 0.7), transparent), transparent 64%);
}
:where([data-fx~="shader-ground"][data-fx-preset="contour"]) {
  --ground-mix: 0.55;
  --ground-grain: 0;
  background-image:
    repeating-radial-gradient(ellipse 120% 80% at 72% 28%, transparent 0 25px, color-mix(in srgb, var(--ground-c1) calc(var(--_m) * 0.5), transparent) 25px 26.25px),
    radial-gradient(60% 50% at 72% 28%, color-mix(in srgb, var(--ground-c1) calc(var(--_m) * 0.25), transparent), transparent 100%);
}
:where([data-fx~="shader-ground"][data-fx-preset="halftone"]) {
  --ground-mix: 0.85;
  --ground-grain: 0;
  background-image:
    radial-gradient(70% 80% at 12% 80%, var(--ground-base) 30%, transparent 100%),
    radial-gradient(circle, color-mix(in srgb, var(--ground-c1) var(--_m), transparent) 0 30%, transparent 33%);
  background-size: auto, calc(var(--ground-cell) * 1px) calc(var(--ground-cell) * 1px);
}

@media (forced-colors: active) {
  :where([data-fx~="shader-ground"]) { background-image: none; }
  :where([data-fx~="shader-ground"]) > :where(.fx-gl, .fx-ground-grain) { display: none; }
}
