/* =========================================================
   S & I DENTAL CLINIC — GALLERY
   gallery.css → gallery-specific styling
   ========================================================= */

/* =========================================================
   GALLERY SECTION SPACING
   ========================================================= */
.si-gallery.section {
  padding-top: 0 !important;
  padding-bottom: 2.75rem !important;
}

/* =========================================================
   GALLERY SECTION HEADER
   ========================================================= */
.si-gallery .section-header {
  margin-top: 0;
  margin-bottom: 1.35rem;
}

/* Eyebrow */
.si-gallery .section-header .eyebrow {
  display: inline-block;
  margin-top: 0;
  margin-bottom: 0.35rem;
  font-size: 1.75rem;
  line-height: 1.2;
  letter-spacing: 0.12em;
}

/* Heading */
.si-gallery .section-header h2 {
  margin-top: 0;
  margin-bottom: 0.4rem;
}

/* Lede */
.si-gallery .section-header .lede {
  max-width: 52ch;
  margin: 0 auto;
}

/* =========================================================
   GALLERY SECTION FOOT
   ========================================================= */
.si-gallery .section-foot {
  margin-top: 1.75rem;
  margin-bottom: 0;
}

/* =========================================================
   GALLERY GRID
   ========================================================= */
.si-gallery__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 190px;
  gap: var(--space-sm);
}

/* =========================================================
   GALLERY ITEM
   ========================================================= */
.si-gallery__item {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  isolation: isolate;
  background: var(--color-cream);
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

/* =========================================================
   GALLERY IMAGE
   ========================================================= */
.si-gallery__item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.65s cubic-bezier(0.2, 0.65, 0.25, 1), filter 0.4s ease;
}

/* =========================================================
   IMAGE HOVER
   ========================================================= */
.si-gallery__item:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 42px rgba(23, 60, 46, 0.13);
}

.si-gallery__item:hover img {
  transform: scale(1.045);
  filter: saturate(1.03);
}

/* =========================================================
   IMAGE OVERLAY
   ========================================================= */
.si-gallery__item::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(180deg, rgba(23, 60, 46, 0) 52%, rgba(23, 60, 46, 0.58) 100%);
  opacity: 0;
  transition: opacity var(--transition-normal);
  pointer-events: none;
}

.si-gallery__item:hover::after {
  opacity: 1;
}

/* =========================================================
   IMAGE LABEL
   ========================================================= */
.si-gallery__item span {
  position: absolute;
  left: 0.9rem;
  bottom: 0.8rem;
  z-index: 2;
  color: var(--color-warm-white);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0.02em;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity var(--transition-normal), transform var(--transition-normal);
  pointer-events: none;
}

.si-gallery__item:hover span {
  opacity: 1;
  transform: translateY(0);
}

/* =========================================================
   GALLERY GRID VARIATIONS
   ========================================================= */
.si-gallery__item--wide {
  grid-column: span 2;
}

.si-gallery__item--tall {
  grid-row: span 2;
}

/* =========================================================
   GALLERY LIGHTBOX
   ========================================================= */
.si-gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(17, 35, 28, 0.84);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* =========================================================
   LIGHTBOX OPEN STATE
   ========================================================= */
.si-gallery-lightbox.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* =========================================================
   LIGHTBOX CONTENT
   ========================================================= */
.si-gallery-lightbox__content {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(1100px, 100%);
  max-height: 90vh;
  transform: translateY(8px) scale(0.985);
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1), opacity 0.3s ease;
}

.si-gallery-lightbox.is-open .si-gallery-lightbox__content {
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* =========================================================
   LIGHTBOX IMAGE
   ========================================================= */
.si-gallery-lightbox__image {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 88vh;
  object-fit: contain;
  border-radius: var(--radius-md);
  background: var(--color-cream);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.30);
}

/* =========================================================
   LIGHTBOX CLOSE BUTTON
   ========================================================= */
.si-gallery-lightbox__close {
  position: absolute;
  top: -0.75rem;
  right: -0.75rem;
  z-index: 3;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid rgba(247, 243, 234, 0.22);
  border-radius: 50%;
  background: rgba(23, 60, 46, 0.94);
  color: var(--color-warm-white);
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  transition:
    background-color var(--transition-normal),
    border-color var(--transition-normal),
    transform var(--transition-normal),
    box-shadow var(--transition-normal);
}

.si-gallery-lightbox__close:hover {
  background-color: var(--color-forest);
  border-color: rgba(var(--rgb-gold), 0.45);
  transform: rotate(4deg) scale(1.04);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.24);
}

.si-gallery-lightbox__close:focus-visible {
  outline: 2px solid var(--color-gold);
  outline-offset: 3px;
}

.si-gallery-lightbox__close svg {
  width: 18px;
  height: 18px;
}

/* =========================================================
   ACCESSIBILITY
   ========================================================= */
.si-gallery__item:focus-visible {
  outline: 2px solid var(--color-gold);
  outline-offset: 3px;
}

/* =========================================================
   REDUCED MOTION
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
  .si-gallery__item,
  .si-gallery__item img,
  .si-gallery__item::after,
  .si-gallery__item span,
  .si-gallery-lightbox,
  .si-gallery-lightbox__content,
  .si-gallery-lightbox__close {
    transition: none;
  }

  .si-gallery__item:hover {
    transform: none;
  }

  .si-gallery__item:hover img {
    transform: none;
    filter: none;
  }
}

/* =========================================================
   TABLET
   ========================================================= */
@media (max-width: 900px) {
  .si-gallery.section {
    padding-top: 0 !important;
    padding-bottom: 2.25rem !important;
  }

  .si-gallery__grid {
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: 170px;
  }

  .si-gallery__item--wide {
    grid-column: span 2;
  }
}

/* =========================================================
   MOBILE
   ========================================================= */
@media (max-width: 575px) {
  .si-gallery.section {
    padding-top: 0 !important;
    padding-bottom: 1.75rem !important;
  }

  .si-gallery .section-header {
    margin-bottom: 1.1rem;
  }

  .si-gallery .section-header .eyebrow {
    margin-bottom: 0.3rem;
    font-size: 1rem;
    line-height: 1.2;
  }

  .si-gallery .section-header h2 {
    margin-bottom: 0.35rem;
  }

  .si-gallery .section-header .lede {
    max-width: 42ch;
  }

  .si-gallery .section-foot {
    margin-top: 1.25rem;
  }

  .si-gallery__grid {
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: 140px;
    gap: 0.65rem;
  }

  .si-gallery__item {
    border-radius: 14px;
  }

  .si-gallery__item--tall {
    grid-row: span 1;
  }

  .si-gallery__item:hover {
    transform: translateY(-2px);
  }

  .si-gallery__item span {
    left: 0.65rem;
    bottom: 0.6rem;
    font-size: 0.7rem;
  }

  .si-gallery-lightbox {
    padding: 0.75rem;
  }

  .si-gallery-lightbox__content {
    width: 100%;
    max-height: 88vh;
  }

  .si-gallery-lightbox__image {
    max-width: 100%;
    max-height: 84vh;
    border-radius: 14px;
  }

  .si-gallery-lightbox__close {
    top: -0.5rem;
    right: -0.25rem;
    width: 36px;
    height: 36px;
  }

  .si-gallery-lightbox__close svg {
    width: 16px;
    height: 16px;
  }
}

/* =========================================================
   VERY SMALL MOBILE
   ========================================================= */
@media (max-width: 380px) {
  .si-gallery__grid {
    grid-auto-rows: 125px;
    gap: 0.55rem;
  }

  .si-gallery__item {
    border-radius: 12px;
  }

  .si-gallery__item span {
    left: 0.55rem;
    bottom: 0.5rem;
    font-size: 0.65rem;
  }

  .si-gallery-lightbox {
    padding: 0.5rem;
  }

  .si-gallery-lightbox__image {
    max-height: 82vh;
    border-radius: 12px;
  }

  .si-gallery-lightbox__close {
    top: -0.35rem;
    right: 0;
    width: 34px;
    height: 34px;
  }
}
