/* P42, gallery zoom. Printed: a grid of square photos, two across on a
   phone and three from 768px, each a link to its full-size file, with its
   caption under it. With the script and <dialog>, a press opens the photo
   over the page instead, with previous, next and close; under motion the
   photo grows out of its square to the full view and the grid rises in turn
   the first time it is seen. Audited against the design tells: no numbers,
   no capitals, no lift; the controls are plain squares. */
.vl-m.vl-p42 {
  padding: 72px 0;
}
.vl-m .vl-p42__in {
  max-width: 1160px;
}
.vl-m .vl-p42__title {
  margin: 0 0 12px;
  max-width: 22ch;
  color: var(--vl-fg);
  font-family: var(--vl-f-display);
  font-size: clamp(30px, 3.8vw, 50px);
  font-weight: var(--vl-display-weight, 800);
  line-height: 1.06;
}
.vl-m .vl-p42__sub {
  margin: 0 0 24px;
  max-width: 48ch;
  font-size: 18px;
  line-height: 1.55;
  color: rgba(var(--vl-fg-rgb), 0.78);
}
.vl-m .vl-p42__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.vl-m .vl-p42__fig {
  margin: 0;
}
.vl-m .vl-p42__open {
  display: block;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  background: rgba(var(--vl-fg-rgb), 0.08);
}
.vl-m .vl-p42__open:focus-visible {
  outline: 2px solid var(--vl-fg);
  outline-offset: 3px;
}
.vl-m .vl-p42__pic {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.vl-m .vl-p42__cap {
  margin: 8px 2px 4px;
  font-size: 15px;
  line-height: 1.4;
  color: rgba(var(--vl-fg-rgb), 0.78);
}
.vl-p42.has-box .vl-p42__open {
  cursor: zoom-in;
}

/* The view, opened by the script. */
.vl-m .vl-p42__box {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(12, 12, 12, 0.95);
  color: #ffffff;
  overflow: hidden;
}
.vl-m .vl-p42__box::backdrop {
  background: transparent;
}
.vl-m .vl-p42__frame {
  position: absolute;
  inset: 64px 12px 72px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.vl-m .vl-p42__big {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  touch-action: pan-y;
}
.vl-m .vl-p42__bcap {
  position: absolute;
  right: 16px;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  left: 16px;
  margin: 0;
  font-size: 16px;
  line-height: 1.4;
  text-align: center;
}
.vl-m.vl-m button.vl-p42__close,
.vl-m.vl-m button.vl-p42__nav {
  position: absolute;
  width: 48px;
  height: 48px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: var(--vl-radius-control, 12px);
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}
.vl-m.vl-m button.vl-p42__close {
  top: calc(10px + env(safe-area-inset-top, 0px));
  right: 12px;
}
.vl-m.vl-m button.vl-p42__prev,
.vl-m.vl-m button.vl-p42__next {
  top: 50%;
  margin-top: -24px;
}
.vl-m.vl-m button.vl-p42__prev {
  left: 10px;
}
.vl-m.vl-m button.vl-p42__next {
  right: 10px;
}
.vl-m .vl-p42__close:focus-visible,
.vl-m .vl-p42__nav:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}
.vl-m .vl-p42__fly {
  position: fixed;
  z-index: 2;
  margin: 0;
  max-width: none;
  object-fit: cover;
  border-radius: 12px;
  pointer-events: none;
}

@media (min-width: 768px) {
  .vl-m .vl-p42__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
  }
  .vl-m .vl-p42__frame {
    inset: 64px 76px 72px;
  }
}
@media (min-width: 900px) {
  .vl-m.vl-p42 {
    padding: 104px 0;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .vl-p42.is-motion:not(.is-in) .vl-p42__item {
    opacity: 0;
  }
  .vl-p42.is-motion.is-in .vl-p42__item {
    /* backwards, not both: a finished rise lets go of the item, so nothing
       holds a transform after it and the item is plain again. */
    animation: vl-p42-rise 0.5s cubic-bezier(0.2, 1.2, 0.4, 1) backwards;
    animation-delay: calc(var(--vl-i, 0) * 60ms);
  }
  .vl-p42.is-motion .vl-p42__pic {
    transition: transform 0.5s ease;
  }
  .vl-p42.is-motion .vl-p42__box {
    transition: opacity 0.25s ease;
  }
  .vl-p42.is-motion .vl-p42__big {
    transition: opacity 0.25s ease;
  }
}
@media (prefers-reduced-motion: no-preference) and (hover: hover) and (pointer: fine) {
  .vl-p42.is-motion .vl-p42__open:hover .vl-p42__pic {
    transform: scale(1.05);
  }
}
@keyframes vl-p42-rise {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
