.building-gallery {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: clamp(.55rem, 1.15vw, 1.15rem);
  aspect-ratio: 2.4;
}

.building-frame {
  --photo-scale: 1;
  --photo-focus: 50% 50%;
  position: relative;
  display: block;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  isolation: isolate;
  border-radius: 5px;
  background: #d2dcd9;
  cursor: zoom-in;
}

.building-frame:focus-visible { outline-offset: -4px; outline-color: white; }
.wide-photo .building-frame { height: 100%; }
.building-crop { display: block; width: 100%; height: 100%; }
.building-frame .building-crop img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--photo-focus);
  transform-origin: var(--photo-focus);
  transform: scale(var(--photo-scale));
  transition: transform .9s cubic-bezier(.18,.74,.24,1);
}

/* Give the existing architectural photographs a consistent daylight treatment. */
.building-frame img, .lightbox-stage img {
  filter: saturate(1.34) contrast(1.115) brightness(1.048);
}

.photo-panorama { --photo-focus: 50% 38%; }
.photo-corner { grid-row: 1 / 3; --photo-focus: 48% 38%; }
.photo-glass { --photo-focus: 60% 68%; --photo-scale: 1.7; }
.photo-entrance { --photo-focus: 25% 57%; --photo-scale: 1.3; }

.expand-photo, .lightbox-button {
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  border: 1px solid #ffffff8f;
}
.expand-photo {
  position: absolute;
  right: clamp(.55rem, 1vw, 1rem);
  bottom: clamp(.55rem, 1vw, 1rem);
  width: 2.55rem;
  height: 2.55rem;
  background: #19372cdc;
  pointer-events: none;
  transition: background-color .25s, transform .35s;
}
.expand-photo .icon { width: 1.1rem; height: 1.1rem; }
@media (hover: hover) and (pointer: fine) {
  .building-frame:hover .building-crop img { transform: scale(calc(var(--photo-scale) + .045)); }
  .building-frame:hover .expand-photo { background: #1e4236; transform: scale(1.08); }
}
@media (prefers-reduced-motion: no-preference) {
  .building-frame.in-view .building-crop {
    animation: centre-camera 2.8s cubic-bezier(.18,.69,.24,1) both;
  }
  .photo-glass.in-view .building-crop { animation-delay: .1s; }
  .photo-entrance.in-view .building-crop { animation-delay: .18s; }
  @keyframes centre-camera {
    from { transform: scale(1.074) translate(-.65%, .5%); }
    to { transform: scale(1) translate(0, 0); }
  }
}

html.gallery-open { overflow: hidden; }
.building-lightbox {
  box-sizing: border-box;
  position: fixed;
  inset: 0;
  margin: 0;
  padding: 0;
  border: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-width: none;
  max-height: none;
  overflow: hidden;
  color: #f7faf7;
  background: #101713f8;
  overscroll-behavior: contain;
}
.building-lightbox:not([open]) { display: none; }
.building-lightbox::backdrop { background: #101713; }
.lightbox-stage {
  position: absolute;
  inset: max(4.7rem, env(safe-area-inset-top)) 5.6rem max(3rem, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: pan-y pinch-zoom;
}
.lightbox-stage img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 3px;
  user-select: none;
  -webkit-user-drag: none;
}
.lightbox-count {
  position: absolute;
  top: max(1.25rem, env(safe-area-inset-top));
  left: max(1.5rem, env(safe-area-inset-left));
  font: 500 .9rem/2.75rem var(--sans);
  letter-spacing: .1em;
  font-variant-numeric: tabular-nums;
}
.lightbox-button {
  position: absolute;
  z-index: 1;
  width: 2.85rem;
  height: 2.85rem;
  background: #22332be0;
  border-color: #819189;
}
.lightbox-button:hover, .lightbox-button:focus-visible { color: #183025; background: #edf1e8; }
.lightbox-close { top: max(1.25rem, env(safe-area-inset-top)); right: max(1.5rem, env(safe-area-inset-right)); }
.lightbox-prev, .lightbox-next { top: 50%; transform: translateY(-50%); }
.lightbox-prev { left: max(1.25rem, env(safe-area-inset-left)); }
.lightbox-next { right: max(1.25rem, env(safe-area-inset-right)); }
.lightbox-error { color: white; text-decoration: underline; }
@media (max-width: 680px) {
  .building-gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto auto;
    gap: .55rem;
    aspect-ratio: auto;
  }
  .photo-corner { grid-column: 1/-1; grid-row: auto; aspect-ratio: 1.4; }
  .photo-glass, .photo-entrance { aspect-ratio: 1.09; }
  .photo-glass { --photo-focus: 62% 65%; --photo-scale: 1.48; }
  .photo-entrance { --photo-focus: 34% 64%; --photo-scale: 1.07; }
  .expand-photo { width: 2rem; height: 2rem; right: .5rem; bottom: .5rem; }
  .expand-photo .icon { width: .96rem; height: .96rem; }
  .lightbox-stage { inset: 4.7rem .55rem 5.7rem; }
  .lightbox-prev, .lightbox-next { top: auto; bottom: max(1.1rem, env(safe-area-inset-bottom)); transform: none; }
  .lightbox-prev { left: calc(50% - 3.4rem); }
  .lightbox-next { right: calc(50% - 3.4rem); }
}
@media (max-height: 520px) and (min-width: 681px) {
  .lightbox-stage { inset-block: .65rem; }
  .lightbox-count, .lightbox-close { top: .65rem; }
}
