/**
 * Миниатюры в каталоге/корзине: контейнер и индикатор загрузки (Load-6).
 * Десктоп: 80×80 px. Мобилка: каталог (взрыв-схема) 70×70 px, корзина 50×50 px.
 */

/* Контейнер миниатюры (обёртка для img и индикатора загрузки).
   position: relative обязателен, чтобы .thumb-fallback (position: absolute) не выходил за пределы ячейки и не перекрывал страницу. */
.thumb-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  min-width: 80px;
  min-height: 80px;
  border-radius: 8px;
  overflow: hidden;
  background-color: #e9ecef;
}
@media (max-width: 767px) {
  .thumb-wrap {
    width: 50px;
    height: 50px;
    min-width: 50px;
    min-height: 50px;
    border-radius: 6px;
  }
  /* Страница каталога (взрыв-схема): миниатюра 70×70 на мобильном */
  .thumb-wrap--catalogue {
    width: 70px;
    height: 70px;
    min-width: 70px;
    min-height: 70px;
    border-radius: 8px;
  }
  .thumb-wrap--catalogue .thumb-loading {
    width: 70px;
    height: 70px;
    min-width: 70px;
    min-height: 70px;
  }
}

/* Миниатюра (img) внутри контейнера */
.thumb-wrap > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.thumb-wrap .thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.thumb-wrap.thumb-loaded .thumb-loading {
  display: none;
}
.thumb-wrap.thumb-loaded .thumb-img {
  opacity: 1;
}
/* Ошибка загрузки: показываем заглушку */
.thumb-wrap .thumb-fallback {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: #e9ecef;
  border-radius: inherit;
}
.thumb-wrap .thumb-fallback img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.thumb-wrap.thumb-error .thumb-loading,
.thumb-wrap.thumb-error .thumb-img {
  display: none !important;
}
.thumb-wrap.thumb-error .thumb-fallback {
  display: flex !important;
}
.thumb-wrap--catalogue {
  cursor: pointer;
}

/* Индикатор загрузки (анимация "Loading...") */
.thumb-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  min-width: 80px;
  min-height: 80px;
  border-radius: 8px;
  background-color: #e9ecef;
  text-align: center;
}
@media (max-width: 767px) {
  .thumb-loading {
    width: 50px;
    height: 50px;
    min-width: 50px;
    min-height: 50px;
    border-radius: 6px;
  }
}

.thumb-loading .letter-holder {
  padding: 6px 4px;
  overflow: hidden;
}

.thumb-loading .letter {
  float: left;
  font-size: 10px;
  line-height: 1;
  color: #6c757d;
  font-weight: 600;
  animation-name: thumbLoadingF;
  animation-duration: 1.6s;
  animation-iteration-count: infinite;
  animation-direction: linear;
}
@media (max-width: 767px) {
  .thumb-loading .letter {
    font-size: 6px;
  }
  .thumb-loading .letter-holder {
    padding: 2px 1px;
  }
}

.thumb-loading .l-1 { animation-delay: 0.48s; }
.thumb-loading .l-2 { animation-delay: 0.6s; }
.thumb-loading .l-3 { animation-delay: 0.72s; }
.thumb-loading .l-4 { animation-delay: 0.84s; }
.thumb-loading .l-5 { animation-delay: 0.96s; }
.thumb-loading .l-6 { animation-delay: 1.08s; }
.thumb-loading .l-7 { animation-delay: 1.2s; }
.thumb-loading .l-8 { animation-delay: 1.32s; }
.thumb-loading .l-9 { animation-delay: 1.44s; }
.thumb-loading .l-10 { animation-delay: 1.56s; }

@keyframes thumbLoadingF {
  0%   { opacity: 0; }
  100% { opacity: 1; }
}

/* --- Карточка товара (product): те же индикатор и логика, размеры без изменений (280×280 / 200px) --- */
.product-image-wrap {
  position: relative;
}
.product-image-wrap .thumb-loading {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  border-radius: 12px;
}
.product-image-wrap .thumb-loading .letter {
  font-size: 18px;
}
.product-image-wrap .thumb-loading .letter-holder {
  padding: 12px 8px;
}
@media (max-width: 767px) {
  .product-image-wrap .thumb-loading .letter {
    font-size: 14px;
  }
  .product-image-wrap .thumb-loading .letter-holder {
    padding: 8px 4px;
  }
}
.product-image-wrap .product-img {
  opacity: 0;
  transition: opacity 0.2s ease;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.product-image-wrap.img-loaded .thumb-loading {
  display: none;
}
.product-image-wrap.img-loaded .product-img {
  opacity: 1;
}
.product-image-wrap.img-error .thumb-loading {
  display: none;
}
.product-image-wrap .product-img-fallback {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  align-items: center;
  justify-content: center;
  color: #6c757d;
  background: #f8f9fa;
  border-radius: 12px;
}
.product-image-wrap.img-error .product-img-fallback {
  display: flex;
}
.product-image-wrap.img-error .product-img {
  display: none;
}
