/*
 * Recommendation blocks. Product cards use the theme styles (product-miniature).
 * The rest reproduces the CSS Hello Retail embeds in its "Box 1 (New design)" boxes,
 * so the blocks look like the old Hello Retail ones. Override in the child theme custom.css.
 * No fixed heights: the block takes the height of its content.
 */

.recomblock {
  margin-top: 1em;
  margin-bottom: 1em;
}

/* Title comes from Hello Retail. Font size: .aw-heading in the theme custom.css. */
.recomblock .aw-heading {
  text-align: center;
}

/* Hello Retail failed, timed out or returned no products. */
.recomblock.is-empty {
  display: none;
}

/*
 * Slides per view + gap: the ONLY place. Same breakpoints as the Hello Retail boxes.
 * Used by the skeleton, by the swiper (products.tpl: slidesPerView "auto") and by the JS
 * (the arrows scroll by --rb-spv slides, like in Hello Retail).
 */
.recomblock {
  --rb-spv: 1;
  --rb-gap: 4px;
}
@media (min-width: 321px) {
  .recomblock { --rb-spv: 2; }
}
@media (min-width: 769px) {
  .recomblock { --rb-spv: 3; }
}
@media (min-width: 992px) {
  .recomblock { --rb-spv: 4; }
}
@media (min-width: 1240px) {
  .recomblock { --rb-spv: 6; }
}

/*
 * The gap is padding inside the slide (not margin): Swiper counts the slide width with padding,
 * but ignores CSS margins when slidesPerView is "auto". The extra gap after the last visible
 * slide falls outside the container and is clipped.
 */
.recomblock .swiper-slide,
.recomblock__skel-slide {
  box-sizing: border-box;
  width: calc((100% + var(--rb-gap)) / var(--rb-spv));
  padding-right: var(--rb-gap);
  flex-shrink: 0;
}

/* ---------- carousel, as in Hello Retail ---------- */

/* 1px room so the card border (box-shadow of .product-miniature) is not clipped by the swiper. */
.recomblock .swiper-wrapper {
  padding: 1px;
}

/* Cards of one row have the same height. */
.recomblock .swiper-slide {
  height: auto;
}
.recomblock .swiper-slide > .product-miniature {
  height: 100%;
}

.recomblock .swiper-button-prev,
.recomblock .swiper-button-next {
  color: #000;
  top: calc((100% - 40px) / 2) !important;
  margin-top: 0;
  background-color: #fff;
  background-image: none;
  width: 40px;
  height: 40px;
  border-radius: 100%;
  box-shadow: 0 0 5px 1px #bbb;
  transition: 0.2s;
  opacity: 0.5;
}
.recomblock .swiper-button-prev:hover,
.recomblock .swiper-button-next:hover {
  opacity: 1;
}
.recomblock .swiper-button-prev::after,
.recomblock .swiper-button-next::after {
  font-size: 20px;
  font-weight: 600;
}
.recomblock .swiper-button-prev {
  left: 5px;
}
.recomblock .swiper-button-next {
  right: 5px;
}
/* Do not click through a disabled arrow into a product page. */
.recomblock .swiper-button-prev.swiper-button-disabled,
.recomblock .swiper-button-next.swiper-button-disabled {
  pointer-events: auto;
  opacity: 0.5 !important;
}

/* ---------- skeleton ---------- */
.recomblock__skel-track {
  display: flex;
  overflow: hidden;
}
.recomblock__skel {
  margin-bottom: 1rem;
}
.recomblock__skel-img,
.recomblock__skel-line,
.recomblock__skel-btn {
  background: linear-gradient(90deg, #f0f0f0 25%, #e6e6e6 37%, #f0f0f0 63%);
  background-size: 400% 100%;
  animation: recomblock-shimmer 1.4s ease infinite;
  border-radius: 4px;
}
.recomblock__skel-img {
  aspect-ratio: 1 / 1;
  width: 100%;
}
.recomblock__skel-line {
  height: 14px;
  margin-top: 12px;
}
.recomblock__skel-line--short {
  width: 45%;
}
.recomblock__skel-btn {
  height: 32px;
  margin-top: 14px;
}
@keyframes recomblock-shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}
@media (prefers-reduced-motion: reduce) {
  .recomblock__skel-img,
  .recomblock__skel-line,
  .recomblock__skel-btn {
    animation: none;
  }
}
