/* The Site Stage: the ONE surface every component sits on (Kyle, Dec 3: "I really like the main image with the dot
   background and the color it is ... I don't think we should have BRIGHT white ever").
   Colours and grid come from tokens/tokens.json (group "stage"): the blocks between the markers are written by
   `node tools/build-tokens.mjs`, never by hand. Linked by System, the UI review, Skin and the Taste loop, AFTER each
   page's own <style>, so it wins over their old per-ground backgrounds.

   Use:  .kd-stage         any surface (the page's theme picks light / dark; a frame is drawn round it)
         .spec.kd-stage    a component specimen: its ground's --bg becomes the stage, light when the spec has .lt
         .kd-clear         a specimen sitting inside a bigger stage: no surface of its own, the stage shows through */

:root,
.spec:not(.lt) {
  /* tokens:stage.dark */
  --stage: #0d0d09;
  --stage-dots: rgba(216, 206, 195, 0.13);
  --stage-warm: rgba(199, 162, 122, 0.07);
  --stage-vignette: rgba(0, 0, 0, 0.55);
  --stage-frame: rgba(216, 206, 195, 0.10);
  --stage-card: rgba(28, 27, 22, 0.88);
  --stage-tip: rgba(20, 18, 14, 0.96);
  /* /tokens */
}
:root[data-theme="light"],
.spec.lt {
  /* tokens:stage.light */
  --stage: #ebe9e3;
  --stage-dots: rgba(38, 37, 30, 0.12);
  --stage-warm: rgba(106, 86, 64, 0.06);
  --stage-vignette: rgba(120, 100, 70, 0.14);
  --stage-frame: rgba(38, 37, 30, 0.09);
  --stage-card: rgba(242, 241, 237, 0.78);
  --stage-tip: rgba(242, 241, 237, 0.97);
  /* /tokens */
}
:root {
  /* tokens:stage.grid */
  --stage-pitch: 13px;
  --stage-dot: 0.9px;
  /* /tokens */
}

.kd-stage,
.spec.kd-stage.kd-stage.kd-stage.kd-stage {
  background:
    radial-gradient(ellipse 70% 60% at 40% 55%, var(--stage-warm), transparent 75%),
    radial-gradient(ellipse at 50% 50%, transparent 45%, var(--stage-vignette) 100%),
    radial-gradient(circle, var(--stage-dots) var(--stage-dot), transparent calc(var(--stage-dot) + 0.4px)) 0 0 / var(--stage-pitch) var(--stage-pitch),
    var(--stage);
}
.kd-stage:not(.spec) { box-shadow: inset 0 0 0 1px var(--stage-frame); }
/* A specimen's ground (paper, paperd, pavl, night, dusk, forest, pav) all become the one stage. */
.spec.kd-stage.kd-stage { --bg: var(--stage); --tip: var(--stage-tip); }
/* The dots switch (System's canvas toolbar) leaves the stage colour, without the grid. */
.spec.kd-stage.kd-stage.kd-stage.kd-stage:not(.dots) { background: var(--stage); }
.spec.kd-stage.kd-stage.kd-stage.kd-stage.kd-clear.kd-clear { background: transparent; }
