/**
 * Optional paper texture overlay (M8).
 *
 * A seamless mid-grey tile painted OVER the block's background colour but UNDER
 * its content: the wrapper gets `position: relative; isolation: isolate` and the
 * tile lives on a `::before` layer with `z-index: -1`, so it never covers text
 * and never creates horizontal overflow (the layer is `inset: 0` inside the
 * element itself). Mid-grey + soft-light/overlay leaves the colour unchanged
 * and only adds the paper's light/dark variation. Works in both themes because
 * it only modulates whatever background is already there.
 *
 * Bands: their cut edges are SVGs *inside* the band, so they paint above the
 * texture layer like any other content. No special-casing needed.
 *
 * Fallback: core/cover renders its background-dim overlay on `::before`, so on
 * covers the texture layer uses `::after` instead (same paint position). No
 * other listed block paints `::before` on its own outer wrapper — inner-element
 * `::before` rules elsewhere in the theme are unaffected.
 *
 * Nothing here animates, so there is no reduced-motion handling beyond that.
 */

/* :where() keeps specificity at zero so a block's own positioning (e.g. the absolutely
   positioned testimonial deck cards) always wins; any positioned element contains the layer. */
:where(.has-edgi-texture) {
	position: relative;
	isolation: isolate;
}
.has-edgi-texture {
	isolation: isolate;
}

.has-edgi-texture:not(.wp-block-cover, .wp-block-edgi-plan, .wp-block-edgi-timeline-item, .wp-block-edgi-testimonial)::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: -1;
	pointer-events: none;
	background-image: var( --edgi-tex );
	background-size: var( --edgi-tex-size, 512px ) auto;
	background-repeat: repeat;
	mix-blend-mode: var( --edgi-tex-blend, soft-light );
	opacity: var( --edgi-tex-opacity, 0.4 );
	border-radius: inherit;
}

/* core/cover reserves ::before for its dim overlay, and some cards draw decoration on
   ::before (Pro plan badge, timeline marker, taped notes): their ::before is left alone
   (excluded above) and the texture uses ::after instead. */
.wp-block-cover.has-edgi-texture::after,
.wp-block-edgi-plan.has-edgi-texture::after,
.wp-block-edgi-timeline-item.has-edgi-texture::after,
.wp-block-edgi-testimonial.has-edgi-texture::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: -1;
	pointer-events: none;
	background-image: var( --edgi-tex );
	background-size: var( --edgi-tex-size, 512px ) auto;
	background-repeat: repeat;
	mix-blend-mode: var( --edgi-tex-blend, soft-light );
	opacity: var( --edgi-tex-opacity, 0.4 );
	border-radius: inherit;
}

/* Print and forced-colours: the paper grain carries no information, hide it. */
@media print {
	.has-edgi-texture:not(.wp-block-cover, .wp-block-edgi-plan, .wp-block-edgi-timeline-item, .wp-block-edgi-testimonial)::before,
	.wp-block-cover.has-edgi-texture::after,
	.wp-block-edgi-plan.has-edgi-texture::after,
	.wp-block-edgi-timeline-item.has-edgi-texture::after,
	.wp-block-edgi-testimonial.has-edgi-texture::after {
		display: none;
	}
}

@media ( forced-colors: active ) {
	.has-edgi-texture:not(.wp-block-cover, .wp-block-edgi-plan, .wp-block-edgi-timeline-item, .wp-block-edgi-testimonial)::before,
	.wp-block-cover.has-edgi-texture::after,
	.wp-block-edgi-plan.has-edgi-texture::after,
	.wp-block-edgi-timeline-item.has-edgi-texture::after,
	.wp-block-edgi-testimonial.has-edgi-texture::after {
		display: none;
	}
}
