/* ————
Blur Edges (.has-blur-edges, js/blur-edges.js)
Blurs a block's content as it scrolls to the top and bottom of the screen. Add the class to a Group under
Advanced > Additional CSS class(es); the Focus block (template-parts/blocks/focus.php) has it built in.
- Two bands (::before/::after) stick to the top and bottom of the screen. They're sticky within the block,
  so they only show over it, never over the blocks around it
- js/blur-edges.js fades each band in once the block's edge has scrolled past that edge of the screen, so
  content near the block's top or bottom isn't blurred while it's in the middle of the screen
- For blocks whose content runs top to bottom, e.g. a plain Group. In a Row, Stack or Grid the bands would be
  laid out as items, so put the class on a plain Group around it instead
- Front end only; the editor shows the block without the bands
——— */

.has-blur-edges {
  --blur-edges-height: 25vh;  /* height of each band: 25% of the screen height */
  --blur-edges-amount: 10px;  /* blur at the screen edge, fading to none at the band's inner edge */
  /* Sticky keeps a band's margin box inside the block, and the negative margins below shrink that to a line
     at the band's outer edge. So near the block's end the top band would hang up to its full height over the
     block after it (and the bottom band over the block before it, near the start). Clip them at the block's
     edges. Unlike 'hidden', 'clip' doesn't make the block a scroll container, so sticky still works in it */
  overflow-y: clip;
}

.has-blur-edges::before,
.has-blur-edges::after {
  content: '';
  position: -webkit-sticky;
  position: sticky;
  z-index: 2; /* above the content */
  display: block;
  height: var(--blur-edges-height);
  pointer-events: none; /* keep links under them clickable */
  -webkit-backdrop-filter: blur(10px); /* older Safari ignores var() here; keep in step with --blur-edges-amount */
  backdrop-filter: blur(var(--blur-edges-amount));
}

/* Fully blurred at the screen edge, fading to sharp. The negative margins overlap the bands onto the
   content instead of adding to the block's height. --blur-edges-top/bottom: 0–1, set by js/blur-edges.js */
.has-blur-edges::before {
  top: 0;
  margin-bottom: calc(-1 * var(--blur-edges-height));
  opacity: var(--blur-edges-top, 1);
  -webkit-mask-image: linear-gradient(to bottom, #000, transparent);
  mask-image: linear-gradient(to bottom, #000, transparent);
}

.has-blur-edges::after {
  bottom: 0;
  margin-top: calc(-1 * var(--blur-edges-height));
  opacity: var(--blur-edges-bottom, 1);
  -webkit-mask-image: linear-gradient(to top, #000, transparent);
  mask-image: linear-gradient(to top, #000, transparent);
}
