/**
 * anjolandingpages — componentes partilhados das landing pages (carrossel, separadores, contagem).
 *
 * @author    André Forte
 * @copyright 2026 André Forte
 * @license   https://opensource.org/licenses/AFL-3.0 Academic Free License (AFL 3.0)
 */

/* Carrossel: scroll nativo com snap; 2 itens no telemóvel, 3 no tablet, 4 no desktop. */
.anjolp .anjolp-carousel {
  position: relative;
}

.anjolp .anjolp-carousel__track {
  display: flex;
  flex-wrap: nowrap;
  gap: 16px;
  margin: 0;
  padding: 0 0 4px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.anjolp .anjolp-carousel__track::-webkit-scrollbar {
  display: none;
}

.anjolp .anjolp-carousel__item,
.anjolp .anjolp-carousel__item.ajax_block_product {
  flex: 0 0 calc((100% - 16px) / 2);
  float: none;
  clear: none;
  width: auto;
  max-width: none;
  min-width: 0;
  margin: 0;
  padding: 0;
  scroll-snap-align: start;
}

/* miniaturas do tema com largura fixa (classic: 250px) passam a ocupar o item */
.anjolp .anjolp-carousel__item .product-miniature,
.anjolp .anjolp-carousel__item .thumbnail-container {
  width: 100%;
  max-width: none;
  margin-left: 0;
  margin-right: 0;
}

.anjolp .anjolp-carousel__item img {
  max-width: 100%;
  height: auto;
}

.anjolp .anjolp-carousel__nav {
  display: none;
}

@media (min-width: 768px) {
  .anjolp .anjolp-carousel__item,
  .anjolp .anjolp-carousel__item.ajax_block_product {
    flex-basis: calc((100% - 32px) / 3);
  }

  .anjolp .anjolp-carousel__nav {
    position: absolute;
    top: 35%;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    color: #111;
    background: #fff;
    border: 0;
    border-radius: 50%;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transform: translateY(-50%);
  }

  .anjolp .anjolp-carousel__nav--prev {
    left: -12px;
  }

  .anjolp .anjolp-carousel__nav--next {
    right: -12px;
  }

  .anjolp .anjolp-carousel__nav:disabled {
    opacity: 0;
    pointer-events: none;
  }
}

@media (min-width: 992px) {
  .anjolp .anjolp-carousel__item,
  .anjolp .anjolp-carousel__item.ajax_block_product {
    flex-basis: calc((100% - 48px) / 4);
  }
}

.anjolp .anjolp-carousel__more {
  margin-top: 24px;
  text-align: center;
}

/* Separadores */
.anjolp [data-anjolp-tabs] [role="tablist"] {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.anjolp [data-anjolp-tabs] [role="tablist"]::-webkit-scrollbar {
  display: none;
}

.anjolp [data-anjolp-tabs] [role="tabpanel"][hidden] {
  display: none;
}

.anjolp [data-anjolp-tabs] [role="tabpanel"].is-loading {
  min-height: 200px;
}

/* Rotação de imagens ([data-anjolp-rotate]): as imagens sobrepõem-se e trocam com fade */
.anjolp [data-anjolp-rotate] {
  position: relative;
}

.anjolp [data-anjolp-rotate] [data-anjolp-slide] {
  position: absolute;
  inset: 0;
  display: block;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.anjolp [data-anjolp-rotate] [data-anjolp-slide].is-active {
  opacity: 1;
}

.anjolp [data-anjolp-rotate] [data-anjolp-slide] img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (prefers-reduced-motion: reduce) {
  .anjolp [data-anjolp-rotate] [data-anjolp-slide] {
    transition: none;
  }
}

/*
 * Aparecer ao fazer scroll ([data-anjolp-reveal]): só esconde depois de o JS arrancar
 * (html.anjolp-reveal-on). --anjolp-reveal-i (0, 1, 2…) desfasa elementos vizinhos.
 */
.anjolp-reveal-on .anjolp [data-anjolp-reveal] {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.6s ease, transform 0.6s ease;
  transition-delay: calc(var(--anjolp-reveal-i, 0) * 90ms);
}

.anjolp-reveal-on .anjolp [data-anjolp-reveal].is-visible {
  opacity: 1;
  transform: none;
}
