/* ─── GALLERY ───────────────────────────────────────────── */

.gallery-grid {
  margin-top: 1.4rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

.gallery-item {
  margin: 0;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(17, 40, 51, 0.12);
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid var(--border);
}

.gallery-open {
  border: 0;
  padding: 0;
  margin: 0;
  width: 100%;
  display: block;
  background: transparent;
  cursor: zoom-in;
}

.gallery-open:focus-visible {
  outline: 2px solid rgba(45, 111, 115, 0.7);
  outline-offset: -2px;
}

.gallery-item img {
  width: 100%;
  height: clamp(170px, 18vw, 210px);
  object-fit: cover;
  display: block;
}

/* Lightbox */
.gallery-lightbox-backdrop[hidden] {
  display: none !important;
}

.gallery-lightbox-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(8, 20, 24, 0.84);
  display: grid;
  place-items: center;
  padding: 1rem;
}

.gallery-lightbox {
  width: min(1200px, 100%);
  max-height: 94vh;
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "prev image next"
    ". counter .";
  align-items: center;
  gap: 0.7rem;
}

.gallery-lightbox-image {
  grid-area: image;
  width: 100%;
  max-height: 84vh;
  object-fit: contain;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.34);
  background: rgba(12, 29, 33, 0.7);
}

.gallery-lightbox-nav,
.gallery-lightbox-close {
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(25, 60, 64, 0.78);
  color: #f5fbfb;
  cursor: pointer;
}

.gallery-lightbox-nav {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  font-size: 1.2rem;
}

.gallery-lightbox-nav.prev {
  grid-area: prev;
}

.gallery-lightbox-nav.next {
  grid-area: next;
}

.gallery-lightbox-close {
  position: absolute;
  top: -0.2rem;
  right: -0.2rem;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  font-size: 1.4rem;
  line-height: 1;
}

.gallery-lightbox-counter {
  grid-area: counter;
  margin: 0.2rem 0 0;
  text-align: center;
  color: rgba(236, 246, 246, 0.9);
  font-size: 0.92rem;
}

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

@media (max-width: 860px) {
  .gallery-lightbox-backdrop {
    padding: 0.4rem;
  }

  .gallery-lightbox {
    width: 100%;
    max-height: none;
    display: block;
  }

  .gallery-lightbox-image {
    display: block;
    width: 100%;
    max-height: calc(100dvh - 0.8rem);
  }

  .gallery-lightbox-close {
    top: calc(env(safe-area-inset-top, 0px) + 0.35rem);
    right: 0.35rem;
    z-index: 2;
  }

  .gallery-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
  }

  .gallery-lightbox-nav.prev {
    left: 0.35rem;
  }

  .gallery-lightbox-nav.next {
    right: 0.35rem;
  }

  .gallery-lightbox-counter {
    position: absolute;
    left: 50%;
    bottom: max(0.4rem, env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    margin: 0;
    z-index: 2;
    padding: 0.18rem 0.5rem;
    border-radius: 999px;
    background: rgba(8, 20, 24, 0.46);
  }
}

