/**
 * EDS Gallery Widget — Frontend Stylesheet
 * eDesign Space · https://edesignspace.com/
 */

/* ── Grid layout ────────────────────────────────────────────────────────────── */
.eds-gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr); /* Elementor responsive selector overrides this */
  gap: 10px;                             /* Elementor responsive selector overrides this */
}

/* Masonry — CSS columns */
.eds-gallery--masonry {
  display: block;
  column-count: 3; /* Elementor selector overrides */
  column-gap: 10px;
}
.eds-gallery--masonry .eds-gallery__item {
  break-inside: avoid;
  margin-bottom: 10px;
  display: block;
}

/* Justified — flex wrap */
.eds-gallery--justified {
  display: flex;
  flex-wrap: wrap;
  gap: var(--eds-gallery-gap, 10px);
}
.eds-gallery--justified .eds-gallery__item { flex: 1 1 200px; }

/* ── Item ─────────────────────────────────────────────────────────────────────── */
.eds-gallery__item {
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.25s ease;
}

/* ── Media wrapper (aspect-ratio box) ───────────────────────────────────────── */
.eds-gallery__media {
  position: relative;
  width: 100%;
  overflow: hidden;
  /* Default 1:1, overridden by inline style per-item */
  padding-bottom: 100%;
}

/* Masonry / justified: let the image define height */
.eds-gallery--masonry .eds-gallery__media,
.eds-gallery--justified .eds-gallery__media {
  padding-bottom: 0 !important;
  height: auto;
}

/* ── Image — ALWAYS fills the media box ─────────────────────────────────────── */
/* Target both the class we inject AND any img WordPress outputs inside the media */
.eds-gallery__img,
.eds-gallery__media > a > img,
.eds-gallery__media > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  transition: transform 0.4s ease, filter 0.3s ease;
}

/* Grid: absolutely fill the ratio box */
.eds-gallery--grid .eds-gallery__img,
.eds-gallery--grid .eds-gallery__media > a > img,
.eds-gallery--grid .eds-gallery__media > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* Masonry / justified: natural height */
.eds-gallery--masonry .eds-gallery__img,
.eds-gallery--masonry .eds-gallery__media > a > img,
.eds-gallery--masonry .eds-gallery__media > img,
.eds-gallery--justified .eds-gallery__img,
.eds-gallery--justified .eds-gallery__media > a > img,
.eds-gallery--justified .eds-gallery__media > img {
  position: static;
  height: auto;
}

/* Image hover effects */
.eds-gallery--img-zoom-in  .eds-gallery__item:hover .eds-gallery__img,
.eds-gallery--img-zoom-in  .eds-gallery__item:hover .eds-gallery__media img { transform: scale(1.08); }

.eds-gallery--img-zoom-out .eds-gallery__img,
.eds-gallery--img-zoom-out .eds-gallery__media img                           { transform: scale(1.08); }
.eds-gallery--img-zoom-out .eds-gallery__item:hover .eds-gallery__img,
.eds-gallery--img-zoom-out .eds-gallery__item:hover .eds-gallery__media img  { transform: scale(1); }

/* ── Link / lightbox trigger fills the whole box ────────────────────────────── */
.eds-gallery__lb-trigger,
.eds-gallery__link {
  display: block;
  position: absolute;
  inset: 0;
  z-index: 1;
}
.eds-gallery--masonry .eds-gallery__lb-trigger,
.eds-gallery--masonry .eds-gallery__link,
.eds-gallery--justified .eds-gallery__lb-trigger,
.eds-gallery--justified .eds-gallery__link {
  position: static;
  display: block;
}

/* ── Overlay ─────────────────────────────────────────────────────────────────── */
.eds-gallery__overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  padding: 16px;
  background: rgba(0,0,0,0.55);
  pointer-events: none;
  /* Transition for all animation types */
  transition: opacity 0.35s ease, transform 0.35s ease, clip-path 0.35s ease;
}

/* ── Overlay: Always visible ─────────────────────────────────────────────────── */
.eds-gallery--overlay-always .eds-gallery__overlay { opacity: 1; transform: none; }

/* ── Overlay: Hover — hidden state (before hover) ───────────────────────────── */
.eds-gallery--overlay-hover.eds-gallery--anim-fade .eds-gallery__overlay {
  opacity: 0;
}

/* Slide from Top: overlay starts fully above the item */
.eds-gallery--overlay-hover.eds-gallery--anim-slide-top .eds-gallery__overlay {
  opacity: 1;
  transform: translateY(-100%);
}

/* Slide from Bottom: overlay starts fully below the item */
.eds-gallery--overlay-hover.eds-gallery--anim-slide-bottom .eds-gallery__overlay {
  opacity: 1;
  transform: translateY(100%);
}

/* Slide from Left: overlay starts fully to the left */
.eds-gallery--overlay-hover.eds-gallery--anim-slide-left .eds-gallery__overlay {
  opacity: 1;
  transform: translateX(-100%);
}

/* Slide from Right: overlay starts fully to the right */
.eds-gallery--overlay-hover.eds-gallery--anim-slide-right .eds-gallery__overlay {
  opacity: 1;
  transform: translateX(100%);
}

/* Zoom In: starts small */
.eds-gallery--overlay-hover.eds-gallery--anim-zoom-in .eds-gallery__overlay {
  opacity: 0;
  transform: scale(0.7);
}

/* Zoom Out: starts oversized */
.eds-gallery--overlay-hover.eds-gallery--anim-zoom-out .eds-gallery__overlay {
  opacity: 0;
  transform: scale(1.2);
}

/* ── Overlay: Hover — visible state (on hover) ────────────────────────────────
   ALL hover animation types resolve to: opacity 1, transform none               */
.eds-gallery--overlay-hover .eds-gallery__item:hover .eds-gallery__overlay {
  opacity: 1;
  transform: none;
}

/* ── Caption ─────────────────────────────────────────────────────────────────── */
.eds-gallery__caption { text-align: center; }
.eds-gallery__caption-title {
  display: block;
  font-weight: 600;
  font-size: 15px;
  color: #fff;
  margin-bottom: 6px;
  line-height: 1.3;
}
.eds-gallery__caption-desc {
  display: block;
  font-size: 13px;
  color: rgba(255,255,255,0.85);
  line-height: 1.5;
}

/* ── Filter bar ──────────────────────────────────────────────────────────────── */
.eds-gallery__filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 24px;
}

.eds-gallery__filter-btn {
  font-size: 14px;
  font-weight: 500;
  padding: 8px 20px;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  background: #fff;
  color: #374151;
  cursor: pointer;
  transition: all 0.18s ease;
  line-height: 1.4;
}
.eds-gallery__filter-btn:hover   { background: #f3f4f6; color: #111; }
.eds-gallery__filter-btn.is-active { background: #6366f1; border-color: #6366f1; color: #fff; }

/* Filter visibility states */
.eds-gallery__item.is-hiding { opacity: 0; pointer-events: none; transform: scale(0.95); transition: opacity 0.3s ease, transform 0.3s ease; }
.eds-gallery__item.is-hidden  { display: none; }

/* ── Lightbox ────────────────────────────────────────────────────────────────── */
.eds-lightbox {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: eds-lb-in 0.25s ease;
}
.eds-lightbox[hidden] { display: none; }

@keyframes eds-lb-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.eds-lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.92);
  cursor: zoom-out;
}

.eds-lightbox__stage {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 92vw;
  max-height: 92vh;
}

.eds-lightbox__image-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 90vw;
  max-height: 80vh;
}

.eds-lightbox__img {
  display: block;
  max-width: 90vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 4px;
  transition: opacity 0.22s ease;
  animation: eds-img-in 0.25s ease;
}
.eds-lightbox__img.is-loading { opacity: 0; }

@keyframes eds-img-in {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}

.eds-lightbox__close {
  position: fixed;
  top: 16px; right: 20px;
  font-size: 28px;
  line-height: 1;
  padding: 6px 10px;
  color: #fff;
  background: rgba(0,0,0,0.45);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.18s ease;
  z-index: 2;
}
.eds-lightbox__close:hover { background: rgba(255,255,255,0.2); }

.eds-lightbox__prev,
.eds-lightbox__next {
  position: fixed;
  top: 50%; transform: translateY(-50%);
  font-size: 54px;
  line-height: 1;
  padding: 0 12px;
  color: rgba(255,255,255,0.85);
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.18s ease, transform 0.18s ease;
  z-index: 2;
}
.eds-lightbox__prev { left: 6px; }
.eds-lightbox__next { right: 6px; }
.eds-lightbox__prev:hover { color: #fff; transform: translateY(-50%) translateX(-3px); }
.eds-lightbox__next:hover { color: #fff; transform: translateY(-50%) translateX(3px); }
.eds-lightbox__prev.is-disabled,
.eds-lightbox__next.is-disabled { opacity: 0.2; pointer-events: none; }

.eds-lightbox__counter {
  position: fixed;
  top: 22px; left: 50%; transform: translateX(-50%);
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.65);
  background: rgba(0,0,0,0.4);
  padding: 4px 12px;
  border-radius: 20px;
}

.eds-lightbox__caption {
  margin-top: 14px;
  text-align: center;
  max-width: 600px;
}
.eds-lightbox__caption-title {
  font-size: 15px; font-weight: 600; color: #fff; margin: 0 0 4px; padding: 0;
}
.eds-lightbox__caption-desc {
  font-size: 13px; color: rgba(255,255,255,0.75); margin: 0; padding: 0;
}

@media (max-width: 767px) {
  .eds-lightbox__prev { left: 0; font-size: 38px; }
  .eds-lightbox__next { right: 0; font-size: 38px; }
  .eds-lightbox__img  { max-height: 70vh; }
}
