/* public/css/components/featured-products.css */

/* Grid Layout */
.featured-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
  margin-bottom: 24px;
}

.featured-grid > * {
  min-width: 0;
}

/* Card Base */
.featured-card {
  transition:
    transform 0.25s ease,
    box-shadow 0.25s ease,
    border-color 0.25s ease;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.featured-card:hover {
  transform: translateY(-4px);
}

/* Image Container (1:1 比例) */
.featured-card__image {
  position: relative;
  width: 100%;
  padding-bottom: 100%;
  overflow: hidden;
  height: 0;
}

.featured-card__image img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition:
    transform 0.3s ease,
    opacity 0.3s ease;
}

.featured-card:hover .featured-card__image img {
  transform: scale(1.05);
}

/* Badge */
.featured-card__badge {
  position: absolute;
  top: 14px;
  right: 14px;
  background: var(--color-primary);
  color: var(--color-white);
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  z-index: 1;
}

/* Info Section */
.featured-card__info {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 18px 0 20px;
  text-align: center;
}

/* Product Name */
.featured-card__name {
  font-size: 1.05rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0 0 8px 0;
  line-height: 1.4;
  min-height: 2.8em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.featured-card__name a {
  color: var(--color-primary);
  text-decoration: none;
  transition:
    color 0.25s ease,
    opacity 0.25s ease;
}

.featured-card__name a:hover,
.featured-card__name a:focus {
  color: var(--color-primary);
  opacity: 0.75;
}

/* Description */
.featured-card__desc {
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  margin-bottom: 12px;
  line-height: 1.5;
  /* white-space: nowrap; */
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Variant Selector */
.featured-card__variant {
  margin-bottom: 12px;
}

.featured-card__variant-select {
  width: 100%;
  max-width: 100%;
  height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  font-size: 0.9rem;
  text-align: center;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
  color: var(--color-black);
  cursor: pointer;
  background-color: var(--color-white);
}

.featured-card__variant-select:hover {
  border-color: var(--color-text-muted);
}

/* iOS Safari 對 <16px 的表單控件 focus 時會強制縮放整頁 */
@media (max-width: 768px) {
  .featured-card__variant-select {
    font-size: 16px;
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.featured-card__variant-spacer {
  height: 42px;
}

/* Price */
.featured-card__price {
  margin-bottom: 14px;
  line-height: 1.6;
}

.featured-card__price-main {
  color: var(--color-black);
  font-size: 1.05rem;
  font-weight: 500;
}

/* 有限時活動價時，原價劃掉；活動價本身另由 sale-badge 貼在圖片上顯示 */
.featured-card__price-main.is-sale-active {
  color: var(--color-text-muted);
  text-decoration: line-through;
}

.featured-card__price-member {
  color: var(--color-member-price);
  font-size: 0.85rem;
  font-weight: 500;
}

/* 沒有會員價、改在同個位置顯示活動價時，用跟原價劃線一致的中性色，不跟真正的會員價混淆 */
.featured-card__price-member.is-sale-line {
  color: var(--color-black);
}

/* 限時活動價徽章：文字直接疊在圖片左上角，無底色色塊 */
.featured-card__sale-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  text-align: left;
  color: var(--color-black);
}

.featured-card__sale-badge-tag {
  display: inline-block;
  padding: 2px 10px;
  background: var(--color-black);
  color: var(--color-white);
  border-radius: 999px;
  font-size: 0.5rem;
  font-weight: 400;
  letter-spacing: 0.12em;
}

/* 標籤/價格/分隔線/標語共用同一個寬度（取其中最寬的那行），
   讓分隔線跟其他行看起來一樣長 */
.featured-card__sale-badge-block {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: fit-content;
}

.featured-card__sale-badge-label,
.featured-card__sale-badge-price {
  display: block;
  width: 100%;
  white-space: nowrap;
  /* 撐開文字間距，讓較短的那行視覺上跟最寬的那行一樣長
     inter-character：純數字/英文（如 NT$759）沒有空白可分配，
     預設 justify 不會生效，要強制逐字元撐開才會跟中文行一樣被拉開 */
  text-align: justify;
  text-align-last: justify;
  text-justify: inter-character;
}

.featured-card__sale-badge-label {
  font-size: 0.7rem;
  font-weight: 400;
}

.featured-card__sale-badge-price {
  font-size: 1rem;
  font-weight: 400;
}

.featured-card__sale-badge-divider {
  width: 100%;
  height: 1px;
  margin: 6px 0;
  background: var(--color-black);
}

/* 商品詳情頁主圖較大，徽章文字放大一階 */
.featured-card__sale-badge--detail {
  top: 20px;
  left: 20px;
  right: 20px;
  gap: 8px;
}

.featured-card__sale-badge--detail .featured-card__sale-badge-tag {
  padding: 4px 16px;
  font-size: 0.75rem;
}

.featured-card__sale-badge--detail .featured-card__sale-badge-label {
  font-size: 1.15rem;
}

.featured-card__sale-badge--detail .featured-card__sale-badge-price {
  font-size: 1.9rem;
}

.featured-card__sale-badge--detail .featured-card__sale-badge-divider {
  margin: 10px 0;
}

.product-card-btn {
  margin-top: auto;
}

/* ==================== Laptop: 769px - 1024px ==================== */
@media (max-width: 1024px) {
  .featured-grid {
    gap: 24px;
  }

  .featured-card__name {
    font-size: 1rem;
  }

  .featured-card__desc {
    font-size: 0.875rem;
  }
}

/* ==================== Tablet: 481px - 768px ==================== */
@media (max-width: 768px) {
  .featured-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 22px;
  }

  .featured-card__info {
    padding: 16px 0 18px;
  }

  .featured-card__name {
    font-size: 0.95rem;
  }

  .featured-card__desc {
    font-size: 0.85rem;
  }

  .featured-card__badge {
    top: 12px;
    right: 12px;
    padding: 3px 10px;
    font-size: 0.75rem;
  }

  .featured-card__sale-badge {
    top: 10px;
    left: 10px;
    right: 10px;
    gap: 3px;
  }
}

/* ==================== Mobile: 480px 以下 ==================== */
@media (max-width: 480px) {
  /* Mobile Carousel */
  /* NOTE: 負 margin 必須等於 .page-container 在 480px 以下的水平 padding（0.75rem），
     超過會使輪播突出視窗，造成整頁可水平滑動 */
  .featured-grid {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    gap: 16px;
    padding: 0 0.75rem 20px;
    margin: 0 -0.75rem 24px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .featured-grid::-webkit-scrollbar {
    display: none;
  }

  .featured-card {
    flex: 0 0 calc(90% - 8px);
    scroll-snap-align: center;
    max-width: 400px;
  }

  .featured-card__info {
    padding: 16px 0 18px;
  }

  .featured-card__name {
    font-size: 1rem;
  }

  .featured-card__desc {
    font-size: 0.85rem;
  }

  .featured-card__badge {
    top: 10px;
    right: 10px;
    padding: 3px 8px;
    font-size: 0.7rem;
  }

  .featured-card__sale-badge {
    top: 8px;
    left: 8px;
    right: 8px;
    gap: 3px;
  }

  .featured-card__sale-badge-tag {
    padding: 2px 8px;
    font-size: 0.45rem;
  }

  .featured-card__sale-badge-label {
    font-size: 0.6rem;
  }

  .featured-card__sale-badge-price {
    font-size: 0.85rem;
  }
}
