/* ============================================================
   LIGHTBOX
   ============================================================ */

html.lightbox-open,
body.lightbox-open {
  overflow: hidden !important;
}

.lightbox,
.lightbox *,
.lightbox *::before,
.lightbox *::after {
  box-sizing: border-box;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 2147483000;

  display: grid;
  place-items: center;

  width: 100vw;
  height: 100vh;
  min-height: 100svh;

  padding: 1rem;

  overflow: hidden;
  isolation: isolate;
}

.lightbox[hidden] {
  display: none !important;
}

.lightbox__backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;

  background: rgba(5, 5, 5, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);

  cursor: pointer;
}

.lightbox__stage {
  position: relative;
  z-index: 1;

  width: min(90vw, 1100px);
  max-width: min(90vw, 1100px);
  max-height: 90svh;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;

  pointer-events: none;
}

.lightbox__img {
  display: block;

  max-width: 100%;
  max-height: 82svh;

  object-fit: contain;

  border-radius: 8px;
  border: 1px solid rgba(214, 168, 79, 0.2);
  box-shadow: 0 8px 64px rgba(0, 0, 0, 0.8);

  transition: opacity 0.2s ease;
  pointer-events: auto;
}

.lightbox__img.is-loading {
  opacity: 0.4;
}

.lightbox__caption {
  margin: 0;

  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 0.875rem;
  line-height: 1.4;
  font-style: italic;

  color: #efe6d2;
  opacity: 0.55;
  text-align: center;

  pointer-events: none;
}

.lightbox__close,
.lightbox__prev,
.lightbox__next {
  position: fixed;
  z-index: 20;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  margin: 0;
  padding: 0;

  background: rgba(18, 13, 11, 0.9);
  border: 1px solid rgba(214, 168, 79, 0.5);
  border-radius: 999px;

  color: #efe6d2;

  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 700;
  text-align: center;

  cursor: pointer;
  pointer-events: auto;

  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);

  transition:
    background-color 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease,
    transform 0.18s ease,
    opacity 0.18s ease;
}

.lightbox__close:hover,
.lightbox__prev:hover,
.lightbox__next:hover {
  background: rgba(214, 168, 79, 0.16);
  border-color: #d6a84f;
  color: #d6a84f;
}

.lightbox__close:focus-visible,
.lightbox__prev:focus-visible,
.lightbox__next:focus-visible {
  outline: 2px solid #d6a84f;
  outline-offset: 4px;
}

.lightbox__close {
  top: max(1rem, env(safe-area-inset-top));
  right: max(1rem, env(safe-area-inset-right));

  width: 44px;
  height: 44px;

  font-size: 1.75rem;
  line-height: 1;
}

.lightbox__prev,
.lightbox__next {
  top: 50%;

  width: 54px;
  height: 54px;

  font-size: 2.35rem;
  line-height: 1;

  transform: translateY(-50%);
}

.lightbox__prev {
  left: max(1rem, env(safe-area-inset-left));
}

.lightbox__next {
  right: max(1rem, env(safe-area-inset-right));
}

.lightbox__prev:hover {
  transform: translateY(-50%) translateX(-2px);
}

.lightbox__next:hover {
  transform: translateY(-50%) translateX(2px);
}

.lightbox__prev:disabled,
.lightbox__next:disabled {
  opacity: 0.28;
  cursor: not-allowed;
  pointer-events: none;
}

.lightbox__counter {
  position: fixed;
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  left: 50%;
  z-index: 10;

  margin: 0;

  transform: translateX(-50%);

  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.12em;
  text-transform: uppercase;

  color: #efe6d2;
  opacity: 0.48;

  pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
  .lightbox:not([hidden]) {
    animation: lb-in 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  .lightbox:not([hidden]) .lightbox__stage {
    animation: lb-stage-in 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  @keyframes lb-in {
    from {
      opacity: 0;
    }

    to {
      opacity: 1;
    }
  }

  @keyframes lb-stage-in {
    from {
      transform: scale(0.94) translateY(8px);
      opacity: 0;
    }

    to {
      transform: scale(1) translateY(0);
      opacity: 1;
    }
  }
}

@media (max-width: 767px) {
  .lightbox {
    padding: 0.75rem;
  }

  .lightbox__stage {
    width: min(86vw, 900px);
    max-width: min(86vw, 900px);
  }

  .lightbox__img {
    max-height: 76svh;
  }

  .lightbox__prev,
  .lightbox__next {
    width: 44px;
    height: 44px;
    font-size: 2rem;
  }

  .lightbox__prev {
    left: 0.75rem;
  }

  .lightbox__next {
    right: 0.75rem;
  }
}

@media (min-width: 768px) {
  .lightbox {
    padding: 2rem;
  }

  .lightbox__prev,
  .lightbox__next {
    width: 58px;
    height: 58px;
  }

  .lightbox__prev {
    left: 2rem;
  }

  .lightbox__next {
    right: 2rem;
  }
}
