#gallery {
  --frame-radius: clamp(40px, 5vw, 96px);
  --frame-pad: clamp(12px, 2vw, 20px);
  background: #f2f2f2;
}

#gallery .news-shell {
  position: relative;
  width: min(1100px, 94vw);
  margin: 0 auto;
  background: #ffffff;
  border-radius: var(--frame-radius);
  border: 1px solid rgba(20, 14, 10, 0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 40px 40px 120px;
  box-shadow: 0 4px 12px rgba(20, 14, 10, 0.06);
  overflow: hidden;
}

#gallery .news-shell + .news-shell {
  margin-top: 40px;
}

#gallery .news-shell > * {
  position: relative;
  z-index: 1;
  width: 100%;
}

#gallery .gallery-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

#gallery .gallery-text .news-heading,
#gallery .gallery-text .news-desc {
  margin: 0;
}

#gallery .gallery-text .news-heading,
#gallery .gallery-text .news-desc {
  text-align: center;
}

#gallery .gallery-cards {
  margin-top: clamp(47px, 9.1vw, 78px);
}

#gallery .popular-grid-scroll {
  overflow: visible;
  scroll-snap-type: none;
}

#gallery .popular-grid {
  position: relative;
  display: block !important;
  height: clamp(300px, 40vw, 440px);
  gap: clamp(16px, 2.4vw, 32px);
  width: 100%;
  max-width: none;
  padding: 0;
  grid-auto-flow: unset;
}

#gallery .popular-card {
  position: absolute;
  left: 50%;
  top: 52%;
  width: clamp(140px, 13vw, 210px);
  flex: 0 0 auto;
  margin-bottom: 0;
  border-radius: 28px;
  border: 1px solid rgba(20, 14, 10, 0.08);
  box-shadow: 0 16px 40px rgba(20, 14, 10, 0.14);
  background: #f4efe7;
  transform-origin: center 70%;
  transform: translate(-50%, -50%)
    translate(var(--slot-x, 0px), calc(var(--slot-y, 0px) + var(--slot-lift, 0%)))
    rotate(var(--slot-rot, 0deg))
    scale(var(--slot-scale, 1));
  transition: transform 800ms cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 800ms cubic-bezier(0.4, 0, 0.2, 1);
}

#gallery .popular-card:hover,
#gallery .popular-grid .popular-card:hover {
  transform: translate(-50%, -50%)
    translate(var(--slot-x, 0px), calc(var(--slot-y, 0px) + var(--slot-lift, 0%)))
    rotate(var(--slot-rot, 0deg))
    scale(var(--slot-scale, 1)) !important;
  box-shadow: 0 16px 40px rgba(20, 14, 10, 0.14) !important;
  z-index: 3;
}

#gallery .popular-card::after {
  background: rgba(20, 14, 10, 0.82);
}

#gallery .popular-card img {
  width: 100%;
  height: auto;
  display: block;
}

/* Arc slots (left -> right) */
#gallery .popular-card.slot-0 {
  --slot-x: clamp(-278px, -21.8vw, -194px);
  --slot-y: clamp(44px, 6vw, 76px);
  --slot-rot: -18deg;
  --slot-scale: 0.9;
  --slot-lift: -15%;
  z-index: 1;
}

#gallery .popular-card.slot-1 {
  --slot-x: clamp(-152px, -10.9vw, -85px);
  --slot-y: clamp(10px, 2vw, 26px);
  --slot-rot: -9deg;
  --slot-scale: 0.98;
  --slot-lift: -15%;
  z-index: 2;
}

#gallery .popular-card.slot-2 {
  --slot-x: 0px;
  --slot-y: -10%;
  --slot-rot: 0deg;
  --slot-scale: 1.12;
  --slot-lift: 0%;
  z-index: 3;
}

#gallery .popular-card.slot-3 {
  --slot-x: clamp(152px, 10.9vw, 85px);
  --slot-y: clamp(10px, 2vw, 26px);
  --slot-rot: 9deg;
  --slot-scale: 0.98;
  --slot-lift: -15%;
  z-index: 2;
}

#gallery .popular-card.slot-4 {
  --slot-x: clamp(278px, 21.8vw, 194px);
  --slot-y: clamp(44px, 6vw, 76px);
  --slot-rot: 18deg;
  --slot-scale: 0.9;
  --slot-lift: -15%;
  z-index: 1;
}

#gallery .popular-grid.count-4 .popular-card.slot-0,
#gallery .popular-grid.count-4 .popular-card.slot-4 {
  --slot-scale: 0.92;
}

#gallery .popular-grid.count-4 .popular-card.slot-1,
#gallery .popular-grid.count-4 .popular-card.slot-3 {
  --slot-y: clamp(10px, 2vw, 26px);
  --slot-scale: 1;
}

#gallery .popular-grid.count-4 .popular-card.slot-1 {
  --slot-x: clamp(-88px, -6.3vw, -49px);
}

#gallery .popular-grid.count-4 .popular-card.slot-3 {
  --slot-x: clamp(88px, 6.3vw, 49px);
}

@media (max-width: 900px) {
  #gallery .news-shell {
    border-radius: 32px;
    padding: 36px 20px 85px;
  }


  #gallery .popular-grid {
    height: clamp(300px, 78vw, 420px);
    padding: 0;
  }

  #gallery .popular-card {
    width: clamp(100px, 32vw, 150px);
    top: 56%;
  }

  #gallery .popular-card.slot-0 {
    --slot-x: clamp(-130px, -34vw, -90px);
    --slot-y: clamp(34px, 9vw, 56px);
  }

  #gallery .popular-card.slot-1 {
    --slot-x: clamp(-70px, -20vw, -50px);
    --slot-y: clamp(12px, 3vw, 22px);
  }

  #gallery .popular-card.slot-2 {
    --slot-y: -16%;
    --slot-scale: 1.08;
  }

  #gallery .popular-card.slot-3 {
    --slot-x: clamp(70px, 20vw, 50px);
    --slot-y: clamp(12px, 3vw, 22px);
  }

  #gallery .popular-card.slot-4 {
    --slot-x: clamp(130px, 34vw, 90px);
    --slot-y: clamp(34px, 9vw, 56px);
  }

  #gallery .popular-grid.count-4 .popular-card.slot-0,
  #gallery .popular-grid.count-4 .popular-card.slot-4 {
    --slot-scale: 0.92;
  }

  #gallery .popular-grid.count-4 .popular-card.slot-1,
  #gallery .popular-grid.count-4 .popular-card.slot-3 {
  --slot-y: clamp(12px, 3vw, 22px);
  --slot-scale: 1;
  }

  #gallery .popular-grid.count-4 .popular-card.slot-1 {
    --slot-x: clamp(-62px, -16vw, -44px);
  }

  #gallery .popular-grid.count-4 .popular-card.slot-3 {
    --slot-x: clamp(62px, 16vw, 44px);
  }
}

  #gallery .gallery-text,
  #gallery .gallery-text .news-heading,
  #gallery .gallery-text .news-desc {
    text-align: center !important;
  }
}

@media (max-width: 1200px) and (min-width: 901px) {
  #gallery .news-shell {
    padding-bottom: 108px;
  }

  #gallery .gallery-cards {
    margin-top: clamp(57px, 11.1vw, 95px);
  }

  #gallery .popular-grid {
    height: clamp(320px, 36vw, 420px);
  }

  #gallery .popular-card {
    width: clamp(150px, 18vw, 200px);
    top: 52%;
  }

  #gallery .popular-card.slot-0 {
    --slot-x: -260px;
    --slot-y: 46px;
  }

  #gallery .popular-card.slot-1 {
    --slot-x: -140px;
    --slot-y: 12px;
  }

  #gallery .popular-card.slot-2 {
    --slot-y: -10%;
    --slot-scale: 1.12;
  }

  #gallery .popular-card.slot-3 {
    --slot-x: 140px;
    --slot-y: 12px;
  }

  #gallery .popular-card.slot-4 {
    --slot-x: 260px;
    --slot-y: 46px;
  }

  #gallery .popular-grid.count-4 .popular-card.slot-0,
  #gallery .popular-grid.count-4 .popular-card.slot-4 {
    --slot-scale: 0.92;
  }

  #gallery .popular-grid.count-4 .popular-card.slot-1,
  #gallery .popular-grid.count-4 .popular-card.slot-3 {
    --slot-y: 12px;
    --slot-scale: 1;
  }

  #gallery .popular-grid.count-4 .popular-card.slot-1 {
    --slot-x: -120px;
  }

  #gallery .popular-grid.count-4 .popular-card.slot-3 {
    --slot-x: 120px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #gallery .popular-grid-scroll {
    scroll-behavior: auto;
  }
}
