{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "sky-backdrop",
  "type": "registry:ui",
  "title": "Sky Backdrop",
  "description": "A calm daytime sky for a friendly hero: a soft gradient, a warm sun glow in one corner, and a few clouds drifting across. It suits pages that want warmth rather than drama, the light counterpart to `Starfield`.",
  "author": "ofri-peretz <https://github.com/ofri-peretz>",
  "categories": [
    "decorative",
    "effect"
  ],
  "dependencies": [],
  "registryDependencies": [
    "https://ds.interlace.tools/r/interlace-base.json",
    "https://ds.interlace.tools/r/cn.json",
    "https://ds.interlace.tools/r/use-reduced-motion.json"
  ],
  "files": [
    {
      "path": "registry/interlace-ui/effects/sky-backdrop.tsx",
      "target": "components/ui/effects/sky-backdrop.tsx",
      "type": "registry:ui",
      "content": "'use client';\n\nimport * as React from 'react';\n\n// @interlace/sky-backdrop v1.0.0 — Interlace design system.\n// Docs, props and live preview: https://ds.interlace.tools/c/sky-backdrop\n// What changed since: https://ds.interlace.tools/c/sky-backdrop#history\n// Generated banner — keep it, the upgrade diff reads this version.\n\n/**\n * @interlace/ui — SkyBackdrop\n *\n * A calm daytime sky for a friendly hero: a soft gradient, a warm sun glow\n * in one corner, and a few clouds drifting across. It suits pages that want\n * warmth rather than drama, the light counterpart to `Starfield`.\n *\n * ## Built on the theme\n *\n * The sky is mixed from tokens (`--info` into `--background`), the sun is\n * `--highlight`, and the clouds are `--card`, so the sky follows the brand\n * and turns to dusk in the dark scheme with no extra props. Every colour can\n * still be set directly.\n *\n * ## Clouds\n *\n * Each cloud is three overlapping soft circles (radial gradients) on one\n * element, so a cloud is a single node with no image and no SVG filter.\n * Cloud sizes, heights and speeds come from a seeded sequence, so the same\n * `seed` draws the same sky on the server and in the browser.\n *\n * ## Motion\n *\n * Clouds drift right to left on 60 to 120 second loops through the Web\n * Animations API, and pause while the sky is out of view. Under\n * `prefers-reduced-motion: reduce` they stay where they are.\n *\n * | Rule | Concept                 | Where in this file                                   |\n * | ---- | ----------------------- | ---------------------------------------------------- |\n * | R4   | Extends native el       | `div` props                                          |\n * | R6   | data-slot per part      | sky-backdrop / -sun / -cloud / -content               |\n * | R7   | cn + ...rest            | `cn(…, className)` + `{...props}`                     |\n * | R8   | Enums, not booleans     | `sun`                                                |\n * | R19  | Tokens only             | `--info`, `--background`, `--highlight`, `--card`     |\n * | R23  | CLS=0                   | sky layers are `absolute`, content stays in flow      |\n * | R25  | Client component        | the drift needs `Element.animate`                     |\n */\n\nimport { cn } from '@/lib/utils';\nimport { useReducedMotion } from '@/hooks/use-reduced-motion';\n\nexport type SkySun = 'top-left' | 'top-right' | 'none';\n\nexport interface SkyBackdropProps extends React.ComponentPropsWithoutRef<'div'> {\n  /** Where the sun glows, or `none`. @default 'top-right' */\n  sun?: SkySun;\n  /** Number of clouds, 0 to 8. @default 4 */\n  clouds?: number;\n  /** Same seed, same sky. @default 3 */\n  seed?: number;\n  /** Colour at the top of the sky. @default a mix of --info into --background */\n  skyColor?: string;\n  /** Sun colour. @default 'var(--highlight)' */\n  sunColor?: string;\n  /** Cloud colour. @default 'var(--card)' */\n  cloudColor?: string;\n  /** Set false to keep the clouds still even when motion is allowed. @default true */\n  animated?: boolean;\n}\n\nfunction seeded(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\nfunction cloudBackground(color: string) {\n  const c = (alpha: number) => `color-mix(in oklab, ${color} ${alpha}%, transparent)`;\n  return [\n    `radial-gradient(closest-side at 30% 60%, ${c(95)}, transparent)`,\n    `radial-gradient(closest-side at 55% 40%, ${c(100)}, transparent)`,\n    `radial-gradient(closest-side at 75% 65%, ${c(90)}, transparent)`,\n  ].join(', ');\n}\n\nexport function SkyBackdrop({\n  sun = 'top-right',\n  clouds = 4,\n  seed = 3,\n  skyColor = 'color-mix(in oklab, var(--info) 30%, var(--background))',\n  sunColor = 'var(--highlight)',\n  cloudColor = 'var(--card)',\n  animated = true,\n  className,\n  children,\n  ...props\n}: SkyBackdropProps) {\n  const layerRef = React.useRef<HTMLDivElement>(null);\n  const reduced = useReducedMotion();\n  const moving = animated && !reduced;\n\n  const cloudList = React.useMemo(() => {\n    const rand = seeded(seed);\n    return Array.from({ length: Math.min(Math.max(0, Math.round(clouds)), 8) }, () => {\n      const top = 5 + rand() * 45;\n      const place = rand();\n      const width = 14 + rand() * 16;\n      return {\n        top,\n        // Each cloud rests fully inside the sky, so its loop always has an\n        // off-screen moment to wrap in and never jumps where it can be seen.\n        left: place * (100 - width),\n        width,\n        seconds: 60 + rand() * 60,\n        opacity: 0.6 + rand() * 0.35,\n      };\n    });\n  }, [clouds, seed]);\n\n  React.useEffect(() => {\n    const layer = layerRef.current;\n    if (!layer || !moving) return;\n    const nodes = Array.from(layer.querySelectorAll<HTMLElement>('[data-slot=\"sky-backdrop-cloud\"]'));\n    if (!nodes.every((n) => typeof n.animate === 'function')) return;\n    const width = layer.clientWidth;\n    const animations = nodes.map((node, i) => {\n      const cloud = cloudList[i]!;\n      // Start at the cloud's resting place, so the first frame matches the\n      // server render: drift off the left edge, re-enter from the right, and\n      // come back to rest. One loop crosses the sky once.\n      const start = node.offsetLeft;\n      const size = node.offsetWidth;\n      const total = width + size || 1;\n      const exitAt = Math.min(Math.max((start + size) / total, 0), 1);\n      return node.animate(\n        [\n          { translate: '0px 0px' },\n          { translate: `${-(start + size)}px 0px`, offset: exitAt },\n          { translate: `${width - start}px 0px`, offset: exitAt },\n          { translate: '0px 0px' },\n        ],\n        { duration: cloud.seconds * 1000, iterations: Infinity, easing: 'linear' },\n      );\n    });\n    const io =\n      typeof IntersectionObserver === 'undefined'\n        ? null\n        : new IntersectionObserver(([entry]) => {\n            for (const a of animations) {\n              if (entry?.isIntersecting) a.play();\n              else a.pause();\n            }\n          });\n    io?.observe(layer);\n    return () => {\n      io?.disconnect();\n      for (const a of animations) a.cancel();\n    };\n  }, [moving, cloudList]);\n\n  return (\n    <div\n      data-slot=\"sky-backdrop\"\n      className={cn('relative isolate overflow-hidden', className)}\n      style={{ background: `linear-gradient(to bottom, ${skyColor}, var(--background))` }}\n      {...props}\n    >\n      <div ref={layerRef} aria-hidden className=\"pointer-events-none absolute inset-0 -z-10\">\n        {sun !== 'none' ? (\n          <span\n            data-slot=\"sky-backdrop-sun\"\n            className=\"absolute size-[60vmin] rounded-full\"\n            style={{\n              top: '-20vmin',\n              [sun === 'top-left' ? 'left' : 'right']: '-15vmin',\n              background: `radial-gradient(closest-side, color-mix(in oklab, ${sunColor} 80%, transparent), color-mix(in oklab, ${sunColor} 25%, transparent) 45%, transparent)`,\n            }}\n          />\n        ) : null}\n        {cloudList.map((cloud, i) => (\n          <span\n            key={i}\n            data-slot=\"sky-backdrop-cloud\"\n            className=\"absolute aspect-[5/2]\"\n            style={{\n              top: `${cloud.top}%`,\n              left: `${cloud.left}%`,\n              width: `${cloud.width}%`,\n              minWidth: '7rem',\n              opacity: cloud.opacity,\n              background: cloudBackground(cloudColor),\n            }}\n          />\n        ))}\n      </div>\n      {children != null ? (\n        <div data-slot=\"sky-backdrop-content\" className=\"relative\">\n          {children}\n        </div>\n      ) : null}\n    </div>\n  );\n}\n"
    }
  ],
  "meta": {
    "tier": "effect",
    "client": true,
    "minViewport": null,
    "loading": false,
    "version": "1.0.0",
    "since": null
  },
  "docs": "## @interlace/sky-backdrop\n\nInstalled to `components/ui/effects/sky-backdrop.tsx`.\n\n```tsx\nimport { /* … */ } from '@/components/ui/effects/sky-backdrop';\n```\n\nProps, a11y contract, live preview and source: https://ds.interlace.tools/c/sky-backdrop\n\nRequires the `@interlace/interlace-base` CSS baseline (installed automatically as a registry dependency). For the Interlace look, also add `@interlace/theme`."
}
