#photos-viewer {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

#photos-viewer[hidden] {
  display: none;
}

#pv-backdrop {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: #000;
  transition: opacity 0.38s cubic-bezier(0.32, 0.72, 0, 1);
}

#pv-track {
  position: absolute;
  inset: 0;
  will-change: transform;
}

.pv-item {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.pv-item-current {
  z-index: 1;
}

.pv-item img {
  position: absolute;
  transform-origin: 0 0;
  -webkit-user-drag: none;
  transition: opacity 0.3s ease;
}

/* Desktop affordance: the open image is click-to-zoom, and the cursor says
   so. While zoomed a drag pans and a click zooms back out. */
.pv-item-current img {
  cursor: zoom-in;
}

#photos-viewer[data-zoom='out'] .pv-item-current img {
  cursor: zoom-out;
}

/* Touch screens pinch instead, and the magnifier cursor is meaningless. */
@media (pointer: coarse) {
  .pv-item-current img {
    cursor: auto;
  }
}

/* While the viewer is open the page's own copies of the gallery images are
   hidden but keep their layout size (visibility, not display), so the hero
   fly-in/out lands into an untouched layout and the swap on close is
   seamless. */
.pv-thumb-hidden {
  visibility: hidden;
}

/* Neighbors stay invisible while the hero flies in/out; they fade in once
   the sheet is fully open, like Photos. */
#photos-viewer[data-state='opening'] .pv-item-current,
#photos-viewer[data-state='closing'] .pv-item-current,
#photos-viewer[data-state='open'] .pv-item {
  opacity: 1;
}

.pv-nav,
.pv-close {
  position: absolute;
  width: 44px;
  height: 44px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: rgba(40, 40, 40, 0.55);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.25s ease,
    background-color 0.18s ease,
    transform 0.18s cubic-bezier(0.32, 0.72, 0, 1);
}

#photos-viewer[data-chrome='show'] .pv-nav,
#photos-viewer[data-chrome='show'] .pv-close {
  opacity: 1;
  pointer-events: auto;
}

/* No neighbour to go to: fade the arrow out instead of showing a dead
   control (the JS disables it at the first/last image). Needs the same
   specificity as the chrome rule above to win while the chrome is up. */
.pv-nav[disabled],
#photos-viewer[data-chrome='show'] .pv-nav[disabled] {
  opacity: 0;
  pointer-events: none;
}

/* Hover only where a real cursor exists, so a tap on a touch screen doesn't
   leave a stuck highlight behind. */
@media (hover: hover) {
  .pv-nav:hover,
  .pv-close:hover {
    background: rgba(72, 72, 72, 0.72);
  }

  .pv-nav:hover {
    transform: scale(1.06);
  }
}

.pv-nav:active,
.pv-close:active {
  background: rgba(26, 26, 26, 0.82);
  transform: scale(0.94);
}

.pv-nav:focus-visible,
.pv-close:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.85);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .pv-nav,
  .pv-close {
    transition: opacity 0.25s ease, background-color 0.18s ease;
  }

  .pv-nav:hover,
  .pv-nav:active,
  .pv-close:active {
    transform: none;
  }
}

.pv-nav::before {
  content: '';
  width: 11px;
  height: 11px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(45deg) translate(2px, -2px);
}

#pv-next::before {
  /* Mirror of the prev chevron: rotate(-135deg) flips the shape, so the same
     local translate lands the glyph on the optical centre instead of
     dropping it right + down. */
  transform: rotate(-135deg) translate(2px, -2px);
}

#pv-prev {
  top: calc(50% - 22px);
  left: calc(12px + env(safe-area-inset-left, 0px));
}

#pv-next {
  top: calc(50% - 22px);
  right: calc(12px + env(safe-area-inset-right, 0px));
}

.pv-close {
  top: calc(12px + env(safe-area-inset-top, 0px));
  right: calc(12px + env(safe-area-inset-right, 0px));
}

.pv-close::before,
.pv-close::after {
  content: '';
  position: absolute;
  left: calc(50% - 9px);
  top: calc(50% - 1px);
  width: 18px;
  height: 2px;
  border-radius: 1px;
  background: #fff;
}

.pv-close::before {
  transform: rotate(45deg);
}

.pv-close::after {
  transform: rotate(-45deg);
}

#pv-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  /* Big bottom fade so the caption stays readable over bright photos:
     the scrim is part of the same element, so it fades with the text. */
  padding: 5rem 1.5rem calc(12px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.8) 0%,
    rgba(0, 0, 0, 0.55) 30%,
    rgba(0, 0, 0, 0.25) 60%,
    transparent 100%
  );
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.92);
  opacity: 0;
  transition: opacity 0.25s ease;
}

#photos-viewer[data-chrome='show'] #pv-caption {
  opacity: 1;
}

@media (pointer: coarse) {
  .pv-nav {
    display: none;
  }
}
