.stmw-wg{
  --stmw-cols: 4;
  --stmw-gap: 10px;
  --stmw-auto-row: 8px;

  position: relative;
}

.stmw-wg__grid{
  display: grid;
  grid-template-columns: repeat(var(--stmw-cols), 1fr);
  gap: var(--stmw-gap);
  grid-auto-rows: var(--stmw-auto-row);
  align-items: stretch;
}

.stmw-wg__item{
  margin: 0;
  overflow: hidden;
  position: relative;
  background: rgba(0,0,0,0.02);
}

.stmw-wg__item img{
  width: 100%;
  height: auto;
  display: block;
  transform: translateZ(0);
  will-change: transform;
  transition: transform .35s ease;
}

.stmw-wg--hover-zoom .stmw-wg__item:hover img{
  transform: scale(1.04);
}

.stmw-wg--hover-shadow .stmw-wg__item{
  transition: box-shadow .25s ease, transform .25s ease;
}
.stmw-wg--hover-shadow .stmw-wg__item:hover{
  box-shadow: 0 14px 40px rgba(0,0,0,.16);
  transform: translateY(-2px);
}

.stmw-wg__caption{
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.2;
  background: linear-gradient(to top, rgba(0,0,0,.60), rgba(0,0,0,0));
  color: #fff;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: none;
}
.stmw-wg__item:hover .stmw-wg__caption{
  opacity: 1;
  transform: translateY(0);
}

/* Preloader overlay */
.stmw-wg__preloader{
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(2px);
  opacity: 1;
  transition: opacity .35s ease;
}
.stmw-wg.is-loaded .stmw-wg__preloader{
  opacity: 0;
  pointer-events: none;
}

/* Dots */
.stmw-wg__loader--dots span{
  display:inline-block;
  width: 10px; height: 10px;
  margin: 0 4px;
  border-radius: 50%;
  background: rgba(0,0,0,.55);
  animation: stmw-wg-dot 1s infinite ease-in-out;
}
.stmw-wg__loader--dots span:nth-child(2){ animation-delay:.15s; }
.stmw-wg__loader--dots span:nth-child(3){ animation-delay:.3s; }
@keyframes stmw-wg-dot{
  0%, 80%, 100% { transform: translateY(0); opacity: .45; }
  40% { transform: translateY(-8px); opacity: 1; }
}

/* Spinner */
.stmw-wg__spinner{
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(0,0,0,.18);
  border-top-color: rgba(0,0,0,.65);
  display: inline-block;
  animation: stmw-wg-spin 0.9s linear infinite;
}
@keyframes stmw-wg-spin{ to { transform: rotate(360deg); } }

/* Bar */
.stmw-wg__loader--bar{
  width: 140px;
  height: 4px;
  background: rgba(0,0,0,.12);
  border-radius: 999px;
  overflow: hidden;
}
.stmw-wg__bar{
  display:block;
  height: 100%;
  width: 40%;
  background: rgba(0,0,0,.55);
  border-radius: 999px;
  animation: stmw-wg-bar 1s ease-in-out infinite;
}
@keyframes stmw-wg-bar{
  0% { transform: translateX(-120%); }
  50% { transform: translateX(120%); }
  100% { transform: translateX(240%); }
}

/* Lightbox */
.stmw-wg__lightbox{
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.82);
  animation: stmw-wg-fadein .18s ease;
}
.stmw-wg__lightbox.is-open{ display:flex; }
@keyframes stmw-wg-fadein{ from{opacity:0} to{opacity:1} }

.stmw-wg__lb-stage{
  max-width: min(1100px, 92vw);
  max-height: 86vh;
  display:flex;
  align-items:center;
  justify-content:center;
}
.stmw-wg__lb-img{
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  box-shadow: 0 30px 80px rgba(0,0,0,.45);
}

.stmw-wg__lb-close,
.stmw-wg__lb-prev,
.stmw-wg__lb-next{
  position: absolute;
  border: 0;
  background: rgba(255,255,255,.12);
  color: #fff;
  width: 44px; height: 44px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 26px;
  display:flex;
  align-items:center;
  justify-content:center;
  transition: background .2s ease, transform .2s ease;
}
.stmw-wg__lb-close{ top: 18px; right: 18px; font-size: 28px; }
.stmw-wg__lb-prev{ left: 18px; }
.stmw-wg__lb-next{ right: 18px; }
.stmw-wg__lb-close:hover,
.stmw-wg__lb-prev:hover,
.stmw-wg__lb-next:hover{
  background: rgba(255,255,255,.20);
  transform: scale(1.03);
}

.stmw-wg__lb-counter{
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,.9);
  font-size: 13px;
  background: rgba(0,0,0,.35);
  padding: 8px 10px;
  border-radius: 999px;
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce){
  .stmw-wg__item img,
  .stmw-wg__caption,
  .stmw-wg__preloader,
  .stmw-wg__loader--dots span,
  .stmw-wg__spinner,
  .stmw-wg__bar,
  .stmw-wg__lightbox{ animation: none !important; transition: none !important; }
}
