/* Treatments: optional finishes, each switched by a word in <html data-fx="…">
   (scripts/treatments.js). Strengths are tokens (tokens.css, "Treatments"). */

/* Grain: one still tile of noise over the whole window, above everything.
   Plain opacity, no blend mode: a blended layer over the page's canvases would make the browser
   composite the whole window through it on every frame. */
.fx-grain{
  display:none;
  inset:0;
  opacity:var(--grain-strength);
  pointer-events:none;
  position:fixed;
  z-index:var(--z-grain);
}
:root[data-fx~="grain"] .fx-grain{
  display:block;
}

/* Glow and tint: the contour maps read these off their host and draw them (graphics.js). */
:root[data-fx~="glow"]{
  --gfx-glow:var(--glow-strength);
}
:root[data-fx~="tint"]{
  --gfx-tint:var(--tint-strength);
}

/* Pen: the live graphics read these off their host and draw with them (graphics.js, penLine). */
:root[data-fx~="pen"]{
  --gfx-pen:var(--pen-pressure);
  --gfx-pen-wobble:var(--pen-wobble);
}

/* Bleed: each element that bleeds is pointed at the SVG filter for its size of type
   (--bleed-filter, set with data-bleed by scripts/treatments.js, which builds the filters). */
:root[data-fx~="bleed"] [data-bleed="type"],
:root[data-fx~="pen-type"] [data-bleed="type"],
:root[data-fx~="pen-type"] [data-bleed="shape"]{
  filter:var(--bleed-filter);
}
/* A layer of its own, so a heading is filtered once and then only moved: without it Safari makes
   the pen's noise again on every frame that something moves behind the heading.
   For Safari only (the `font` keyword is one only WebKit knows). Chromium does the opposite: an
   element that is a layer and has a filter is filtered again, on the graphics card, every frame
   the window is drawn, whether or not anything changed; left in its parent's layer it is filtered
   once, when that layer is painted. */
@supports (font:-apple-system-body){
  :root[data-fx~="pen-type"] :is([data-bleed="type"],[data-bleed="shape"]){
    will-change:transform;
  }
}
/* the filters' own svg takes no room */
.fx-defs{
  height:0;
  position:absolute;
  width:0;
}
