

.item-grid {
  display: flex;
  flex-wrap: wrap; /* Allows items to wrap to the next row */
  justify-content: space-between; /* Ensures even spacing between items */
  width: 100%;
  max-width: 1200px; /* Default max width */
  margin: 25px auto;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

.item {
  position: relative;
  flex: 1 1 calc(25% - 10px); /* Default: 4 items per row with spacing */
  background-color: #000;
  overflow: hidden;
  box-sizing: border-box;
}

.item:nth-child(4n) {
  margin-right: 0; /* Prevent extra spacing at the end of rows */
}

.item:after {
  content: "";
  display: block;
  background-color: inherit;
  opacity: 0.85;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  transform: scale(2) translateX(-75%) translateY(-75%) translateZ(0) rotate(-28deg);
  transition: transform 3s cubic-bezier(0.23, 1, 0.32, 1);
}

.item:hover:after {
  transform: scale(2) translateX(0%) translateY(0%) translateZ(0) rotate(-28deg);
}

.item:hover .item-image {
  transform: scale(1.2) translateZ(0);
}

.item:hover .item-text {
  opacity: 1;
  transform: translateY(0);
}

.item-image {
  height: 480px;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  transform: translateZ(0);
  transition: transform 750ms cubic-bezier(0.23, 1, 0.32, 1);
}

.item-image::before {
  content: "";
  display: block;
  padding-top: 75%;
  overflow: hidden;
}

.item-image img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: auto;
  line-height: 0;
}

.item-text {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  bottom: 0;
  opacity: 0;
  text-align: center;
  z-index: 1;
  color: #ffffff;
  transition: opacity 500ms cubic-bezier(0.23, 1, 0.32, 1), transform 500ms cubic-bezier(0.23, 1, 0.32, 1);
  transition-delay: 300ms;
  transform: translateY(-20%);
}

.item-text-wrapper {
  width: 100%;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}

.item-text-title {
  font-weight: normal;
  font-size: 16px;
  padding: 0 15px;
  margin: 5px 0 0 0;
}

.item-text-dek {
  text-transform: uppercase;
  font-size: 14px;
  opacity: 0.7;
  margin: 0;
}

.item-link {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 2;
  line-height: 0;
  overflow: hidden;
  text-indent: -9999px;
}

/* Responsive Adjustments */
@media screen and (max-width: 1024px) {
  .item-grid {
    max-width: 900px; /* Adjust max width for 3 items per row */
  }

  .item {
    flex: 1 1 calc(33.33% - 10px); /* 3 items per row */
  }
}

@media screen and (max-width: 768px) {
  .item {
    flex: 1 1 calc(50% - 10px); /* 2 items per row */
  }

  .item-image {
    height: auto;
  }
}

@media screen and (max-width: 480px) {
  .item {
    flex: 1 1 100%; /* 1 item per row */
  }
}
