/* ---------------------------------------------------------------------------
   Film grain over photos and video, to match the Magic Box decks (2026-10-25).

   One static noise tile (assets/img/brand/grain-tile.png, 256 px drawn at
   128 CSS px so it is sharp on phones, 25 KB, grey 128 is neutral) repeats
   over each photo container as a ::before layer. It is the site's existing
   .grain noise (feTurbulence fractalNoise, now 0.7, 2 octaves, greyscale,
   contrast 2.4) rendered once to a bitmap, because an SVG filter tile is
   recomputed on every raster tile and doubled paint cost on phones. It is
   monochrome, about one CSS pixel per speck, blended with soft-light so skin,
   concrete and blacks keep their tone, and it never animates. The image files
   are untouched, so the AVIF and WebP pipeline is unchanged.

   --mb-grain is the only strength knob (0 turns the grain off everywhere).
   At .45 it adds about 3.5 levels (of 255) of fine noise at every tone, which
   is the grain measured in the deck's spotlight photos.

   To grain a new photo container, add its selector to the two lists below
   (the second one only if the container has no position of its own). Never
   add logos, floor plans, maps, icons, text blocks, ShoSoft UI frames, form
   fields or the cookie card.
   --------------------------------------------------------------------------- */
:root{
  --mb-grain:.45;
  --mb-grain-on:"";
  --mb-grain-size:128px;
}
@media (prefers-reduced-transparency:reduce){
  :root{--mb-grain-on:none}
}

/* Photo containers. Each one keeps its own size and position; isolation only
   keeps the grain inside the photo, under any text or pill drawn on it. */
:is(
  .hero-media,
  .collage-stage,
  .fs-card,
  .qi-card:not(.qi-card--book),
  .hv-vcard,
  .spotlight-card,
  .np-shot:not(.np-shot--plan):not(:has(img[src*="shosoft"])),
  .fe-ph,
  .feat-media,
  .spot-act-media,
  .vid-card,
  .kt-frame:not(.kt-frame--plan),
  .news-card .thumb,
  .explore-card
){isolation:isolate}

:is(
  .hero-media,
  .collage-stage,
  .fs-card,
  .qi-card:not(.qi-card--book),
  .hv-vcard,
  .spotlight-card,
  .np-shot:not(.np-shot--plan):not(:has(img[src*="shosoft"])),
  .fe-ph,
  .feat-media,
  .spot-act-media,
  .vid-card,
  .kt-frame:not(.kt-frame--plan),
  .news-card .thumb,
  .explore-card
)::before{
  content:var(--mb-grain-on);
  position:absolute;
  inset:0;
  z-index:1;
  pointer-events:none;
  border-radius:inherit;
  background:url("../assets/img/brand/grain-tile.png") 0 0/var(--mb-grain-size) var(--mb-grain-size) repeat;
  mix-blend-mode:soft-light;
  opacity:var(--mb-grain);
}

/* Containers that were static get a position so the layer has a box to fill.
   No offsets, so nothing moves. */
:is(.fs-card, .news-card .thumb){position:relative}

/* The spaces strip card is photo on top, words below: grain the photo only. */
.fs-card::before{inset:0 0 auto 0;aspect-ratio:16/10;border-radius:0}

/* Words and labels drawn on a photo stay above the grain. */
.collage-center,
.kt-frame .kt-ph-label,
.kt-frame .kt-concept{z-index:2}
@media (max-width:900px){
  .collage-stage:not(.has-belts) .collage-center{position:relative}
}

/* The heroes and gradient panels that already carried .grain use the same
   tile, blend and strength, so there is one grain across the site. */
.grain::after{
  content:var(--mb-grain-on);
  background-image:url("../assets/img/brand/grain-tile.png");
  background-size:var(--mb-grain-size) var(--mb-grain-size);
  mix-blend-mode:soft-light;
  opacity:var(--mb-grain);
}

/* Cream stays cream (2026-10-26). Grain belongs on photos and the brand
   gradients only. The Let's Make Magic cards carry .grain for their gradient
   ring, so their cream panel sits above the layer. The case study photo grid
   is no longer grained as one block, because its cream gutters turned grey.
   */
:is(.cta-outer, .cs-cta-outer, .v-cta-outer).grain > :is(.cta-inner, .cs-cta-inner, .v-cta-inner){position:relative;z-index:2}
