/* Reusable case-study image lightbox.
   Minimal, viewport-filling overlay for eligible case study content images. */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.88);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 240ms ease, visibility 0s linear 240ms;
}

.lightbox.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 240ms ease, visibility 0s linear 0s;
}

.lightbox[hidden] {
  display: none;
}

.lightbox__stage {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right))
    max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  box-sizing: border-box;
}

.lightbox__figure {
  margin: 0;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.96);
  transition: transform 240ms ease, opacity 240ms ease;
}

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

.lightbox.is-closing .lightbox__figure {
  opacity: 0;
  transform: scale(0.96);
}

.lightbox__image {
  display: block;
  max-width: 90vw;
  max-height: 85vh;
  width: auto;
  height: auto;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.lightbox.lightbox--large .lightbox__figure {
  max-width: 96vw;
  max-height: 92vh;
}

.lightbox.lightbox--large .lightbox__image {
  max-width: 96vw;
  max-height: 92vh;
}

.lightbox__close {
  position: absolute;
  top: max(0.75rem, env(safe-area-inset-top));
  right: max(0.75rem, env(safe-area-inset-right));
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  z-index: 2;
  transition: background-color 180ms ease, opacity 180ms ease;
}

.lightbox__close:hover,
.lightbox__close:focus-visible {
  background: rgba(255, 255, 255, 0.18);
  outline: none;
}

.lightbox__close svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  fill: none;
}

.lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  padding: 0;
  z-index: 2;
  transition: background-color 180ms ease, opacity 180ms ease;
}

.lightbox__nav:hover,
.lightbox__nav:focus-visible {
  background: rgba(255, 255, 255, 0.18);
  outline: none;
}

.lightbox__nav--prev {
  left: max(0.75rem, env(safe-area-inset-left));
}

.lightbox__nav--next {
  right: max(0.75rem, env(safe-area-inset-right));
}

.lightbox__nav[hidden] {
  display: none;
}

.lightbox__nav svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.lightbox__counter {
  position: absolute;
  left: 50%;
  bottom: max(0.75rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.85);
  font-family: var(--inter, system-ui, -apple-system, sans-serif);
  font-size: 0.875rem;
  line-height: 1.4;
  letter-spacing: 0.02em;
  z-index: 2;
  user-select: none;
}

.lightbox__counter[hidden] {
  display: none;
}

body.lightbox-open {
  overflow: hidden;
}

@media (max-width: 760px) {
  .lightbox__nav {
    top: auto;
    bottom: max(0.75rem, env(safe-area-inset-bottom));
    transform: none;
  }

  .lightbox__nav--prev {
    left: max(0.75rem, env(safe-area-inset-left));
  }

  .lightbox__nav--next {
    right: max(0.75rem, env(safe-area-inset-right));
  }

  .lightbox__counter {
    bottom: calc(max(0.75rem, env(safe-area-inset-bottom)) + 2.75rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .lightbox,
  .lightbox__figure,
  .lightbox__close,
  .lightbox__nav {
    transition: none;
  }
}
