/**
 * Gallery page — full-bleed photo grid + lightbox.
 */

.rc-gallery-page {
  background: var(--rc-wash, #f5f7f9);
}

.rc-gallery-hero {
  padding: 5.5rem 0 2.25rem;
}

.rc-gallery-hero .rc-page-hero__lead {
  max-width: 34rem;
}

.rc-gallery {
  width: min(var(--rc-container, 1320px), calc(100% - (2 * var(--rc-gutter, 1rem))));
  margin: 0 auto;
  padding: 1.75rem 0 4rem;
}

.rc-gallery__inner {
  max-width: none;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

/* Override WP block gallery flex layout → dense photo grid */
.rc-gallery-page .wp-block-gallery,
.rc-gallery-page .wp-block-gallery.is-layout-flex,
.rc-gallery-page .wp-block-gallery-is-layout-flex {
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem !important;
  align-items: stretch !important;
  flex-wrap: unset !important;
  margin: 0 !important;
  padding: 0 !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

.rc-gallery-page .wp-block-gallery > .wp-block-image,
.rc-gallery-page .wp-block-gallery figure.wp-block-image {
  position: relative;
  margin: 0 !important;
  width: 100% !important;
  max-width: none !important;
  flex: none !important;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 0.55rem;
  background: #d8dee4;
  cursor: zoom-in;
}

.rc-gallery-page .wp-block-gallery .wp-block-image a,
.rc-gallery-page .wp-block-gallery .wp-block-image img {
  display: block;
  width: 100%;
  height: 100%;
}

.rc-gallery-page .wp-block-gallery .wp-block-image img {
  object-fit: cover;
  object-position: center;
  transition: transform 0.45s ease, filter 0.35s ease;
}

.rc-gallery-page .wp-block-gallery .wp-block-image::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 55%, rgba(10, 16, 22, 0.28) 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.rc-gallery-page .wp-block-gallery .wp-block-image:hover img,
.rc-gallery-page .wp-block-gallery .wp-block-image:focus-within img {
  transform: scale(1.045);
  filter: brightness(1.03);
}

.rc-gallery-page .wp-block-gallery .wp-block-image:hover::after,
.rc-gallery-page .wp-block-gallery .wp-block-image:focus-within::after {
  opacity: 1;
}

.rc-gallery-page .wp-block-gallery .wp-block-image:focus-within {
  outline: 2px solid var(--rc-brand, #17457b);
  outline-offset: 2px;
}

/* —— Lightbox —— */
.rc-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(8, 12, 16, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s ease, visibility 0.22s ease;
}

.rc-lightbox.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.rc-lightbox__dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  width: min(1100px, 100%);
  max-height: min(92vh, 100%);
  outline: none;
}

.rc-lightbox__figure {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: calc(92vh - 3rem);
}

.rc-lightbox__img {
  display: block;
  max-width: 100%;
  max-height: calc(92vh - 3rem);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 0.45rem;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
  transform: translateY(10px) scale(0.98);
  opacity: 0;
  transition: transform 0.28s ease, opacity 0.28s ease;
}

.rc-lightbox.is-open .rc-lightbox__img {
  transform: none;
  opacity: 1;
}

.rc-lightbox__caption {
  margin: 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.85rem;
  text-align: center;
}

.rc-lightbox__count {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  pointer-events: none;
}

.rc-lightbox__btn {
  position: absolute;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.rc-lightbox__btn:hover,
.rc-lightbox__btn:focus-visible {
  background: rgba(255, 255, 255, 0.2);
  outline: none;
}

.rc-lightbox__btn:focus-visible {
  box-shadow: 0 0 0 2px #8fb4e3;
}

.rc-lightbox__close {
  top: 1rem;
  right: 1rem;
}

.rc-lightbox__prev,
.rc-lightbox__next {
  top: 50%;
  transform: translateY(-50%);
}

.rc-lightbox__prev {
  left: 0.75rem;
}

.rc-lightbox__next {
  right: 0.75rem;
}

.rc-lightbox__prev:hover,
.rc-lightbox__next:hover,
.rc-lightbox__prev:focus-visible,
.rc-lightbox__next:focus-visible {
  transform: translateY(-50%);
}

.rc-gallery-page .wp-lightbox-container > button,
.rc-gallery-page .wp-lightbox-overlay {
  display: none !important;
}

body.rc-lightbox-open {
  overflow: hidden;
}

@media (max-width: 980px) {
  .rc-gallery-page .wp-block-gallery,
  .rc-gallery-page .wp-block-gallery.is-layout-flex,
  .rc-gallery-page .wp-block-gallery-is-layout-flex {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .rc-gallery-page .wp-block-gallery,
  .rc-gallery-page .wp-block-gallery.is-layout-flex,
  .rc-gallery-page .wp-block-gallery-is-layout-flex {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem !important;
  }

  .rc-gallery-page .wp-block-gallery > .wp-block-image,
  .rc-gallery-page .wp-block-gallery figure.wp-block-image {
    border-radius: 0.4rem;
  }

  .rc-lightbox__prev,
  .rc-lightbox__next {
    width: 2.35rem;
    height: 2.35rem;
  }

  .rc-lightbox__prev {
    left: 0.35rem;
  }

  .rc-lightbox__next {
    right: 0.35rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rc-gallery-page .wp-block-gallery .wp-block-image img,
  .rc-gallery-page .wp-block-gallery .wp-block-image::after,
  .rc-lightbox,
  .rc-lightbox__img {
    transition: none;
  }

  .rc-gallery-page .wp-block-gallery .wp-block-image:hover img {
    transform: none;
  }
}
