/* Paper tooth, shared by every page except the legal ones.
   One pre-rendered 128px noise tile, not an SVG filter: the filter version was
   re-rasterised by the browser across a 1900px-tall pinned section and cost
   real frame time. The tile is centred on mid-grey and slightly blurred, so it
   reads as paper tooth rather than television static.
   It was a base64 data URI inside hero/code-taste.css, which only index.html
   loads. As a file it is 10.6KB instead of 14.1KB of base64, it is fetched
   once and then served from cache for every other page, and there is still
   only one copy in the repo. */
:root{--paper-grain:url(paper-grain.png);}

/* The recipe: the same tile laid twice at coprime sizes (84 and 131) with an
   offset start. Each alone repeats visibly; together the combined pattern only
   repeats every 84x131px, which no eye picks up. Same image both times, so it
   is decoded once.
   soft-light, not overlay: overlay pushes saturation at both ends and turns
   the gold khaki.
   Only background-image is set, so the element keeps whatever background-color
   it already had and that colour is the bottom layer the two tiles blend into.
   An element whose background is a gradient has to restate it instead, because
   a gradient lives in background-image and would be overwritten. */
.wh-grain{
  background-image:var(--paper-grain),var(--paper-grain);
  background-position:0 0,37px 61px;
  background-size:84px 84px,131px 131px;
  background-repeat:repeat,repeat;
  background-blend-mode:soft-light,soft-light;
}

/* Where it goes. Applied to the page grounds and the large flat bands, not to
   the small cards that sit on top of them: the approach section set that
   precedent, graining its shell and its cards but nothing smaller.
   Deliberately left out:
     - the hero (#page and #bg-canvas), which is a live canvas; a blended layer
       over it would repaint every frame
     - met-traders' .rw-pill, which is a client brand colour and must stay the
       colour it is
     - privacy.html, terms.html and cookies.html, which carry no grain at all
   #philosophy's shell and #process's .pw-panel already carry it in their own
   stylesheets and are not repeated here. */
#standards,            /* index */
/* #faq, #pricing and #contact were removed 1 November 2026. Their ground is pure
   white, and soft-light grain on #FFF bakes to flat #FFF (_qa/grain-bake.html
   ?ground=%23FFFFFF: sd 0), so the texture never showed there. What did show was
   the blend's edge: at fractional scales (Windows 125%/150%, browser zoom, the
   DevTools device frame) Chrome greyed the part-covered pixel row where two of
   these sections meet, a full-width hairline. */
.brand-option,
.craft-hero,           /* work */
.lp-hero,              /* audit, financial-advisers, met-traders */
body .lp-card.theme-dark,  /* only the dark variant: plain .lp-card is
                              background:transparent, where a blended tile has
                              nothing to blend into and paints as raw grey
                              noise. The body prefix lifts specificity over the
                              page's own .lp-card.theme-dark{background:...}
                              shorthand, which would otherwise reset the
                              background-image back to none. */
.lp-cta-band,
.case-close,
.start-form-wrap,      /* start */
body.wh-grain,         /* 404, which has no section ground of its own */
#footer{               /* every page */
  background-image:var(--paper-grain),var(--paper-grain);
  background-position:0 0,37px 61px;
  background-size:84px 84px,131px 131px;
  background-repeat:repeat,repeat;
  background-blend-mode:soft-light,soft-light;
}

/* The approach shell carries the grain already composited, as one opaque tile
   with no blend mode. It is the only ground where the shared two-layer recipe
   was costing frames: the section is ~2,000px tall and the glyph canvases are
   animating over it, and measured while scrolling it ran at 56.9fps with a p95
   of 32.8ms. Dropping to one soft-light layer gave 59.1/17.5 and dropping the
   blend entirely gave 60fps, p95 17.5, p99 17.6, nothing dropped -- so each
   blend layer is the cost, and only zero is clean.
   Pre-compositing is possible here and nowhere else because this ground is a
   flat var(--bg) rather than a gradient, so the whole stack collapses to a
   picture. It only tiles, though, if the two layers share a period: 84 and
   131 repeat together every lcm = 11,004px, so the second layer moved to 126px,
   making lcm(84,126) = 252 exactly. _qa/grain-bake.html bakes the tile through
   Skia's own soft-light and measures the result against today's: mean identical
   to 0.01 of a level, standard deviation at 0.986, low-frequency energy at
   0.97-0.98, and the repeat edge stepping less than ordinary adjacent noise, so
   there is no seam. The 1.4% contrast shortfall is five hundredths of one level
   and is left uncorrected -- an 8-bit contrast pass can only overshoot it.
   Every other ground keeps the shared two-layer recipe above, untouched. */

.page-flow{
  background-image:url(flow-grain-baked.webp);
  background-position:0 0;
  background-size:252px 252px;
  background-repeat:repeat;
  background-blend-mode:normal;
}

/* .page-flow carries the grain pre-composited too, for the same reason as the
   approach shell: it wraps the whole body of work/audit/financial-advisers/
   met-traders, and two soft-light layers over something that tall cost real
   frames. Measured on work.html, scrolling, order-fair over 1200+ frames per
   variant: with the blend 55.9fps and 2% of frames dropped, without it 58.6fps
   and 0.4%.
   All four pages compute this ground as rgb(250,250,247), checked rather than
   assumed, so one tile serves them all. Baked by _qa/grain-bake.html the same
   way (?ground=%23FAFAF7): mean identical, standard deviation at 0.987, and the
   repeat edge stepping 2/255 against ordinary adjacent noise of 3, so no seam.
   On a near-white ground the texture has only 10 distinct colours, so the tile
   is 8.8KB -- smaller than the shared paper-grain.png it replaces here. */
#philosophy[data-simple-entrance] .approach-shell{
  background-image:url(approach-grain-baked.webp);
  background-position:0 0;
  background-size:252px 252px;
  background-repeat:repeat;
  background-blend-mode:normal;
}
