/* Gallery cards: square image on top, fixed-height caption at the bottom */
.md-typeset .grid.cards.gallery {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.md-typeset .grid.cards.gallery > ul > li {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.md-typeset .grid.cards.gallery > ul > li > p:first-child {
  margin: 0;
}

.md-typeset .grid.cards.gallery img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background-color: white;
}

.md-typeset .grid.cards.gallery img.contain {
  object-fit: contain;
}

.md-typeset .grid.cards.gallery > ul > li > hr {
  margin: 0;
}

/* Caption: fixed height so text starts at the same place in every card */
.md-typeset .grid.cards.gallery > ul > li > p:last-child {
  margin: 0;
  margin-top: auto;
  padding: 0.4rem 0.6rem;
  height: 3.9em; /* 3 lines */
  box-sizing: content-box;
  overflow: hidden;
  font-size: 0.55rem;
  line-height: 1.3;
}

.md-typeset .grid.cards.gallery > ul > li > p:last-child strong {
  display: block;
}
