/* Masonry-Stil für den Gallery-Block */

/* Core-Flex-Styles für die Masonry-Variante aushebeln */
.wp-block-gallery.is-style-masonry.has-nested-images figure.wp-block-image:not(#individual-image) {
  width: 100% !important;
  margin: 0 0 1em !important;
}

@media (min-width: 600px) {
  .wp-block-gallery.is-style-masonry.has-nested-images.columns-default figure.wp-block-image:not(#individual-image) {
    width: 100% !important;
  }
}

.wp-block-gallery.is-style-masonry.has-nested-images.is-cropped figure.wp-block-image:not(#individual-image) {
  align-self: inherit;
}

.wp-block-gallery.is-style-masonry {
  display: block !important;
  gap: 16px !important;
}

.wp-block-gallery.is-style-masonry figure.wp-block-image {
  display: inline-block;
  break-inside: avoid;
}

.wp-block-gallery.is-style-masonry.columns-default {
  column-count: 3;
}

.wp-block-gallery.is-style-masonry.columns-1 {
  column-count: 1;
}
.wp-block-gallery.is-style-masonry.columns-2 {
  column-count: 2;
}
.wp-block-gallery.is-style-masonry.columns-3 {
  column-count: 3;
}
.wp-block-gallery.is-style-masonry.columns-4 {
  column-count: 4;
}
.wp-block-gallery.is-style-masonry.columns-5 {
  column-count: 5;
}
.wp-block-gallery.is-style-masonry.columns-6 {
  column-count: 6;
}
.wp-block-gallery.is-style-masonry.columns-7 {
  column-count: 7;
}
.wp-block-gallery.is-style-masonry.columns-8 {
  column-count: 8;
}

@media (max-width: 992px) {
  .wp-block-gallery.is-style-masonry {
    column-count: 2 !important;
  }
}

.masonry-gallery-wrapper {
  position: relative;
}

.masonry-gallery-inner {
  max-height: 40vh;
  overflow: hidden;
  transition: max-height 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.masonry-gallery-wrapper.is-expanded .masonry-gallery-inner {
  max-height: 10000px;
}

.masonry-gallery-fade {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 120px;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0) 0%, var(--color-body) 85%);
  backdrop-filter: blur(1px);
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.masonry-gallery-wrapper.is-expanded .masonry-gallery-fade {
  opacity: 0;
}

.masonry-gallery-toggle {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--color-button);
  border: 1px solid var(--color-button);
  color: var(--color-body);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: background 0.2s ease;
}

.masonry-gallery-toggle:hover {
  background: transparent;
  color: var(--color-button);
}

.masonry-gallery-chevron {
  transition: transform 0.35s ease;
}

.masonry-gallery-wrapper.is-expanded .masonry-gallery-toggle .masonry-gallery-chevron {
  transform: rotate(180deg);
}

/* Gilt für Frontend UND Editor-iframe */
.editor-styles-wrapper .wp-block-gallery.is-style-masonry,
.wp-block-gallery.is-style-masonry {
  display: block !important;
  column-count: 3;
  gap: 16px !important;
}

.editor-styles-wrapper .wp-block-gallery.is-style-masonry figure.wp-block-image,
.wp-block-gallery.is-style-masonry figure.wp-block-image {
  display: inline-block;
  break-inside: avoid;
  width: 100% !important;
  margin: 0 0 1em !important;
}
