/* Loading state for the gallery modal and the stay lightbox.
   app.js adds .is-loading to the frame while a new photo downloads: the current
   photo dims and a small spinner shows until the new one has loaded. */

/* Wraps the gallery photo so the spinner centres on the image, not on the nav. */
.gallery-modal-frame {
  position: relative;
  display: inline-block;
  max-width: 100%;
  line-height: 0;
}
.gallery-modal-frame > img {
  display: block;
}

.stay-lightbox-img,
.gallery-modal-frame > img {
  transition: opacity 0.15s ease;
}

/* The stay lightbox is a full-screen flex overlay, so its spinner centres on the screen. */
.stay-lightbox.is-loading .stay-lightbox-img,
.gallery-modal-frame.is-loading > img {
  opacity: 0.4;
}

.stay-lightbox.is-loading::after,
.gallery-modal-frame.is-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 36px;
  height: 36px;
  margin: -18px 0 0 -18px;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  pointer-events: none;
  animation: lightbox-spin 0.8s linear infinite;
}

@keyframes lightbox-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .stay-lightbox.is-loading::after,
  .gallery-modal-frame.is-loading::after {
    animation-duration: 2.4s;
  }
}
