/* ==========================================================================
   WP Block Gallery → Swiper Slideshow Overrides
   Scoped to .wp-block-gallery so we don't affect other gallery/figure usage.
   ========================================================================== */

/* --- Reset the flex grid layout that WP sets on the gallery --- */

.wp-block-gallery.wp-block-gallery-slideshow {
  display: block;        /* override: display: flex / is-layout-flex */
  flex-wrap: unset;      /* override: flex-wrap: wrap */
  align-items: unset;    /* override: align-items: center / normal */
  gap: 0;               /* override: gallery gap custom properties */
  margin: 0;            /* override: figure margin resets */
  position: relative;
  width: 100%;
  --wp-gallery-slideshow-height: clamp(240px, 52vw, 600px);
  height: var(--wp-gallery-slideshow-height);
  max-height: 600px;
  overflow: hidden;
}

/* --- Override the column-width calc on child figures --- */

.wp-block-gallery.wp-block-gallery-slideshow .swiper-slide {
  width: 100% !important;  /* override: calc(33.33% - …) and calc(50% - …) */
  height: 100%;
  flex-shrink: 0;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
}

.wp-block-gallery.wp-block-gallery-slideshow figure.wp-block-image {
  width: 100% !important;  /* override: column width calcs */
  height: 100%;
  max-width: 100%;
  margin: 0;              /* override: margin: 1em 0 / 1em 40px */
  flex-grow: unset;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- Image styles scoped under the slideshow --- */

.wp-block-gallery.wp-block-gallery-slideshow figure.wp-block-image img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain !important;   /* override: object-fit: cover from is-cropped */
  object-position: center center !important;
  border-radius: 8px;
}

/* --- Swiper pagination --- */

.wp-block-gallery.wp-block-gallery-slideshow .wp-block-gallery-slideshow__pagination {
  position: relative;
  margin-top: 12px;
  text-align: center;
}

.wp-block-gallery.wp-block-gallery-slideshow .wp-block-gallery-slideshow__pagination .swiper-pagination-bullet {
  width: 10px;
  height: 10px;
  background: #ccc;
  opacity: 1;
  margin: 0 5px;
  transition: background 0.3s ease;
}

.wp-block-gallery.wp-block-gallery-slideshow .wp-block-gallery-slideshow__pagination .swiper-pagination-bullet-active {
  background: #333;
}

/* --- Swiper navigation arrows --- */

.wp-block-gallery.wp-block-gallery-slideshow .swiper-button-prev,
.wp-block-gallery.wp-block-gallery-slideshow .swiper-button-next {
  color: #fff;
  top: calc(50% - 20px); /* offset for pagination height */
  width: 40px;
  height: 40px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 50%;
  transition: background 0.3s ease;
}

.wp-block-gallery.wp-block-gallery-slideshow .swiper-button-prev:hover,
.wp-block-gallery.wp-block-gallery-slideshow .swiper-button-next:hover {
  background: rgba(0, 0, 0, 0.6);
}

.wp-block-gallery.wp-block-gallery-slideshow .swiper-button-prev::after,
.wp-block-gallery.wp-block-gallery-slideshow .swiper-button-next::after {
  font-size: 18px;
}

/* --- Ensure .is-layout-flex on the gallery itself doesn't interfere --- */

.wp-block-gallery.wp-block-gallery-slideshow.is-layout-flex {
  display: block;
  gap: 0;
}

.wp-block-gallery.wp-block-gallery-slideshow .swiper-wrapper {
  height: 100%;
}

@media (max-width: 767px) {
  .wp-block-gallery.wp-block-gallery-slideshow {
    --wp-gallery-slideshow-height: clamp(220px, 64vw, 420px);
  }
}

/* --- Override any post-template specific margin on images inside gallery --- */

.post-default-template .wp-block-gallery.wp-block-gallery-slideshow .wp-block-image {
  margin-top: 0;
}

.post-default-template .wp-block-gallery.wp-block-gallery-slideshow .wp-block-image img {
  margin-bottom: 0;
}
