/*
 * Image zoom lightbox utility
 * All selectors are component-owned and independent of portfolio layout styles.
 */

.u-image-lightbox-trigger {
  display: inline-block;
  max-width: 100%;
  cursor: zoom-in;
}

.u-image-lightbox-trigger img {
  display: block;
  max-width: 100%;
  height: auto;
}

.u-image-lightbox-overlay {
  position: fixed;
  z-index: 10000;
  inset: 0;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  padding: clamp(1rem, 4vw, 2.5rem);
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  background: rgb(0 0 0 / 82%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 180ms ease,
    visibility 0s linear 180ms;
}

.u-image-lightbox-overlay.u-image-lightbox-is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}

.u-image-lightbox-dialog {
  position: relative;
  box-sizing: border-box;
  width: fit-content;
  max-width: 100%;
  margin: auto;
  color: #fff;
}

.u-image-lightbox-figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  max-width: 100%;
  margin: 0;
}

.u-image-lightbox-image {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: calc(100vh - 8rem);
  max-height: calc(100dvh - 8rem);
  object-fit: contain;
  border-radius: 0.25rem;
  box-shadow: 0 1.5rem 4rem rgb(0 0 0 / 45%);
}

.u-image-lightbox-caption {
  max-width: min(50rem, 100%);
  margin: 0;
  color: inherit;
  font: 400 0.9375rem/1.45 system-ui, sans-serif;
  text-align: center;
}

.u-image-lightbox-caption:empty {
  display: none;
}

.u-image-lightbox-close {
  position: absolute;
  z-index: 1;
  top: -0.75rem;
  right: -0.75rem;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  color: #111;
  background: #fff;
  box-shadow: 0 0.25rem 1rem rgb(0 0 0 / 35%);
  cursor: pointer;
}

.u-image-lightbox-close:hover {
  background: #e9e9e9;
}

.u-image-lightbox-close:focus-visible {
  outline: 3px solid #69b7ff;
  outline-offset: 3px;
}

.u-image-lightbox-close-icon {
  width: 1.25rem;
  height: 1.25rem;
  pointer-events: none;
}

html.u-image-lightbox-scroll-lock,
html.u-image-lightbox-scroll-lock body {
  overflow: hidden;
}

@media (max-width: 40rem) {
  .u-image-lightbox-overlay {
    align-items: center;
    padding:
      calc(4.25rem + env(safe-area-inset-top))
      calc(0.75rem + env(safe-area-inset-right))
      calc(0.75rem + env(safe-area-inset-bottom))
      calc(0.75rem + env(safe-area-inset-left));
  }

  .u-image-lightbox-dialog,
  .u-image-lightbox-figure {
    width: 100%;
    max-height: 100%;
  }

  .u-image-lightbox-image {
    max-height: calc(100vh - 6.5rem - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    max-height: calc(100dvh - 6.5rem - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }

  .u-image-lightbox-close {
    position: fixed;
    top: max(0.75rem, env(safe-area-inset-top));
    right: max(0.75rem, env(safe-area-inset-right));
  }
}

@media (prefers-reduced-motion: reduce) {
  .u-image-lightbox-overlay {
    transition: none;
  }
}
