#thumbnail-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); /* Используем auto-fit */
  grid-auto-flow: dense; /* Автоматически заполняем пустые места */
  gap: 50px;
  box-sizing: border-box;
  width: 85%;
  align-content: start;
  padding-bottom: 100px; /* Добавляем отступ снизу */
}


@keyframes slideInLeft {
  from {
    transform: translateX(-30px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.thumbnail {
  border-radius: 1em;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  opacity: 1;
  transition: opacity 0.3s;
  background-color: #e0e0e0;
  width: 100%; /* Full width of grid item */
  padding-top: 75%; /* Makes the height equal to the width, keeping it square */
  position: relative; /* Contain absolutely positioned elements */
}

.thumbnail {
  position: relative;
  box-shadow: 0px 15px 30px rgba(0, 0, 0, 0.4); /* Тень снизу */
  border-radius: 1em;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  opacity: 1;
  transition: opacity 0.3s;
  background-color: #e0e0e0;
  width: 100%; /* Full width of grid item */
  padding-top: 75%; /* Makes the height equal to the width, keeping it square */
  position: relative; /* Contain absolutely positioned elements */
}


.thumbnail {
  position: relative;
  transition: transform 0.5s ease-out;
  transform-origin: center;
}




.thumbnail img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center center;
}

.thumbnail-title {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  color: white;
  font-size: 18px;
  opacity: 0;
  transition: opacity 0.5s;
  text-align: center;
  width: 100%;
  text-shadow: 2px 4px 6px rgba(0, 0, 0, 0.8); /* Добавляем тень за текстом */
}






.thumbnail.is-hovered { transform: scale(1.05); }

.thumbnail.is-hovered .thumbnail-title { opacity: 1; }

.thumbnail.is-hovered .overlay-icon {
  opacity: 1;
  animation: slideInLeft 0.6s ease;
}




.thumbnail.is-hovered::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  opacity: 1;
  transition: opacity 0.5s;
  background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0), #1f1f1f);
  z-index: 1;
}



.overlay-icon {
  position: absolute;
  top: 10px;
  left: 10px;
  font-size: 14px;
  color: white;
  margin-right: 5px;
  opacity: 0;
  transition: opacity 0.5s;
  z-index: 2;
}






.overlay-icon + .overlay-icon {
  left: 40px; /* Adjust spacing between icons */
}



/* Для больших превью <a> тоже должен быть больше */
.thumbnail-large-link {
  grid-column: span 2 !important;
  grid-row: span 2 !important;
}

/* 📱 Телефоны: 1 колонка, убираем увеличение больших превью */
@media (max-width: 767px) {
  #thumbnail-container {
    grid-template-columns: 1fr;
  }
  .thumbnail-large,
  .thumbnail-large-link {
    grid-column: span 1 !important; /* Занимает одну колонку */
    grid-row: span 1 !important; /* Занимает одну строку */
    
  }
}

/* 📱 Планшеты: 2 колонки */
@media (min-width: 768px) and (max-width: 991px) {
  #thumbnail-container {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* 💻 Небольшие ноутбуки: 3 колонки */
@media (min-width: 992px) and (max-width: 1199px) {
  #thumbnail-container {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* 🖥️ Десктопы: 4 колонки */
@media (min-width: 1200px) {
  #thumbnail-container {
    grid-template-columns: repeat(4, 1fr);
    
  }
}



/* Делаем так, чтобы <a> тоже масштабировался */
.thumbnail-link {
  display: block;
  width: 100%;
  height: auto;
  -webkit-tap-highlight-color: transparent;
  touch-action: pan-y;
}

.thumbnail::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  opacity: 0;
  transition: opacity 0.5s;
  background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0), #1f1f1f);
  z-index: 1;
}


.thumbnail-large-link {
  display: flex;
}
  

/* Hover effects ONLY for devices with real hover (mouse/trackpad) */
@media (hover: hover) and (pointer: fine) {

  .thumbnail:hover {
    transform: scale(1.05);
  }

  .thumbnail:hover .thumbnail-title {
    opacity: 1;
  }

  .thumbnail:hover .overlay-icon {
    opacity: 1;
    animation: slideInLeft 0.5s forwards;
  }

  .thumbnail:hover::before {
    opacity: 1;
  }

  /* Gradient colors on hover */
  .thumbnail.gradient-green:hover::before {
    background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0), #00b400);
  }

  .thumbnail.gradient-blue:hover::before {
    background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0), #0080ff);
  }

  .thumbnail.gradient-pink:hover::before {
    background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0), #ff4bff);
  }

  .thumbnail.gradient-orange:hover::before {
    background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0), #ff8000);
  }
}


  




/* Цвета градиентов .is-hovered*/
.thumbnail.gradient-green.is-hovered::before {
  background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0), #00b400);
}
.thumbnail.gradient-blue.is-hovered::before {
  background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0), #0080ff);
}
.thumbnail.gradient-pink.is-hovered::before {
  background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0), #ff4bff);
}
.thumbnail.gradient-orange.is-hovered::before {
  background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0), #ff8000);
}
