/**
 * DAM Gallery Block - Frontend Styles
 */

.wp-block-dam-gallery {
  margin: 0 0 1em 0;
}

.wp-block-dam-gallery .blocks-gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.wp-block-dam-gallery.columns-1 .blocks-gallery-grid {
  grid-template-columns: repeat(1, 1fr);
}

.wp-block-dam-gallery.columns-2 .blocks-gallery-grid {
  grid-template-columns: repeat(2, 1fr);
}

.wp-block-dam-gallery.columns-3 .blocks-gallery-grid {
  grid-template-columns: repeat(3, 1fr);
}

.wp-block-dam-gallery.columns-4 .blocks-gallery-grid {
  grid-template-columns: repeat(4, 1fr);
}

.wp-block-dam-gallery.columns-5 .blocks-gallery-grid {
  grid-template-columns: repeat(5, 1fr);
}

.wp-block-dam-gallery.columns-6 .blocks-gallery-grid {
  grid-template-columns: repeat(6, 1fr);
}

.wp-block-dam-gallery .blocks-gallery-item {
  position: relative;
  overflow: hidden;
}

.wp-block-dam-gallery .blocks-gallery-item img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.3s ease;
}

.wp-block-dam-gallery .blocks-gallery-item:hover img {
  transform: scale(1.05);
}

.wp-block-dam-gallery.is-cropped .blocks-gallery-item {
  aspect-ratio: 1 / 1;
}

.wp-block-dam-gallery.is-cropped .blocks-gallery-item img {
  height: 100%;
  object-fit: cover;
}

.wp-block-dam-gallery .blocks-gallery-item figcaption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 0.875em;
  text-align: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.wp-block-dam-gallery .blocks-gallery-item:hover figcaption {
  opacity: 1;
}

/* Masonry layout */
.wp-block-dam-gallery.layout-masonry .blocks-gallery-grid {
  display: block;
  column-count: 3;
  column-gap: 16px;
}

.wp-block-dam-gallery.layout-masonry .blocks-gallery-item {
  break-inside: avoid;
  margin-bottom: 16px;
}

/* Carousel layout */
.wp-block-dam-gallery.layout-carousel .blocks-gallery-grid {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  gap: 16px;
  scrollbar-width: thin;
  scrollbar-color: #888 #f1f1f1;
}

.wp-block-dam-gallery.layout-carousel .blocks-gallery-grid::-webkit-scrollbar {
  height: 8px;
}

.wp-block-dam-gallery.layout-carousel .blocks-gallery-grid::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.wp-block-dam-gallery.layout-carousel .blocks-gallery-grid::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 4px;
}

.wp-block-dam-gallery.layout-carousel .blocks-gallery-grid::-webkit-scrollbar-thumb:hover {
  background: #555;
}

.wp-block-dam-gallery.layout-carousel .blocks-gallery-item {
  flex: 0 0 auto;
  scroll-snap-align: start;
  width: 300px;
}

/* Lightbox styles */
.wp-block-dam-gallery.has-lightbox .blocks-gallery-item {
  cursor: pointer;
}

/* Responsive */
@media (max-width: 768px) {
  .wp-block-dam-gallery .blocks-gallery-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .wp-block-dam-gallery.layout-masonry .blocks-gallery-grid {
    column-count: 2;
  }
}

@media (max-width: 480px) {
  .wp-block-dam-gallery .blocks-gallery-grid {
    grid-template-columns: repeat(1, 1fr);
  }

  .wp-block-dam-gallery.layout-masonry .blocks-gallery-grid {
    column-count: 1;
  }
}
