/* ====== Gallery grid (Gutenberg + shortcode + fallback uz atsevišķiem attēliem) ====== */

/* Gutenberg gallery */
.wp-block-gallery{
  --gap:14px;
  display:grid !important;
  grid-template-columns:repeat(auto-fill, minmax(220px,1fr));
  gap:var(--gap);
  margin:24px 0;
  justify-content:start;   /* vienmēr pie kreisās malas */
  align-content:start;
}

/* Shortcode [gallery] (klasiskā galerija ar <dl> + <br clear="both">) */
.gallery{
  --gap:14px;
  display:grid !important;
  grid-template-columns:repeat(auto-fill, minmax(220px,1fr));
  gap:var(--gap);
  margin:24px 0;
  justify-content:start;   /* vienmēr pie kreisās malas */
  align-content:start;
}

/* Noņem WP default float/width/margin, kas bojā grid izlīdzinājumu */
.gallery .gallery-item{
  float:none !important;
  width:auto !important;
  margin:0 !important;
}

/* Paslēpj <br clear="both">, kas nobīda nākamo rindu pa labi */
.gallery > br{
  display:none !important;
}

/* Fallback: ja rakstā ir daudz .wp-block-image – veidojām galerijas gridu */
.cb-single__content .ojs-auto-gallery{
  --gap:14px;
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(220px,1fr));
  gap:var(--gap);
  margin:24px 0;
  justify-content:start;
}

/* Image cards */
.wp-block-gallery figure,
.gallery .gallery-item,
.cb-single__content .ojs-auto-gallery .wp-block-image{
  position:relative;
  overflow:hidden;
  border-radius:16px;
  background:#f3f4f6;
  margin:0;
}

.wp-block-gallery figure img,
.gallery .gallery-item img,
.cb-single__content .ojs-auto-gallery .wp-block-image img{
  width:100%;
  height:100%;
  object-fit:cover;
  transition:transform .35s ease;
  display:block;
}

/* Hover zoom */
.wp-block-gallery figure:hover img,
.gallery .gallery-item:hover img,
.cb-single__content .ojs-auto-gallery .wp-block-image:hover img{
  transform:scale(1.03);
}

/* Clickable overlay */
.wp-block-gallery figure a,
.gallery .gallery-item a,
.cb-single__content .ojs-auto-gallery .wp-block-image a{
  display:block;
  line-height:0;
}

/* Captions */
.wp-element-caption,
.wp-block-gallery figcaption,
.gallery .gallery-caption,
.cb-single__content .ojs-auto-gallery .wp-block-image figcaption{
  position:absolute;
  left:0; right:0; bottom:0;
  padding:10px 12px;
  font-size:13px;
  color:#fff;
  background:linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,.55) 100%);
}

/* ====== Lightbox (Bootstrap modal) ====== */
.ojs-glightbox .modal-dialog{ max-width:min(1200px,94vw); }
.ojs-glightbox__stage{
  position:relative; width:100%; min-height:200px;
  display:flex; align-items:center; justify-content:center;
}
.ojs-glightbox__img{
  max-width:100%;
  max-height:calc(90vh - 100px);
  border-radius:14px;
  box-shadow:0 20px 60px rgba(0,0,0,.35);
}
.ojs-glightbox__caption{
  color:#fff; text-align:center; margin-top:10px;
  text-shadow:0 2px 8px rgba(0,0,0,.45);
}

/* Prev / Next */
.ojs-glightbox__nav{
  position:absolute; top:50%; transform:translateY(-50%);
  border:0; width:44px; height:44px; border-radius:50%;
  background:rgba(0,0,0,.45); color:#fff; font-size:22px; line-height:44px;
  text-align:center; cursor:pointer; transition:background .2s ease;
}
.ojs-glightbox__nav:hover{ background:rgba(0,0,0,.65); }
.ojs-glightbox__prev{ left:12px; }
.ojs-glightbox__next{ right:12px; }
