/* Native Galerieblöcke: identische Layouts im Frontend und Block-Editor. */
figure.wp-block-gallery.has-nested-images:is(.is-style-people-free, .is-style-nature-wild, .is-style-products-grid) {
  --portfolio-gap: clamp(1rem, 3vw, 2rem);
  box-sizing: border-box;
  gap: var(--portfolio-gap);
}

/* Die gleiche Selektorform wie WordPress setzt dessen Flex-Breiten zurück. */
figure.wp-block-gallery.has-nested-images:is(.is-style-people-free, .is-style-nature-wild, .is-style-products-grid) > figure.wp-block-image:not(#individual-image) {
  box-sizing: border-box;
  min-width: 0;
  width: auto;
  max-width: none;
  margin: 0;
  flex: initial;
}

figure.wp-block-gallery.has-nested-images:is(.is-style-people-free, .is-style-nature-wild, .is-style-products-grid) > figure.wp-block-image:not(#individual-image) > a {
  display: block;
  width: 100%;
  height: auto;
  margin: 0;
  flex: initial;
}

figure.wp-block-gallery.has-nested-images:is(.is-style-people-free, .is-style-nature-wild, .is-style-products-grid) > figure.wp-block-image:not(#individual-image) img {
  display: block;
  width: 100%;
  height: auto;
}

/* Menschen: eine freie, asymmetrische Bildkomposition im Rhythmus von 6 Bildern. */
figure.wp-block-gallery.has-nested-images.is-style-people-free {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  align-items: start;
  row-gap: clamp(2rem, 6vw, 4rem);
  padding: 1.5rem 1rem;
}

figure.wp-block-gallery.has-nested-images.is-style-people-free > figure.wp-block-image:not(#individual-image) {
  grid-column: span 6;
  padding: clamp(0.35rem, 1vw, 0.65rem);
  background: #fff;
  box-shadow: 0 0.5rem 1.75rem rgb(32 35 33 / 9%);
}

figure.wp-block-gallery.has-nested-images.is-style-people-free > figure.wp-block-image:nth-of-type(6n + 1):not(#individual-image) {
  grid-column: 1 / span 7;
  transform: rotate(-1.4deg);
}

figure.wp-block-gallery.has-nested-images.is-style-people-free > figure.wp-block-image:nth-of-type(6n + 2):not(#individual-image) {
  grid-column: 9 / span 4;
  align-self: center;
  transform: rotate(3deg);
}

figure.wp-block-gallery.has-nested-images.is-style-people-free > figure.wp-block-image:nth-of-type(6n + 3):not(#individual-image) {
  grid-column: 2 / span 5;
  transform: rotate(1.8deg);
}

figure.wp-block-gallery.has-nested-images.is-style-people-free > figure.wp-block-image:nth-of-type(6n + 4):not(#individual-image) {
  grid-column: 8 / span 5;
  align-self: center;
  transform: rotate(-2deg);
}

figure.wp-block-gallery.has-nested-images.is-style-people-free > figure.wp-block-image:nth-of-type(6n + 5):not(#individual-image) {
  grid-column: 1 / span 7;
  transform: rotate(-0.8deg);
}

figure.wp-block-gallery.has-nested-images.is-style-people-free > figure.wp-block-image:nth-of-type(6n + 6):not(#individual-image) {
  grid-column: 9 / span 4;
  align-self: center;
  transform: rotate(2deg);
}

/* Natur: unterschiedlich hohe Bilder in lockeren, leicht versetzten Spalten. */
figure.wp-block-gallery.has-nested-images.is-style-nature-wild {
  display: block;
  columns: 3;
  column-gap: var(--portfolio-gap);
  padding: 1rem 0.5rem;
}

figure.wp-block-gallery.has-nested-images.is-style-nature-wild > figure.wp-block-image:not(#individual-image) {
  display: inline-block;
  width: 100%;
  margin: 0 0 var(--portfolio-gap);
  break-inside: avoid;
  vertical-align: top;
  overflow: hidden;
  border-radius: 0.25rem 1.2rem 0.5rem 1rem;
  box-shadow: 0 0.3rem 1rem rgb(32 35 33 / 7%);
}

figure.wp-block-gallery.has-nested-images.is-style-nature-wild > figure.wp-block-image:nth-of-type(3n + 1):not(#individual-image) {
  margin-top: 0.5rem;
  transform: rotate(-0.8deg);
}

figure.wp-block-gallery.has-nested-images.is-style-nature-wild > figure.wp-block-image:nth-of-type(3n + 2):not(#individual-image) {
  margin-top: 1.75rem;
  border-radius: 1rem 0.3rem 1.25rem 0.5rem;
  transform: rotate(1deg);
}

figure.wp-block-gallery.has-nested-images.is-style-nature-wild > figure.wp-block-image:nth-of-type(3n):not(#individual-image) {
  transform: rotate(-0.3deg);
}

figure.wp-block-gallery.has-nested-images.is-style-nature-wild > figure.wp-block-image:focus-within {
  outline: 2px solid currentColor;
  outline-offset: 4px;
}

/* Produkte: gleichmäßige, quadratische Bildfelder mit einheitlichen Abständen. */
figure.wp-block-gallery.has-nested-images.is-style-products-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  gap: 1rem;
}

figure.wp-block-gallery.has-nested-images.is-style-products-grid > figure.wp-block-image:not(#individual-image) {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  place-items: center;
  min-height: 0;
  aspect-ratio: 1;
  padding: clamp(0.5rem, 1.5vw, 1rem);
  border: 1px solid #d8dcd6;
  background: #fff;
}

figure.wp-block-gallery.has-nested-images.is-style-products-grid > figure.wp-block-image:not(#individual-image) > a {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
}

figure.wp-block-gallery.has-nested-images.is-style-products-grid > figure.wp-block-image:not(#individual-image) img {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
}

figure.wp-block-gallery.has-nested-images.is-style-products-grid > figure.wp-block-image:not(#individual-image) figcaption {
  grid-row: 2;
  position: static;
  padding: 0.75rem 0 0;
  color: inherit;
  background: none;
  text-shadow: none;
}

/* Auf kleinen Displays ruhiger anordnen und gedrehte Randüberstände vermeiden. */
@media (max-width: 640px) {
  figure.wp-block-gallery.has-nested-images.is-style-people-free {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    padding: 0.5rem 0;
  }

  figure.wp-block-gallery.has-nested-images.is-style-people-free > figure.wp-block-image:nth-of-type(n):not(#individual-image) {
    grid-column: auto;
    align-self: start;
    transform: none;
  }

  figure.wp-block-gallery.has-nested-images.is-style-nature-wild {
    columns: 2;
    padding: 0;
  }

  figure.wp-block-gallery.has-nested-images.is-style-nature-wild > figure.wp-block-image:nth-of-type(n):not(#individual-image) {
    margin-top: 0;
    transform: none;
  }

  figure.wp-block-gallery.has-nested-images.is-style-products-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 380px) {
  figure.wp-block-gallery.has-nested-images.is-style-people-free {
    grid-template-columns: minmax(0, 1fr);
  }

  figure.wp-block-gallery.has-nested-images.is-style-nature-wild {
    columns: 1;
  }
}
