/* Photo gallery --------------------------------------------------------
   A gallery is the tile grid above with quieter captions: the photographs
   are the content, the words under them are a footnote. The block is named
   photo-gallery rather than gallery because .gallery is already the product
   page's picture column further down this stylesheet, and a section carrying
   both classes would get that flex column instead of the grid. */

.photo-gallery__item .tile__caption {
  padding: var(--space-2) var(--space-3);
}

/* The item is a <button> (sections.go galleryItem), not an anchor: an anchor
   to the large image was a download link under the right button. A button
   brings its own padding, centred text and font, so it is put back to what
   the tile is — and it takes the anchor tile's hover, which tiles.css gives
   to a.tile only. */
.photo-gallery__item {
  width: 100%;
  padding: 0;
  font: inherit;
  text-align: inherit;
  cursor: pointer;
}

.photo-gallery__item:hover {
  border-color: var(--primary);
  box-shadow: var(--glow-pink);
}

.photo-gallery__item:hover img {
  transform: scale(1.03);
}

@media (prefers-reduced-motion: reduce) {
  .photo-gallery__item:hover img {
    transform: none;
  }
}


/* Photo reader ---------------------------------------------------------
   The one dialog every enlargeable photo opens in (ui.PhotoReader, drawn
   once per page): the product gallery, a gallery section, a version's
   contents sheet. It wears the shared .dialog shell for its motion and
   takes the whole screen: a bar of controls on top, the photo in a body
   that scrolls, prev/next at the bottom. The photo is fitted to the width,
   so a tall contents sheet reads like a page instead of shrinking to a
   strip; a picture that is not a sheet also fits the height, so a cover is
   seen whole. Controls sit on the darker scrim in light ink in both themes,
   as over every photo. */

.reader {
  inset: 0;
  width: 100%;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--hero-ink);
  overflow: hidden;
}

.reader[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.reader[open]::backdrop {
  background: var(--backdrop-deep);
}

/* How far through the photo the body is scrolled. Decorative: the body's
   own scrollbar is the control. */
.reader__progress {
  position: absolute;
  inset: 0 0 auto;
  z-index: 1;
  height: 3px;
  pointer-events: none;
}

.reader__progress > span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--primary);
}

.reader__top {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: max(var(--space-3), env(safe-area-inset-top)) max(var(--space-3), env(safe-area-inset-right)) var(--space-2) max(var(--space-3), env(safe-area-inset-left));
}

.reader__chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--control-height);
  padding: 0 var(--space-4);
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--scrim-strong);
  color: var(--hero-ink);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
}

.reader__chip--icon {
  width: var(--control-height);
  padding: 0;
}

.reader__chip:hover {
  color: var(--primary);
}

.reader__chip[hidden] {
  display: none;
}

.reader__body {
  overflow: auto;
  overscroll-behavior: contain;
  padding: 0 var(--space-3);
}

.reader__body:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.reader__img {
  display: block;
  margin: 0 auto;
  width: min(720px, 100%);
  height: auto;
}

/* A picture that is not a sheet is seen whole: it keeps to the width limit
   and to the height of the body. */
.reader:not(.is-tall) .reader__img {
  width: auto;
  max-width: min(720px, 100%);
  max-height: 100%;
}

.reader:not(.is-tall) .reader__body {
  display: grid;
  place-items: center;
  align-content: center;
}

/* Zoomed in: a sheet's small print, wider than the screen, scrolled both
   ways. */
.reader.is-zoomed .reader__img {
  width: min(1200px, 160%);
  max-width: none;
}

.reader__caption {
  max-width: 720px;
  margin: var(--space-3) auto;
  color: var(--hero-ink-soft);
  font-size: var(--text-sm);
  text-align: center;
}

.reader__caption:empty {
  display: none;
}

.reader__nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-2) var(--space-3) max(var(--space-3), env(safe-area-inset-bottom));
}

.reader__nav[hidden] {
  display: none;
}

.reader__count {
  min-width: 4ch;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  background: var(--scrim-strong);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  text-align: center;
}
