Skip to content

Herk Edit Kit by Nate Herk: edit videos, reels, and YouTube Shorts with Codex or Claude Code. 15 skills, transcript-driven cuts, storytelling, 406 motion-graphics cards, and HyperFrames templates.

6.3 KB
Raw Blame
<template id="ambient-bg-template">
  <div
    data-composition-id="ambient-bg"
    data-start="0"
    data-width="1920"
    data-height="1080"
    data-duration="19.5"
  >
    <div class="amb-root">
      <div class="amb-base"></div>

      <div class="amb-grid" id="amb-grid"></div>

      <!-- Center crosshair: subtle callback element. Pulses at 0.4s and again at the
           outro lockup (~17.0s) per MOTION_PHILOSOPHY rule of one callback. -->
      <svg
        class="amb-crosshair"
        id="amb-crosshair"
        viewBox="0 0 60 60"
        xmlns="http://www.w3.org/2000/svg"
      >
        <line x1="30" y1="0" x2="30" y2="22" stroke="#37bdf8" stroke-width="1.5" />
        <line x1="30" y1="38" x2="30" y2="60" stroke="#37bdf8" stroke-width="1.5" />
        <line x1="0" y1="30" x2="22" y2="30" stroke="#37bdf8" stroke-width="1.5" />
        <line x1="38" y1="30" x2="60" y2="30" stroke="#37bdf8" stroke-width="1.5" />
        <circle cx="30" cy="30" r="2.5" fill="#37bdf8" />
      </svg>

      <div class="amb-particles">
        <div class="amb-dot" style="left: 8%; top: 14%;"></div>
        <div class="amb-dot" style="left: 22%; top: 9%;"></div>
        <div class="amb-dot" style="left: 38%; top: 24%;"></div>
        <div class="amb-dot" style="left: 56%; top: 12%;"></div>
        <div class="amb-dot" style="left: 71%; top: 22%;"></div>
        <div class="amb-dot" style="left: 88%; top: 8%;"></div>
        <div class="amb-dot" style="left: 12%; top: 64%;"></div>
        <div class="amb-dot" style="left: 30%; top: 78%;"></div>
        <div class="amb-dot" style="left: 48%; top: 86%;"></div>
        <div class="amb-dot" style="left: 66%; top: 72%;"></div>
        <div class="amb-dot" style="left: 84%; top: 84%;"></div>
        <div class="amb-dot" style="left: 94%; top: 56%;"></div>
      </div>

      <div class="amb-vignette"></div>
    </div>

    <style>
      [data-composition-id="ambient-bg"] {
        position: absolute;
        inset: 0;
        pointer-events: none;
      }
      [data-composition-id="ambient-bg"] .amb-root {
        position: absolute;
        inset: 0;
        overflow: hidden;
        background: #050b13;
      }
      [data-composition-id="ambient-bg"] .amb-base {
        position: absolute;
        inset: 0;
        background:
          radial-gradient(
            ellipse 70% 80% at 50% 50%,
            #0f2033 0%,
            #0a1828 45%,
            #07121c 80%,
            #050b13 100%
          );
      }
      [data-composition-id="ambient-bg"] .amb-grid {
        position: absolute;
        inset: -80px;
        background-image:
          linear-gradient(rgba(55, 189, 248, 0.06) 1px, transparent 1px),
          linear-gradient(90deg, rgba(55, 189, 248, 0.06) 1px, transparent 1px);
        background-size: 96px 96px;
        opacity: 0.6;
        will-change: transform;
        /* Slight perspective tilt — reads as a "control room" floor */
        transform-origin: 50% 100%;
      }
      [data-composition-id="ambient-bg"] .amb-crosshair {
        position: absolute;
        left: 50%;
        top: 50%;
        width: 60px;
        height: 60px;
        margin-left: -30px;
        margin-top: -30px;
        opacity: 0.18;
        will-change: transform, opacity;
      }
      [data-composition-id="ambient-bg"] .amb-particles {
        position: absolute;
        inset: 0;
      }
      [data-composition-id="ambient-bg"] .amb-dot {
        position: absolute;
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: #37bdf8;
        box-shadow: 0 0 14px rgba(55, 189, 248, 0.55);
        opacity: 0.45;
        will-change: transform, opacity;
      }
      [data-composition-id="ambient-bg"] .amb-vignette {
        position: absolute;
        inset: 0;
        background: radial-gradient(
          ellipse 100% 80% at 50% 50%,
          transparent 50%,
          rgba(5, 11, 19, 0.35) 80%,
          rgba(5, 11, 19, 0.85) 100%
        );
      }
    </style>

    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/gsap.min.js"></script>
    <script>
      (function () {
        const tl = gsap.timeline({ paused: true });
        const scope = '[data-composition-id="ambient-bg"] ';
        const TOTAL = 19.5;

        const GRID_CYCLE = 14;
        tl.to(
          scope + "#amb-grid",
          {
            x: -96,
            y: -96,
            duration: GRID_CYCLE,
            ease: "none",
            repeat: Math.max(Math.floor(TOTAL / GRID_CYCLE) - 1, 0),
          },
          0,
        );

        // Crosshair callback: open pulse + outro pulse
        tl.fromTo(
          scope + "#amb-crosshair",
          { scale: 0.6, opacity: 0 },
          { scale: 1, opacity: 0.22, duration: 0.7, ease: "expo.out" },
          0.2,
        );
        tl.to(
          scope + "#amb-crosshair",
          { opacity: 0.1, duration: 1.4, ease: "sine.inOut" },
          1.0,
        );
        // Outro pulse on the lockup
        tl.to(
          scope + "#amb-crosshair",
          { scale: 1.4, opacity: 0.42, duration: 0.6, ease: "expo.out" },
          16.6,
        );
        tl.to(
          scope + "#amb-crosshair",
          { scale: 1.2, opacity: 0.28, duration: 1.2, ease: "sine.inOut" },
          17.4,
        );

        const dots = document.querySelectorAll(scope + ".amb-dot");
        dots.forEach(function (dot, i) {
          const dx = 36 + (i % 3) * 18;
          const dy = 26 + ((i + 1) % 3) * 14;
          const dur = 7 + (i % 4) * 1.4;
          const cycles = Math.max(Math.floor(TOTAL / (dur * 2)), 1);
          tl.to(
            dot,
            {
              x: dx * (i % 2 === 0 ? 1 : -1),
              y: -dy,
              duration: dur,
              ease: "sine.inOut",
              yoyo: true,
              repeat: cycles * 2 - 1,
            },
            0,
          );
          const opDur = dur * 0.55;
          const opCycles = Math.max(Math.floor(TOTAL / (opDur * 2)), 1);
          tl.to(
            dot,
            {
              opacity: 0.78,
              duration: opDur,
              ease: "sine.inOut",
              yoyo: true,
              repeat: opCycles * 2 - 1,
            },
            0,
          );
        });

        tl.set({}, {}, TOTAL);

        window.__timelines = window.__timelines || {};
        window.__timelines["ambient-bg"] = tl;
      })();
    </script>
  </div>
</template>