/* ==========================================================================
   Faster - screenshot gallery and lightbox.

   Same class contract as the other Metromedya app sites, so js/gallery.js is
   interchangeable: .gridscroll img opens .modal-overlay > .modal-content with
   .modal-image, .modal-close, .modal-nav.modal-prev/.modal-next, .modal-counter.

   Two deliberate differences from the sibling sites:

   1. The chrome is dark first. Faster's screenshots are of a dark app, so a
      white scrim would flash before the image lands.
   2. The modal image gets no border-radius and no box-shadow. Faster's
      screenshots are transparent PNGs that already carry their own rounded
      window corners and drop shadow. Adding a CSS radius would clip the
      shadow, and a CSS shadow would draw a rectangle around the transparent
      bounding box.
   ========================================================================== */

.image-gallery {
  cursor: zoom-in;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.72);
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  /* visibility flips instantly on open and only after the fade on close.
     Transitioning it symmetrically would leave the overlay computed as hidden
     for the whole 0.3s, and nothing inside a hidden subtree can take focus, so
     moving focus into the dialog on open would silently fail. */
  transition: opacity 0.3s ease, visibility 0s linear 0.3s;
}

@media (prefers-color-scheme: light) {
  .modal-overlay {
    background-color: rgba(20, 20, 19, 0.55);
  }
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s ease, visibility 0s linear 0s;
}

.modal-content {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 95%;
  max-height: 95vh;
}

.modal-close,
.modal-nav,
.modal-counter {
  opacity: 0;
  transition: opacity 0.3s ease 0.15s;
}

.modal-overlay.active .modal-close,
.modal-overlay.active .modal-nav,
.modal-overlay.active .modal-counter {
  opacity: 0.85;
}

.modal-close,
.modal-nav {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.22);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  transition: background 0.2s cubic-bezier(0.2, 0, 0.2, 1),
    transform 0.2s cubic-bezier(0.2, 0, 0.2, 1), opacity 0.2s ease;
}

.modal-close {
  position: fixed;
  top: 20px;
  right: 20px;
  font-size: 24px;
  line-height: 1;
}

.modal-close:hover,
.modal-nav:hover {
  background: rgba(255, 255, 255, 0.24);
}

.modal-overlay.active .modal-close:hover,
.modal-overlay.active .modal-nav:hover,
.modal-overlay.active .modal-close:focus-visible,
.modal-overlay.active .modal-nav:focus-visible {
  opacity: 1;
}

.modal-close:focus-visible,
.modal-nav:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.modal-close:hover {
  transform: scale(1.05);
}

.modal-close:active {
  transform: scale(0.95);
}

.modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}

.modal-nav:hover {
  transform: translateY(-50%) scale(1.05);
}

.modal-nav:active {
  transform: translateY(-50%) scale(0.95);
}

.modal-prev {
  left: 20px;
}

.modal-next {
  right: 20px;
}

/* Arrows drawn from two borders rotated 45 degrees, as on the sibling sites. */
.modal-prev::before,
.modal-next::before {
  content: '';
  display: block;
  width: 10px;
  height: 10px;
  border-top: 2px solid #fff;
  border-left: 2px solid #fff;
  position: absolute;
}

.modal-prev::before {
  transform: rotate(-45deg);
  left: 19px;
  top: 16px;
}

.modal-next::before {
  transform: rotate(135deg);
  right: 19px;
  top: 16px;
}

.modal-counter {
  position: absolute;
  bottom: -34px;
  left: 0;
  right: 0;
  text-align: center;
  color: #fff;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 0.8125rem;
  letter-spacing: 0.06em;
}

.loading-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  pointer-events: none;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 1s ease-in-out infinite;
}

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

.modal-image {
  display: block;
  width: auto;
  height: auto;
  max-width: 95vw;
  max-height: 85vh;
  transition: opacity 0.3s cubic-bezier(0.2, 0, 0.2, 1);
}

@media (max-width: 1280px) {
  .modal-nav {
    width: 38px;
    height: 38px;
  }

  .modal-prev {
    left: 10px;
  }

  .modal-next {
    right: 10px;
  }

  .modal-prev::before,
  .modal-next::before {
    width: 8px;
    height: 8px;
  }

  .modal-prev::before {
    left: 16px;
    top: 14px;
  }

  .modal-next::before {
    right: 16px;
    top: 14px;
  }

  .modal-content {
    max-width: 96vw;
  }

  .modal-image {
    max-width: 100vw;
    max-height: 80vh;
  }
}

/* The zoom-from-thumbnail transition is motion for its own sake. Under Reduce
   Motion the lightbox still opens and closes, it just cross fades instead.
   js/gallery.js reads the same preference and skips the transform maths. */
@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
    border-top-color: rgba(255, 255, 255, 0.28);
  }
}
