/**
 * Home "인기딜" section — below category tabs, above infinite-scroll grid.
 * Visual language follows design-system v2 tokens (css/hotduk-tokens.css).
 */

.hd-popular {
  margin: 0 0 18px;
  padding: 14px 0 4px;
  border-radius: var(--r-xl);
  background: var(--grad-hot-soft);
  border: 1px solid var(--border-hot);
}

.hd-popular__inner {
  padding: 0 12px 12px;
}

.hd-popular__head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 12px;
  padding: 0 2px;
}

.hd-popular__head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.hd-popular__title {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--text-strong);
}

.hd-popular__more {
  flex-shrink: 0;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--hot-600);
  text-decoration: none;
  white-space: nowrap;
}

.hd-popular__more:hover {
  color: var(--hot-700, var(--hot-600));
  text-decoration: underline;
}

.hd-popular__sub {
  margin: 0;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--text-muted);
}

/* Mobile: horizontal snap carousel */
.hd-popular__track {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding: 2px 2px 8px;
  scrollbar-width: none;
}

.hd-popular__track::-webkit-scrollbar {
  display: none;
}

.hd-popular__card {
  flex: 0 0 168px;
  scroll-snap-align: start;
  overflow: hidden;
  border-radius: var(--r-lg);
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--duration-base, 200ms) var(--ease-out),
    transform var(--duration-base, 200ms) var(--ease-out);
  text-decoration: none;
  color: inherit;
  display: block;
}

.hd-popular__card:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-1px);
}

.hd-popular__thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--bg-subtle);
  overflow: hidden;
}

.hd-popular__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.hd-popular__rank {
  position: absolute;
  left: 8px;
  top: 8px;
  z-index: 2;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  background: var(--gray-900);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(30, 30, 30, 0.35);
}

.hd-popular__body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px;
}

.hd-popular__price-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 6px;
}

.hd-popular__discount {
  font-size: 12px;
  font-weight: 800;
  color: var(--hot-600);
}

.hd-popular__price {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--price);
  font-variant-numeric: tabular-nums;
}

.hd-popular__list-price {
  font-size: 11px;
  color: var(--text-muted);
  text-decoration: line-through;
}

.hd-popular__title-text {
  margin: 0;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-strong);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.7em;
}

.hd-popular__chip {
  align-self: flex-start;
  border-radius: 4px;
  background: var(--chip-category-bg);
  color: var(--chip-category-fg);
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.2;
  padding: 2px 7px;
}

.hd-popular__quotes {
  margin-top: 2px;
  padding-top: 6px;
  border-top: 1px solid var(--border-default);
}

.hd-popular__quotes-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--hot-600);
  margin-bottom: 3px;
}

.hd-popular__quote {
  margin: 0;
  font-size: 10.5px;
  line-height: 1.35;
  color: var(--text-body);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hd-popular__quote + .hd-popular__quote {
  margin-top: 2px;
}

.hd-popular__swipe-hint {
  display: block;
  margin: 2px 2px 0;
  padding: 0 2px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-muted);
  letter-spacing: -0.01em;
}

/* Dedicated popular page (/deals/popular): no carousel — 2x2 grid on mobile */
@media (max-width: 767.98px) {
  .hd-popular-page .hd-popular__track {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    overflow-x: visible;
    scroll-snap-type: none;
  }

  .hd-popular-page .hd-popular__card {
    flex: none;
    width: auto;
  }
}

@media (min-width: 768px) {
  .hd-popular {
    margin-bottom: 22px;
    padding: 16px 0 6px;
  }

  .hd-popular__inner {
    padding: 0 16px 14px;
  }

  .hd-popular__title {
    font-size: 19px;
  }

  .hd-popular__swipe-hint {
    display: none;
  }

  .hd-popular__track {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    overflow: visible;
    scroll-snap-type: none;
    padding-bottom: 2px;
  }

  /* 후보 6개 → 3열, 8개(기본) → 4열 — 마지막 줄이 비지 않게 */
  .hd-popular[data-count="6"] .hd-popular__track,
  .hd-popular[data-count="5"] .hd-popular__track,
  .hd-popular[data-count="3"] .hd-popular__track {
    grid-template-columns: repeat(3, 1fr);
  }

  .hd-popular[data-count="4"] .hd-popular__track,
  .hd-popular[data-count="2"] .hd-popular__track {
    grid-template-columns: repeat(2, 1fr);
  }

  .hd-popular[data-count="1"] .hd-popular__track {
    grid-template-columns: minmax(0, 1fr);
    max-width: 280px;
  }

  .hd-popular__card {
    flex: none;
    width: auto;
  }
}
