/*
 * Scala's original Figma vectors. Left/right names identify the decorated side.
 * A Group uses up to its full width; a Cover uses half, like the home hero.
 * Both are capped at the original 640px width to protect content on wide screens.
 * Optional CSS overrides: --scala-notch-width and --scala-notch-color.
 * The default warm colour matches the adjoining light sections in the design.
 */
:is(.wp-block-group, .wp-block-cover):is(
  .is-style-notch-left,
  .is-style-notch-right,
  .is-style-notch-2-left,
  .is-style-notch-2-right
) {
  position: relative;
  isolation: isolate;
  --scala-notch-span: var(--scala-notch-width, min(100%, 640px));
  --scala-notch-fill: var(--scala-notch-color, var(--wp--preset--color--warm, #f2eee8));
}

.wp-block-cover:is(.is-style-notch-left, .is-style-notch-right, .is-style-notch-2-left, .is-style-notch-2-right) {
  --scala-notch-span: var(--scala-notch-width, min(50%, 640px));
}

@media (max-width: 781px) {
  :is(.wp-block-group, .wp-block-cover):is(
    .is-style-notch-left,
    .is-style-notch-right,
    .is-style-notch-2-left,
    .is-style-notch-2-right
  ) {
    --scala-notch-span: var(--scala-notch-width, 100%);
  }  
}

/* Reserve space without clipping content, editor controls or focus outlines.
 * Explicit padding chosen in the block editor takes precedence over this default.
 */
:is(.wp-block-group, .wp-block-cover):is(.is-style-notch-left, .is-style-notch-right) {
  padding-bottom: 12rem;
}

:is(.wp-block-group, .wp-block-cover):is(.is-style-notch-2-left, .is-style-notch-2-right) {
  padding-top: 9rem;
}

:is(.wp-block-group, .wp-block-cover):is(.is-style-notch-left, .is-style-notch-right)::after,
:is(.wp-block-group, .wp-block-cover):is(.is-style-notch-2-left, .is-style-notch-2-right)::after {
  content: "";
  position: absolute;
  z-index: 2;
  display: block;
  width: var(--scala-notch-span);
  max-width: none;
  margin: 0;
  background: var(--scala-notch-fill);
  pointer-events: none;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
}

:is(.wp-block-group, .wp-block-cover):is(.is-style-notch-left, .is-style-notch-right)::after {
  /* One-pixel bleed prevents an antialiased seam at fractional widths. */
  bottom: -1px;
  aspect-ratio: 640 / 152;
  -webkit-mask-image: url("../images/notch.svg");
  mask-image: url("../images/notch.svg");
  /* The source vector is rotated 180 degrees in the Figma hero. */
  transform: rotate(180deg);
}

:is(.wp-block-group, .wp-block-cover):is(.is-style-notch-2-left, .is-style-notch-2-right)::after {
  top: 0;
  aspect-ratio: 639 / 103.195;
  -webkit-mask-image: url("../images/notch-2.svg");
  mask-image: url("../images/notch-2.svg");
}

:is(.wp-block-group, .wp-block-cover):is(.is-style-notch-right, .is-style-notch-2-right)::after {
  right: 0;
}

:is(.wp-block-group, .wp-block-cover):is(.is-style-notch-left, .is-style-notch-2-left)::after {
  left: 0;
}

:is(.wp-block-group, .wp-block-cover).is-style-notch-left::after {
  transform: rotate(180deg) scaleX(-1);
}

:is(.wp-block-group, .wp-block-cover).is-style-notch-2-left::after {
  transform: scaleX(-1);
}

/* Figma notch 3 is a 91px rise over the 640px-wide, 740px-high image.
 * Clip the media, not its figure: captions and the editor remain accessible.
 * A proportional polygon keeps the edge responsive for any image dimensions.
 */
.wp-block-image.is-style-notch-3 img {
  -webkit-clip-path: polygon(0 0, 100% 0, 100% 87.702703%, 0 100%);
  clip-path: polygon(0 0, 100% 0, 100% 87.702703%, 0 100%);
}

/* Banner clipper: a 71px top cut over the 600px-high Figma banner image.
 * Use percentages so the edge scales with responsive and resized images.
 * Target only the image, including linked images and the editor's media wrapper;
 * captions, selection outlines and resize controls stay outside the clipping.
 */
.wp-block-image.is-style-banner-clip img {
  -webkit-clip-path: polygon(0 11.833333%, 100% 0, 100% 100%, 0 100%);
  clip-path: polygon(0 11.833333%, 100% 0, 100% 100%, 0 100%);
}

@media (max-width: 781px) {
  :is(.wp-block-group, .wp-block-cover):is(.is-style-notch-left, .is-style-notch-right) {
    padding-bottom: clamp(7rem, 28vw, 12rem);
  }
  :is(.wp-block-group, .wp-block-cover):is(.is-style-notch-2-left, .is-style-notch-2-right) {
    padding-top: clamp(5rem, 18vw, 9rem);
  }
  /* Keep the hero detail on its selected side when columns stack. */
  .wp-block-cover:is(.is-style-notch-left, .is-style-notch-right, .is-style-notch-2-left, .is-style-notch-2-right) {
    --scala-notch-span: var(--scala-notch-width, min(75%, 640px));
  }
}
