.popular-products-section {
  --sold-out-badge-bg-color: var(--black-200);
  --sale-badge-bg-color: var(--red-100);
  --original-price-color: var(--grey-100); 
}

.popular-products-section .container {
  row-gap: 2rem;

  @media (width >= 56.25rem) {
    row-gap: 3rem;
  }
}

.popular-products-slider {
  position: relative;

  &[aria-busy="true"]:has([data-stock="true"]) .skeleton {
    color: transparent;
    border-radius: 0.5rem;
    border: var(--border-transparent);
    background-color: var(--skeleton-start-bg-color);
    animation: skeleton-loading 1s infinite alternate;
    opacity: 0.7;
    pointer-events: none;
  }
}

.popular-products-slider .scroll-button {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;

  &.hidden {
    display: none;
  }

  &.left {
    left: 0;

    &:after {
      display: block;
      mask-image: url('../../assets/icons/angle-left.svg');
    }
  }

  &.right {
    right: 0;

    &:after {
      display: block;
      mask-image: url('../../assets/icons/angle-right.svg');
    }
  }
}

.popular-products-list {
  display: flex;
  overflow-x: auto;
  scroll-behavior: smooth;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  column-gap: 2rem;
}

.popular-product-item {
  flex: 0 0 60%;
  scroll-snap-stop: always;
  scroll-snap-align: start;
  position: relative;
  max-width: 15rem;

  @media (width >= 37.5rem) {
    flex: 0 0 calc(50% - 1.125rem);
  }

  @media (width >= 56.25rem) {
    flex: 0 0 calc(33.33% - 1.5rem);
  }

  @media (width >= 75rem) {
    flex: 0 0 calc(25% - 1.7rem);
  }
}

.popular-product-link {
  row-gap: 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 100%;

  &:hover .popular-product-image {
    opacity: 0.5;
  }
}

.popular-products-slider[aria-busy="true"]:has([data-stock="true"]) .popular-product-link {
  pointer-events: none;
}

.popular-product-image-container {
  display: flex;
  justify-content: center;
}

.popular-product-image {
  object-fit: cover;
  aspect-ratio: 1 / 1;
  transition: opacity 0.3s;
}

.popular-products-slider[aria-busy="true"]:has([data-stock="true"]) .popular-product-image {
  opacity: 0;
}

.popular-products-slider hgroup {
  row-gap: 0.5rem;
  text-align: center;
  height: 100%;
  justify-content: space-between;
}

.popular-product-name {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;  
  -moz-line-clamp: 3;
  -moz-box-orient: vertical;
  line-clamp: 3;
  box-orient: vertical;
  overflow: hidden;
}

.popular-products-slider[aria-busy="false"] .popular-product-price {
  display: flex;
  gap: 0.5rem;
  justify-content: center;

  &:has(.popular-product-sale-price:not(:empty)) .popular-product-original-price {
    text-decoration: line-through;
    color: var(--original-price-color);
  }
}

.popular-products-slider .sold-out-badge {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  background-color: var(--sold-out-badge-bg-color);
  padding: 0.1rem 0.25rem;
  display: none;
  z-index: 1;

  &.visible {
    display: block;
  }
}

.popular-products-slider .sale-badge {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background-color: var(--sale-badge-bg-color);
  padding: 0.1rem 0.25rem;
  display: block;
  z-index: 1;
}

.popular-product-item:has(.sold-out-badge.visible) .sale-badge {
  display: none;
}

.popular-products-slider[aria-busy="true"]:has([data-stock="true"]) :is(.sold-out-badge, .sale-badge) {
  display: none;
}

.popular-products-section .button {
  justify-self: center;
}