/* ==========================================================================
   DeviceHub — Products Section (Home)
   Path: assets/css/home/devhub-products-section.css
   Depends on: style.css, components/product-card.css
   ========================================================================== */

/* ==========================================================================
   1. Section header
   ========================================================================== */

.devhub-products__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--devhub-border);
  gap: 16px;
  flex-wrap: nowrap;
}

.devhub-products__title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--devhub-text-4xl);
  font-weight: 700;
  color: var(--devhub-black);
  position: relative;
  padding-left: 14px;
}

.devhub-products__title::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 22px;
  background: var(--devhub-primary);
  border-radius: 2px;
}

/* ==========================================================================
   2. Product grid
   ========================================================================== */

.devhub-products__grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  column-gap: 0;
  row-gap: 36px;
}

.devhub-products__carousel {
  position: relative;
}

.devhub-products__carousel-nav {
  display: none;
}

.devhub-products .devhub-product-card {
  background: transparent;
  border-color: transparent;
  border-radius: 0;
  box-shadow: none;
  outline: 0;
  --devhub-card-pad: 12px;
  padding: var(--devhub-card-pad);
}

.devhub-products .devhub-product-card::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 1px;
  height: 100%;
  background: rgba(220, 224, 230, 0.95);
  pointer-events: none;
}

.devhub-products__grid > *:nth-child(5n) .devhub-product-card::after {
  display: none;
}

.devhub-products .devhub-product-card:hover::after,
.devhub-products .devhub-product-card:focus-within::after {
  opacity: 0;
}

.devhub-products .devhub-product-card:has(+ .devhub-product-card:hover)::after,
.devhub-products
  .devhub-product-card:has(+ .devhub-product-card:focus-within)::after {
  opacity: 0;
}

.devhub-products .devhub-product-card:hover,
.devhub-products .devhub-product-card:focus-within {
  background: #fff;
  border-color: transparent;
  border-radius: 8px;
  box-shadow: 0 14px 30px rgba(17, 17, 17, 0.12);
  outline: 1px solid rgba(220, 224, 230, 0.95);
}

.devhub-products .devhub-product-card__img-wrap {
  height: 170px;
  margin-bottom: 26px;
  border-radius: 0;
  overflow: visible;
}

.devhub-products .devhub-product-card__img-wrap img,
.devhub-products
  .devhub-product-card__img-wrap
  .devhub-product-card__img-placeholder {
  margin-top: 26px;
}

.devhub-products .devhub-product-card__offer-badge {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -18px;
  z-index: 2;
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 28px;
  padding: 0;
  border-radius: 0 18px 0 0;
  background: linear-gradient(90deg, #7a0f8f 0%, #d4147b 38%, #ff0d67 100%);
  box-shadow: none;
  color: #fff;
  text-align: left;
}

.devhub-products .devhub-product-card__offer-badge::before {
  content: none;
}

.devhub-products .devhub-product-card__offer-value {
  display: block;
  flex: 0 0 auto;
  padding: 4px 0 4px 14px;
  font-size: 1.3rem;
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: -0.04em;
  color: #fff;
  white-space: nowrap;
}

.devhub-products .devhub-product-card__offer-caption {
  display: block;
  min-width: 0;
  margin-top: 1px;
  padding: 4px 14px 4px 0;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255, 244, 251, 0.95);
}

.devhub-products .devhub-product-card__body {
  gap: 6px;
}

.devhub-products .devhub-product-card__bundle {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 5px;
  min-height: 20px;
  padding: 2px 8px;
  background: linear-gradient(180deg, #fff3ea 0%, #ffe7d6 100%);
  color: #c45508;
  border: 1px solid rgba(255, 102, 0, 0.18);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0.01em;
  box-shadow: none;
}

/* Small open-box icon before the label (it replaces the old orange dot). */
.devhub-products .devhub-product-card__bundle::before {
  content: "";
  width: 13px;
  height: 13px;
  background: currentColor;
  -webkit-mask: url("../../images/bundle-pkg-icon.svg") center / contain
    no-repeat;
  mask: url("../../images/bundle-pkg-icon.svg") center / contain no-repeat;
  flex: 0 0 13px;
}

.devhub-products .devhub-product-card__badge {
  top: 12px;
  left: 12px;
  padding: 0.42rem 0.72rem;
  font-size: var(--devhub-text-md);
}

.devhub-products .devhub-product-card__name {
  font-size: var(--devhub-text-2xl);
}

.devhub-products .devhub-product-card__price {
  font-size: var(--devhub-text-2xl);
}

.devhub-products .devhub-product-card__price del {
  font-size: var(--devhub-text-lg);
}

.devhub-products .devhub-product-card__price-prefix {
  font-size: 0.72em;
}

.devhub-products .devhub-product-card__stock {
  top: 12px;
  right: 12px;
  font-size: var(--devhub-text-xl) !important;
}

.devhub-products .devhub-product-card__action {
  min-height: 34px;
  padding: 8px 14px;
}

/* ==========================================================================
   4. View all footer
   ========================================================================== */

.devhub-products__view-all {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  margin-left: auto;
  gap: 6px;
  font-size: var(--devhub-text-2xl);
  font-weight: 600;
  color: var(--devhub-primary);
  border: 0;
  border-radius: 0;
  padding: 0;
  transition:
    color var(--devhub-transition),
    transform var(--devhub-transition);
}

.devhub-products__view-all:hover {
  background: transparent;
  color: var(--devhub-primary-dark);
  transform: translateX(2px);
}

/* ==========================================================================
   5. Responsive
   ========================================================================== */

@media (max-width: 1024px) {
  .devhub-products__grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .devhub-products__grid > * .devhub-product-card::after {
    display: block;
  }

  .devhub-products__grid > *:nth-child(5n) .devhub-product-card::after {
    display: block;
  }

  .devhub-products__grid > *:nth-child(4n) .devhub-product-card::after {
    display: none;
  }
}

@media (max-width: 768px) {
  .devhub-products__grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .devhub-products__header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 12px;
  }

  .devhub-products__title {
    font-size: clamp(2.2rem, 6vw, var(--devhub-text-4xl));
  }

  .devhub-products__view-all {
    margin-left: auto;
    font-size: clamp(1.8rem, 4.6vw, var(--devhub-text-2xl));
  }

  .devhub-products__grid > * .devhub-product-card::after {
    display: block;
  }

  .devhub-products__grid > *:nth-child(4n) .devhub-product-card::after {
    display: block;
  }

  .devhub-products__grid > *:nth-child(2n) .devhub-product-card::after {
    display: none;
  }
}

@media (max-width: 575px) {
  .devhub-products__carousel {
    padding-inline: 0;
  }

  .devhub-products__carousel-nav {
    position: absolute;
    top: 50%;
    z-index: 5;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(255, 102, 0, 0.22);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.96);
    color: var(--devhub-primary);
    box-shadow: 0 10px 22px rgba(17, 17, 17, 0.12);
    transform: translateY(-50%);
    transition:
      color var(--devhub-transition),
      border-color var(--devhub-transition),
      background-color var(--devhub-transition),
      opacity var(--devhub-transition);
  }

  .devhub-products__carousel-nav:hover {
    border-color: rgba(255, 102, 0, 0.45);
    background: #fff5f0;
  }

  .devhub-products__carousel-nav:focus,
  .devhub-products__carousel-nav:focus-visible,
  .devhub-products__carousel-nav:active {
    outline: none !important;
    box-shadow: 0 10px 22px rgba(17, 17, 17, 0.12) !important;
  }

  .devhub-products__carousel-nav:disabled,
  .devhub-products__carousel-nav[disabled] {
    opacity: 0.32;
    pointer-events: none;
  }

  .devhub-products__carousel-nav.is-hidden {
    opacity: 0;
    pointer-events: none;
  }

  .devhub-products__carousel-nav--prev {
    left: 0;
  }

  .devhub-products__carousel-nav--next {
    right: 0;
  }

  .devhub-products__grid {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: 80%;
    gap: 12px;
    overflow-x: auto;
    overflow-y: visible;
    padding: 10px 44px 8px 0;
    scroll-snap-type: x mandatory;
    scroll-padding-left: 0;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .devhub-products__grid::-webkit-scrollbar {
    display: none;
  }

  .devhub-products__carousel--active
    .devhub-products__grid
    > .devhub-product-card {
    scroll-snap-align: start;
  }

  .devhub-products__grid--single-card {
    grid-auto-columns: 100%;
    padding-right: 0;
    overflow-x: hidden;
  }

  .devhub-products .devhub-product-card {
    min-width: 0;
    --devhub-card-pad: 10px;
    padding: var(--devhub-card-pad);
  }

  .devhub-products .devhub-product-card {
    scroll-snap-align: start;
  }

  .devhub-products .devhub-product-card__img-wrap {
    height: 150px;
    margin-bottom: 24px;
  }

  .devhub-products .devhub-product-card__img-wrap img,
  .devhub-products
    .devhub-product-card__img-wrap
    .devhub-product-card__img-placeholder {
    margin-top: 20px;
  }

  .devhub-products .devhub-product-card__body {
    gap: 7px;
  }

  .devhub-products .devhub-product-card__action {
    min-height: 34px;
    padding: 8px 10px;
  }
}
