/* Media gallery */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.piece {
  text-align: center;
}

.piece a {
  display: block;
  background: var(--border);
  border-radius: 8px;
  padding: 1rem;
  transition:
    transform 0.15s,
    box-shadow 0.15s;
}

.piece a:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgb(0 0 0 / 15%);
}

.piece img {
  width: 100%;
  height: 120px;
  object-fit: contain;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.piece-title {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

/* Large thumbnails for blog post images */
.piece.large {
  max-width: 100%;
  margin: 1.5rem 0;
}

.piece.large img {
  height: auto;
  max-height: 400px;
  image-rendering: auto;
}

/* Video thumbnails */
.piece.video .video-thumb {
  position: relative;
  display: block;
  width: 100%;
  background: var(--border);
  border: none;
  border-radius: 8px;
  padding: 1rem;
  cursor: pointer;
  transition:
    transform 0.15s,
    box-shadow 0.15s;
}

.piece.video .video-thumb:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgb(0 0 0 / 15%);
}

.piece.video video {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
  border-radius: 4px;
}

.piece.video.large video {
  height: auto;
  max-height: 400px;
}

@media (width <= 400px) {
  .gallery {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }
}

/* Gallery piece button */
.piece button {
  display: block;
  width: 100%;
  background: var(--border);
  border: none;
  border-radius: 8px;
  padding: 1rem;
  cursor: pointer;
  transition:
    transform 0.15s,
    box-shadow 0.15s;
}

.piece button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgb(0 0 0 / 15%);
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 90%);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.2s,
    visibility 0.2s;
  z-index: 1101;
}

.lightbox.open {
  opacity: 1;
  visibility: visible;
}

.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  text-align: center;
}

.lightbox-content img {
  max-width: 100%;
  max-height: 80vh;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #fff;
  border-radius: 4px;
}

.lightbox-content video {
  display: none;
  max-width: 100%;
  max-height: 80vh;
  border-radius: 4px;
}

.lightbox-close {
  position: absolute;
  top: 0.5rem;
  right: -3.5rem;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  width: 2.5rem;
  height: 2.5rem;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.lightbox-close:hover {
  background: var(--accent-secondary);
}

@media (width <= 600px) {
  .lightbox-close {
    right: 0.5rem;
  }
}

#lightbox-title {
  color: #fff;
  margin-top: 1rem;
  font-size: 1.1rem;
}
