/* Real moving photography: preserve document order through the mosaic. */
.pg-photo-collage {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: clamp(145px, 15vw, 210px);
  grid-auto-flow: row;
  gap: 12px;
}
.pg-photo-tile {
  position: relative;
  display: block;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: 6px;
  background: #eef0f3;
  color: #fff;
  text-decoration: none;
  isolation: isolate;
}
.pg-photo-tile:nth-child(8n + 1),
.pg-photo-tile:nth-child(8n + 3),
.pg-photo-tile:nth-child(8n + 5),
.pg-photo-tile:nth-child(8n + 6) { grid-row: span 2; }
.pg-photo-tile figure { position: relative; height: 100%; width: 100%; margin: 0; }
.pg-photo-tile img {
  display: block;
  height: 100%;
  width: 100%;
  object-fit: cover;
  object-position: center;
  transition: transform .35s ease;
}
.pg-photo-tile figure::after {
  content: '';
  pointer-events: none;
  position: absolute;
  inset: 40% 0 0;
  background: linear-gradient(transparent, #11172fd9);
}
.pg-photo-tile figcaption {
  position: absolute;
  z-index: 1;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 1rem 3rem 1rem 1rem;
  color: #fff;
  font-size: .79rem;
  font-weight: 600;
  line-height: 1.5;
  text-wrap: pretty;
}
.pg-photo-tile .pg-photo-tile__zoom,
.pg-photo-tile > .bi,
.pg-photo-tile figure > .bi {
  position: absolute;
  z-index: 2;
  right: .7rem;
  bottom: .7rem;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid #ffffff66;
  border-radius: 50%;
  color: #fff;
  background: #1c23405e;
  font-size: .8rem;
  pointer-events: none;
}
.pg-photo-tile:hover { color: #fff; }
.pg-photo-tile:hover img { transform: scale(1.025); }
.pg-photo-tile:focus-visible { outline: 3px solid #cc5500; outline-offset: 4px; }

#pg-photo-viewer {
  box-sizing: border-box;
  width: min(1160px, calc(100vw - 40px));
  max-width: none;
  height: min(900px, calc(100vh - 40px));
  height: min(900px, calc(100dvh - 40px));
  max-height: none;
  margin: auto;
  padding: 64px 76px 20px;
  border: 1px solid #ffffff26;
  border-radius: 10px;
  background: #1c2340;
  color: #fff;
  box-shadow: 0 24px 100px #0006;
  overflow: hidden;
  overscroll-behavior: contain;
}
#pg-photo-viewer::backdrop { background: #0a1026e6; }
#pg-photo-viewer[open] {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 15px;
}
#pg-photo-viewer *, #pg-photo-viewer *::before, #pg-photo-viewer *::after { box-sizing: border-box; }
#pg-photo-viewer [data-gallery-image] {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  min-width: 0;
  min-height: 0;
  object-fit: contain;
  grid-column: 1;
  grid-row: 1;
  align-self: center;
  justify-self: center;
}
#pg-photo-viewer [data-gallery-caption] {
  grid-column: 1;
  grid-row: 2;
  margin: 0;
  color: #fff;
  font-size: .85rem;
  font-weight: 400;
  line-height: 1.65;
  text-align: center;
  max-height: 90px;
  overflow: auto;
}
#pg-photo-viewer [data-gallery-counter] {
  position: absolute;
  top: 23px;
  left: 24px;
  color: #e3e6ee;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .04em;
}
#pg-photo-viewer button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  margin: 0;
  border: 1px solid #ffffff40;
  border-radius: 50%;
  color: #fff;
  background: #ffffff08;
  font-family: inherit;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  transition: background-color .18s ease, border-color .18s ease;
  -webkit-tap-highlight-color: transparent;
}
#pg-photo-viewer button:hover { background: #ffffff16; border-color: #ffffffa6; }
#pg-photo-viewer button:focus-visible { outline: 2px solid #ffad70; outline-offset: 4px; }
#pg-photo-viewer [data-gallery-close] { position: absolute; top: 10px; right: 12px; }
#pg-photo-viewer [data-gallery-prev], #pg-photo-viewer [data-gallery-next] { position: absolute; top: 50%; transform: translateY(-50%); }
#pg-photo-viewer [data-gallery-prev] { left: 15px; }
#pg-photo-viewer [data-gallery-next] { right: 15px; }

@media (min-width: 768px) and (max-width: 991px) {
  .pg-photo-collage { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 200px; }
}
@media (max-width: 767px) {
  .pg-photo-collage {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: clamp(118px, 32vw, 190px);
    gap: 12px;
  }
  .pg-photo-tile,
  .pg-photo-tile:nth-child(8n + 1),
  .pg-photo-tile:nth-child(8n + 3),
  .pg-photo-tile:nth-child(8n + 5),
  .pg-photo-tile:nth-child(8n + 6) { grid-column: span 1; grid-row: span 2; }
  .pg-photo-tile:nth-child(5n + 1) { grid-column: span 2; grid-row: span 3; }
  .pg-photo-tile figcaption { font-size: .73rem; padding: .85rem 2.8rem .85rem .85rem; }
  #pg-photo-viewer {
    width: calc(100vw - 16px);
    height: calc(100vh - 24px);
    height: calc(100dvh - 24px);
    padding: 60px 12px 74px;
    gap: 12px;
    border-radius: 8px;
  }
  #pg-photo-viewer [data-gallery-caption] { font-size: .78rem; line-height: 1.5; max-height: 84px; }
  #pg-photo-viewer [data-gallery-prev], #pg-photo-viewer [data-gallery-next] { top: auto; bottom: 14px; transform: none; }
  #pg-photo-viewer [data-gallery-prev] { left: calc(50% - 56px); }
  #pg-photo-viewer [data-gallery-next] { right: calc(50% - 56px); }
  #pg-photo-viewer [data-gallery-counter] { top: 25px; left: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .pg-photo-tile img, #pg-photo-viewer button { transition: none; }
  .pg-photo-tile:hover img { transform: none; }
}
