Shaders JS behaviour

Noise field

A section background woven from five octaves of domain-warped fbm — fluid noise you rein in or let loose with the scale and speed sliders. The colour ramp turns the contrast up in dark theme; raw WebGL1, half resolution, parked off screen, a still frame under reduced motion and a static gradient without WebGL.

Documentation

Real scenarios

The component as it is used in a product — not a specimen grid.

A section that breathes

Five octaves of value noise, warped through a second fbm pass so the field folds instead of scrolling — the texture of an engine room without a single image. The sliders rewrite two uniforms live; the ramp swaps for real contrast when the theme goes dark.

Meridian Cloud · engine room

Infrastructure that never sleeps

We route 2.4M requests a second across 38 regions — Dublin to Singapore. This noise is that network’s pulse.

99.99% uptime 38 regions 81ms p95

5 octaves of domain-warped fbm · half resolution · parked off screen · still under reduced motion.

Important props

Important props
Prop Type Default What it does
octaves int 5 Five fbm octaves; each octave halves the amplitude and roughly doubles the frequency.
scale range '0.6 – 3.0' The scale slider; uv is multiplied by it before the fbm sampling — from even mist to fine veins.
speed range '0 – 2' The speed slider; the field’s time drift and domain warp are both multiplied by it.
contrast theme 'dark ramp' The colour ramp is two-ended: in dark theme the base deepens and the crests brighten to keep contrast.
resolution scale '0.5×' The canvas renders at half CSS resolution and upscales — the five-octave fbm stays cheap.

Snippet

<div class="shnf" x-data="{ scale: 1.4, speed: 0.8 }">
<div class="shnf-stage">
<canvas class="shnf-cv" aria-hidden="true"></canvas>
<div class="shnf-copy">
<small>Meridian Cloud · engine room</small>
<h2>Infrastructure that never sleeps</h2>
<p>We route 2.4M requests a second across 38 regions.</p>
</div>
<div class="shnf-panel">
<label>Scale <input type="range" min="0.6" max="3" step="0.1" x-model.number="scale"></label>
<label>Speed <input type="range" min="0" max="2" step="0.1" x-model.number="speed"></label>
</div>
</div>
</div>

<style>
.shnf-stage { position: relative; overflow: clip; border-radius: 1.25rem; min-block-size: 22rem;
              display: grid; align-content: space-between; padding: 1.75rem; background: #eef2ff; }
.shnf-cv { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; }
.shnf-copy, .shnf-panel { position: relative; z-index: 1; }
.shnf-panel { display: flex; flex-wrap: wrap; gap: 1rem 2rem; padding: .9rem 1.1rem; border-radius: 1rem;
              background: #ffffffb3; backdrop-filter: blur(12px); }
</style>
// app/Pages/EngineRoom.jsx — Inertia (React) page; renders the React
// snippet below unchanged, with Inertia's Link wired into the provider.
import { Link } from '@inertiajs/react';
import { NabuXUIProvider } from '@nabuxai/ui-react';
import NoiseSection from '@/components/NoiseSection';

export default function EngineRoom() {
  return (
    <NabuXUIProvider locale="en" linkComponent={Link}>
      <main className="nx-page">
        <NoiseSection />
      </main>
    </NabuXUIProvider>
  );
}
// NoiseSection.jsx — domain-warped fbm as a section background, raw WebGL1
import { useEffect, useRef, useState } from 'react';

const FRAG = `precision mediump float;
uniform vec2 u_res; uniform float u_time; uniform float u_scale; uniform float u_speed;
uniform vec3 u_lo; uniform vec3 u_mid; uniform vec3 u_hi;
float hash(vec2 p) { return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453); }
float noise(vec2 p) {
  vec2 i = floor(p); vec2 f = fract(p);
  vec2 u = f * f * (3.0 - 2.0 * f);
  return mix(mix(hash(i), hash(i + vec2(1.0, 0.0)), u.x),
             mix(hash(i + vec2(0.0, 1.0)), hash(i + vec2(1.0, 1.0)), u.x), u.y);
}
float fbm(vec2 p) {
  float v = 0.0; float a = 0.5;
  for (int k = 0; k < 5; k++) { v += a * noise(p); p = p * 2.02 + vec2(9.4, 3.7); a *= 0.5; }
  return v;
}
void main() {
  vec2 uv = (gl_FragCoord.xy * 2.0 - u_res) / min(u_res.x, u_res.y);
  vec2 drift = vec2(u_time * 0.05, u_time * -0.04) * u_speed * 2.0;
  vec2 q = uv * u_scale + drift;
  float n = fbm(q + fbm(q * 1.7 + u_time * 0.02 * u_speed) * 0.6); // domain warp keeps it fluid
  vec3 col = mix(u_lo, u_mid, smoothstep(0.15, 0.75, n));
  col = mix(col, u_hi, smoothstep(0.72, 0.98, n));
  gl_FragColor = vec4(col, 1.0);
}`;
const RAMPS = {
  light: ['#eef2ff', '#a5b4fc', '#4338ca'],
  dark: ['#020617', '#155e75', '#7dd3fc'], // deeper base, brighter crests — contrast in the dark
};
const rgb = (h) => [1, 3, 5].map((i) => parseInt(h.slice(i, i + 2), 16) / 255);
const isDark = () => {
  const t = document.documentElement.dataset.theme;
  return t === 'dark' || (!t && matchMedia('(prefers-color-scheme: dark)').matches);
};

export default function NoiseSection() {
  const canvasRef = useRef(null);
  const apiRef = useRef(null);
  const live = useRef({ scale: 1.4, speed: 0.8 });
  const [scale, setScale] = useState(1.4);
  const [speed, setSpeed] = useState(0.8);
  const [noGl, setNoGl] = useState(false);

  useEffect(() => {
    live.current = { scale, speed }; apiRef.current?.redraw();
  }, [scale, speed]);

  useEffect(() => {
    const canvas = canvasRef.current;
    const gl = canvas.getContext('webgl', { antialias: false, powerPreference: 'low-power' });
    if (!gl) { setNoGl(true); return; }
    const sh = (type, src) => {
      const s = gl.createShader(type); gl.shaderSource(s, src); gl.compileShader(s); return s;
    };
    const prog = gl.createProgram();
    gl.attachShader(prog, sh(gl.VERTEX_SHADER, 'attribute vec2 a; void main() { gl_Position = vec4(a, 0.0, 1.0); }'));
    gl.attachShader(prog, sh(gl.FRAGMENT_SHADER, FRAG));
    gl.linkProgram(prog); gl.useProgram(prog);
    gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer());
    gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]), gl.STATIC_DRAW);
    const a = gl.getAttribLocation(prog, 'a');
    gl.enableVertexAttribArray(a); gl.vertexAttribPointer(a, 2, gl.FLOAT, false, 0, 0);
    const U = {};
    for (const n of ['u_res', 'u_time', 'u_scale', 'u_speed', 'u_lo', 'u_mid', 'u_hi']) {
      U[n] = gl.getUniformLocation(prog, n);
    }

    const mq = matchMedia('(prefers-reduced-motion: reduce)');
    const s = { raf: 0, visible: true, t0: performance.now(), last: 2 };
    const size = () => { // half resolution keeps the fbm cheap
      canvas.width = Math.max(2, Math.round(canvas.clientWidth * 0.5));
      canvas.height = Math.max(2, Math.round(canvas.clientHeight * 0.5));
    };
    const draw = (t) => {
      gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
      gl.uniform2f(U.u_res, gl.drawingBufferWidth, gl.drawingBufferHeight);
      gl.uniform1f(U.u_time, t);
      gl.uniform1f(U.u_scale, live.current.scale); gl.uniform1f(U.u_speed, live.current.speed);
      const ramp = RAMPS[isDark() ? 'dark' : 'light'];
      gl.uniform3f(U.u_lo, ...rgb(ramp[0])); gl.uniform3f(U.u_mid, ...rgb(ramp[1])); gl.uniform3f(U.u_hi, ...rgb(ramp[2]));
      gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
    };
    const redraw = () => draw(mq.matches ? 6.0 : s.last); // still frame under reduced motion
    const run = () => {
      cancelAnimationFrame(s.raf);
      if (!s.visible) return;            // parked while off screen
      if (mq.matches) { redraw(); return; }
      const loop = (now) => { s.last = (now - s.t0) / 1000; draw(s.last); s.raf = requestAnimationFrame(loop); };
      s.raf = requestAnimationFrame(loop);
    };
    apiRef.current = { redraw };

    const io = new IntersectionObserver(([e]) => { s.visible = e.isIntersecting; run(); });
    io.observe(canvas);
    const ro = new ResizeObserver(() => { size(); redraw(); });
    ro.observe(canvas);
    const mo = new MutationObserver(redraw); // the data-theme flip re-ramps the colours
    mo.observe(document.documentElement, { attributes: true, attributeFilter: ['data-theme'] });
    size(); run();

    return () => { // full cleanup — context included
      cancelAnimationFrame(s.raf); io.disconnect(); ro.disconnect(); mo.disconnect();
      apiRef.current = null;
      gl.getExtension('WEBGL_lose_context')?.loseContext();
    };
  }, []);

  return (
    <>
      <style>{`
        .shnf-stage { position: relative; overflow: clip; border-radius: 1.25rem; min-block-size: 22rem;
                      display: grid; align-content: space-between; padding: 1.75rem; background: #eef2ff; }
        .shnf-cv, .shnf-fallback { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; }
        .shnf-copy, .shnf-panel { position: relative; z-index: 1; }
        .shnf-panel { display: flex; flex-wrap: wrap; gap: 1rem 2rem; padding: .9rem 1.1rem; border-radius: 1rem;
                      background: rgba(255, 255, 255, .7); backdrop-filter: blur(12px); }
        .shnf-panel label { display: grid; gap: .35rem; font: 600 .78rem system-ui; }
      `}</style>
      <div className="shnf-stage">
        {noGl
          ? <div className="shnf-fallback" style={{ background: 'linear-gradient(160deg, #eef2ff, #a5b4fc 55%, #4338ca)' }} />
          : <canvas ref={canvasRef} className="shnf-cv" aria-hidden="true" />}
        <div className="shnf-copy">
          <small>Meridian Cloud · engine room</small>
          <h2>Infrastructure that never sleeps</h2>
          <p>We route 2.4M requests a second across 38 regions — Dublin to Singapore. This noise is that network’s pulse.</p>
        </div>
        <div className="shnf-panel">
          <label>Scale
            <input type="range" min="0.6" max="3" step="0.1" value={scale}
                   onChange={(e) => setScale(+e.target.value)} />
          </label>
          <label>Speed
            <input type="range" min="0" max="2" step="0.1" value={speed}
                   onChange={(e) => setSpeed(+e.target.value)} />
          </label>
        </div>
      </div>
    </>
  );
}
<!-- NoiseSection.vue — domain-warped fbm as a section background, raw WebGL1 -->
<script setup lang="ts">
import { onBeforeUnmount, onMounted, ref } from 'vue';

const FRAG = `precision mediump float;
uniform vec2 u_res; uniform float u_time; uniform float u_scale; uniform float u_speed;
uniform vec3 u_lo; uniform vec3 u_mid; uniform vec3 u_hi;
float hash(vec2 p) { return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453); }
float noise(vec2 p) {
  vec2 i = floor(p); vec2 f = fract(p);
  vec2 u = f * f * (3.0 - 2.0 * f);
  return mix(mix(hash(i), hash(i + vec2(1.0, 0.0)), u.x),
             mix(hash(i + vec2(0.0, 1.0)), hash(i + vec2(1.0, 1.0)), u.x), u.y);
}
float fbm(vec2 p) {
  float v = 0.0; float a = 0.5;
  for (int k = 0; k < 5; k++) { v += a * noise(p); p = p * 2.02 + vec2(9.4, 3.7); a *= 0.5; }
  return v;
}
void main() {
  vec2 uv = (gl_FragCoord.xy * 2.0 - u_res) / min(u_res.x, u_res.y);
  vec2 drift = vec2(u_time * 0.05, u_time * -0.04) * u_speed * 2.0;
  vec2 q = uv * u_scale + drift;
  float n = fbm(q + fbm(q * 1.7 + u_time * 0.02 * u_speed) * 0.6); // domain warp keeps it fluid
  vec3 col = mix(u_lo, u_mid, smoothstep(0.15, 0.75, n));
  col = mix(col, u_hi, smoothstep(0.72, 0.98, n));
  gl_FragColor = vec4(col, 1.0);
}`;
const RAMPS = {
  light: ['#eef2ff', '#a5b4fc', '#4338ca'],
  dark: ['#020617', '#155e75', '#7dd3fc'], // deeper base, brighter crests — contrast in the dark
};
const rgb = (h: string) => [1, 3, 5].map((i) => parseInt(h.slice(i, i + 2), 16) / 255);
const isDark = () => {
  const t = document.documentElement.dataset.theme;
  return t === 'dark' || (!t && matchMedia('(prefers-color-scheme: dark)').matches);
};

const canvas = ref<HTMLCanvasElement | null>(null);
const scale = ref(1.4);
const speed = ref(0.8);
const noGl = ref(false);
let stop: (() => void) | null = null;

onMounted(() => {
  const cv = canvas.value!;
  const gl = cv.getContext('webgl', { antialias: false, powerPreference: 'low-power' });
  if (!gl) { noGl.value = true; return; }
  const sh = (type: number, src: string) => {
    const s = gl.createShader(type)!; gl.shaderSource(s, src); gl.compileShader(s); return s;
  };
  const prog = gl.createProgram()!;
  gl.attachShader(prog, sh(gl.VERTEX_SHADER, 'attribute vec2 a; void main() { gl_Position = vec4(a, 0.0, 1.0); }'));
  gl.attachShader(prog, sh(gl.FRAGMENT_SHADER, FRAG));
  gl.linkProgram(prog); gl.useProgram(prog);
  gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer());
  gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]), gl.STATIC_DRAW);
  const a = gl.getAttribLocation(prog, 'a');
  gl.enableVertexAttribArray(a); gl.vertexAttribPointer(a, 2, gl.FLOAT, false, 0, 0);
  const U: Record<string, WebGLUniformLocation | null> = {};
  for (const n of ['u_res', 'u_time', 'u_scale', 'u_speed', 'u_lo', 'u_mid', 'u_hi']) {
    U[n] = gl.getUniformLocation(prog, n);
  }

  const mq = matchMedia('(prefers-reduced-motion: reduce)');
  let raf = 0, visible = true, last = 2;
  const t0 = performance.now();
  const size = () => { // half resolution keeps the fbm cheap
    cv.width = Math.max(2, Math.round(cv.clientWidth * 0.5));
    cv.height = Math.max(2, Math.round(cv.clientHeight * 0.5));
  };
  const draw = (t: number) => {
    gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
    gl.uniform2f(U.u_res!, gl.drawingBufferWidth, gl.drawingBufferHeight);
    gl.uniform1f(U.u_time!, t);
    gl.uniform1f(U.u_scale!, scale.value); gl.uniform1f(U.u_speed!, speed.value);
    const ramp = RAMPS[isDark() ? 'dark' : 'light'];
    gl.uniform3f(U.u_lo!, ...rgb(ramp[0])); gl.uniform3f(U.u_mid!, ...rgb(ramp[1])); gl.uniform3f(U.u_hi!, ...rgb(ramp[2]));
    gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
  };
  const redraw = () => draw(mq.matches ? 6.0 : last); // still frame under reduced motion
  const run = () => {
    cancelAnimationFrame(raf);
    if (!visible) return;            // parked while off screen
    if (mq.matches) { redraw(); return; }
    const loop = (now: number) => { last = (now - t0) / 1000; draw(last); raf = requestAnimationFrame(loop); };
    raf = requestAnimationFrame(loop);
  };

  const io = new IntersectionObserver(([e]) => { visible = e.isIntersecting; run(); });
  io.observe(cv);
  const ro = new ResizeObserver(() => { size(); redraw(); });
  ro.observe(cv);
  const mo = new MutationObserver(redraw); // the data-theme flip re-ramps the colours
  mo.observe(document.documentElement, { attributes: true, attributeFilter: ['data-theme'] });
  size(); run();

  stop = () => { // full cleanup — context included
    cancelAnimationFrame(raf); io.disconnect(); ro.disconnect(); mo.disconnect();
    gl.getExtension('WEBGL_lose_context')?.loseContext();
  };
});
onBeforeUnmount(() => stop?.());
</script>

<template>
  <div class="shnf-stage">
    <div v-if="noGl" class="shnf-fallback"
         style="background: linear-gradient(160deg, #eef2ff, #a5b4fc 55%, #4338ca)"></div>
    <canvas v-else ref="canvas" class="shnf-cv" aria-hidden="true"></canvas>
    <div class="shnf-copy">
      <small>Meridian Cloud · engine room</small>
      <h2>Infrastructure that never sleeps</h2>
      <p>We route 2.4M requests a second across 38 regions — Dublin to Singapore. This noise is that network’s pulse.</p>
    </div>
    <div class="shnf-panel">
      <label>Scale <input type="range" min="0.6" max="3" step="0.1" v-model.number="scale"></label>
      <label>Speed <input type="range" min="0" max="2" step="0.1" v-model.number="speed"></label>
    </div>
  </div>
</template>

<style scoped>
.shnf-stage { position: relative; overflow: clip; border-radius: 1.25rem; min-block-size: 22rem;
              display: grid; align-content: space-between; padding: 1.75rem; background: #eef2ff; }
.shnf-cv, .shnf-fallback { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; }
.shnf-copy, .shnf-panel { position: relative; z-index: 1; }
.shnf-panel { display: flex; flex-wrap: wrap; gap: 1rem 2rem; padding: .9rem 1.1rem; border-radius: 1rem;
              background: rgba(255, 255, 255, .7); backdrop-filter: blur(12px); }
.shnf-panel label { display: grid; gap: .35rem; font: 600 .78rem system-ui; }
</style>
<!-- NoiseSection.svelte — domain-warped fbm as a section background, raw WebGL1 -->
<script lang="ts">
  import { onMount } from 'svelte';

  const FRAG = `precision mediump float;
  uniform vec2 u_res; uniform float u_time; uniform float u_scale; uniform float u_speed;
  uniform vec3 u_lo; uniform vec3 u_mid; uniform vec3 u_hi;
  float hash(vec2 p) { return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453); }
  float noise(vec2 p) {
    vec2 i = floor(p); vec2 f = fract(p);
    vec2 u = f * f * (3.0 - 2.0 * f);
    return mix(mix(hash(i), hash(i + vec2(1.0, 0.0)), u.x),
               mix(hash(i + vec2(0.0, 1.0)), hash(i + vec2(1.0, 1.0)), u.x), u.y);
  }
  float fbm(vec2 p) {
    float v = 0.0; float a = 0.5;
    for (int k = 0; k < 5; k++) { v += a * noise(p); p = p * 2.02 + vec2(9.4, 3.7); a *= 0.5; }
    return v;
  }
  void main() {
    vec2 uv = (gl_FragCoord.xy * 2.0 - u_res) / min(u_res.x, u_res.y);
    vec2 drift = vec2(u_time * 0.05, u_time * -0.04) * u_speed * 2.0;
    vec2 q = uv * u_scale + drift;
    float n = fbm(q + fbm(q * 1.7 + u_time * 0.02 * u_speed) * 0.6); // domain warp keeps it fluid
    vec3 col = mix(u_lo, u_mid, smoothstep(0.15, 0.75, n));
    col = mix(col, u_hi, smoothstep(0.72, 0.98, n));
    gl_FragColor = vec4(col, 1.0);
  }`;
  const RAMPS = {
    light: ['#eef2ff', '#a5b4fc', '#4338ca'],
    dark: ['#020617', '#155e75', '#7dd3fc'], // deeper base, brighter crests — contrast in the dark
  };
  const rgb = (h: string) => [1, 3, 5].map((i) => parseInt(h.slice(i, i + 2), 16) / 255);
  const isDark = () => {
    const t = document.documentElement.dataset.theme;
    return t === 'dark' || (!t && matchMedia('(prefers-color-scheme: dark)').matches);
  };

  let canvas: HTMLCanvasElement;
  let scale = $state(1.4);
  let speed = $state(0.8);
  let noGl = $state(false);

  onMount(() => {
    const gl = canvas.getContext('webgl', { antialias: false, powerPreference: 'low-power' });
    if (!gl) { noGl = true; return; }
    const sh = (type: number, src: string) => {
      const s = gl.createShader(type)!; gl.shaderSource(s, src); gl.compileShader(s); return s;
    };
    const prog = gl.createProgram()!;
    gl.attachShader(prog, sh(gl.VERTEX_SHADER, 'attribute vec2 a; void main() { gl_Position = vec4(a, 0.0, 1.0); }'));
    gl.attachShader(prog, sh(gl.FRAGMENT_SHADER, FRAG));
    gl.linkProgram(prog); gl.useProgram(prog);
    gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer());
    gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]), gl.STATIC_DRAW);
    const a = gl.getAttribLocation(prog, 'a');
    gl.enableVertexAttribArray(a); gl.vertexAttribPointer(a, 2, gl.FLOAT, false, 0, 0);
    const U: Record<string, WebGLUniformLocation | null> = {};
    for (const n of ['u_res', 'u_time', 'u_scale', 'u_speed', 'u_lo', 'u_mid', 'u_hi']) {
      U[n] = gl.getUniformLocation(prog, n);
    }

    const mq = matchMedia('(prefers-reduced-motion: reduce)');
    let raf = 0, visible = true, last = 2;
    const t0 = performance.now();
    const size = () => { // half resolution keeps the fbm cheap
      canvas.width = Math.max(2, Math.round(canvas.clientWidth * 0.5));
      canvas.height = Math.max(2, Math.round(canvas.clientHeight * 0.5));
    };
    const draw = (t: number) => {
      gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
      gl.uniform2f(U.u_res!, gl.drawingBufferWidth, gl.drawingBufferHeight);
      gl.uniform1f(U.u_time!, t);
      gl.uniform1f(U.u_scale!, scale); gl.uniform1f(U.u_speed!, speed);
      const ramp = RAMPS[isDark() ? 'dark' : 'light'];
      gl.uniform3f(U.u_lo!, ...rgb(ramp[0])); gl.uniform3f(U.u_mid!, ...rgb(ramp[1])); gl.uniform3f(U.u_hi!, ...rgb(ramp[2]));
      gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
    };
    const redraw = () => draw(mq.matches ? 6.0 : last); // still frame under reduced motion
    const run = () => {
      cancelAnimationFrame(raf);
      if (!visible) return;            // parked while off screen
      if (mq.matches) { redraw(); return; }
      const loop = (now: number) => { last = (now - t0) / 1000; draw(last); raf = requestAnimationFrame(loop); };
      raf = requestAnimationFrame(loop);
    };

    const io = new IntersectionObserver(([e]) => { visible = e.isIntersecting; run(); });
    io.observe(canvas);
    const ro = new ResizeObserver(() => { size(); redraw(); });
    ro.observe(canvas);
    const mo = new MutationObserver(redraw); // the data-theme flip re-ramps the colours
    mo.observe(document.documentElement, { attributes: true, attributeFilter: ['data-theme'] });
    size(); run();

    return () => { // full cleanup — context included
      cancelAnimationFrame(raf); io.disconnect(); ro.disconnect(); mo.disconnect();
      gl.getExtension('WEBGL_lose_context')?.loseContext();
    };
  });
</script>

<div class="shnf-stage">
  {#if noGl}
    <div class="shnf-fallback" style="background: linear-gradient(160deg, #eef2ff, #a5b4fc 55%, #4338ca)"></div>
  {:else}
    <canvas bind:this={canvas} class="shnf-cv" aria-hidden="true"></canvas>
  {/if}
  <div class="shnf-copy">
    <small>Meridian Cloud · engine room</small>
    <h2>Infrastructure that never sleeps</h2>
    <p>We route 2.4M requests a second across 38 regions — Dublin to Singapore. This noise is that network’s pulse.</p>
  </div>
  <div class="shnf-panel">
    <label>Scale <input type="range" min="0.6" max="3" step="0.1" value={scale} oninput={(e) => (scale = +e.currentTarget.value)} /></label>
    <label>Speed <input type="range" min="0" max="2" step="0.1" value={speed} oninput={(e) => (speed = +e.currentTarget.value)} /></label>
  </div>
</div>

<style>
.shnf-stage { position: relative; overflow: clip; border-radius: 1.25rem; min-block-size: 22rem;
              display: grid; align-content: space-between; padding: 1.75rem; background: #eef2ff; }
.shnf-cv, .shnf-fallback { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; }
.shnf-copy, .shnf-panel { position: relative; z-index: 1; }
.shnf-panel { display: flex; flex-wrap: wrap; gap: 1rem 2rem; padding: .9rem 1.1rem; border-radius: 1rem;
              background: rgba(255, 255, 255, .7); backdrop-filter: blur(12px); }
.shnf-panel label { display: grid; gap: .35rem; font: 600 .78rem system-ui; }
</style>