/* Kit grounds, second set (2026-12-01): dots, grid, floor grid, beams, conic, duotone, aurora, horizon arc.
   Same rules as the grounds in finish.css: role variables only, one light, colour stays in the accent family,
   3-5% grain over every colour field. Each ground owns ::before (the pattern or light) and ::after (grain or mask light),
   sets position: relative and isolation: isolate, and keeps the top of the field calm for type unless noted. */
@layer components {

@property --cs-g-a { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
@property --cs-g-x { syntax: "<percentage>"; inherits: false; initial-value: 30%; }
@property --cs-g-y { syntax: "<percentage>"; inherits: false; initial-value: 40%; }

:where(.cs-ground-dots, .cs-ground-grid, .cs-ground-beams, .cs-ground-conic, .cs-ground-duotone, .cs-ground-aurora, .cs-ground-arc) {
  --cs-noise: 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='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --cs-grain: .04;
  --g-accent: var(--primary);
  --g-line: color-mix(in oklab, var(--foreground) 13%, transparent);
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background-color: var(--background);
}
:is(.cs-ground-dots, .cs-ground-grid, .cs-ground-beams, .cs-ground-conic, .cs-ground-duotone, .cs-ground-aurora, .cs-ground-arc)::before,
:is(.cs-ground-dots, .cs-ground-grid, .cs-ground-beams, .cs-ground-conic, .cs-ground-duotone, .cs-ground-aurora, .cs-ground-arc)::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  border-radius: inherit;
}
/* grain over the colour grounds */
:is(.cs-ground-conic, .cs-ground-duotone, .cs-ground-aurora, .cs-ground-arc)::after {
  background-image: var(--cs-noise);
  background-size: 180px 180px;
  opacity: var(--cs-grain);
}

/* dots: a fine dot lattice that fades to the edges; a slow light in the accent drifts across it and lights the dots it passes.
   --dot-gap (default 22px), --dot-size (1.2px). data-cs-dots="still" stops the drifting light. */
.cs-ground-dots::before {
  background-image: radial-gradient(circle, var(--g-line) var(--dot-size, 1.2px), transparent calc(var(--dot-size, 1.2px) + .6px));
  background-size: var(--dot-gap, 22px) var(--dot-gap, 22px);
  background-position: center;
  mask-image: radial-gradient(ellipse 70% 65% at 50% 45%, #000 30%, transparent 100%);
}
.cs-ground-dots::after {
  background-image: radial-gradient(circle, var(--g-accent) calc(var(--dot-size, 1.2px) + .3px), transparent calc(var(--dot-size, 1.2px) + .9px));
  background-size: var(--dot-gap, 22px) var(--dot-gap, 22px);
  background-position: center;
  mask-image: radial-gradient(circle var(--dot-light, 170px) at var(--cs-g-x) var(--cs-g-y), #000, transparent 100%);
  animation: cs-g-wander 26s ease-in-out infinite alternate;
}
.cs-ground-dots[data-cs-dots=still]::after { animation: none; --cs-g-x: 50%; --cs-g-y: 38%; }

/* grid: hairline squares fading out from a lit top edge. --grid-gap (default 48px).
   data-cs-grid="floor": a perspective floor that scrolls toward the viewer under a horizon glow. */
.cs-ground-grid::before {
  background-image:
    linear-gradient(var(--g-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--g-line) 1px, transparent 1px);
  background-size: var(--grid-gap, 48px) var(--grid-gap, 48px);
  background-position: center top;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 0%, #000 20%, transparent 85%);
}
.cs-ground-grid::after {
  background: radial-gradient(60% 45% at 50% 0%, color-mix(in oklab, var(--g-accent) 34%, transparent), transparent 70%);
}
.cs-ground-grid[data-cs-grid=floor]::before {
  inset: 60% -60% -10% -60%;
  background-size: var(--grid-gap, 56px) var(--grid-gap, 56px);
  transform: perspective(420px) rotateX(62deg);
  transform-origin: 50% 0;
  mask-image: linear-gradient(to bottom, transparent, #000 30%, #000);
  animation: cs-g-floor 3.2s linear infinite;
}
.cs-ground-grid[data-cs-grid=floor]::after {
  background:
    linear-gradient(to bottom, transparent 59.6%, color-mix(in oklab, var(--g-accent) 70%, var(--foreground)) 60%, transparent 60.4%),
    radial-gradient(70% 22% at 50% 60%, color-mix(in oklab, var(--g-accent) 46%, transparent), transparent 70%);
}

/* beams: faint vertical rails with drops of light falling down a few of them at different speeds (background beams). */
.cs-ground-beams::before {
  background-image: repeating-linear-gradient(90deg, transparent 0 calc(var(--beam-gap, 96px) - 1px), var(--g-line) calc(var(--beam-gap, 96px) - 1px) var(--beam-gap, 96px));
  mask-image: linear-gradient(to bottom, transparent, #000 25%, #000 70%, transparent);
}
.cs-ground-beams::after {
  --drop: linear-gradient(to bottom, transparent, color-mix(in oklab, var(--g-accent) 90%, var(--foreground)) 85%, transparent 100%);
  background-image: var(--drop), var(--drop), var(--drop), var(--drop), var(--drop);
  background-size: 1px 140px, 1px 90px, 1px 180px, 1px 110px, 1px 150px;
  background-repeat: no-repeat;
  filter: drop-shadow(0 0 6px var(--g-accent));
  animation: cs-g-beams 9s linear infinite;
}

/* conic: a slow sweep of accent light turning about a point above the field, softened and grained. --conic-x / --conic-y set the pivot. */
.cs-ground-conic::before {
  inset: -40%;
  background: conic-gradient(from var(--cs-g-a) at var(--conic-x, 50%) var(--conic-y, 18%),
    transparent 0deg, color-mix(in oklab, var(--g-accent) 85%, transparent) 30deg, color-mix(in oklab, var(--g-accent) 35%, transparent) 70deg, transparent 110deg,
    transparent 190deg, color-mix(in oklab, var(--g-accent) 55%, transparent) 235deg, transparent 285deg);
  filter: blur(2.5rem);
  opacity: .85;
  animation: cs-g-turn 40s linear infinite;
}

/* duotone: two tones of the accent family split on a soft diagonal, deep to light, with one soft bloom on the seam. */
.cs-ground-duotone {
  --duo-a: color-mix(in oklab, var(--g-accent) 46%, #000);
  --duo-b: color-mix(in oklab, var(--g-accent) 42%, var(--background));
  background-image:
    radial-gradient(42% 60% at 62% 54%, color-mix(in oklab, var(--g-accent) 38%, transparent), transparent 70%),
    linear-gradient(118deg, var(--duo-a) 0%, var(--duo-a) 34%, var(--duo-b) 72%, var(--duo-b) 100%);
}
@supports (color: oklch(from red l c h)) {
  .cs-ground-duotone { --duo-b: oklch(from var(--g-accent) calc(l * .62) calc(c * .8) calc(h + 26)); }
}
/* on a light ground both tones are pale so dark ink keeps its contrast */
.cs-ground-duotone[data-cs-tone=light] {
  --duo-a: color-mix(in oklab, var(--g-accent) 34%, var(--background));
  --duo-b: color-mix(in oklab, var(--g-accent) 14%, var(--background));
  background-image:
    radial-gradient(42% 60% at 62% 54%, color-mix(in oklab, var(--background) 70%, transparent), transparent 70%),
    linear-gradient(118deg, var(--duo-a) 0%, var(--duo-a) 30%, var(--duo-b) 72%, var(--duo-b) 100%);
}

/* aurora: soft vertical curtains of accent light drifting across the top-right of the field. */
.cs-ground-aurora::before {
  inset: -10% -15% 25% -15%;
  --au-1: var(--g-accent);
  --au-2: color-mix(in oklab, var(--g-accent) 45%, #fff);
  background:
    linear-gradient(to top, transparent 34%, color-mix(in oklab, var(--au-2) 40%, transparent) 44%, var(--au-2) 50%, var(--au-1) 54%, color-mix(in oklab, var(--au-1) 55%, transparent) 66%, color-mix(in oklab, var(--au-1) 18%, transparent) 78%, transparent 90%);
  -webkit-mask-image: repeating-linear-gradient(96deg, #000 0 9px, rgb(0 0 0 / .5) 13px, #000 17px, rgb(0 0 0 / .7) 26px, rgb(0 0 0 / .35) 31px, #000 38px, rgb(0 0 0 / .55) 47px), radial-gradient(75% 46% at 46% 28%, #000 20%, transparent 85%);
  mask-image: repeating-linear-gradient(96deg, #000 0 9px, rgb(0 0 0 / .5) 13px, #000 17px, rgb(0 0 0 / .7) 26px, rgb(0 0 0 / .35) 31px, #000 38px, rgb(0 0 0 / .55) 47px), radial-gradient(75% 46% at 46% 28%, #000 20%, transparent 85%);
  -webkit-mask-composite: source-in;
  mask-composite: intersect;
  filter: blur(5px) saturate(1.2) drop-shadow(0 0 24px color-mix(in oklab, var(--au-1) 70%, transparent));
  transform-origin: 50% 26%;
  animation: cs-g-aurora 22s ease-in-out infinite alternate;
}

/* arc: a dark planet edge rising from the bottom, a thin bright rim and a halo of accent light above it (one light). */
.cs-ground-arc::before {
  inset: auto -30% -1px -30%;
  height: 120%;
  top: var(--arc-top, 58%);
  border-radius: 50% 50% 0 0 / 46% 46% 0 0;
  background: radial-gradient(70% 60% at 50% 0%, color-mix(in oklab, var(--background) 92%, var(--g-accent)), var(--background) 70%);
  box-shadow:
    0 -1px 0 0 color-mix(in oklab, var(--g-accent) 60%, #fff),
    0 -2px 6px 0 color-mix(in oklab, var(--g-accent) 80%, transparent),
    0 -30px 90px -10px color-mix(in oklab, var(--g-accent) 55%, transparent),
    0 -90px 200px 10px color-mix(in oklab, var(--g-accent) 26%, transparent);
}

@keyframes cs-g-wander {
  0% { --cs-g-x: 22%; --cs-g-y: 30%; }
  50% { --cs-g-x: 70%; --cs-g-y: 58%; }
  100% { --cs-g-x: 48%; --cs-g-y: 24%; }
}
@keyframes cs-g-floor { to { background-position: center var(--grid-gap, 56px); } }
@keyframes cs-g-turn { to { --cs-g-a: 360deg; } }
@keyframes cs-g-aurora {
  0% { transform: skewY(-5deg) translateX(-4%); mask-position: 0 0, 0 0; opacity: .85; }
  50% { transform: skewY(3deg) translateX(2%) scaleY(1.08); mask-position: 60px 0, 0 0; opacity: 1; }
  100% { transform: skewY(-2deg) translateX(5%); mask-position: 140px 0, 0 0; opacity: .9; }
}
@keyframes cs-g-beams {
  0% { background-position: calc(var(--beam-gap, 96px) * 2 - 1px) -30%, calc(var(--beam-gap, 96px) * 5 - 1px) -60%, calc(var(--beam-gap, 96px) * 7 - 1px) -20%, calc(var(--beam-gap, 96px) * 10 - 1px) -90%, calc(var(--beam-gap, 96px) * 4 - 1px) -140%; }
  100% { background-position: calc(var(--beam-gap, 96px) * 2 - 1px) 130%, calc(var(--beam-gap, 96px) * 5 - 1px) 190%, calc(var(--beam-gap, 96px) * 7 - 1px) 120%, calc(var(--beam-gap, 96px) * 10 - 1px) 160%, calc(var(--beam-gap, 96px) * 4 - 1px) 150%; }
}

@media (prefers-reduced-motion: reduce) {
  :is(.cs-ground-dots, .cs-ground-grid, .cs-ground-beams, .cs-ground-conic, .cs-ground-aurora)::before,
  :is(.cs-ground-dots, .cs-ground-beams)::after { animation: none; }
}
}
