kitbash Sign in Connect agent
Components

Night water statement

A full-width canvas of dark swells with flickering orange glints, one small centred serif sentence with an asterisk, and its footnote pinned bottom left.

Part of the style

Night Water Footnote

7 parts that belong together, with their tokens, type and rules.

Preview

Code
<style>
/* Goes after the pack's base.css */
:root {
  --night: #251a1a;
  --mist: #fbf4ee;
  --day: #6e6862;
  --wall: #fffffe;
  --mat: #fffffe;
  --ink: #6f6363;
  --ink-soft: #d2cac4;
  --rule: #fffffe;
  --mist-soft: #a07b75;
  --night-deep: #180000;
  --night-swell: #460703;
  --glint: #a07b75;
  --glint-core: #a7928e;
}
</style>

<section class="nightwater" aria-labelledby="nightwater-statement">
  <canvas class="nightwater__canvas" role="img" aria-label="Dark water at night with small clusters of orange light glinting on the swell"></canvas>
  <a class="nightwater__statement" id="nightwater-statement" href="#">Water keeps no record of itself, so I keep it, an hour at a time, on paper that remembers.<sup class="nightwater__mark">*</sup></a>
  <p class="nightwater__footnote"><sup>*</sup>From the harbour notebook, the winter of the long tides</p>
</section>

<style>
  .nightwater {
    position: relative;
    display: grid;
    place-items: center;
    height: clamp(520px, 56vw, 820px);
    padding: var(--space-l) var(--edge);
    overflow: hidden;
    background: var(--night);
    color: var(--mist);
  }
  .nightwater__canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    color: var(--glint);
  }
  .nightwater__statement {
    position: relative;
    max-width: 36em;
    padding: var(--space-s) 0;
    color: inherit;
    font-size: var(--text-m);
    line-height: var(--leading);
    text-align: center;
    text-decoration: none;
    text-wrap: balance;
    transition: color var(--fade) var(--ease);
  }
  .nightwater__statement:hover,
  .nightwater__statement:focus-visible {
    color: var(--day);
  }
  .nightwater__statement:focus-visible {
    outline: var(--line) solid currentColor;
    outline-offset: 6px;
  }
  .nightwater__mark {
    font-size: 0.6em;
    line-height: 0;
  }
  .nightwater__footnote {
    position: absolute;
    left: var(--edge);
    bottom: var(--edge);
    right: var(--edge);
    margin: 0;
    font-size: var(--text-s);
    line-height: var(--leading);
  }
  .nightwater__footnote sup {
    font-size: 0.7em;
    line-height: 0;
  }

  @media (max-width: 40rem) {
    .nightwater {
      height: clamp(560px, 170vw, 720px);
    }
    .nightwater__statement {
      max-width: 22em;
      font-size: calc(var(--text-m) + 2px);
    }
  }
</style>

<script>
  (() => {
    const still = matchMedia('(prefers-reduced-motion: reduce)');

    // A fixed random field so every load shows the same sea.
    function field(count) {
      let seed = 7;
      const rand = () => ((seed = (seed * 16807) % 2147483647) / 2147483647);
      const glints = [];
      for (let i = 0; i < count; i += 1) {
        glints.push({
          band: Math.floor(rand() * 7),
          x: rand(),
          dy: (rand() - 0.5) * 2 * rand(),
          length: 1 + rand() * 4.5,
          rate: 1.5 + rand() * 4,
          phase: rand() * Math.PI * 2,
        });
      }
      return glints;
    }

    function paint(context, width, height, seconds, colours, glints) {
      const sea = context.createLinearGradient(0, 0, 0, height);
      sea.addColorStop(0, colours.night);
      sea.addColorStop(1, colours.deep);
      context.globalCompositeOperation = 'source-over';
      context.fillStyle = sea;
      context.fillRect(0, 0, width, height);

      // Slow swells: layered sine bands filled downward, lighter crests over darker troughs, drifting sideways.
      for (let i = 0; i < 12; i += 1) {
        const lit = i % 2 === 0;
        const base = ((i + 0.3) / 12) * height;
        const drift = seconds * (lit ? 0.05 : -0.035);
        context.beginPath();
        context.moveTo(0, height);
        for (let x = 0; x <= width + 24; x += 24) {
          const y = base + Math.sin(x / width * (3 + (i % 4)) + drift + i * 1.3) * height * 0.025
            + Math.sin(x / width * 11 - drift * 1.7 + i) * height * 0.006;
          context.lineTo(x, y);
        }
        context.lineTo(width, height);
        context.closePath();
        context.globalAlpha = lit ? 0.16 : 0.22;
        context.fillStyle = lit ? colours.swell : colours.deep;
        context.fill();
      }
      context.globalAlpha = 1;

      // Glints: dashes along seven wavy crest lines; a slow travelling envelope gathers them into clusters.
      context.globalCompositeOperation = 'lighter';
      context.lineCap = 'round';
      const rows = 7;
      for (const g of glints) {
        const row = (g.band + 0.5) / rows;
        const wave = Math.sin(g.x * 5.5 + g.band * 1.7 + seconds * 0.18) * height * 0.035;
        const x = g.x * width;
        const y = row * height + wave + g.dy * height * 0.03;
        const gather = Math.sin(g.x * 9 + g.band * 2.3 - seconds * 0.22) * Math.sin(g.x * 3.1 - g.band + seconds * 0.13);
        const flicker = 0.5 + 0.5 * Math.sin(seconds * g.rate + g.phase);
        const light = Math.max(0, gather - 0.12) * 1.5 * flicker;
        if (light < 0.05) continue;
        const reach = g.length * (0.4 + light * 0.8);
        context.beginPath();
        context.moveTo(x - reach, y);
        context.lineTo(x + reach, y);
        context.strokeStyle = colours.glint;
        context.globalAlpha = Math.min(0.22, light * 0.18);
        context.lineWidth = 3.5 + light * 2.5;
        context.stroke();
        context.globalAlpha = Math.min(1, light * 1.1);
        context.strokeStyle = light > 0.85 ? colours.core : colours.glint;
        context.lineWidth = 0.9 + light * 1.2;
        context.stroke();
      }
      context.globalAlpha = 1;
      context.globalCompositeOperation = 'source-over';
    }

    function run(canvas) {
      const context = canvas.getContext('2d');
      const css = getComputedStyle(canvas);
      const colours = {
        night: css.getPropertyValue('--night').trim(),
        deep: css.getPropertyValue('--night-deep').trim(),
        swell: css.getPropertyValue('--night-swell').trim(),
        glint: css.getPropertyValue('--glint').trim(),
        core: css.getPropertyValue('--glint-core').trim(),
      };
      let glints = field(1200);
      let frame = 0;
      const draw = (now) => paint(context, canvas.clientWidth, canvas.clientHeight, now / 1000 + 40, colours, glints);
      const fit = () => {
        const density = Math.min(2, devicePixelRatio || 1);
        canvas.width = canvas.clientWidth * density;
        canvas.height = canvas.clientHeight * density;
        context.setTransform(density, 0, 0, density, 0, 0);
        glints = field(Math.round(Math.min(2600, Math.max(900, canvas.clientWidth * 1.8))));
        draw(performance.now());
      };
      const tick = (now) => {
        draw(now);
        frame = requestAnimationFrame(tick);
      };
      new ResizeObserver(fit).observe(canvas);
      new IntersectionObserver(([entry]) => {
        cancelAnimationFrame(frame);
        if (entry.isIntersecting && !still.matches) frame = requestAnimationFrame(tick);
      }).observe(canvas);
    }

    document.querySelectorAll('.nightwater__canvas').forEach(run);
  })();
</script>

Similar components

Fog hero with fluid blob

Fog hero with fluid blob

Film reel

Film reel

Concertina hero

Concertina hero

Kraft split hero

Kraft split hero

Stage

Stage

Hero with editor window

Hero with editor window

Blue light hero

Blue light hero

Corner frame hero

Corner frame hero