/**
 * Product Carousel V2 Styles
 */

/* 确保自定义元素是 block 显示，间距设置才能生效 */
theme-product-carousel-v2 {
  display: block;
}

.product-carousel-v2 {
  width: 100%;
  overflow: hidden;
  background-color: rgb(var(--color-background));
}

/* 覆盖商品卡片的固定背景色，使用主题颜色系统 */
.product-carousel-v2 .block-product-card__image-wrapper {
  background-color: rgb(var(--color-image-background, 243, 243, 243));
}

.product-carousel-v2 .block-product-card .product-card-style--card {
  background-color: rgb(var(--color-background));
}

.product-carousel-v2__container {
  width: 100%;
  max-width: calc(var(--page-padding) * 2 + var(--page-width));
  margin-inline: auto;
  padding-inline: var(--page-padding);
}

/* Subtitle */
.product-carousel-v2__subtitle {
  text-align: center;
  font-size: 14px;
  letter-spacing: 2px;
  color: rgba(var(--color-foreground), 0.6);
  margin-bottom: 20px;
}

/* Tabs */
.product-carousel-v2__tabs {
  display: flex;
  justify-content: center;
  font-size: 26px;
  letter-spacing: 2px;
  padding-bottom: 0px;
  margin-bottom: 40px;
  position: relative;
}

.product-carousel-v2__tab {
  background: none;
  border: none;
  padding: 0 25px 15px 25px;
  font-size: inherit;
  font-weight: 500;
  color: rgba(var(--color-foreground), 1);
  cursor: pointer;
  position: relative;
  letter-spacing: 5px;
}

.product-carousel-v2__tab::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 25px;
  right: 25px;
  width: auto;
  height: 1px;
  background-color: currentColor;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.4s cubic-bezier(0.65, 0, 0.35, 1);
}

.product-carousel-v2__tab.active::after {
  transform: scaleX(1);
}

/* 下划线方向动画 */
.product-carousel-v2__tabs:has(.product-carousel-v2__tab:nth-child(1).active) .product-carousel-v2__tab:nth-child(2)::after,
.product-carousel-v2__tabs:has(.product-carousel-v2__tab:nth-child(2).active) .product-carousel-v2__tab:nth-child(1)::after {
  transform-origin: right center;
}

.product-carousel-v2__tabs:has(.product-carousel-v2__tab:nth-child(2).active) .product-carousel-v2__tab:nth-child(3)::after,
.product-carousel-v2__tabs:has(.product-carousel-v2__tab:nth-child(3).active) .product-carousel-v2__tab:nth-child(2)::after {
  transform-origin: right center;
}

/* Tab Contents */
.product-carousel-v2__contents {
  position: relative;
}

.product-carousel-v2__content {
  display: none;
}

.product-carousel-v2__content.active {
  display: block;
}

/* Track Wrapper */
.product-carousel-v2__track-wrapper {
  position: relative;
}

/* 自定义箭头按钮 */
.product-carousel-v2__btn {
  --circle-button-background: 255, 255, 255;
  --circle-button-text-color: 28, 28, 28;
  --circle-button-size: 2.75rem;
  
  position: absolute;
  /* 由 JS 根据首张图片实际高度动态计算；回退到 35% */
  top: var(--carousel-btn-top, 35%);
  transform: translateY(-50%);
  width: var(--circle-button-size);
  height: var(--circle-button-size);
  background: rgb(var(--circle-button-background));
  color: rgb(var(--circle-button-text-color));
  border: none;
  border-radius: 50%;
  box-shadow: 0 0.25rem 1rem rgb(var(--circle-button-text-color) / 0.25);
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 10;
  transition: all 0.3s ease;
  opacity: 0;
  padding: 0;
}

.product-carousel-v2__btn:hover {
  box-shadow: 0 0.375rem 1.5rem rgb(var(--circle-button-text-color) / 0.3);
}

.product-carousel-v2__btn.prev-btn {
  left: 20px;
}

.product-carousel-v2__btn.next-btn {
  right: 20px;
}

.product-carousel-v2__btn svg {
  width: 16px;
  height: 16px;
  display: block;
}

.product-carousel-v2__btn:disabled {
  opacity: 0.3 !important;
  cursor: not-allowed;
}

/* hover 时显示箭头（仅在需要滚动时） */
.product-carousel-v2__track-wrapper:not(.no-scroll):hover .product-carousel-v2__btn {
  opacity: 1;
}

.product-carousel-v2__track-wrapper:not(.no-scroll) .product-carousel-v2__btn:hover {
  opacity: 1;
}

/* 商品数量不足以滚动时，完全隐藏箭头 */
.product-carousel-v2__track-wrapper.no-scroll .product-carousel-v2__btn {
  display: none !important;
}

/* 隐藏 product-list 自带的箭头 */
.product-carousel-v2 .block-product-list__button {
  display: none !important;
}

/* Footer */
.product-carousel-v2__footer {
  display: flex;
  justify-content: center;
  margin-top: 40px;
}

/* Mobile */
@media (max-width: 959px) {
  .product-carousel-v2__container {
    max-width: 100%;
    padding-inline: var(--page-padding);
  }

  .product-carousel-v2__tabs {
    justify-content: flex-start;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    font-size: 18px;
  }

  .product-carousel-v2__tabs::-webkit-scrollbar {
    display: none;
  }

  .product-carousel-v2__tab {
    flex-shrink: 0;
    padding: 0 15px 10px 15px;
    letter-spacing: 3px;
  }

  .product-carousel-v2__tab::after {
    left: 15px;
    right: 15px;
  }

  .product-carousel-v2__footer {
    margin-top: 24px;
  }

  .product-carousel-v2__btn {
    display: none;
  }

  .product-carousel-v2__placeholder-list {
    gap: 12px;
  }

  .product-carousel-v2__placeholder-card {
    flex: 0 0 calc((100% - 12px) / 2);
    min-width: 140px;
  }
}

/* 占位卡片样式 */
.product-carousel-v2__placeholder-list {
  display: flex;
  gap: 20px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.product-carousel-v2__placeholder-card {
  flex: 0 0 calc((100% - 60px) / 4);
  min-width: 200px;
  text-align: center;
}

.product-carousel-v2__placeholder-image {
  width: 100%;
  aspect-ratio: 3/4;
  background-color: rgb(var(--color-image-background, 245, 245, 245));
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.product-carousel-v2__placeholder-image svg {
  width: 60%;
  height: 60%;
  opacity: 0.5;
}

.product-carousel-v2__placeholder-title {
  font-size: 14px;
  margin-top: 12px;
  color: rgb(var(--color-foreground));
}

.product-carousel-v2__placeholder-price {
  font-size: 14px;
  margin-top: 6px;
  color: rgba(var(--color-foreground), 0.7);
}
