/* Responsive photo-gallery layout.
   This stylesheet affects only the responsive gallery classes below. */

.responsive-gallery {
  display: grid;

  /*
   * Equal-width tracks keep all three column centers aligned.
   * Images retain their natural dimensions and are centered within
   * their columns rather than determining the width of each track.
   */
  grid-template-columns: repeat(3, minmax(0, 250px));
  justify-content: center;
  justify-items: center;
  align-items: start;

  column-gap: 5px;
  row-gap: 26px;

  width: calc(100% - 24px);
  max-width: 1100px;
  margin: 0 auto;
  padding: 5px 0 22px;
}

.responsive-gallery-item {
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0;
  text-align: center;
  justify-self: center;
}

.responsive-gallery-item > a {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
}

.responsive-gallery-item img {
  display: block;

  /*
   * Preserve the original display dimensions on desktop and tablet.
   * The image is centered inside an equal-width gallery column.
   */
  width: auto;
  max-width: none;
  height: auto;

  margin: 0 auto;
  border: 0;
}

.responsive-gallery-item figcaption {
  width: 100%;
  margin-top: 8px;
  line-height: 1.3;
  text-align: center;
}

/* Two equal-width centered columns on tablets and narrower windows. */
@media screen and (max-width: 920px) {
  .responsive-gallery {
    grid-template-columns: repeat(2, minmax(0, 250px));
    column-gap: 5px;
    row-gap: 24px;
  }
}

/* One column on phones. */
@media screen and (max-width: 600px) {
  .responsive-gallery {
    grid-template-columns: minmax(0, 1fr);
    width: calc(100% - 16px);
    column-gap: 0;
    row-gap: 24px;
  }

  .responsive-gallery-item {
    width: 100%;
  }

  .responsive-gallery-item img {
    max-width: 100%;
  }
}
