.service-gallery {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.service-gallery-primary,
.service-gallery-secondary {
  display: grid;
  min-width: 0;
}

.service-gallery-primary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.service-gallery-secondary {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.service-gallery-item {
  position: relative;
  min-width: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  color: var(--text-light);
  text-align: left;
  cursor: zoom-in;
  background: var(--graphite-2);
  border: 1px solid rgba(32, 41, 50, 0.16);
  border-radius: var(--radius);
  box-shadow: 0 18px 48px rgba(16, 24, 32, 0.14);
  isolation: isolate;
}

.service-gallery-item::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(180deg, transparent 42%, rgba(10, 15, 20, 0.86) 100%);
}

.service-gallery-item img {
  width: 100%;
  height: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  transition: transform 420ms cubic-bezier(0.2, 0.75, 0.25, 1);
}

.service-gallery-item:hover img,
.service-gallery-item:focus-visible img {
  transform: scale(1.025);
}

.service-gallery-item:focus-visible {
  outline: 3px solid rgba(184, 100, 60, 0.78);
  outline-offset: 3px;
}

.service-gallery-caption {
  position: absolute;
  right: 16px;
  bottom: 14px;
  left: 16px;
  z-index: 2;
  display: grid;
  gap: 2px;
}

.service-gallery-caption strong {
  color: var(--text-light);
  font-size: 1rem;
  line-height: 1.2;
}

.service-gallery-caption span {
  color: rgba(243, 246, 247, 0.7);
  font-size: 0.78rem;
}

.service-gallery-secondary .service-gallery-caption {
  right: 12px;
  bottom: 11px;
  left: 12px;
}

.service-gallery-secondary .service-gallery-caption strong {
  font-size: 0.9rem;
}

.service-gallery-secondary .service-gallery-caption span {
  display: none;
}

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

.gallery-lightbox[hidden] {
  display: none;
}

.gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  grid-template-columns: minmax(48px, 1fr) minmax(0, 1280px) minmax(48px, 1fr);
  align-items: center;
  gap: 16px;
  padding: 28px;
  color: var(--text-light);
  background: rgba(7, 11, 15, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.gallery-lightbox-figure {
  min-width: 0;
  margin: 0;
  text-align: center;
}

.gallery-lightbox-image {
  width: auto;
  max-width: 100%;
  max-height: min(78vh, 900px);
  margin: 0 auto;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.48);
}

.gallery-lightbox-caption {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: start;
  max-width: 980px;
  margin: 14px auto 0;
  color: rgba(243, 246, 247, 0.8);
  font-size: 0.92rem;
  text-align: left;
}

.gallery-lightbox-counter {
  color: rgba(243, 246, 247, 0.58);
  white-space: nowrap;
}

.gallery-lightbox-close,
.gallery-lightbox-prev,
.gallery-lightbox-next {
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  color: var(--text-light);
  cursor: pointer;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  transition: background 180ms ease, border-color 180ms ease, transform 180ms ease;
}

.gallery-lightbox-close:hover,
.gallery-lightbox-prev:hover,
.gallery-lightbox-next:hover,
.gallery-lightbox-close:focus-visible,
.gallery-lightbox-prev:focus-visible,
.gallery-lightbox-next:focus-visible {
  background: rgba(184, 100, 60, 0.72);
  border-color: rgba(255, 255, 255, 0.42);
  outline: none;
  transform: scale(1.04);
}

.gallery-lightbox-close {
  position: absolute;
  top: 24px;
  right: 24px;
}

.gallery-lightbox-prev {
  justify-self: end;
}

.gallery-lightbox-next {
  justify-self: start;
}

.gallery-lightbox-icon {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  stroke-width: 1.8;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (max-width: 980px) {
  .service-gallery-primary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .service-gallery-primary .service-gallery-item:first-child {
    grid-column: 1 / -1;
  }

  .service-gallery-secondary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .service-gallery-primary,
  .service-gallery-secondary {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .service-gallery-primary .service-gallery-item:first-child {
    grid-column: auto;
  }

  .service-gallery-secondary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .service-gallery-secondary .service-gallery-caption strong {
    font-size: 0.8rem;
  }

  .gallery-lightbox {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 72px 14px 82px;
  }

  .gallery-lightbox-figure {
    grid-row: 1;
  }

  .gallery-lightbox-image {
    max-height: 68vh;
  }

  .gallery-lightbox-prev,
  .gallery-lightbox-next {
    position: absolute;
    bottom: 18px;
  }

  .gallery-lightbox-prev {
    left: calc(50% - 62px);
  }

  .gallery-lightbox-next {
    right: calc(50% - 62px);
  }

  .gallery-lightbox-close {
    top: 14px;
    right: 14px;
  }

  .gallery-lightbox-caption {
    gap: 12px;
    margin-top: 10px;
    font-size: 0.82rem;
  }
}

@media (max-width: 430px) {
  .service-gallery-secondary {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .service-gallery-item img,
  .gallery-lightbox-close,
  .gallery-lightbox-prev,
  .gallery-lightbox-next {
    transition: none;
  }
}

/* Keep the existing photo crop and caption geometry; improve text contrast. */
.service-gallery-caption { background-color: rgba(7, 11, 15, 0.8); }
