/* ==========================================================================
   Clean Image Gallery – gallery.css
   Version: 1.0.0
   ========================================================================== */

/* ── CSS Custom Properties ────────────────────────────────────────────────── */
:root {
  --cig-columns: 3;
  --cig-gap: 12px;
  --cig-transition-duration: 0.38s;
  --cig-transition-ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --cig-lightbox-bg: rgba(10, 10, 12, 0.96);
  --cig-lightbox-z: 999999;
}

/* ── Placeholder (editor only) ───────────────────────────────────────────── */
.cig-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  border: 2px dashed #d0d3db;
  border-radius: 8px;
  color: #a0a5b1;
  font-size: 14px;
  font-family: inherit;
  text-align: center;
  padding: 24px;
}

/* ── Gallery Base ─────────────────────────────────────────────────────────── */
.cig-gallery {
  --cig-columns: 3;
  --cig-gap: 12px;
  width: 100%;
}

/* ── Grid Layout ──────────────────────────────────────────────────────────── */
.cig-gallery--grid {
  display: grid;
  grid-template-columns: repeat(var(--cig-columns), 1fr);
  gap: var(--cig-gap);
}

.cig-gallery--grid .cig-item {
  overflow: hidden;
  position: relative;
  aspect-ratio: 1 / 1;
}

.cig-gallery--grid .cig-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ── Masonry Layout ───────────────────────────────────────────────────────── */
.cig-gallery--masonry {
  columns: var(--cig-columns);
  column-gap: var(--cig-gap);
}

.cig-gallery--masonry .cig-item {
  break-inside: avoid;
  overflow: hidden;
  position: relative;
  margin-bottom: var(--cig-gap);
}

.cig-gallery--masonry .cig-item img {
  width: 100%;
  height: auto;
  display: block;
}

/* ── Gallery Item – shared ────────────────────────────────────────────────── */
.cig-item {
  cursor: pointer;
  border-radius: 8px;
  background: #f3f4f6;
}

.cig-item img {
  transition: transform var(--cig-transition-duration) var(--cig-transition-ease),
              opacity 0.3s ease;
  will-change: transform;
  backface-visibility: hidden;
  border-radius: inherit;
}

/* ── Hover Zoom ───────────────────────────────────────────────────────────── */
.cig-gallery--zoom .cig-item {
  overflow: hidden;
}

/* Default scale (overridden per-widget via Elementor selectors) */
.cig-gallery--zoom .cig-item:hover img {
  transform: scale(1.05);
}

/* ── Link Reset ───────────────────────────────────────────────────────────── */
.cig-link {
  display: block;
  width: 100%;
  height: 100%;
  text-decoration: none;
  overflow: hidden;
  border-radius: inherit;
}

.cig-gallery--grid .cig-link {
  position: absolute;
  inset: 0;
}

/* ── Lightbox Overlay ─────────────────────────────────────────────────────── */
.cig-lightbox {
  position: fixed;
  inset: 0;
  z-index: var(--cig-lightbox-z);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cig-lightbox-bg);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.cig-lightbox.is-open {
  opacity: 1;
  visibility: visible;
}

/* ── Lightbox Stage ───────────────────────────────────────────────────────── */
.cig-lightbox__stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: min(92vw, 1200px);
  max-height: 90vh;
}

/* ── Lightbox Image ───────────────────────────────────────────────────────── */
.cig-lightbox__img {
  display: block;
  max-width: min(92vw, 1200px);
  max-height: 90vh;
  object-fit: contain;
  border-radius: 6px;
  opacity: 0;
  transform: scale(0.94);
  transition: opacity 0.35s var(--cig-transition-ease),
              transform 0.35s var(--cig-transition-ease);
  user-select: none;
  -webkit-user-drag: none;
}

.cig-lightbox.is-open .cig-lightbox__img {
  opacity: 1;
  transform: scale(1);
}

/* ── Close Button ─────────────────────────────────────────────────────────── */
.cig-lightbox__close {
  position: fixed;
  top: 20px;
  right: 24px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  cursor: pointer;
  color: #fff;
  transition: background 0.2s ease, transform 0.2s ease;
  outline: none;
  padding: 0;
  z-index: 1;
}

.cig-lightbox__close:hover,
.cig-lightbox__close:focus-visible {
  background: rgba(255, 255, 255, 0.22);
  transform: scale(1.1);
}

.cig-lightbox__close svg {
  pointer-events: none;
}

/* ── Prev / Next Buttons ──────────────────────────────────────────────────── */
.cig-lightbox__nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  cursor: pointer;
  color: #fff;
  transition: background 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
  outline: none;
  padding: 0;
  z-index: 1;
  opacity: 0.75;
}

.cig-lightbox__nav:hover,
.cig-lightbox__nav:focus-visible {
  background: rgba(255, 255, 255, 0.22);
  opacity: 1;
}

.cig-lightbox__nav--prev {
  left: 20px;
}

.cig-lightbox__nav--next {
  right: 20px;
}

.cig-lightbox__nav:disabled {
  opacity: 0.25;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Counter ──────────────────────────────────────────────────────────────── */
.cig-lightbox__counter {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.55);
  font-size: 13px;
  font-family: system-ui, -apple-system, sans-serif;
  letter-spacing: 0.06em;
  pointer-events: none;
  white-space: nowrap;
}

/* ── Loader ───────────────────────────────────────────────────────────────── */
.cig-lightbox__loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.cig-lightbox__loader::after {
  content: "";
  width: 32px;
  height: 32px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  animation: cig-spin 0.75s linear infinite;
}

.cig-lightbox__loader.is-hidden {
  display: none;
}

@keyframes cig-spin {
  to { transform: rotate(360deg); }
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .cig-gallery {
    --cig-columns: 2;
  }
}

@media (max-width: 767px) {
  .cig-gallery {
    --cig-columns: 1;
  }

  .cig-lightbox__nav--prev { left: 8px; }
  .cig-lightbox__nav--next { right: 8px; }
  .cig-lightbox__nav {
    width: 38px;
    height: 38px;
  }
}

/* ── Accessibility: focus rings ───────────────────────────────────────────── */
.cig-link:focus-visible {
  outline: 2px solid rgba(99, 179, 237, 0.8);
  outline-offset: 3px;
  border-radius: inherit;
}

/* ── Reduced motion ───────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .cig-item img,
  .cig-lightbox,
  .cig-lightbox__img {
    transition: none;
  }
  .cig-gallery--zoom .cig-item:hover img {
    transform: none;
  }
  .cig-lightbox__loader::after {
    animation: none;
  }
}
