﻿.cats-wrapper {
  margin-bottom: 4.1875rem;
}

.cats-wrapper .item {
  width: calc(100% / 6);
  max-width: 100%;
  /* padding: 0.75rem; */
  border-radius: var(--radius);
}

.cats-wrapper .item .img-box {
  width: 100%;
  position: relative;
}

.cats-wrapper .item .img-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  mix-blend-mode: multiply;
  display: block;
  margin: auto;
}

.cats-wrapper .item .title {
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  color: var(--text-dark-1);
  position: absolute;
  bottom: 0.36rem;
  width: 100%;
  font-size: 1.14286rem;
  font-style: normal;
  font-weight: 700;
  line-height: 2.57143rem;
}

@media (max-width:480px) {

  .cats-wrapper .item .title {
    font-size: 0.9rem;
  }

}

@media (max-width: 1200px) {
  .cats-wrapper .item {
    width: calc(100% / 4);
  }
}

@media (max-width: 992px) {
  .cats-wrapper .item {
    width: calc(100% / 3);
  }
}

@media (max-width: 768px) {
  .cats-wrapper .item {
    width: calc(100% / 2)-2rem;
  }
}

@media (max-width: 480px) {
  .cats-wrapper .item {
    width: 45%;
  }
}

.image-box {
  position: relative;
  overflow: hidden;
  background: #f3f4f6;
}

/* placeholder برای حفظ نسبت ابعاد و جلوگیری از جابجایی */
.lazy-placeholder {
  width: 100%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* اسپینر لودینگ در مرکز باکس */
.loading-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border: 4px solid rgba(0, 0, 0, 0.1);
  border-top-color: #3498db;
  border-radius: 50%;
  animation: spin 1s ease-in-out infinite;
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.2s;
}

.image-box.lazy-loading .loading-spinner {
  opacity: 1;
}

@keyframes spin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* پنهان کردن تصویر اصلی تا زمان لود کامل */
.lazy-picture img {
  opacity: 0;
  transition: opacity 0.3s;
  width: 100%;
  height: auto;
  display: block;
  position: relative;
  z-index: 1;
}

.lazy-picture img.loaded {
  opacity: 1;
}

.magic-picture {
  position: relative;
  display: block;
  overflow: hidden;
  width: 100%;
  background: #f3f4f6;
  /* aspect-ratio: 1 / 1; */
}

.magic-picture img.magic-img {
  display: block;
  width: 100%;
  height: auto;
  opacity: 1;
}

.magic-picture--lazy img.magic-img {
  opacity: 0;
  transition: opacity 280ms ease;
}

.magic-picture--lazy.is-loaded img.magic-img {
  opacity: 1;
}

.magic-img-skeleton {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(90deg,
      #eeeeee 25%,
      #f8f8f8 37%,
      #eeeeee 63%);
  background-size: 400% 100%;
  animation: magicSkeletonLoading 1.3s ease infinite;
}

.magic-picture.is-loaded .magic-img-skeleton,
.magic-picture.is-error .magic-img-skeleton {
  opacity: 0;
  visibility: hidden;
  transition: opacity 200ms ease, visibility 200ms ease;
}

.magic-picture.is-error {
  background: #f5f5f5;
}

.magic-picture.is-error::after {
  content: "تصویر بارگذاری نشد";
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  font-size: 13px;
  text-align: center;
}

@keyframes magicSkeletonLoading {
  0% {
    background-position: 100% 50%;
  }

  100% {
    background-position: 0 50%;
  }
}