.orpi-gallery{
  display: grid;
  grid-template-columns: repeat(var(--orpi-cols, 3), minmax(0, 1fr));
  gap: 0.875rem;
}

@media (max-width: 61.25rem){
  .orpi-gallery{
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 37.5rem){
  .orpi-gallery{
    grid-template-columns: 1fr;
  }
}

.orpi-item{
  margin: 0;
  position: relative;
  overflow: hidden;
}

.orpi-lb-trigger,
.orpi-link{
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  appearance: none;
  -webkit-appearance: none;
}

.orpi-img{
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  object-fit: cover;
  border-radius: 0;
}

.orpi-cap{
  display: none;
}

/* Featured 5-image layout: 1 large left + 4 small right */
.orpi-gallery.orpi-gallery--layout-featured{
  display: grid !important;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr) !important;
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr) !important;
  grid-template-areas:
    "main small1 small2"
    "main small3 small4" !important;
  gap: 0.5rem !important;
  height: 34rem !important;
  overflow: hidden;
  border-radius: 0;
}

.orpi-gallery.orpi-gallery--layout-featured .orpi-item,
.orpi-gallery.orpi-gallery--layout-featured .orpi-lb-trigger,
.orpi-gallery.orpi-gallery--layout-featured .orpi-link{
  height: 100% !important;
  min-height: 0 !important;
}

.orpi-gallery.orpi-gallery--layout-featured .orpi-item:nth-child(1){
  grid-area: main !important;
}

.orpi-gallery.orpi-gallery--layout-featured .orpi-item:nth-child(2){
  grid-area: small1 !important;
}

.orpi-gallery.orpi-gallery--layout-featured .orpi-item:nth-child(3){
  grid-area: small2 !important;
}

.orpi-gallery.orpi-gallery--layout-featured .orpi-item:nth-child(4){
  grid-area: small3 !important;
}

.orpi-gallery.orpi-gallery--layout-featured .orpi-item:nth-child(5){
  grid-area: small4 !important;
}

.orpi-gallery.orpi-gallery--layout-featured .orpi-img{
  width: 100% !important;
  height: 100% !important;
  aspect-ratio: auto !important;
  border-radius: 0 !important;
  object-fit: cover !important;
  transition: transform 0.25s ease, filter 0.25s ease;
}

.orpi-gallery.orpi-gallery--layout-featured .orpi-lb-trigger:hover .orpi-img,
.orpi-gallery.orpi-gallery--layout-featured .orpi-link:hover .orpi-img{
  transform: scale(1.035);
  filter: brightness(0.92);
}

/* Hide Show All button/overlay for featured layout */
.orpi-gallery.orpi-gallery--layout-featured .orpi-item--show-all .orpi-lb-trigger::after,
.orpi-gallery.orpi-gallery--layout-featured .orpi-show-all-label{
  display: none !important;
}

/* Mobile: 1 large image top + 4 small images in one row */
@media (max-width: 767px){
  .orpi-gallery.orpi-gallery--layout-featured{
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    grid-template-rows: 32rem 8rem !important;
    grid-template-areas:
      "main main main main"
      "small1 small2 small3 small4" !important;
    gap: 0.5rem !important;
    height: auto !important;
    border-radius: 0rem;
  }

  .orpi-gallery.orpi-gallery--layout-featured .orpi-item:nth-child(1){
    height: 32rem !important;
  }

  .orpi-gallery.orpi-gallery--layout-featured .orpi-item:nth-child(n+2){
    height: 8rem !important;
  }
}

.orpi-item--show-all .orpi-lb-trigger::after{
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.22);
  pointer-events: none;
}

.orpi-show-all-label{
  position: absolute;
  right: 0.875rem;
  bottom: 0.875rem;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.375rem;
  padding: 0.5625rem 0.875rem;
  border-radius: 0.5rem;
  background: #fff;
  color: #111;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  box-shadow: 0 0.5rem 1.375rem rgba(0,0,0,0.22);
  pointer-events: none;
}

@media (max-width: 767px){
  .orpi-show-all-label{
    right: 0.625rem;
    bottom: 0.625rem;
    min-height: 2.125rem;
    padding: 0.5rem 0.6875rem;
    font-size: 0.8125rem;
  }
}

.orpi-error{
  padding: 0.75rem 0.875rem;
  border: 0.0625rem solid rgba(0,0,0,0.1);
  border-radius: 0.625rem;
  background: #fff8f8;
}

/* Lightbox */
.orpi-lb{
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: none;
}

.orpi-lb.is-open{
  display: block;
}

html.orpi-lb-open,
html.orpi-lb-open body{
  overflow: hidden !important;
}

.orpi-lb__backdrop{
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.86);
  opacity: 0;
  transition: opacity 0.18s ease;
}

.orpi-lb.is-open .orpi-lb__backdrop{
  opacity: 1;
}

.orpi-lb__panel{
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.75rem 1.125rem 1.125rem;
  gap: 0.875rem;
}

.orpi-lb__top{
  position: fixed;
  top: 1rem;
  left: 1rem;
  right: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.orpi-lb__counter{
  pointer-events: auto;
  font-size: 0.8125rem;
  color: rgba(255,255,255,0.85);
  background: rgba(0,0,0,0.35);
  border: 0.0625rem solid rgba(255,255,255,0.18);
  padding: 0.4375rem 0.625rem;
  border-radius: 999rem;
  backdrop-filter: blur(0.375rem);
}

.orpi-lb__figure{
  margin: 0;
  max-width: min(75rem, 94vw);
  max-height: min(78vh, 56.25rem);
  display: flex;
  align-items: center;
  justify-content: center;
}

.orpi-lb__img{
  display: block;
  max-width: 94vw;
  max-height: 78vh;
  width: auto;
  height: auto;
  border-radius: 0;
  box-shadow: 0 1.25rem 3.75rem rgba(0,0,0,0.55);
  opacity: 1;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.orpi-lb.is-loading .orpi-lb__img{
  opacity: 0.25;
  transform: scale(0.995);
}

.orpi-lb__cap{
  max-width: min(56.25rem, 94vw);
  text-align: center;
  font-size: 0.875rem;
  line-height: 1.35;
  color: rgba(255,255,255,0.9);
  opacity: 0.95;
  padding: 0.5rem 0.75rem;
}

.orpi-lb__close{
  pointer-events: auto;
  width: 2.75rem;
  height: 2.75rem;
  border: none;
  background: transparent;
  color: #fff;
  font-size: 2.125rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.orpi-lb__nav{
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 3.25rem;
  height: 3.25rem;
  border: none;
  background: transparent;
  color: #fff;
  font-size: 3.5rem;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
  padding: 0;
  opacity: 0.85;
}

.orpi-lb__nav:hover{
  opacity: 1;
}

.orpi-lb__prev{
  left: 1.25rem;
}

.orpi-lb__next{
  right: 1.25rem;
}

@media (max-width: 767px){
  .orpi-lb__nav{
    width: 2.75rem;
    height: 2.75rem;
    font-size: 2.75rem;
  }

  .orpi-lb__prev{
    left: 0.375rem;
  }

  .orpi-lb__next{
    right: 0.375rem;
  }

  .orpi-lb__img{
    max-width: 94vw;
    max-height: 72vh;
  }
}


@media (max-width: 767px) {
  /* Image grid/container */
  .orpi-gallery.orpi-gallery--layout-featured {
    position: relative !important;
    z-index: 10 !important;
  }

  .orpi-gallery.orpi-gallery--layout-featured .orpi-item,
  .orpi-gallery.orpi-gallery--layout-featured .orpi-lb-trigger {
    position: relative !important;
    z-index: 11 !important;
    pointer-events: auto !important;
  }


}
