/* ==========================================================================
   lightbox.css
   Image viewer for the Achievements and Events pages only.
   The dialog itself is created by lightbox.js, so these styles do nothing
   on pages that do not load that script.
   ========================================================================== */

/* Stop the layout shifting when the page scrollbar is hidden behind the viewer. */
html {
  scrollbar-gutter: stable;
}

html:has(.lightbox[open]) {
  overflow: hidden;
}

.is-zoomable {
  cursor: zoom-in;
}

img.is-zoomable:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

.lightbox {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff;
  overflow: hidden;
}

.lightbox[open] {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4rem 1rem 1.25rem;
}

.lightbox::backdrop {
  background: rgba(12, 10, 8, 0.88);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.lightbox-figure {
  display: grid;
  justify-items: center;
  gap: 0.85rem;
  margin: 0;
  max-width: min(100%, 1200px);
}

.lightbox-image {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100vh - 11rem);
  max-height: calc(100dvh - 11rem);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.lightbox-image.is-loaded {
  opacity: 1;
}

.lightbox-caption {
  max-width: 62ch;
  margin: 0;
  color: rgba(255, 255, 255, 0.86);
  font-size: 0.9rem;
  line-height: 1.5;
  text-align: center;
  text-wrap: balance;
}

.lightbox-full {
  margin-left: 0.4rem;
  color: #fff;
  font-weight: 600;
  white-space: nowrap;
}

.lightbox-full:hover {
  color: #fff;
}

.lightbox-close {
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 1.1rem;
  line-height: 1;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.lightbox-close:hover {
  border-color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.2);
}

.lightbox :focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

@media (prefers-reduced-motion: no-preference) {
  @keyframes lightbox-in {
    from {
      opacity: 0;
      transform: scale(0.96);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }

  @keyframes lightbox-backdrop-in {
    from {
      opacity: 0;
    }
  }

  @keyframes lightbox-out {
    to {
      opacity: 0;
    }
  }

  .lightbox[open] .lightbox-figure {
    animation: lightbox-in 0.3s cubic-bezier(0.22, 0.7, 0.2, 1) both;
  }

  .lightbox[open]::backdrop {
    animation: lightbox-backdrop-in 0.25s ease both;
  }

  .lightbox.is-closing {
    animation: lightbox-out 0.18s ease-in both;
  }
}

@media (max-width: 640px) {
  .lightbox[open] {
    padding-top: 3.75rem;
  }

  .lightbox-image {
    max-height: calc(100vh - 12rem);
    max-height: calc(100dvh - 12rem);
  }
}
