/* =========================================================================
   Homepage — Product carousel section
   ========================================================================= */

.hp-products {
  padding: 72px 0 72px;
}

.hp-products--solution {
  padding-top: 96px;
}

/* Desktop: --solution variant full chieu cao viewport */
@media screen and (min-width: 1025px) {
  .hp-products--solution {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-sizing: border-box;
  }
}

/* --- Head: title + view-all ------------------------------------------------ */
.hp-products__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 40px;
}

.hp-products__text {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hp-products__title {
  margin: 0;
  color: #293948;
  font-family: var(--font-hn);
  font-weight: 700;
  font-size: 30px;
  line-height: 136%;
  letter-spacing: 0.01em;
}

.hp-products__desc {
  margin: 0;
  color: #616161;
  font-family: var(--font-hn);
  font-weight: 300;
  font-size: 16px;
  line-height: 150%;
  letter-spacing: 0.01em;
}

.hp-products__view-all {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  color: #9E9E9E;
  font-family: var(--font-hn);
  font-weight: 500;
  font-size: 16px;
  line-height: 150%;
  letter-spacing: 0.02em;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.25s ease;
}

.hp-products__view-all svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  transition: color 0.25s ease;
}

.hp-products__view-all:hover,
.hp-products__view-all:focus {
  color: #D85401;
}

/* --- Carousel -------------------------------------------------------------- */
/* The carousel element also carries `.container`, so it inherits the site's
   max-width cascade. overflow:hidden then clips the peeking slide at the
   container edge on every screen size — and stops the off-screen slides from
   creating a horizontal scrollbar on mobile. */
.hp-products__carousel {
  position: relative;
  overflow: hidden;
}

.swiper.hp-products__swiper {
  position: relative;
  display: block;
  overflow: visible;
  box-sizing: border-box;
  touch-action: pan-y;
  cursor: grab;
}

.hp-products__swiper.is-dragging {
  cursor: grabbing;
}

.hp-products__swiper .swiper-wrapper {
  position: relative;
  display: flex;
  width: 100%;
  height: 100%;
  box-sizing: content-box;
  gap: 16px;
  transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

.swiper-slide.hp-products__slide {
  position: relative;
  display: block;
  flex-shrink: 0;
  width: 75%;
  height: auto;
  overflow: hidden;
  border-radius: 20px;
}

.hp-products__image {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 20px;
}

.hp-products__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 20px;
  transition: transform 0.5s ease;
}

/* Info box — overlay bottom-right */
.hp-products__info {
  position: absolute;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 600px;
  padding: 32px;
  box-sizing: border-box;
  border-radius: 20px;
  background: #293948;
  opacity: 1;
  transition: opacity 0.35s ease;
}

/* Non-active slides: smaller, hide info */
.hp-products__slide:not(.swiper-slide-active) .hp-products__info {
  opacity: 0;
  pointer-events: none;
}

.hp-products__info-text {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hp-products__product-title {
  margin: 0;
  color: #FFFFFF;
  font-family: var(--font-hn);
  font-weight: 700;
  font-size: 24px;
  line-height: 135%;
  letter-spacing: 0.01em;
}

.hp-products__product-desc {
  margin: 0;
  color: #FFFFFF;
  font-family: var(--font-hn);
  font-weight: 300;
  font-size: 14px;
  line-height: 145%;
  letter-spacing: 0.01em;
}

/* Actions row: detail button + fraction */
.hp-products__info-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.hp-products__detail-btn {
  position: relative;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  border: 0;
  border-radius: 40px;
  background: #FFFFFF;
  color: #293948;
  font-family: var(--font-hn);
  font-weight: 500;
  font-size: 16px;
  line-height: 150%;
  letter-spacing: 0.02em;
  text-decoration: none;
  cursor: pointer;
  pointer-events: auto;
  transition: background-color 0.25s ease, color 0.25s ease;
}

button.hp-products__detail-btn:hover,
button.hp-products__detail-btn:focus,
button.hp-products__detail-btn:active,
a.hp-products__detail-btn:hover,
a.hp-products__detail-btn:focus,
a.hp-products__detail-btn:active {
  background: #D85401 !important;
  color: #FFFFFF !important;
}

.hp-products__detail-btn--disabled {
  opacity: 0.5;
  cursor: default;
  pointer-events: none;
}

.hp-products__fraction {
  color: #FFFFFF;
  font-family: var(--font-hn);
  font-weight: 700;
  font-size: 30px;
  line-height: 136%;
  letter-spacing: 0.01em;
  user-select: none;
}

/* --- Nav buttons ----------------------------------------------------------- */
.hp-products__nav-wrap {
  display: flex;
  justify-content: flex-end;
  margin-top: 24px;
}

/* Desktop composition, expressed as percentages of the container's content box
   so it scales with every container breakpoint instead of the raw viewport.
   At the 1440px container (1410px content) these resolve to the Figma values:
   active 960 + gap 210 + 240 of the 480px peeking slide = 1410px. */
@media screen and (min-width: 1025px) {
  .hp-products__swiper .swiper-wrapper {
    gap: 14.894%;
    align-items: flex-start;
  }

  /* Active slide: 960 × 540 at the widest container. Keeping the 16/9 ratio
     instead of a fixed height means narrower containers scale the image down
     rather than cropping it. */
  .swiper-slide.hp-products__slide {
    width: 68.085%;
    max-width: 960px;
    height: auto;
    aspect-ratio: 16 / 9;
    overflow: visible;
    z-index: 1;
  }

  .swiper-slide.hp-products__slide.swiper-slide-active {
    z-index: 2;
  }

  /* Non-active slide: 480 × 270, top-aligned, half of it clipped by the carousel */
  .swiper-slide.hp-products__slide:not(.swiper-slide-active) {
    width: 34.043%;
    max-width: 480px;
    height: auto;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    flex-shrink: 0;
  }

  /* Info box: straddles the boundary between the active image and the right gap. */
  .hp-products__info {
    top: 50%;
    right: -26%;
    bottom: auto;
    width: 66%;
    max-width: none;
    transform: translateY(-50%);
    z-index: 5;
    pointer-events: auto;
    cursor: auto;
  }

  /* Nav buttons: centered in the gap, at the bottom of the active image */
  .hp-products__nav-wrap {
    position: absolute;
    top: auto;
    bottom: 1px;
    left: 68.085%;
    right: 17.021%;
    width: auto;
    max-width: none;
    margin: 0;
    padding: 0;
    justify-content: end;
    z-index: 10;
  }
}

.hp-products__nav {
  display: flex;
  gap: 12px;
}

.hp-products__prev,
.hp-products__next {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  transition: opacity 0.25s ease;
}

.hp-products__prev:hover,
.hp-products__next:hover {
  opacity: 0.7;
}

.hp-products__prev:disabled,
.hp-products__next:disabled {
  opacity: 0.45;
  cursor: default;
}

.hp-products__prev:disabled:hover,
.hp-products__next:disabled:hover {
  opacity: 0.45;
}

.hp-products__prev svg,
.hp-products__next svg {
  display: block;
  width: 48px;
  height: 48px;
}

/* --- Responsive ------------------------------------------------------------ */
@media screen and (max-width: 1024px) {
  .hp-products {
    padding: 56px 0 56px;
  }

  .swiper-slide.hp-products__slide {
    width: 80%;
  }

  .hp-products__info {
    max-width: 480px;
  }

  .hp-products__product-title {
    font-size: 20px;
  }
}

@media screen and (max-width: 767px) {
  .hp-products {
    padding: 40px 0 40px;
  }

  .hp-products__head {
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
  }

  .swiper-slide.hp-products__slide {
    width: 90%;
  }

  .hp-products__info {
    position: relative;
    right: auto;
    bottom: auto;
    max-width: 100%;
    border-radius: 0 0 20px 20px;
  }

  .hp-products__image {
    border-radius: 20px 20px 0 0;
  }

  .hp-products__img {
    border-radius: 20px 20px 0 0;
  }

  .hp-products__slide:not(.swiper-slide-active) .hp-products__info {
    opacity: 1;
    pointer-events: auto;
  }

  .hp-products__product-title {
    font-size: 18px;
  }

  .hp-products__product-desc {
    font-size: 13px;
  }

  .hp-products__fraction {
    font-size: 22px;
  }

  .hp-products__title {
    font-size: 24px;
  }

  .hp-products__nav-wrap {
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hp-products__swiper .swiper-wrapper {
    transition-duration: 0ms;
  }
}

/* =========================================================================
   Solutions popup (opened from "Xem chi tiết")
   ========================================================================= */
.hp-sol-popup {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
}

.hp-sol-popup[hidden] {
  display: none;
}

.hp-sol-popup__overlay {
  position: absolute;
  inset: 0;
  background: rgba(41, 57, 72, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.hp-sol-popup__box {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1200px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 48px;
  border-radius: 20px;
  background: #FFFFFF;
  box-sizing: border-box;
}

.hp-sol-popup__close {
  position: absolute;
  top: 20px;
  right: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.hp-sol-popup__close:hover {
  background: rgba(41, 57, 72, 0.08);
}

.hp-sol-popup__grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
}

.hp-sol-popup__card {
  position: relative;
  display: block;
  flex: 0 0 calc((100% - 80px) / 5);
  max-width: calc((100% - 80px) / 5);
  height: 218px;
  border-radius: 20px;
  overflow: hidden;
  text-decoration: none;
}

.hp-sol-popup__card img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hp-sol-popup__card-title {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  padding: 12px;
  background: #323F4866;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #FFFFFF;
  font-family: var(--font-hn);
  font-weight: 500;
  font-size: 16px;
  line-height: 150%;
  letter-spacing: 0.01em;
  box-sizing: border-box;
  border-bottom-left-radius: 20px;
  border-bottom-right-radius: 20px;
}

/* --- Popup responsive ------------------------------------------------------ */
@media screen and (max-width: 1024px) {
  .hp-sol-popup__box {
    padding: 32px;
  }

  .hp-sol-popup__card {
    flex: 0 0 calc((100% - 60px) / 4);
    max-width: calc((100% - 60px) / 4);
  }
  body.page-template-tpl-solution .hp-products--solution {
    padding-top: 96px;
  }
}

@media screen and (max-width: 767px) {
  .hp-sol-popup {
    padding: 16px;
  }

  .hp-sol-popup__box {
    padding: 20px;
    max-height: 90vh;
  }

  .hp-sol-popup__close {
    top: 12px;
    right: 12px;
  }

  .hp-sol-popup__grid {
    gap: 12px;
  }

  .hp-sol-popup__card {
    flex: 0 0 calc((100% - 12px) / 2);
    max-width: calc((100% - 12px) / 2);
  }

  .hp-sol-popup__card-title {
    font-size: 14px;
    padding: 10px;
  }
}
