{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "golden-hour",
  "type": "registry:ui",
  "title": "Golden Hour",
  "description": "A painted valley lit for an hour of the day. Every color comes from that hour: the sky, the sun and its glow, the light along each ridge, the road and the stars. Change it and the sun travels there through the hours in between, so noon to night passes golden hour and dusk on the way. It can follow the visitor's own clock, or go down as the page scrolls.",
  "author": "KeyframeUI <https://keyframeui.com>",
  "categories": [
    "background",
    "hero",
    "svg"
  ],
  "docs": "Live preview, examples and props: https://keyframeui.com/components/golden-hour",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "registryDependencies": [
    "utils"
  ],
  "files": [
    {
      "path": "components/ui/golden-hour.tsx",
      "type": "registry:ui",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport {\n  animate,\n  cancelFrame,\n  frame,\n  motionValue,\n  useInView,\n  useReducedMotion,\n  useScroll,\n  useSpring,\n  type AnimationPlaybackControls,\n} from \"motion/react\";\n\nimport { cn } from \"@/lib/utils\";\n\n/**\n * Keep:\n * - Every color, the sun and the layer offsets are written straight to the SVG from motion values,\n *   batched into one `frame.render` per frame, so nothing re-renders while the light moves.\n * - The markup is drawn once from `initial` (read in `useState`) and the paint effect finds each\n *   node by its `data-gh` key; later renders never repaint the colors it keeps current.\n * - Layers move by `transform` only, one per `LAYERS` entry back to front: the pointer drift\n *   through `translate3d` and the first-view rise through `translateY`.\n * - A new `time` travels the short way round the clock (`shortWay`) through every hour between,\n *   so noon to night passes golden hour and dusk.\n * - Reduced motion skips the settling and the pointer drift and jumps to a new time; the scroll\n *   sunset still runs, on raw `scrollYProgress` instead of the spring. Touch never drifts.\n */\nconst TIMING = {\n  /** Each ridge rising into place on first view. */\n  settle: { type: \"spring\", visualDuration: 0.9, bounce: 0 },\n  /** Between ridges as they rise, back to front, in seconds. */\n  stagger: 0.06,\n  /** The light moving on to the hour asked for, on first view: seconds and its curve. */\n  ripen: { duration: 1.5, ease: [0.22, 1, 0.36, 1] },\n  /** The sun moving to a new `time`: `duration`, plus `travelPerHour` per hour of the way. */\n  travel: { type: \"spring\", bounce: 0 },\n  /** The sun's travel before the per-hour part, in seconds (the `duration` prop). */\n  duration: 0.7,\n  /** Added to the sun's travel for every hour of the way, in seconds. */\n  travelPerHour: 0.05,\n  /** Between reads of the visitor's clock, with time=\"auto\", in ms. */\n  clock: 30_000,\n  /** The scroll's sunset trailing the page, as a spring. */\n  scroll: { stiffness: 120, damping: 30, mass: 0.4 },\n  /** The ridges following the pointer, as a spring. */\n  pointer: { stiffness: 70, damping: 18, mass: 1 },\n} as const;\n\n/* ─────────────────────────────────────────────────────────\n * GOLDEN HOUR STORYBOARD\n *\n *  rest     a painted valley under a grainy sky: ridge after ridge\n *           going hazy toward the horizon, a road winding up from the\n *           bottom edge and over the near hill, trees on the slopes\n *           in front. Every color comes from one number, the hour:\n *           the sky, the sun and its glow, the light along each\n *           crest, the road, the stars\n *  view     the first time it shows, the land settles: each ridge\n *           rises a few percent into place, back to front, 60ms\n *           apart, on a 0.9s spring with no bounce, while the light\n *           moves on half an hour to the time asked for (1.5s,\n *           easing out)\n *  time     a new `time` carries the sun along its arc through every\n *           hour in between, the short way round the clock, on a\n *           spring of 0.7s plus 0.05s an hour: noon to night passes\n *           golden hour and dusk on the way. Below the far ridge the hills hide the sun, and\n *           its glow lingers on the horizon after it sets\n *  auto     `time=\"auto\"` follows the visitor's clock, checked every\n *           30s\n *  scroll   with `sunset`, the hour moves on as the page scrolls,\n *           from wherever the scene sat at load until it leaves the\n *           top (2 hours by default), through the house scroll\n *           spring: gold to violet to night, the stars prick in and\n *           the road's lights come on. Scrolling back raises it\n *  hover    the ridges drift against the pointer, nearer ones more:\n *           18px at the front, 2px at the far ridge, on a 70/18\n *           spring. Mouse only; touch leaves them still\n *  reduced  no settling and no drift. A new time lands at once; the\n *           scroll still moves the sun, without the smoothing\n * ───────────────────────────────────────────────────────── */\n\nconst GOLDEN = {\n  lead: 0.5, // hours the light starts behind the hour asked for, on first view\n  sunset: 2, // hours the sun moves on while the scene scrolls away, when `sunset` is true\n  shift: 18, // px the front ridge drifts sideways with the pointer at the scene's edge\n  lift: 5, // px it drifts up or down\n} as const;\n\n// Back to front. `depth` scales the pointer drift; `rise` is how far the layer\n// starts below its place on first view, as a share of its height.\nconst LAYERS = [\n  { depth: 0, rise: 0 }, // sky, sun, moon and stars\n  { depth: 0.1, rise: 0.012 }, // the far ridge\n  { depth: 0.22, rise: 0.024 }, // the hills\n  { depth: 0.42, rise: 0.04 }, // the middle ridge, its trees and the mist behind it\n  { depth: 0.68, rise: 0.06 }, // the meadow, the near hill and the road\n  { depth: 1, rise: 0.085 }, // the slopes in front and their trees\n] as const;\n\nexport type GoldenHourPreset = \"dawn\" | \"morning\" | \"noon\" | \"afternoon\" | \"golden\" | \"sunset\" | \"dusk\" | \"night\";\n\nconst PRESETS: Record<GoldenHourPreset, number> = {\n  dawn: 6.1,\n  morning: 9.5,\n  noon: 12.5,\n  afternoon: 15.5,\n  golden: 17.6,\n  sunset: 18.6,\n  dusk: 19.4,\n  night: 22,\n};\n\n// The world: 1000 units tall, centered on x = 0 and drawn as wide as any\n// sensible box needs. The huge viewBox with \"slice\" always fits the height, so\n// the horizon sits at the same share of every box, wide or tall, with no\n// measuring, and the server's render is already the right picture.\nconst WORLD = { left: -2200, right: 2200, floor: 1012, step: 55 };\nconst VIEWBOX = \"-50000 0 100000 1000\";\nconst SUN = { rise: 6.55, set: 18.85, span: 240, height: 470, radius: 40, halo: 760, reach: 1100 }; // reach: how far the light along the crests spreads from under the sun\nconst ROAD = { end: 170, near: 380, far: 6 }; // x where it tops the near hill; width at the bottom edge and at the top\n\n/* ── The light ──────────────────────────────────────────── */\n\n// One palette per key hour. Crest → foot for each ridge, back to front.\ntype Light = {\n  sky: [string, string, string, string, string]; // zenith → horizon\n  sun: string;\n  glow: string;\n  halo: number; // the glow's strength, 0–1\n  ridges: [[string, string], [string, string], [string, string], [string, string], [string, string]]; // far, hills, middle, near, front\n  rim: string; // light along the crests, brightest under the sun\n  rimAlpha: number;\n  mist: string; // haze settled between the ridges\n  mistAlpha: number;\n  road: [string, string]; // near, far\n  sheen: string; // light on the road surface\n  sheenAlpha: number;\n  lamps: string; // the road's center line, which lights up at night\n  lampsAlpha: number;\n  trees: string;\n  stars: number; // 0–1\n};\n\nconst NIGHT: Light = {\n  sky: [\"#050817\", \"#0a1029\", \"#111739\", \"#1a1f4a\", \"#262a5c\"],\n  sun: \"#ffffff\",\n  glow: \"#3c4488\",\n  halo: 0.22,\n  ridges: [\n    [\"#1c1e48\", \"#17193e\"],\n    [\"#15173a\", \"#111331\"],\n    [\"#0f122e\", \"#0b0e25\"],\n    [\"#0e1526\", \"#0a101c\"],\n    [\"#070b15\", \"#04070e\"],\n  ],\n  rim: \"#7480d0\",\n  rimAlpha: 0.14,\n  mist: \"#2a2e6a\",\n  mistAlpha: 0.22,\n  road: [\"#141a2c\", \"#1b2038\"],\n  sheen: \"#ffb35c\",\n  sheenAlpha: 0.12,\n  lamps: \"#ffcf7a\",\n  lampsAlpha: 0.95,\n  trees: \"#02040a\",\n  stars: 1,\n};\n\nconst DAWN: Light = {\n  sky: [\"#1a2762\", \"#36397c\", \"#6e5596\", \"#c47c9c\", \"#f2ae8e\"],\n  sun: \"#ffd9b8\",\n  glow: \"#ffad86\",\n  halo: 0.5,\n  ridges: [\n    [\"#7a70ab\", \"#675f9b\"],\n    [\"#53528e\", \"#46457e\"],\n    [\"#303b67\", \"#283158\"],\n    [\"#2f4c44\", \"#223a35\"],\n    [\"#142520\", \"#0d1916\"],\n  ],\n  rim: \"#ffc9a8\",\n  rimAlpha: 0.35,\n  mist: \"#e6a0b4\",\n  mistAlpha: 0.38,\n  road: [\"#6e6078\", \"#8c7088\"],\n  sheen: \"#ffc8a0\",\n  sheenAlpha: 0.3,\n  lamps: \"#ffe0c0\",\n  lampsAlpha: 0.45,\n  trees: \"#09140f\",\n  stars: 0.35,\n};\n\nconst SUNRISE: Light = {\n  sky: [\"#3557a8\", \"#5f74c0\", \"#a090c8\", \"#efaaa0\", \"#ffd3a0\"],\n  sun: \"#fff3dc\",\n  glow: \"#ffcf98\",\n  halo: 0.72,\n  ridges: [\n    [\"#9590c6\", \"#827fb6\"],\n    [\"#6d76aa\", \"#5e689a\"],\n    [\"#3e5872\", \"#344b64\"],\n    [\"#4e7c48\", \"#365e38\"],\n    [\"#1f3b26\", \"#14291b\"],\n  ],\n  rim: \"#ffdcaa\",\n  rimAlpha: 0.6,\n  mist: \"#f4c4b4\",\n  mistAlpha: 0.4,\n  road: [\"#dcab88\", \"#cc9c90\"],\n  sheen: \"#ffe8c4\",\n  sheenAlpha: 0.42,\n  lamps: \"#fff4e0\",\n  lampsAlpha: 0.35,\n  trees: \"#0f1f15\",\n  stars: 0,\n};\n\nconst MORNING: Light = {\n  sky: [\"#3f78cf\", \"#5d93df\", \"#86b3ea\", \"#bcd8f2\", \"#eef0e4\"],\n  sun: \"#fffdf3\",\n  glow: \"#fff4d6\",\n  halo: 0.42,\n  ridges: [\n    [\"#a3b9d6\", \"#93abca\"],\n    [\"#82a1bf\", \"#7192b2\"],\n    [\"#4e8077\", \"#406e67\"],\n    [\"#5d9449\", \"#457a3a\"],\n    [\"#295b31\", \"#1b4224\"],\n  ],\n  rim: \"#fff6d2\",\n  rimAlpha: 0.35,\n  mist: \"#eaf2f6\",\n  mistAlpha: 0.36,\n  road: [\"#d8d0c0\", \"#c8c3b8\"],\n  sheen: \"#ffffff\",\n  sheenAlpha: 0.22,\n  lamps: \"#ffffff\",\n  lampsAlpha: 0.55,\n  trees: \"#163a20\",\n  stars: 0,\n};\n\nconst NOON: Light = {\n  sky: [\"#2f6fd4\", \"#4f8ee6\", \"#78aef0\", \"#aacff5\", \"#e2eff8\"],\n  sun: \"#ffffff\",\n  glow: \"#ffffff\",\n  halo: 0.32,\n  ridges: [\n    [\"#a7bfda\", \"#97b2d0\"],\n    [\"#86a8c6\", \"#789aba\"],\n    [\"#558b7b\", \"#477b6c\"],\n    [\"#66a24d\", \"#4d873f\"],\n    [\"#2f6835\", \"#204c27\"],\n  ],\n  rim: \"#ffffff\",\n  rimAlpha: 0.26,\n  mist: \"#eef6fa\",\n  mistAlpha: 0.3,\n  road: [\"#ddd7c9\", \"#cfcac1\"],\n  sheen: \"#ffffff\",\n  sheenAlpha: 0.26,\n  lamps: \"#ffffff\",\n  lampsAlpha: 0.65,\n  trees: \"#1a4224\",\n  stars: 0,\n};\n\nconst AFTERNOON: Light = {\n  sky: [\"#3b6ccb\", \"#5c88d8\", \"#8fa8de\", \"#c9c6e0\", \"#f5dcbc\"],\n  sun: \"#fff6e0\",\n  glow: \"#ffe2ad\",\n  halo: 0.55,\n  ridges: [\n    [\"#a59ec8\", \"#9690bc\"],\n    [\"#8389b8\", \"#747aaa\"],\n    [\"#4c6b7c\", \"#405d6d\"],\n    [\"#609545\", \"#487a38\"],\n    [\"#2b5b2f\", \"#1d4223\"],\n  ],\n  rim: \"#ffe6b2\",\n  rimAlpha: 0.52,\n  mist: \"#f4dccc\",\n  mistAlpha: 0.35,\n  road: [\"#e6c9a0\", \"#d9b997\"],\n  sheen: \"#fff0d0\",\n  sheenAlpha: 0.36,\n  lamps: \"#ffffff\",\n  lampsAlpha: 0.5,\n  trees: \"#173a1f\",\n  stars: 0,\n};\n\nconst GOLDEN_LIGHT: Light = {\n  sky: [\"#2b46bc\", \"#5952d3\", \"#ad4c9f\", \"#e85868\", \"#f68a48\"],\n  sun: \"#fff3d1\",\n  glow: \"#ffb257\",\n  halo: 0.9,\n  ridges: [\n    [\"#9a5cae\", \"#7d4ea3\"],\n    [\"#5d47a3\", \"#4a3b8f\"],\n    [\"#3d3a7c\", \"#2e2d66\"],\n    [\"#5d8f3f\", \"#2f5a2f\"],\n    [\"#1f4325\", \"#11281a\"],\n  ],\n  rim: \"#ffd27a\",\n  rimAlpha: 0.85,\n  mist: \"#f0907a\",\n  mistAlpha: 0.32,\n  road: [\"#ffb048\", \"#ff7f4a\"],\n  sheen: \"#ffe5a8\",\n  sheenAlpha: 0.55,\n  lamps: \"#fff2cc\",\n  lampsAlpha: 0.3,\n  trees: \"#0e2014\",\n  stars: 0,\n};\n\nconst SUNSET: Light = {\n  sky: [\"#212a85\", \"#4a3a9c\", \"#94408c\", \"#de4a62\", \"#ff7a3c\"],\n  sun: \"#ffcf8f\",\n  glow: \"#ff6e3a\",\n  halo: 0.95,\n  ridges: [\n    [\"#7a4596\", \"#633c88\"],\n    [\"#46357f\", \"#392d70\"],\n    [\"#2c2a60\", \"#232250\"],\n    [\"#3c5c35\", \"#223d27\"],\n    [\"#16291b\", \"#0c1a11\"],\n  ],\n  rim: \"#ff9c5a\",\n  rimAlpha: 0.6,\n  mist: \"#e0607a\",\n  mistAlpha: 0.3,\n  road: [\"#ff9445\", \"#f0683c\"],\n  sheen: \"#ffc98a\",\n  sheenAlpha: 0.5,\n  lamps: \"#ffd9a0\",\n  lampsAlpha: 0.55,\n  trees: \"#0a160e\",\n  stars: 0.06,\n};\n\nconst DUSK: Light = {\n  sky: [\"#10173f\", \"#221f5c\", \"#4a2f72\", \"#8f4a78\", \"#d0706a\"],\n  sun: \"#ff9a6a\",\n  glow: \"#e86a52\",\n  halo: 0.45,\n  ridges: [\n    [\"#3c3069\", \"#31295b\"],\n    [\"#2c2758\", \"#231f4a\"],\n    [\"#1b1d40\", \"#151834\"],\n    [\"#1b2a2c\", \"#121d20\"],\n    [\"#0d1714\", \"#08100d\"],\n  ],\n  rim: \"#d48aa0\",\n  rimAlpha: 0.18,\n  mist: \"#8a4a7a\",\n  mistAlpha: 0.26,\n  road: [\"#2c2c44\", \"#3a3553\"],\n  sheen: \"#ff9e52\",\n  sheenAlpha: 0.28,\n  lamps: \"#ffc46b\",\n  lampsAlpha: 0.9,\n  trees: \"#050b09\",\n  stars: 0.6,\n};\n\n// Key hours around the clock. Between two keys the light eases from one to the\n// other, mixed in OKLab so no hour goes muddy on the way.\nconst KEYS: [number, Light][] = [\n  [0, NIGHT],\n  [4.8, NIGHT],\n  [6, DAWN],\n  [7, SUNRISE],\n  [9.5, MORNING],\n  [12.5, NOON],\n  [15.5, AFTERNOON],\n  [17.6, GOLDEN_LIGHT],\n  [18.6, SUNSET],\n  [19.4, DUSK],\n  [21.2, NIGHT],\n  [24, NIGHT],\n];\n\n/* ── Color ──────────────────────────────────────────────── */\n\ntype Lab = [number, number, number];\n\nfunction toLab(hex: string): Lab {\n  const n = parseInt(hex.slice(1), 16);\n  const lin = (c: number) => {\n    const v = c / 255;\n    return v <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4;\n  };\n  const r = lin((n >> 16) & 255);\n  const g = lin((n >> 8) & 255);\n  const b = lin(n & 255);\n  const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);\n  const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);\n  const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);\n  return [\n    0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s,\n    1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s,\n    0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s,\n  ];\n}\n\nfunction toRgb([L, a, b]: Lab) {\n  const l = (L + 0.3963377774 * a + 0.2158037573 * b) ** 3;\n  const m = (L - 0.1055613458 * a - 0.0638541728 * b) ** 3;\n  const s = (L - 0.0894841775 * a - 1.291485548 * b) ** 3;\n  const encode = (c: number) => {\n    const v = c <= 0.0031308 ? 12.92 * Math.max(0, c) : 1.055 * c ** (1 / 2.4) - 0.055;\n    return Math.round(Math.min(1, Math.max(0, v)) * 255);\n  };\n  return `rgb(${encode(4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s)}, ${encode(\n    -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,\n  )}, ${encode(-0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s)})`;\n}\n\nconst mixLab = (a: Lab, b: Lab, t: number): Lab => [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t, a[2] + (b[2] - a[2]) * t];\n\n// Each key flattened once: every color in a fixed order, then every number. The\n// meadow between the middle ridge and the near hill takes its colors from both.\nconst flatten = (light: Light) => {\n  const ridges = light.ridges.map(([crest, foot]) => [toLab(crest), toLab(foot)]);\n  const meadow = [mixLab(ridges[2][0], ridges[3][0], 0.62), mixLab(ridges[2][1], ridges[3][1], 0.55)];\n  return {\n    colors: [\n      ...light.sky.map(toLab),\n      toLab(light.sun),\n      toLab(light.glow),\n      ...ridges.slice(0, 3).flat(),\n      ...meadow,\n      ...ridges.slice(3).flat(),\n      ...[light.rim, light.mist, ...light.road, light.sheen, light.lamps, light.trees].map(toLab),\n    ],\n    numbers: [light.halo, light.rimAlpha, light.mistAlpha, light.sheenAlpha, light.lampsAlpha, light.stars],\n  };\n};\nconst FLAT_KEYS = KEYS.map(([hour, light]) => [hour, flatten(light)] as const);\n\ntype Lit = {\n  sky: string[];\n  sun: string;\n  glow: string;\n  ridges: [string, string][];\n  rim: string;\n  mist: string;\n  road: string[];\n  sheen: string;\n  lamps: string;\n  trees: string;\n  halo: number;\n  rimAlpha: number;\n  mistAlpha: number;\n  sheenAlpha: number;\n  lampsAlpha: number;\n  stars: number;\n};\n\nfunction lightAt(hour: number): Lit {\n  const h = mod(hour, 24);\n  let i = 0;\n  while (i < FLAT_KEYS.length - 2 && FLAT_KEYS[i + 1][0] <= h) i++;\n  const [h0, a] = FLAT_KEYS[i];\n  const [h1, b] = FLAT_KEYS[i + 1];\n  const t = smoothstep(0, 1, (h - h0) / (h1 - h0));\n  const c = a.colors.map((from, k) => toRgb(mixLab(from, b.colors[k], t)));\n  const n = a.numbers.map((from, k) => from + (b.numbers[k] - from) * t);\n  return {\n    sky: c.slice(0, 5),\n    sun: c[5],\n    glow: c[6],\n    ridges: [0, 1, 2, 3, 4, 5].map((r) => [c[7 + r * 2], c[8 + r * 2]] as [string, string]),\n    rim: c[19],\n    mist: c[20],\n    road: [c[21], c[22]],\n    sheen: c[23],\n    lamps: c[24],\n    trees: c[25],\n    halo: n[0],\n    rimAlpha: n[1],\n    mistAlpha: n[2],\n    sheenAlpha: n[3],\n    lampsAlpha: n[4],\n    stars: n[5],\n  };\n}\n\n// Where the sun is at an hour: along an arc from the left of the valley to the\n// right, under the far ridge outside daylight.\nfunction sunAt(hour: number, horizon: number) {\n  const t = (mod(hour, 24) - SUN.rise) / (SUN.set - SUN.rise);\n  const x = -SUN.span + 2 * SUN.span * clamp(t, -0.06, 1.06);\n  // The arc tops out a little under the top edge, however high the horizon sits.\n  const y = horizon + 36 - Math.sin(Math.PI * clamp(t, 0, 1)) * Math.min(SUN.height, horizon - 60);\n  return { x, y, up: t > -0.03 && t < 1.03 };\n}\n\n/* ── Helpers ────────────────────────────────────────────── */\n\nconst clamp = (v: number, lo: number, hi: number) => Math.min(hi, Math.max(lo, v));\nconst mod = (v: number, m: number) => ((v % m) + m) % m;\nconst round = (v: number) => Math.round(v);\nfunction smoothstep(edge0: number, edge1: number, v: number) {\n  const t = clamp((v - edge0) / (edge1 - edge0), 0, 1);\n  return t * t * (3 - 2 * t);\n}\n\nfunction mulberry32(seed: number) {\n  let a = seed >>> 0;\n  return () => {\n    a = (a + 0x6d2b79f5) >>> 0;\n    let t = a;\n    t = Math.imul(t ^ (t >>> 15), t | 1);\n    t ^= t + Math.imul(t ^ (t >>> 7), t | 61);\n    return ((t ^ (t >>> 14)) >>> 0) / 4294967296;\n  };\n}\n\n// A ridge line: three sines of falling size, each with its own phase.\nfunction wave(rand: () => number, base: number, amp: number, lengths: [number, number, number]) {\n  const phases = lengths.map(() => rand() * Math.PI * 2);\n  const weights = [0.6, 0.28, 0.12];\n  return (x: number) => base - amp * lengths.reduce((sum, length, i) => sum + weights[i] * Math.sin(x / length + phases[i]), 0);\n}\n\n// A smooth line through f across the world (quadratic curves through the\n// midpoints), closed down to the floor so it can be filled.\nfunction ridgePath(f: (x: number) => number) {\n  const xs: number[] = [];\n  for (let x = WORLD.left; x <= WORLD.right; x += WORLD.step) xs.push(x);\n  const ys = xs.map(f);\n  let d = `M${xs[0]} ${round(ys[0])}`;\n  for (let i = 1; i < xs.length - 1; i++) {\n    d += `Q${xs[i]} ${round(ys[i])} ${round((xs[i] + xs[i + 1]) / 2)} ${round((ys[i] + ys[i + 1]) / 2)}`;\n  }\n  const last = xs.length - 1;\n  return `${d}L${xs[last]} ${round(ys[last])}L${xs[last]} ${WORLD.floor}L${xs[0]} ${WORLD.floor}Z`;\n}\n\nfunction ellipse(cx: number, cy: number, rx: number, ry: number) {\n  const x = round(cx - rx);\n  const w = round(rx * 2);\n  return `M${x} ${round(cy)}a${round(rx)} ${round(ry)} 0 1 0 ${w} 0a${round(rx)} ${round(ry)} 0 1 0 ${-w} 0`;\n}\n\n// Trees standing along a line, in clumps: tall cypresses and round crowns.\nfunction forest(\n  rand: () => number,\n  ground: (x: number) => number,\n  spans: [number, number][],\n  size: [number, number],\n  gap: [number, number],\n  sparse: number, // -1 (everywhere) to 1 (almost nowhere)\n  cypress: number, // share of tall cypresses among round crowns\n) {\n  const clumps = wave(rand, 0, 1, [230, 97, 41]);\n  let d = \"\";\n  for (const [from, to] of spans) {\n    for (let x = from; x < to; x += gap[0] + rand() * (gap[1] - gap[0])) {\n      if (clumps(x) < sparse) continue;\n      const h = size[0] + rand() * (size[1] - size[0]);\n      const base = ground(x) + h * 0.06;\n      d +=\n        rand() < cypress\n          ? ellipse(x, base - h * 0.5, h * 0.16, h * 0.5)\n          : ellipse(x, base - h * 0.42, h * 0.3, h * 0.36) + `M${round(x - h * 0.03)} ${round(base - h * 0.1)}h${Math.max(2, round(h * 0.06))}V${round(base)}h${-Math.max(2, round(h * 0.06))}Z`;\n    }\n  }\n  return d;\n}\n\n// Points along a cubic Bézier and its direction.\nfunction bezier(p: [number, number][], t: number) {\n  const u = 1 - t;\n  const x = u * u * u * p[0][0] + 3 * u * u * t * p[1][0] + 3 * u * t * t * p[2][0] + t * t * t * p[3][0];\n  const y = u * u * u * p[0][1] + 3 * u * u * t * p[1][1] + 3 * u * t * t * p[2][1] + t * t * t * p[3][1];\n  const dx = 3 * u * u * (p[1][0] - p[0][0]) + 6 * u * t * (p[2][0] - p[1][0]) + 3 * t * t * (p[3][0] - p[2][0]);\n  const dy = 3 * u * u * (p[1][1] - p[0][1]) + 6 * u * t * (p[2][1] - p[1][1]) + 3 * t * t * (p[3][1] - p[2][1]);\n  const len = Math.hypot(dx, dy) || 1;\n  return { x, y, nx: -dy / len, ny: dx / len };\n}\n\n// A strip along the road's center line, `share` of the road's width, from t0 to t1.\nfunction strip(curve: [number, number][], width: (t: number) => number, share: number, t0: number, t1: number, steps: number) {\n  const left: string[] = [];\n  const right: string[] = [];\n  for (let i = 0; i <= steps; i++) {\n    const t = t0 + ((t1 - t0) * i) / steps;\n    const p = bezier(curve, t);\n    const w = (width(t) * share) / 2;\n    left.push(`${round(p.x + p.nx * w)} ${round(p.y + p.ny * w)}`);\n    right.push(`${round(p.x - p.nx * w)} ${round(p.y - p.ny * w)}`);\n  }\n  return `M${left.join(\"L\")}L${right.reverse().join(\"L\")}Z`;\n}\n\n/* ── The scene's shapes ─────────────────────────────────── */\n\nfunction buildScene(seed: number, horizon: number) {\n  const rand = mulberry32(seed * 7919 + 17);\n  const far = wave(rand, horizon + 2, 30, [300, 140, 70]);\n  const hills = wave(rand, horizon + 40, 40, [400, 180, 90]);\n  const mid = wave(rand, horizon + 92, 50, [520, 230, 110]);\n  const meadow = wave(rand, horizon + 150, 58, [860, 300, 130]);\n  const near = wave(rand, horizon + 214, 66, [980, 340, 150]);\n  const bump = wave(rand, 0, 18, [260, 120, 60]);\n  // The slopes in front rise toward both sides and leave the middle open for the road.\n  const front = (x: number) => {\n    const side = smoothstep(220, 1250, Math.abs(x));\n    return WORLD.floor + 40 - 330 * side + bump(x) * smoothstep(200, 600, Math.abs(x));\n  };\n\n  const ridges = [\n    { d: ridgePath(far), top: horizon - 30 },\n    { d: ridgePath(hills), top: horizon },\n    { d: ridgePath(mid), top: horizon + 42 },\n    { d: ridgePath(meadow), top: horizon + 104 },\n    { d: ridgePath(near), top: horizon + 160 },\n    { d: ridgePath(front), top: WORLD.floor - 300 },\n  ];\n\n  // The road: wide at the bottom edge, winding up and over the near hill.\n  const end = near(ROAD.end) + 5;\n  // Near the viewer it runs almost straight, so the wide end never folds over\n  // itself; the bends tighten as it recedes.\n  const curve: [number, number][] = [\n    [-40, 1110],\n    [80, 950],\n    [-250, end + 70],\n    [ROAD.end, end],\n  ];\n  const width = (t: number) => ROAD.far + (ROAD.near - ROAD.far) * (1 - t) ** 1.5;\n  const road = {\n    body: strip(curve, width, 1, 0, 1, 64),\n    sheen: strip(curve, width, 0.4, 0, 0.985, 64),\n    // Dashes down the middle, closer together as the road recedes.\n    lamps: Array.from({ length: 20 }, (_, k) => {\n      const t0 = 1 - (1 - k / 20) ** 1.3;\n      const t1 = t0 + (1 - (1 - (k + 1) / 20) ** 1.3 - t0) * 0.45;\n      return strip(curve, width, 0.04, t0, Math.min(t1, 0.99), 3);\n    }).join(\"\"),\n    top: round(end),\n  };\n\n  const trees = {\n    front: forest(rand, front, [[WORLD.left, -330], [330, WORLD.right]], [56, 132], [15, 32], -0.3, 0.55),\n    mid: forest(rand, mid, [[WORLD.left, WORLD.right]], [11, 24], [11, 19], 0.3, 0.25),\n  };\n\n  // Stars thin out toward the horizon; three brightness classes keep it to three paths.\n  const stars = [\"\", \"\", \"\"];\n  for (let i = 0; i < 90; i++) {\n    const x = WORLD.left + rand() * (WORLD.right - WORLD.left);\n    const y = 14 + (horizon - 150) * rand() ** 1.7;\n    const r = 0.8 + rand() * 1.6;\n    stars[Math.floor(rand() * 3)] += `M${round(x - r)} ${round(y)}a${r.toFixed(1)} ${r.toFixed(1)} 0 1 0 ${(r * 2).toFixed(1)} 0a${r.toFixed(1)} ${r.toFixed(1)} 0 1 0 ${(-r * 2).toFixed(1)} 0`;\n  }\n\n  return { horizon, ridges, road, trees, stars };\n}\n\n/* ── Clock ──────────────────────────────────────────────── */\n\n// The visitor's local hour, to the minute, read on the client only.\nconst readClock = () => {\n  const now = new Date();\n  return now.getHours() + now.getMinutes() / 60;\n};\nconst subscribeClock = (onChange: () => void) => {\n  const timer = window.setInterval(onChange, TIMING.clock);\n  return () => window.clearInterval(timer);\n};\nconst noSubscribe = () => () => {};\nconst noClock = () => null;\n\nfunction resolveHour(time: GoldenHourProps[\"time\"], clock: number | null) {\n  if (time === \"auto\") return clock ?? PRESETS.golden;\n  if (typeof time === \"number\") return mod(time, 24);\n  return PRESETS[time ?? \"golden\"] ?? PRESETS.golden;\n}\n\n/* ── Types ──────────────────────────────────────────────── */\n\nexport interface GoldenHourProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"children\"> {\n  /** The hour the scene is lit for: a preset (`\"dawn\"`, `\"morning\"`, `\"noon\"`, `\"afternoon\"`, `\"golden\"`, `\"sunset\"`, `\"dusk\"`, `\"night\"`), an hour from 0 to 24 (17.5 is half past five in the evening), or `\"auto\"` for the visitor's own clock. A new value carries the sun there through the hours in between. */\n  time?: GoldenHourPreset | number | \"auto\";\n  /** Let the sun go down as the page scrolls on, from where the scene sat when the page loaded until it leaves the top. `true` moves it on 2 hours; a number sets the hours. */\n  sunset?: boolean | number;\n  /** Where the far ridge meets the sky, as a share of the height from the top. Lower it to leave room for a headline in the sky. */\n  horizon?: number;\n  /** The winding road from the bottom edge over the near hill. */\n  road?: boolean;\n  /** Trees on the slopes in front and along the middle ridge. */\n  trees?: boolean;\n  /** Strength of the film grain, from `0` (none) to `1`. */\n  grain?: number;\n  /** Reshapes the hills, the trees and the stars. Any whole number. */\n  seed?: number;\n  /** Settle the land into place and move the light on to the hour the first time the scene shows. */\n  intro?: boolean;\n  /** Let the ridges drift against the pointer, nearer ones more. */\n  parallax?: boolean;\n  /** Pixels the front ridge drifts sideways with the pointer at the scene's edge. Farther ridges drift less, and the up-and-down drift scales with it. */\n  parallaxShift?: number;\n  /** Seconds the sun takes to travel to a new `time`, plus 0.05s for every hour on the way. */\n  duration?: number;\n  /** Content laid over the scene, like a product shot or a headline. The root is `relative`, so it can be placed with `absolute`. */\n  children?: React.ReactNode;\n}\n\n/* ── GoldenHour ─────────────────────────────────────────── */\n\nexport function GoldenHour({\n  time = \"golden\",\n  sunset = false,\n  horizon = 0.58,\n  road = true,\n  trees = true,\n  grain = 0.5,\n  seed = 3,\n  intro = true,\n  parallax = true,\n  parallaxShift = GOLDEN.shift,\n  duration = TIMING.duration,\n  className,\n  style,\n  children,\n  ...props\n}: GoldenHourProps) {\n  const rootRef = React.useRef<HTMLDivElement>(null);\n  const uid = React.useId().replace(/[^a-zA-Z0-9]/g, \"\");\n  const ref = (name: string) => `gh${uid}-${name}`;\n  const reduced = useReducedMotion();\n\n  const horizonY = Math.round(clamp(horizon, 0.3, 0.82) * 1000);\n  const scene = React.useMemo(() => buildScene(Math.round(seed), horizonY), [seed, horizonY]);\n\n  const clock = React.useSyncExternalStore(\n    time === \"auto\" ? subscribeClock : noSubscribe,\n    time === \"auto\" ? readClock : noClock,\n    noClock,\n  );\n  const target = resolveHour(time, clock);\n\n  // What the server draws: the hour asked for, or half an hour short of it when\n  // the light is still to move on. Read once, so later renders never repaint\n  // over the colors the effects keep current.\n  const [initial] = React.useState(() => {\n    const hour = intro ? target - GOLDEN.lead : target;\n    return { hour, light: lightAt(hour), sun: sunAt(hour, horizonY), lowered: intro };\n  });\n  const [hour] = React.useState(() => motionValue(initial.hour));\n  const [lifts] = React.useState(() => LAYERS.map(() => motionValue(initial.lowered ? 1 : 0)));\n\n  const sunsetHours = sunset === true ? GOLDEN.sunset : typeof sunset === \"number\" ? sunset : 0;\n  const { scrollYProgress } = useScroll({ target: rootRef, offset: [\"start end\", \"end start\"] });\n  const drift = useSpring(scrollYProgress, TIMING.scroll);\n  const px = useSpring(0, TIMING.pointer);\n  const py = useSpring(0, TIMING.pointer);\n\n  const seen = useInView(rootRef, { once: true, amount: 0.2 });\n  const settled = React.useRef(!intro);\n  const scrollStart = React.useRef<number | null>(null);\n  const travel = React.useRef<AnimationPlaybackControls | null>(null);\n  const rising = React.useRef<AnimationPlaybackControls[]>([]);\n\n  // Paint: every color, the sun and the layer offsets, written straight to the\n  // SVG once a frame while anything moves.\n  React.useLayoutEffect(() => {\n    const root = rootRef.current;\n    if (!root) return;\n    const nodes = new Map<string, SVGElement>();\n    root.querySelectorAll<SVGElement>(\"[data-gh]\").forEach((node) => nodes.set(node.dataset.gh!, node));\n    const layers = Array.from(root.querySelectorAll<SVGSVGElement>(\"[data-gh-layer]\"));\n    const set = (key: string, name: string, value: string | number) => nodes.get(key)?.setAttribute(name, String(value));\n\n    // The sun sets over the scroll from wherever the scene sat when the page\n    // loaded to where it leaves the top, so the first look is always `time`.\n    if (scrollStart.current === null) {\n      const box = root.getBoundingClientRect();\n      scrollStart.current = clamp((window.innerHeight - box.top) / (window.innerHeight + box.height), 0, 1);\n    }\n    const start = scrollStart.current;\n    const span = Math.max(0.25, 1 - start);\n    const setting = () => clamp(((reduced ? scrollYProgress.get() : drift.get()) - start) / span, 0, 1);\n\n    const paint = () => {\n      const h = hour.get() + sunsetHours * setting();\n      const lit = lightAt(h);\n      const sun = sunAt(h, horizonY);\n      lit.sky.forEach((color, i) => set(`sky${i}`, \"stop-color\", color));\n      set(\"sun\", \"cx\", sun.x.toFixed(1));\n      set(\"sun\", \"cy\", sun.y.toFixed(1));\n      set(\"sun\", \"opacity\", sun.up ? 1 : 0);\n      set(\"sun0\", \"stop-color\", lit.sun);\n      set(\"sun1\", \"stop-color\", lit.sun);\n      set(\"sun2\", \"stop-color\", lit.glow);\n      set(\"glow\", \"cx\", sun.x.toFixed(1));\n      set(\"glow\", \"cy\", Math.min(sun.y, horizonY + 10).toFixed(1));\n      set(\"glow0\", \"stop-color\", lit.glow);\n      set(\"glow0\", \"stop-opacity\", lit.halo.toFixed(3));\n      set(\"glow1\", \"stop-color\", lit.glow);\n      set(\"glow1\", \"stop-opacity\", (lit.halo * 0.38).toFixed(3));\n      set(\"glow2\", \"stop-color\", lit.glow);\n      set(\"stars\", \"opacity\", lit.stars.toFixed(3));\n      set(\"moon\", \"opacity\", smoothstep(0.55, 1, lit.stars).toFixed(3));\n      set(\"rim\", \"x1\", (sun.x - SUN.reach).toFixed(0));\n      set(\"rim\", \"x2\", (sun.x + SUN.reach).toFixed(0));\n      for (const i of [0, 1, 2]) set(`rim${i}`, \"stop-color\", lit.rim);\n      lit.ridges.forEach(([crest, foot], i) => {\n        set(`ridge${i}a`, \"stop-color\", crest);\n        set(`ridge${i}b`, \"stop-color\", foot);\n        set(`ridge${i}`, \"stroke-opacity\", (lit.rimAlpha * (i === 5 ? 0.5 : 1)).toFixed(3));\n      });\n      for (const i of [0, 1, 2]) set(`mist${i}`, \"stop-color\", lit.mist);\n      set(\"mist1\", \"stop-opacity\", lit.mistAlpha.toFixed(3));\n      set(\"road0\", \"stop-color\", lit.road[0]);\n      set(\"road1\", \"stop-color\", lit.road[1]);\n      set(\"sheen\", \"fill\", lit.sheen);\n      set(\"sheen\", \"fill-opacity\", lit.sheenAlpha.toFixed(3));\n      set(\"lamps\", \"fill\", lit.lamps);\n      set(\"lamps\", \"fill-opacity\", lit.lampsAlpha.toFixed(3));\n      set(\"trees\", \"fill\", lit.trees);\n      set(\"treesMid\", \"fill\", lit.ridges[2][1]);\n    };\n\n    const place = () => {\n      layers.forEach((layer, i) => {\n        const { depth, rise } = LAYERS[i];\n        const x = -px.get() * depth * parallaxShift;\n        const y = -py.get() * depth * GOLDEN.lift * (parallaxShift / GOLDEN.shift);\n        layer.style.transform = `translate3d(${x.toFixed(2)}px, ${y.toFixed(2)}px, 0) translateY(${(lifts[i].get() * rise * 100).toFixed(3)}%)`;\n      });\n    };\n\n    let painted = false;\n    let placed = false;\n    const flush = () => {\n      if (painted) paint();\n      if (placed) place();\n      painted = placed = false;\n    };\n    const needPaint = () => {\n      painted = true;\n      frame.render(flush);\n    };\n    const needPlace = () => {\n      placed = true;\n      frame.render(flush);\n    };\n\n    paint();\n    place();\n    const offs = [\n      hour.on(\"change\", needPaint),\n      ...(sunsetHours ? [drift.on(\"change\", needPaint), scrollYProgress.on(\"change\", needPaint)] : []),\n      px.on(\"change\", needPlace),\n      py.on(\"change\", needPlace),\n      ...lifts.map((lift) => lift.on(\"change\", needPlace)),\n    ];\n    return () => {\n      offs.forEach((off) => off());\n      cancelFrame(flush);\n    };\n  }, [scene, road, trees, horizonY, sunsetHours, reduced, hour, lifts, drift, scrollYProgress, px, py, parallaxShift]);\n\n  // First view: the land settles and the light moves on to the hour.\n  React.useEffect(() => {\n    if (settled.current || !seen) return;\n    settled.current = true;\n    if (reduced) {\n      lifts.forEach((lift) => lift.jump(0));\n      hour.jump(target);\n      return;\n    }\n    rising.current = lifts.map((lift, i) => animate(lift, 0, { ...TIMING.settle, delay: i * TIMING.stagger }));\n    travel.current = animate(hour, hour.get() + shortWay(hour.get(), target), TIMING.ripen);\n  }, [seen, reduced, target, hour, lifts]);\n\n  // A new hour after that: the sun travels there the short way round the clock.\n  React.useEffect(() => {\n    if (!settled.current) return;\n    const to = hour.get() + shortWay(hour.get(), target);\n    if (Math.abs(to - hour.get()) < 0.001) return;\n    travel.current?.stop();\n    if (reduced) hour.jump(to);\n    else {\n      const visualDuration = Math.max(0, duration) + TIMING.travelPerHour * Math.abs(to - hour.get());\n      travel.current = animate(hour, to, { ...TIMING.travel, visualDuration });\n    }\n  }, [target, reduced, hour, duration]);\n\n  React.useEffect(\n    () => () => {\n      travel.current?.stop();\n      rising.current.forEach((control) => control.stop());\n    },\n    [],\n  );\n\n  // The ridges drift against a mouse; touch leaves them still.\n  React.useEffect(() => {\n    const root = rootRef.current;\n    if (!root || !parallax || reduced) {\n      px.set(0);\n      py.set(0);\n      return;\n    }\n    const move = (event: PointerEvent) => {\n      if (event.pointerType !== \"mouse\") return;\n      const box = root.getBoundingClientRect();\n      px.set(clamp(((event.clientX - box.left) / box.width) * 2 - 1, -1, 1));\n      py.set(clamp(((event.clientY - box.top) / box.height) * 2 - 1, -1, 1));\n    };\n    const leave = () => {\n      px.set(0);\n      py.set(0);\n    };\n    root.addEventListener(\"pointermove\", move);\n    root.addEventListener(\"pointerleave\", leave);\n    return () => {\n      root.removeEventListener(\"pointermove\", move);\n      root.removeEventListener(\"pointerleave\", leave);\n    };\n  }, [parallax, reduced, px, py]);\n\n  const { light, sun } = initial;\n  const layerClass = \"absolute -top-6 -left-6 h-[calc(100%+3rem)] w-[calc(100%+3rem)] overflow-hidden\";\n  const layerStyle = (i: number): React.CSSProperties => ({\n    transform: `translate3d(0px, 0px, 0) translateY(${(initial.lowered ? LAYERS[i].rise * 100 : 0).toFixed(3)}%)`,\n    willChange: i > 0 && parallax ? \"transform\" : undefined,\n  });\n  const svg = { viewBox: VIEWBOX, preserveAspectRatio: \"xMidYMid slice\", \"data-gh-layer\": \"\" };\n  const ridgeFill = (i: number) => (\n    <path\n      data-gh={`ridge${i}`}\n      d={scene.ridges[i].d}\n      fill={`url(#${ref(`ridge${i}`)})`}\n      stroke={`url(#${ref(\"rim\")})`}\n      strokeWidth={i >= 4 ? 3 : 2.5}\n      strokeOpacity={light.rimAlpha * (i === 5 ? 0.5 : 1)}\n      suppressHydrationWarning\n    />\n  );\n\n  return (\n    <div\n      ref={rootRef}\n      data-slot=\"golden-hour\"\n      className={cn(\"relative isolate overflow-hidden\", className)}\n      style={style}\n      {...props}\n    >\n      <div aria-hidden className=\"pointer-events-none absolute inset-0 -z-10 overflow-hidden\">\n        {/* The sky, with every gradient the scene uses. */}\n        <svg {...svg} className={layerClass} style={layerStyle(0)}>\n          <defs>\n            <linearGradient id={ref(\"sky\")} gradientUnits=\"userSpaceOnUse\" x1=\"0\" y1=\"0\" x2=\"0\" y2={scene.horizon + 30}>\n              {[0, 0.3, 0.56, 0.8, 1].map((offset, i) => (\n                <stop key={offset} data-gh={`sky${i}`} offset={offset} stopColor={light.sky[i]} suppressHydrationWarning />\n              ))}\n            </linearGradient>\n            <radialGradient id={ref(\"glow\")}>\n              <stop data-gh=\"glow0\" offset=\"0\" stopColor={light.glow} stopOpacity={light.halo} suppressHydrationWarning />\n              <stop data-gh=\"glow1\" offset=\"0.32\" stopColor={light.glow} stopOpacity={light.halo * 0.38} suppressHydrationWarning />\n              <stop data-gh=\"glow2\" offset=\"1\" stopColor={light.glow} stopOpacity=\"0\" suppressHydrationWarning />\n            </radialGradient>\n            <radialGradient id={ref(\"sun\")}>\n              <stop data-gh=\"sun0\" offset=\"0\" stopColor={light.sun} suppressHydrationWarning />\n              <stop data-gh=\"sun1\" offset=\"0.55\" stopColor={light.sun} suppressHydrationWarning />\n              <stop data-gh=\"sun2\" offset=\"1\" stopColor={light.glow} stopOpacity=\"0\" suppressHydrationWarning />\n            </radialGradient>\n            <radialGradient id={ref(\"moon\")}>\n              <stop offset=\"0\" stopColor=\"#f6f3ea\" />\n              <stop offset=\"0.12\" stopColor=\"#f6f3ea\" />\n              <stop offset=\"0.16\" stopColor=\"#c9ccef\" stopOpacity=\"0.35\" />\n              <stop offset=\"1\" stopColor=\"#c9ccef\" stopOpacity=\"0\" />\n            </radialGradient>\n            <linearGradient\n              id={ref(\"rim\")}\n              data-gh=\"rim\"\n              gradientUnits=\"userSpaceOnUse\"\n              x1={round(sun.x - SUN.reach)}\n              x2={round(sun.x + SUN.reach)}\n              y1=\"0\"\n              y2=\"0\"\n              suppressHydrationWarning\n            >\n              <stop data-gh=\"rim0\" offset=\"0\" stopColor={light.rim} stopOpacity=\"0\" suppressHydrationWarning />\n              <stop data-gh=\"rim1\" offset=\"0.5\" stopColor={light.rim} suppressHydrationWarning />\n              <stop data-gh=\"rim2\" offset=\"1\" stopColor={light.rim} stopOpacity=\"0\" suppressHydrationWarning />\n            </linearGradient>\n            {scene.ridges.map((ridge, i) => (\n              <linearGradient\n                key={i}\n                id={ref(`ridge${i}`)}\n                gradientUnits=\"userSpaceOnUse\"\n                x1=\"0\"\n                y1={ridge.top}\n                x2=\"0\"\n                y2={i === 5 ? WORLD.floor : Math.min(WORLD.floor, ridge.top + 340)}\n              >\n                <stop data-gh={`ridge${i}a`} offset=\"0\" stopColor={light.ridges[i][0]} suppressHydrationWarning />\n                <stop data-gh={`ridge${i}b`} offset=\"1\" stopColor={light.ridges[i][1]} suppressHydrationWarning />\n              </linearGradient>\n            ))}\n            <linearGradient id={ref(\"mist\")} gradientUnits=\"userSpaceOnUse\" x1=\"0\" y1={scene.horizon - 40} x2=\"0\" y2={scene.horizon + 250}>\n              <stop data-gh=\"mist0\" offset=\"0\" stopColor={light.mist} stopOpacity=\"0\" suppressHydrationWarning />\n              <stop data-gh=\"mist1\" offset=\"0.5\" stopColor={light.mist} stopOpacity={light.mistAlpha} suppressHydrationWarning />\n              <stop data-gh=\"mist2\" offset=\"1\" stopColor={light.mist} stopOpacity=\"0\" suppressHydrationWarning />\n            </linearGradient>\n            <linearGradient id={ref(\"road\")} gradientUnits=\"userSpaceOnUse\" x1=\"0\" y1={WORLD.floor} x2=\"0\" y2={scene.road.top}>\n              <stop data-gh=\"road0\" offset=\"0\" stopColor={light.road[0]} suppressHydrationWarning />\n              <stop data-gh=\"road1\" offset=\"1\" stopColor={light.road[1]} suppressHydrationWarning />\n            </linearGradient>\n            <clipPath id={ref(\"ground\")}>\n              <path d={scene.ridges[4].d} />\n            </clipPath>\n          </defs>\n          <rect x={WORLD.left} y=\"-20\" width={WORLD.right - WORLD.left} height={WORLD.floor + 40} fill={`url(#${ref(\"sky\")})`} />\n          <circle data-gh=\"glow\" cx={sun.x} cy={Math.min(sun.y, scene.horizon + 10)} r={SUN.halo} fill={`url(#${ref(\"glow\")})`} suppressHydrationWarning />\n          <g data-gh=\"stars\" opacity={light.stars} fill=\"#fdfbf4\" suppressHydrationWarning>\n            {scene.stars.map((d, i) => (\n              <path key={i} d={d} opacity={[0.45, 0.7, 1][i]} />\n            ))}\n          </g>\n          <g data-gh=\"moon\" opacity={smoothstep(0.55, 1, light.stars)} suppressHydrationWarning>\n            <circle cx=\"-250\" cy=\"170\" r=\"120\" fill={`url(#${ref(\"moon\")})`} />\n          </g>\n          <circle\n            data-gh=\"sun\"\n            cx={sun.x}\n            cy={sun.y}\n            r={SUN.radius}\n            opacity={sun.up ? 1 : 0}\n            fill={`url(#${ref(\"sun\")})`}\n            suppressHydrationWarning\n          />\n        </svg>\n\n        <svg {...svg} className={layerClass} style={layerStyle(1)}>\n          {ridgeFill(0)}\n        </svg>\n\n        <svg {...svg} className={layerClass} style={layerStyle(2)}>\n          {ridgeFill(1)}\n        </svg>\n\n        <svg {...svg} className={layerClass} style={layerStyle(3)}>\n          <rect x={WORLD.left} y={scene.horizon - 40} width={WORLD.right - WORLD.left} height=\"290\" fill={`url(#${ref(\"mist\")})`} />\n          {ridgeFill(2)}\n          {trees && <path data-gh=\"treesMid\" d={scene.trees.mid} fill={light.ridges[2][1]} suppressHydrationWarning />}\n        </svg>\n\n        <svg {...svg} className={layerClass} style={layerStyle(4)}>\n          {ridgeFill(3)}\n          {ridgeFill(4)}\n          {road && (\n            <g clipPath={`url(#${ref(\"ground\")})`}>\n              <path d={scene.road.body} fill={`url(#${ref(\"road\")})`} />\n              <path data-gh=\"sheen\" d={scene.road.sheen} fill={light.sheen} fillOpacity={light.sheenAlpha} suppressHydrationWarning />\n              <path data-gh=\"lamps\" d={scene.road.lamps} fill={light.lamps} fillOpacity={light.lampsAlpha} suppressHydrationWarning />\n            </g>\n          )}\n        </svg>\n\n        <svg {...svg} className={layerClass} style={layerStyle(5)}>\n          {ridgeFill(5)}\n          {trees && <path data-gh=\"trees\" d={scene.trees.front} fill={light.trees} suppressHydrationWarning />}\n        </svg>\n\n        {/* Film grain: a tile of noise laid over everything in overlay. */}\n        {grain > 0 && (\n          <div\n            className=\"absolute inset-0 mix-blend-overlay\"\n            style={{ backgroundImage: GRAIN, backgroundSize: \"180px 180px\", opacity: clamp(grain, 0, 1) * 0.55 }}\n          />\n        )}\n      </div>\n      {children}\n    </div>\n  );\n}\n\n// The shortest signed way round the clock from one hour to another.\nfunction shortWay(from: number, to: number) {\n  return mod(to - from + 12, 24) - 12;\n}\n\nconst GRAIN = `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='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='1.7 0 0 0 -0.35 1.7 0 0 0 -0.35 1.7 0 0 0 -0.35 0 0 0 0 1'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E\")`;\n"
    }
  ]
}