{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "elevated",
  "title": "elevated",
  "description": "A utility function for elevated.",
  "files": [
    {
      "path": "registry/default/lib/elevated.tsx",
      "content": "import type * as React from \"react\";\n\nimport { cn } from \"@/lib/utils\";\n\nexport type SurfaceLevel = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;\n\n/** Every `SurfaceLevel`, for exhaustive iteration. Keep in sync with the type. */\nexport const SURFACE_LEVELS = [\n  1, 2, 3, 4, 5, 6, 7, 8,\n] as const satisfies readonly SurfaceLevel[];\n\nexport const SURFACE_BG: Record<SurfaceLevel, string> = {\n  1: \"bg-surface-1\",\n  2: \"bg-surface-2\",\n  3: \"bg-surface-3\",\n  4: \"bg-surface-4\",\n  5: \"bg-surface-5\",\n  6: \"bg-surface-6\",\n  7: \"bg-surface-7\",\n  8: \"bg-surface-8\",\n};\n\n/**\n * Every shadow below uses the `shadow-(--var)` form, pointing at a single theme\n * variable. Two reasons, and both break if you \"simplify\" it back:\n *\n * 1. tailwind-merge only treats this form as the `shadow` group. A theme-key\n *    name and a square-bracket arbitrary value both land in `shadow-color`, so\n *    a caller's `className=\"shadow-none\"` never overrides them and stylesheet\n *    order silently picks the winner. (Do not spell those two forms out here:\n *    Tailwind scans comments, and a bracket example compiles to a real,\n *    broken utility.)\n * 2. The variable is a `--surface-*` source token, not a `@theme` alias. Source\n *    tokens are re-declared in `.dark`, so they resolve per element. A `@theme`\n *    alias is declared once on `:root`, which makes a `.dark` scoped to a\n *    subtree inherit the light value (same trap as `--border`).\n */\nexport const SURFACE_SHADOW: Record<SurfaceLevel, string> = {\n  1: \"shadow-(--surface-shadow-1)\",\n  2: \"shadow-(--surface-shadow-2)\",\n  3: \"shadow-(--surface-shadow-3)\",\n  4: \"shadow-(--surface-shadow-4)\",\n  5: \"shadow-(--surface-shadow-5)\",\n  6: \"shadow-(--surface-shadow-6)\",\n  7: \"shadow-(--surface-shadow-7)\",\n  8: \"shadow-(--surface-shadow-8)\",\n};\n\nexport const SURFACE_RIM: Record<SurfaceLevel, string> = {\n  1: \"after:shadow-(--surface-rim-1)\",\n  2: \"after:shadow-(--surface-rim-2)\",\n  3: \"after:shadow-(--surface-rim-3)\",\n  4: \"after:shadow-(--surface-rim-4)\",\n  5: \"after:shadow-(--surface-rim-5)\",\n  6: \"after:shadow-(--surface-rim-6)\",\n  7: \"after:shadow-(--surface-rim-7)\",\n  8: \"after:shadow-(--surface-rim-8)\",\n};\n\n/**\n * Exposes the surface level to descendants as `--popup-surface` so children\n * (arrow fills, sticky labels, fade gradients) can track the popup's level\n * via `bg-(--popup-surface,var(--popover))`.\n */\nexport const SURFACE_VAR: Record<SurfaceLevel, string> = {\n  1: \"[--popup-surface:var(--surface-1)]\",\n  2: \"[--popup-surface:var(--surface-2)]\",\n  3: \"[--popup-surface:var(--surface-3)]\",\n  4: \"[--popup-surface:var(--surface-4)]\",\n  5: \"[--popup-surface:var(--surface-5)]\",\n  6: \"[--popup-surface:var(--surface-6)]\",\n  7: \"[--popup-surface:var(--surface-7)]\",\n  8: \"[--popup-surface:var(--surface-8)]\",\n};\n\n/**\n * Drops + rim insets in a single `box-shadow` (no `::after`). Used by `solidSurface()`.\n * Literal Tailwind classes so the scanner picks them up.\n */\nexport const SURFACE_SHADOW_COMBINED: Record<SurfaceLevel, string> = {\n  1: \"shadow-(--surface-shadow-combined-1)\",\n  2: \"shadow-(--surface-shadow-combined-2)\",\n  3: \"shadow-(--surface-shadow-combined-3)\",\n  4: \"shadow-(--surface-shadow-combined-4)\",\n  5: \"shadow-(--surface-shadow-combined-5)\",\n  6: \"shadow-(--surface-shadow-combined-6)\",\n  7: \"shadow-(--surface-shadow-combined-7)\",\n  8: \"shadow-(--surface-shadow-combined-8)\",\n};\n\n/**\n * The inverse fill, off the elevation ladder: `--neutral`, charcoal in light\n * and near-white in dark. Only for surfaces that dismiss themselves (tooltips,\n * toasts).\n *\n * Pair it with `data-surface=\"inverse\"` on the same element so page classes\n * inside paint against the fill. Fill only, like `SURFACE_BG` + `SURFACE_VAR`;\n * it needs no edge.\n */\nexport const INVERSE_SURFACE = \"bg-neutral [--popup-surface:var(--neutral)]\";\n\nexport function surfaceClasses(\n  level: SurfaceLevel,\n  shadowLevel: SurfaceLevel = level,\n): string {\n  return `${SURFACE_BG[level]} ${SURFACE_SHADOW[shadowLevel]} ${SURFACE_VAR[level]}`;\n}\n\n/**\n * Like `surfaceClasses`, but adds a `::after` overlay that re-paints the rim\n * above the container's children. Use on elevated containers with opaque\n * children near their edges (sticky labels, pinned inputs, dialog headers).\n *\n * Host requirements: positioned, `border-radius` class, clipped overflow.\n * Overlay is `z-index: 2` — bump if children exceed that.\n */\nexport function elevatedSurface(\n  level: SurfaceLevel,\n  shadowLevel: SurfaceLevel = level,\n): string {\n  return `${SURFACE_BG[level]} ${SURFACE_SHADOW[shadowLevel]} ${SURFACE_RIM[level]} ${SURFACE_VAR[level]} after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] after:z-[2]`;\n}\n\n/**\n * Like `elevatedSurface`, but paints the rim in the popup's own `box-shadow`\n * (no `::after`) — leaves `::after` free for other purposes. Use for elevated\n * containers with no opaque children near their edges; switch to\n * `elevatedSurface()` if you add a sticky/opaque child.\n *\n * When `level !== shadowLevel` the rim color tracks `shadowLevel`; for\n * independent rim/drop control use `elevatedSurface` instead.\n */\nexport function solidSurface(\n  level: SurfaceLevel,\n  shadowLevel: SurfaceLevel = level,\n): string {\n  return `${SURFACE_BG[level]} ${SURFACE_SHADOW_COMBINED[shadowLevel]} ${SURFACE_VAR[level]}`;\n}\n\n/**\n * `::after` classes for a 1px inset rim on a single edge — for viewport-flush\n * containers (Sheet/Drawer) so the rim only shows on the inner-facing edge.\n * Color is `--surface-rim-color` (transparent in light, ~4% white in dark).\n */\nexport const SURFACE_RIM_EDGE: Record<\n  \"top\" | \"bottom\" | \"left\" | \"right\",\n  string\n> = {\n  top: \"after:shadow-[inset_0_1px_0_0_var(--surface-rim-color)]\",\n  bottom: \"after:shadow-[inset_0_-1px_0_0_var(--surface-rim-color)]\",\n  left: \"after:shadow-[inset_1px_0_0_0_var(--surface-rim-color)]\",\n  right: \"after:shadow-[inset_-1px_0_0_0_var(--surface-rim-color)]\",\n};\n\n/**\n * `::after` overlay with a 1px rim on the specified inner-facing edge.\n * Pair with `surfaceClasses()` (NOT `elevatedSurface()`) for flush variants.\n */\nexport function innerEdgeRim(\n  innerEdge: \"top\" | \"bottom\" | \"left\" | \"right\",\n): string {\n  return `after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] after:z-[2] ${SURFACE_RIM_EDGE[innerEdge]}`;\n}\n\n/** Maps attach-side → inner-facing edge for `innerEdgeRim`. */\nexport const INNER_EDGE_FROM_ATTACH_SIDE: Record<\n  \"top\" | \"bottom\" | \"left\" | \"right\",\n  \"top\" | \"bottom\" | \"left\" | \"right\"\n> = {\n  top: \"bottom\",\n  bottom: \"top\",\n  left: \"right\",\n  right: \"left\",\n};\n\n/**\n * Directional drop shadow for a viewport-flush surface: casts toward the\n * inner-facing edge (into the content) rather than always straight down. A\n * flush surface only sheds shadow on the one edge that isn't pinned to the\n * viewport, so the radial `--surface-shadow-N` recipe (which casts down on\n * every surface) points the wrong way for top/bottom/left attach sides.\n *\n * This is the level-5 recipe, rotated per edge. It matches the floating\n * variant's edge ring EXACTLY by mirroring how that recipe handles the ring\n * per mode: the base shadow uses --surface-shadow-ring (light: 4.5%) and the\n * `dark:` shadow inlines oklch(0 0 0 / 0.12) (the level-5 dark ring). The drop\n * layers reference --surface-shadow-near/mid/far, which already redefine per\n * mode, so they're identical between the two and don't need splitting.\n * The ring casts on all four edges — the three viewport-pinned ones fall\n * off-screen.\n */\nexport const INNER_EDGE_SHADOW: Record<\n  \"top\" | \"bottom\" | \"left\" | \"right\",\n  string\n> = {\n  left: \"shadow-[0_0_0_1px_var(--surface-shadow-ring),-1px_0_1px_-0.5px_var(--surface-shadow-near),-3px_0_3px_-1.5px_var(--surface-shadow-mid),-6px_0_6px_-3px_var(--surface-shadow-mid),-12px_0_12px_-6px_var(--surface-shadow-far)] dark:shadow-[0_0_0_1px_oklch(0_0_0/0.12),-1px_0_1px_-0.5px_var(--surface-shadow-near),-3px_0_3px_-1.5px_var(--surface-shadow-mid),-6px_0_6px_-3px_var(--surface-shadow-mid),-12px_0_12px_-6px_var(--surface-shadow-far)]\",\n  right:\n    \"shadow-[0_0_0_1px_var(--surface-shadow-ring),1px_0_1px_-0.5px_var(--surface-shadow-near),3px_0_3px_-1.5px_var(--surface-shadow-mid),6px_0_6px_-3px_var(--surface-shadow-mid),12px_0_12px_-6px_var(--surface-shadow-far)] dark:shadow-[0_0_0_1px_oklch(0_0_0/0.12),1px_0_1px_-0.5px_var(--surface-shadow-near),3px_0_3px_-1.5px_var(--surface-shadow-mid),6px_0_6px_-3px_var(--surface-shadow-mid),12px_0_12px_-6px_var(--surface-shadow-far)]\",\n  top: \"shadow-[0_0_0_1px_var(--surface-shadow-ring),0_-1px_1px_-0.5px_var(--surface-shadow-near),0_-3px_3px_-1.5px_var(--surface-shadow-mid),0_-6px_6px_-3px_var(--surface-shadow-mid),0_-12px_12px_-6px_var(--surface-shadow-far)] dark:shadow-[0_0_0_1px_oklch(0_0_0/0.12),0_-1px_1px_-0.5px_var(--surface-shadow-near),0_-3px_3px_-1.5px_var(--surface-shadow-mid),0_-6px_6px_-3px_var(--surface-shadow-mid),0_-12px_12px_-6px_var(--surface-shadow-far)]\",\n  bottom:\n    \"shadow-[0_0_0_1px_var(--surface-shadow-ring),0_1px_1px_-0.5px_var(--surface-shadow-near),0_3px_3px_-1.5px_var(--surface-shadow-mid),0_6px_6px_-3px_var(--surface-shadow-mid),0_12px_12px_-6px_var(--surface-shadow-far)] dark:shadow-[0_0_0_1px_oklch(0_0_0/0.12),0_1px_1px_-0.5px_var(--surface-shadow-near),0_3px_3px_-1.5px_var(--surface-shadow-mid),0_6px_6px_-3px_var(--surface-shadow-mid),0_12px_12px_-6px_var(--surface-shadow-far)]\",\n};\n\n/**\n * Flush-surface elevation: bg + a directional drop shadow cast toward the\n * inner edge + the single-edge inset rim on that edge. Use for viewport-flush\n * containers (Sheet/Drawer `default` variant) instead of `solidSurface` (whose\n * all-around, downward shadow only suits a free-floating surface). `innerEdge`\n * is the content-facing edge — derive it from the attach side via\n * `INNER_EDGE_FROM_ATTACH_SIDE`.\n */\nexport function flushSurface(\n  level: SurfaceLevel,\n  innerEdge: \"top\" | \"bottom\" | \"left\" | \"right\",\n): string {\n  return `${SURFACE_BG[level]} ${SURFACE_VAR[level]} ${INNER_EDGE_SHADOW[innerEdge]} ${innerEdgeRim(innerEdge)}`;\n}\n\nexport interface ElevatedProps extends React.ComponentProps<\"div\"> {\n  level: SurfaceLevel;\n  shadowLevel?: SurfaceLevel;\n}\n\nfunction Elevated({ level, shadowLevel, className, ...props }: ElevatedProps) {\n  return (\n    <div\n      data-slot=\"elevated\"\n      data-level={level}\n      className={cn(surfaceClasses(level, shadowLevel ?? level), className)}\n      {...props}\n    />\n  );\n}\n\nexport { Elevated };\n",
      "type": "registry:lib",
      "target": "lib/cubby-ui/elevated.tsx"
    }
  ],
  "type": "registry:lib"
}