/* Your justified gallery CSS */
.op-gal-grid {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
  --gap: 4px;
  --row-height: 200px;
  --radius: 12px;
}

/* Responsive row heights for better mosaic at different viewports */
@media (min-width: 768px) {
  .op-gal-grid {
    --row-height: 220px;
    --gap: 6px;
  }
}

@media (min-width: 1024px) {
  .op-gal-grid {
    --row-height: 240px;
    --gap: 8px;
  }
}

@media (min-width: 1200px) {
  .op-gal-grid {
    --row-height: 20vmin;
    --gap: 8px;
  }
}

@media (min-width: 1600px) {
  .op-gal-grid {
    --row-height: 25vmin;
    --gap: 10px;
  }
}

/**
* This pseudo-element helps to fill the last row properly
* by taking up extra space based on the row height.
*/
.op-gal-grid::after {
  content: "";
  flex-basis: calc(2 * var(--row-height));
  flex-grow: 999999; /* Slightly lower to allow more flexibility */
}

.op-gal-grid-item {
  --ratio: var(--ar);
  --overlay-opacity: 0;
  flex-grow: calc(var(--ratio) * 100);
  flex-basis: calc(var(--ratio) * var(--row-height));
  max-height: calc(
    var(--row-height) * 1.5
  ); /* Prevent items from getting too tall */
  position: relative;
  overflow: hidden;
  background-color: rgba(155, 155, 155, 0.1);
  margin-bottom: var(--gap);
  margin-right: var(--gap);
  opacity: 1;
  overflow: hidden;
  border-radius: var(--radius);

  transition:
    filter 0.3s ease 0.3s,
    opacity 0.3s ease 0.3s,
    transform 0.3s ease;

  &:hover {
    --overlay-opacity: 1;
  }
}

.op-gal-grid-item-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #00000044;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: var(--overlay-opacity);
  transition: opacity 0.3s ease;
  display: flex;
  flex-flow: column;
  justify-content: flex-end;

  overflow: hidden;
}

.op-gal-grid-item-overlay-info {
  width: 100%;
  padding: 0.5rem;
  box-sizing: border-box;
  text-align: center;
}

.op-gal-grid-item-title {
  font-weight: bold;
  font-size: 0.95em;
  line-height: 1.5;
  display: flex;
  justify-content: center;
  gap: 0.5rem;
}
.op-gal-grid-item-artist {
  font-weight: 400;
  font-size: 0.8rem;
  line-height: 2;
}

.op-gal-grid-item-img {
  width: 100%;
  height: 100%;
  max-height: 100%;
  max-width: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}
