/* =========================
   Musimack Facet Gallery CSS
   (Fixes chips/grid “gap” by removing row-spanning layout)
   ========================= */

.mfg-gallery,
.mfg-gallery *{
  box-sizing: border-box;
}

/* ===== Outer layout: ONLY columns ===== */
.mfg-gallery{
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  align-items: start;
  align-content: start;
}

/* ===== Left column (filters) ===== */
.mfg-gallery__filters{
  display: grid;
  gap: 12px;
  align-content: start;

  position: sticky;
  top: 24px;
}

/* ===== Right column wrapper (chips + grid stacked) ===== */
.mfg-gallery__main{
  min-width: 0;
  display: grid;
  gap: 12px;
  align-content: start;
}

/* ===== Chips ===== */
.mfg-gallery__chips{
  min-width: 0;
  align-self: start;
}

/* ===== Grid ===== */
.mfg-gallery__grid{
  min-width: 0;

  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));

  /* Keep results packed top-left (builders can inject alignment) */
  align-content: start !important;
  align-items: start !important;
  justify-content: start !important;
}

/* ===== Filters ===== */
.mfg-gallery__filter-group{
  display: grid;
  gap: 6px;
}

.mfg-gallery__filter-title{
  font-weight: 600;
}

.mfg-gallery__check{
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ===== Items (fixed tiles so filtered views don’t look ragged) ===== */

/* Clear any random margins Bricks/theme might apply */
.mfg-gallery .mfg-gallery__grid > *{
  margin: 0 !important;
}

/* Tile */
.mfg-gallery .mfg-gallery__grid .mfg-gallery__item{
  padding: 0 !important;
  border: 0 !important;
  background: rgba(255,255,255,0.03);
  cursor: pointer;

  display: block !important;
  width: 100%;

  border-radius: 10px;
  overflow: hidden;

  /* Prevent grid “holes” and uneven row packing */
  aspect-ratio: 3 / 4 !important;
  position: relative !important;
}

/* Image fills tile */
.mfg-gallery .mfg-gallery__grid .mfg-gallery__item img{
  position: absolute !important;
  inset: 0 !important;

  width: 100% !important;
  height: 100% !important;

  display: block !important;
  max-width: none !important;

  object-fit: cover !important;
  border-radius: 0 !important;
}

/* ===== Empty state ===== */
.mfg-gallery__empty{
  padding: 16px;
  opacity: 0.8;
}

/* ===== Lightbox ===== */
.mfg-lightbox{
  position: fixed;
  inset: 0;
  display: none;
  z-index: 999999;
}

.mfg-lightbox.is-open{
  display: block;
}

.mfg-lightbox__backdrop{
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.75);
}

.mfg-lightbox__panel{
  position: relative;
  margin: 5vh auto;
  max-width: 90vw;
  max-height: 90vh;
  width: fit-content;
}

.mfg-lightbox__img{
  max-width: 90vw;
  max-height: 90vh;
  display: block;
  border-radius: 12px;
}

.mfg-lightbox__close{
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 28px;
  line-height: 1;
  background: rgba(255,255,255,0.85);
  border: 0;
  border-radius: 999px;
  width: 40px;
  height: 40px;
  cursor: pointer;
}

/* =========================
   Staggered thumbnail fade-in
   ========================= */

@media (prefers-reduced-motion: reduce){
  .mfg-gallery .mfg-gallery__grid .mfg-gallery__item{
    animation: none !important;
    transition: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}

/* Base state: visible */
.mfg-gallery .mfg-gallery__grid .mfg-gallery__item{
  opacity: 1;
  transform: none;
}

/* Only entering items start hidden + offset */
.mfg-gallery .mfg-gallery__grid .mfg-gallery__item.is-entering{
  opacity: 0;
  transform: translateY(8px);
  animation: mfgFadeUp 420ms ease-out both;
  will-change: opacity, transform;
}

@keyframes mfgFadeUp{
  to{
    opacity: 1;
    transform: translateY(0);
  }
}





/* ===== Responsive ===== */
@media (max-width: 900px){
  .mfg-gallery{
    grid-template-columns: 1fr;
  }

  .mfg-gallery__filters{
    position: static;
    top: auto;
  }
}
