/*

* {
  box-sizing: border-box;
}
*/ 

.wrapper {
  width: 100%;
  padding: 0 2rem 2rem;
  text-align: center;
  display: flex;
  justify-content: center;
}
.polaroid {
  background: #fff;
  padding: 1rem;
  box-shadow: 0 0.2rem 1.2rem rgba(0,0,0,0.2);
  
}
.polaroid > img{
  max-width: 100%;
  height: auto;
  /* added late for preview */
  cursor: zoom-in;
  transition: transform 0.25s ease;
}
.caption {
  font-size: 1.8rem;
  text-align: center;
  line-height: 2em;
}
.item {
  width: 40%;
  display: inline-block;
  margin-top: 2rem;
  /* filter: grayscale(100%); */
}
.item .polaroid:before {
  content: '';
  position: absolute;
  z-index: -1;
  transition: all 0.35s;
}
.item:nth-of-type(4n+1) {
  transform: scale(0.8, 0.8) rotate(5deg);
  transition: all 0.35s;
}
.item:nth-of-type(4n+1) .polaroid:before {
  transform: rotate(6deg);
  height: 20%;
  width: 47%;
  bottom: 30px;
  right: 12px;
  box-shadow: 0 2.1rem 2rem rgba(0,0,0,0.4);
}
.item:nth-of-type(4n+2) {
  transform: scale(0.8, 0.8) rotate(-5deg);
  transition: all 0.35s;
}
.item:nth-of-type(4n+2) .polaroid:before {
  transform: rotate(-6deg);
  height: 20%;
  width: 47%;
  bottom: 30px;
  left: 12px;
  box-shadow: 0 2.1rem 2rem rgba(0,0,0,0.4);
}
.item:nth-of-type(4n+4) {
  transform: scale(0.8, 0.8) rotate(3deg);
  transition: all 0.35s;
}
.item:nth-of-type(4n+4) .polaroid:before {
  transform: rotate(4deg);
  height: 20%;
  width: 47%;
  bottom: 30px;
  right: 12px;
  box-shadow: 0 2.1rem 2rem rgba(0,0,0,0.3);
}
.item:nth-of-type(4n+3) {
  transform: scale(0.8, 0.8) rotate(-3deg);
  transition: all 0.35s;
}
.item:nth-of-type(4n+3) .polaroid:before {
  transform: rotate(-4deg);
  height: 20%;
  width: 47%;
  bottom: 30px;
  left: 12px;
  box-shadow: 0 2.1rem 2rem rgba(0,0,0,0.3);
}
.item:hover {
  filter: none;
  transform: scale(1, 1) rotate(0deg) !important;
  transition: all 0.35s;
}
.item:hover .polaroid:before {
  content: '';
  position: absolute;
  z-index: -1;
  transform: rotate(0deg);
  height: 90%;
  width: 90%;
  bottom: 0%;
  right: 5%;
  box-shadow: 0 1rem 3rem rgba(0,0,0,0.2);
  transition: all 0.35s;
}
/* Full-screen image preview */
.image-preview {
  display: none;
  position: fixed;
  z-index: 9999;
  inset: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);

  /* Center the image */
  align-items: center;
  justify-content: center;

  padding: 2rem;
  box-sizing: border-box;

  cursor: zoom-out;
}

/* Show the preview */
.image-preview.active {
  display: flex;
}

/* Enlarged image */
.image-preview img {
  max-width: 90vw;
  max-height: 90vh;
  width: auto;
  height: auto;

  object-fit: contain;

  border-radius: 4px;
  box-shadow: 0 1rem 4rem rgba(0, 0, 0, 0.5);

  cursor: default;

  animation: imageZoom 0.25s ease;
}

/* Close button */
.image-preview .close {
  position: absolute;
  top: 1.5rem;
  right: 2rem;

  color: #fff;
  font-size: 3rem;
  font-weight: 300;
  line-height: 1;

  cursor: pointer;
  user-select: none;

  transition: opacity 0.2s ease;
}

.image-preview .close:hover {
  opacity: 0.7;
}

/* Opening animation */
@keyframes imageZoom {
  from {
    opacity: 0;
    transform: scale(0.8);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}
/* Gallery mode — removes the random Polaroid rotations */
.no-rotate {
  transform: scale(1, 1) rotate(0deg) !important;
  filter: none !important;
  transition: all 0.35s;
  /* width: 27%; */
} */
/* Keep the gallery grayscale behavior if desired */
.no-rotate:hover {
  transform: scale(1, 1) rotate(0deg) !important;
  filter: none !important;
}
/* Optional: remove the shadow effects created by the
   rotated Polaroid pseudo-elements */
.no-rotate .item:hover .polaroid:before {
  transform: rotate(0deg) !important;
}
.item2 {
  transform: scale(0.8, 0.8) rotate(-5deg);
  transition: all 0.35s;
}
.item2 .polaroid:before {
  transform: rotate(-6deg);
  height: 20%;
  width: 47%;
  bottom: 30px;
  left: 12px;
  box-shadow: 0 2.1rem 2rem rgba(0,0,0,0.4);
}
@media (max-width: 768px) {
    .wrapper {
        padding: 0 0.5rem 2rem;
    }
    .item {
        width: 46%;
        margin: 1.5rem 1%;
    }
    .polaroid {
        padding: 0.5rem;
    }
    .polaroid > img {
        width: 100%;
        display: block;
    }
    .caption {
        font-size: 1rem;
        line-height: 1.4;
    }
    .item:nth-of-type(4n+1),
    .item:nth-of-type(4n+2),
    .item:nth-of-type(4n+3),
    .item:nth-of-type(4n+4) {
        transform: scale(0.95) rotate(5deg);
    }
    .item:hover {
        transform: scale(0.95) rotate(0deg) !important;
    }
    .image-preview {
        padding: 1rem;
    }
    .image-preview img {
        max-width: 95vw;
        max-height: 85vh;
    }
    .image-preview .close {
        top: 1rem;
        right: 1.25rem;
        font-size: 2.5rem;
    }
}