.lightbox {
  --lightbox-frame-padding: clamp(8px, 2vw, 20px);
  --lightbox-max-width: min(calc(100vw - 2 * var(--lightbox-frame-padding)), 1400px);
  --lightbox-max-height: calc(100vh - 2 * var(--lightbox-frame-padding));
}

.lightbox-content {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  background: none;
  border-radius: 0 !important;
  box-shadow: none;
  overflow: visible;
  pointer-events: auto;
  padding: var(--lightbox-frame-padding);
  width: auto;
  height: auto;
  max-width: var(--lightbox-max-width);
  max-height: var(--lightbox-max-height);
  flex: 0 1 auto;
}

.lightbox-media {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  isolation: isolate;
  overflow: hidden;
}

.lightbox-img {
  max-width: min(100%, var(--lightbox-max-width));
  max-height: min(100%, var(--lightbox-max-height));
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  margin: 0;
  border-radius: 0 !important;
  background: none;
  border: 1px solid rgba(0, 0, 0, 0.25);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25), 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: opacity 0.44s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.44s cubic-bezier(0.4, 0, 0.2, 1);
}

.lightbox-img--video {
  filter: none;
}

.lightbox-media--video::after {
  content: '';
  position: absolute;
  inset: clamp(32px, 8vh, 52px) clamp(20px, 3vw, 38px) clamp(48px, 8vh, 64px);
  border-radius: inherit;
  background: radial-gradient(circle at 50% 35%, rgba(255, 255, 255, 0.35), transparent 55%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0));
  mix-blend-mode: soft-light;
  opacity: 0.45;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 2;
}

.lightbox-media--video:hover::after {
  opacity: 0.6;
}

/* For larger screens, constrain proportionally inside viewport */
@media (min-width: 900px) {
  .lightbox {
    --lightbox-max-width: min(calc(95vw - 2 * var(--lightbox-frame-padding)), 1600px);
  }
}

.lightbox-close {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: -16px;
  right: -16px;
  z-index: 1000001;
  background: transparent !important;
  color: #222;
  font-size: 2.3rem;
  font-weight: 400;
  border: none;
  border-radius: 0;
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.2s;
  box-shadow: none !important;
  outline: none;
  padding: 0;
  width: 44px;
  height: 44px;
  line-height: 1;
  user-select: none;
  -webkit-user-select: none;
  text-shadow: none;
}

.lightbox--active .lightbox-img {
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), 0 12px 30px rgba(0, 0, 0, 0.35), 0 0 1px rgba(0, 0, 0, 0.45);
}
.lightbox-close:active {
  opacity: 0.6;
}
/* Minimal, unified lightbox overlay and contained media */
.lightbox {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 999999;
  transition: opacity 0.44s cubic-bezier(0.4, 0, 0.2, 1),
    visibility 0.44s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.lightbox.lightbox--active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
