/* Photo-only gallery; photos remain standard editable WordPress blocks. */
.union-photo-section.wp-block-group {
  padding-block: 48px;
  background: #edf4e9;
}

.union-photo-section .wrap.wp-block-group {
  position: relative;
}

/* Apply the simple layout to galleries already saved in the Site Editor. */
.union-photo-section .union-photo-head.wp-block-group,
.union-photo-section .union-photo-caption.wp-block-group,
.union-photo-section .union-photo-foot.wp-block-group,
.union-photo-section .union-photo-image figcaption {
  display: none;
}

.union-photo-section .union-photo-grid.wp-block-group {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin: 0;
}

.union-photo-section .union-photo-card.wp-block-group {
  display: block;
  min-width: 0;
  min-height: 0;
  margin: 0;
  overflow: hidden;
  border: 0;
  border-radius: 12px;
  background: #dfe8dc;
}

.union-photo-section .union-photo-card-main {
  grid-column: auto;
  grid-row: auto;
}

.union-photo-section .union-photo-image.wp-block-image {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 0;
  height: auto;
  aspect-ratio: 3 / 2;
  margin: 0;
  overflow: hidden;
}

.union-photo-section .union-photo-image img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

/* Public slideshow. Controls sit over the image rather than in extra rows. */
.union-photo-section.union-gallery-ready .union-photo-grid.wp-block-group {
  display: block;
  position: relative;
  height: clamp(300px, 48vw, 620px);
  overflow: hidden;
  border-radius: 12px;
  background: #dfe8dc;
  touch-action: pan-y;
}

.union-photo-section.union-gallery-ready .union-gallery-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 650ms ease;
}

.union-photo-section.union-gallery-ready .union-gallery-slide.is-active {
  z-index: 1;
  opacity: 1;
  pointer-events: auto;
}

.union-photo-section.union-gallery-ready .union-photo-image.wp-block-image {
  height: 100%;
  aspect-ratio: auto;
}

.union-photo-section.union-gallery-ready .is-active .union-photo-image img {
  animation: union-gallery-drift 5.5s linear both;
}

.union-photo-section.union-gallery-ready.is-gallery-paused .is-active .union-photo-image img {
  animation-play-state: paused;
}

.union-photo-section .union-gallery-toolbar {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: block;
  margin: 0;
  padding: 0;
  pointer-events: none;
}

.union-photo-section .union-gallery-counter {
  display: none;
}

.union-photo-section .union-gallery-toolbar button {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .88);
  color: #18392b;
  box-shadow: 0 3px 16px rgba(0, 0, 0, .16);
  font: inherit;
  cursor: pointer;
  pointer-events: auto;
}

.union-photo-section .union-gallery-toolbar .union-gallery-rotation {
  position: absolute;
  top: 16px;
  right: 16px;
}

.union-photo-section .union-gallery-rotation svg {
  display: block;
  margin: auto;
}

.union-photo-section .union-gallery-arrows {
  position: absolute;
  top: 50%;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  transform: translateY(-50%);
  pointer-events: none;
}

.union-photo-section .union-gallery-arrows button {
  font-size: 21px;
  line-height: 1;
}

.union-photo-section .union-gallery-toolbar button:hover {
  background: #fff;
}

.union-photo-section .union-gallery-thumbs {
  position: absolute;
  left: 50%;
  bottom: 16px;
  z-index: 5;
  display: flex;
  gap: 2px;
  margin: 0;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .28);
  transform: translateX(-50%);
}

.union-photo-section .union-gallery-thumb {
  display: grid;
  place-items: center;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  max-width: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.union-photo-section .union-gallery-thumb::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 99px;
  background: #fff;
  opacity: .55;
  transition: width 180ms ease, opacity 180ms ease;
}

.union-photo-section .union-gallery-thumb[aria-pressed="true"]::before {
  width: 16px;
  opacity: 1;
}

.union-photo-section .union-gallery-thumb:hover::before {
  opacity: 1;
}

.union-photo-section .union-gallery-thumb img {
  display: none;
}

.union-photo-section .union-gallery-toolbar button:focus-visible,
.union-photo-section .union-gallery-thumb:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.union-gallery-announcement {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes union-gallery-drift {
  from { transform: scale(1); }
  to { transform: scale(1.025); }
}

@media (max-width: 900px) {
  .union-photo-section .union-photo-grid.wp-block-group {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .union-photo-section.wp-block-group {
    padding-block: 32px;
  }

  .union-photo-section .union-photo-grid.wp-block-group {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }

  .union-photo-section.union-gallery-ready .union-photo-grid.wp-block-group {
    height: clamp(260px, 82vw, 420px);
  }

  .union-photo-section .union-gallery-toolbar .union-gallery-rotation {
    top: 12px;
    right: 12px;
  }

  .union-photo-section .union-gallery-arrows {
    left: 12px;
    right: 12px;
  }

  .union-photo-section .union-gallery-thumbs {
    bottom: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .union-photo-section.union-gallery-ready .union-gallery-slide,
  .union-photo-section .union-gallery-thumb::before {
    transition: none;
  }

  .union-photo-section.union-gallery-ready .is-active .union-photo-image img {
    animation: none;
  }
}
