/* =========================================================
   04. НОВИНКИ / PRODUCTS
   ========================================================= */

.section-heading h2 {
  margin: 0;

  font-size: clamp(22px, 1.65vw, 30px);
  font-weight: 300;
  line-height: 1.04;
  letter-spacing: -0.1px;
}


/* =========================================================
   SECTION
   ========================================================= */

.products-section {
  padding-top: var(--space-section);
  padding-right: var(--page-right-gap);
  padding-left: var(--page-left-gap);
}


/* =========================================================
   VIEWPORT / TRACK
   ========================================================= */

.products-viewport {
  width: 100%;
  min-width: 0;

  overflow-x: hidden;
  overflow-y: hidden;
}


.products-track {
  display: flex;
  flex-wrap: nowrap;

  width: 100%;
  min-width: 0;

  gap: 15px;

  margin-top: var(--space-heading);

  transition: transform 300ms ease;
}


/*
 * Desktop:
 * ровно 4 карточки внутри ширины viewport.
 *
 * 3 промежутка × 15px = 45px.
 */
.product-card {
  flex: 0 0 calc((100% - 45px) / 4);

  min-width: 0;
  margin: 0;
}


/* =========================================================
   PRODUCT IMAGE
   ========================================================= */

.product-card__image {
  position: relative;

  display: block;

  width: 100%;
  aspect-ratio: 357 / 313;

  overflow: hidden;

  background: #ecece7;
}


.product-card__slides {
  position: absolute;
  inset: 0;

  display: block;
}


.product-card__slide {
  position: absolute;
  inset: 0;

  display: block;

  width: 100%;
  height: 100%;

  object-fit: cover;
  object-position: center;

  opacity: 0;

  transform: none;
  transform-origin: center;

  pointer-events: none;
  user-select: none;
}


.product-card__slide--1 {
  opacity: 1;
}


/* =========================================================
   DOTS
   ========================================================= */

.product-card__dots {
  position: absolute;
  z-index: 4;

  left: 50%;
  bottom: 12px;

  display: flex;
  align-items: center;

  gap: 7px;

  transform: translateX(-50%);

  pointer-events: none;
}


.product-card__dots span {
  width: 5px;
  height: 5px;

  border-radius: 50%;

  background: rgb(13 13 13 / 28%);
}


.product-card__dots span:first-child {
  background: #111;
}


/* =========================================================
   PRODUCT PREVIEW ANIMATION
   Desktop:
   1 → 2 → 3 → 1
   ========================================================= */

@media (hover: hover) and (pointer: fine) {

  .product-card:hover .product-card__slide--1 {
    animation: product-preview-slide-1 2.5s linear 1 forwards;
  }

  .product-card:hover .product-card__slide--2 {
    animation: product-preview-slide-2 2.5s linear 1 forwards;
  }

  .product-card:hover .product-card__slide--3 {
    animation: product-preview-slide-3 2.5s linear 1 forwards;
  }


  .product-card:hover .product-card__dots span:nth-child(1) {
    animation: product-preview-dot-1 2.5s linear 1 forwards;
  }

  .product-card:hover .product-card__dots span:nth-child(2) {
    animation: product-preview-dot-2 2.5s linear 1 forwards;
  }

  .product-card:hover .product-card__dots span:nth-child(3) {
    animation: product-preview-dot-3 2.5s linear 1 forwards;
  }

}


/* =========================================================
   SLIDE KEYFRAMES
   ========================================================= */

@keyframes product-preview-slide-1 {

  0%,
  30% {
    opacity: 1;
  }

  34%,
  95% {
    opacity: 0;
  }

  100% {
    opacity: 1;
  }

}


@keyframes product-preview-slide-2 {

  0%,
  30% {
    opacity: 0;
  }

  34%,
  63% {
    opacity: 1;
  }

  67%,
  100% {
    opacity: 0;
  }

}


@keyframes product-preview-slide-3 {

  0%,
  63% {
    opacity: 0;
  }

  67%,
  95% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }

}


/* =========================================================
   DOT KEYFRAMES
   ========================================================= */

@keyframes product-preview-dot-1 {

  0%,
  30%,
  100% {
    background: #111;
  }

  34%,
  95% {
    background: rgb(13 13 13 / 28%);
  }

}


@keyframes product-preview-dot-2 {

  0%,
  30%,
  67%,
  100% {
    background: rgb(13 13 13 / 28%);
  }

  34%,
  63% {
    background: #111;
  }

}


@keyframes product-preview-dot-3 {

  0%,
  63%,
  100% {
    background: rgb(13 13 13 / 28%);
  }

  67%,
  95% {
    background: #111;
  }

}


/* =========================================================
   HEADING
   ========================================================= */

.product-card__heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;

  gap: 16px;

  width: 100%;

  padding: 21px 0 0;
}


.product-card__heading h3,
.product-card__heading strong {
  margin: 0;

  font-size: clamp(17px, 1.1vw, 20px);
  font-weight: 400;
  line-height: 1.2;
}


.product-card__heading h3 {
  min-width: 0;
}


.product-card__heading strong {
  flex: 0 0 auto;

  white-space: nowrap;
}


/* =========================================================
   META
   ========================================================= */

.product-card__meta {
  margin: 28px 0 0;
}


.product-card__meta div {
  display: grid;

  grid-template-columns:
    minmax(82px, .8fr)
    1.35fr;

  gap: 12px;

  margin-top: 8px;
}


.product-card__meta dt,
.product-card__meta dd {
  margin: 0;

  font-size: 13px;
  font-weight: 300;
  line-height: 1.3;
}


.product-card__meta dt {
  color: #777;
}


/* =========================================================
   OUTLINE BUTTON
   ========================================================= */


.outline-button {
  display: grid;

  width: min(100%, 236px);
  min-height: 50px;

  place-items: center;

  margin-top: 28px;

  border: 2px solid var(--accent);
  border-radius: 999px;

  background: transparent;

  font-size: 17px;
  line-height: 1;

  transition:
    background 180ms ease,
    color 180ms ease,
    transform 180ms ease;
}


.outline-button:hover {
  color: #fff;
  background: var(--accent);
}


/* =========================================================
   PRODUCT ACTIONS
   ========================================================= */

.product-card__actions {
  display: grid;

  grid-template-columns:
    minmax(0, 1fr)
    50px;

  gap: 10px;

  width: 100%;

  margin-top: 28px;
}


.product-card__actions .outline-button {
  width: 100%;
  margin-top: 0;
}


/* =========================================================
   QUICK CART
   ========================================================= */
.product-card__quick-cart-form {
  width: 50px;
  height: 50px;
  margin: 0;
}

.product-card__quick-cart {
  display: grid;

  width: 50px;
  height: 50px;

  place-items: center;

  padding: 0;

  border: 0;
  border-radius: 6px;

  color: #2d2f31;
  background: #e1e3df;

  cursor: pointer;

  transition:
    background 180ms ease,
    color 180ms ease,
    transform 180ms ease;
}


.product-card__quick-cart svg {
  width: 22px;
  height: 22px;
}


.product-card__quick-cart path,
.product-card__quick-cart circle {
  fill: none;

  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;

  vector-effect: non-scaling-stroke;
}


.product-card__quick-cart:hover,
.product-card__quick-cart:focus-visible {
  color: #fff;
  background: var(--sidebar-bg);

  outline: none;
}


.product-card__quick-cart:active {
  transform: scale(.96);
}


/* =========================================================
   SECTION FOOTER
   ========================================================= */

.section-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 24px;

  margin-top: var(--space-heading);
}


/* =========================================================
   SLIDER ARROWS
   ========================================================= */

.slider-arrows {
  display: flex;
  align-items: center;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  gap: 28px;
}


.slider-arrow {
  display: grid;

  width: 108px;
  height: 32px;

  place-items: center;

  padding: 0;

  border: 0;

  color: #111;
  background: transparent;

  cursor: pointer;
}


.slider-arrow svg {
  width: 100%;

  overflow: visible;
}


.slider-arrow path {
  fill: none;

  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;

  vector-effect: non-scaling-stroke;
}


.slider-arrow--accent {
  color: var(--accent);
}


.slider-arrow:disabled {
  opacity: .25;

  cursor: default;
}


/* =========================================================
   CATALOG LINK
   ========================================================= */

.catalog-link {
  padding-right: 12px;

  font-size: 18px;

  text-decoration: underline;
  text-underline-offset: 5px;
}


/* =========================================================
   ADAPTIVE — <= 1280px
   ========================================================= */

@media (max-width: 1280px) {

  .products-viewport {
    overflow-x: auto;
    overflow-y: hidden;

    scrollbar-width: none;

    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;

    -webkit-overflow-scrolling: touch;
  }


  .products-viewport::-webkit-scrollbar {
    display: none;
  }


  .products-track {
    width: max-content;
  }


  .product-card {
    flex: 0 0 min(310px, 31vw);

    width: min(310px, 31vw);
    max-width: none;

    scroll-snap-align: start;
    scroll-snap-stop: normal;
  }

}


/* =========================================================
   ADAPTIVE — <= 1024px
   ========================================================= */

@media (max-width: 1024px) {

  .products-section {
    padding-top: var(--space-section);
    padding-right: var(--tablet-page-gap);
    padding-left: var(--tablet-page-gap);
  }


  .product-card {
    flex: 0 0 min(310px, 42vw);

    width: min(310px, 42vw);
  }

}


/* =========================================================
   ADAPTIVE — <= 760px
   ========================================================= */

@media (max-width: 760px) {

  .products-section {
    padding-top: var(--space-section);
  }


  .products-track {
    margin-top: var(--space-heading);
  }


  .product-card {
    flex: 0 0 min(295px, 76vw);

    width: min(295px, 76vw);
  }


  .section-footer {
    margin-top: var(--space-heading);
  }


  .catalog-link {
    font-size: 16px;
  }


  .slider-arrow {
    width: 80px;
  }


  .product-card__dots {
    bottom: 10px;
  }


  .product-card__actions {
    gap: 8px;
  }


  .product-card__quick-cart {
    width: 48px;
    height: 50px;
  }

}


/* =========================================================
   ADAPTIVE — <= 480px
   ========================================================= */

@media (max-width: 480px) {

  .products-section {
    padding-right: var(--mobile-page-gap);
    padding-left: var(--mobile-page-gap);
  }


  .products-viewport {
    width: 100%;
    max-width: 100%;
  }


  .products-track {
    gap: 12px;
  }


  .product-card {
    flex: 0 0 min(285px, 85vw);

    width: min(285px, 85vw);
    max-width: none;
  }


  .section-footer--products {
    align-items: flex-end;
  }


  .slider-arrows {
    gap: 12px;
  }


  .slider-arrow {
    width: 68px;
  }


  .product-card__dots {
    bottom: 9px;

    gap: 6px;
  }


  .product-card__quick-cart {
    width: 46px;
  }

}


/* =========================================================
   ADAPTIVE — <= 360px
   ========================================================= */

@media (max-width: 360px) {

  .products-viewport {
    width: 100%;
    max-width: 100%;

    overflow-x: auto;
    overflow-y: hidden;
  }


  .products-track {
    width: 100%;

    gap: 12px;
  }


  .product-card {
    flex: 0 0 100%;

    width: 100%;
    max-width: 100%;

    margin: 0;
  }

}


/* =========================================================
   REDUCED MOTION
   ========================================================= */

@media (prefers-reduced-motion: reduce) {

  .products-viewport {
    scroll-behavior: auto;
  }


  .product-card:hover .product-card__slide,
  .product-card:hover .product-card__dots span {
    animation: none !important;
  }

}

/* =========================================================
   RECENTLY VIEWED
   DESKTOP — GRID 4 × 2
   ========================================================= */

.products-section--recent .products-viewport {
  width: 100%;

  overflow: visible;
}


.products-section--recent .products-track {
  display: grid;

  grid-template-columns:
    repeat(4, minmax(0, 1fr));

  gap:
    34px
    15px;

  width: 100%;
}


.products-section--recent .product-card {
  width: 100%;
  min-width: 0;

  flex: none;
}


/*
 * На desktop навигация не нужна:
 * карточки сразу лежат сеткой.
 */
.section-footer--recent {
  display: none;
}


/* =========================================================
   RECENTLY VIEWED
   TABLET
   Остаемся сеткой, но по 2 карточки
   ========================================================= */

@media (max-width: 1024px) and (min-width: 761px) {

  .products-section--recent .products-track {
    grid-template-columns:
      repeat(2, minmax(0, 1fr));

    gap:
      32px
      18px;
  }

}


/* =========================================================
   RECENTLY VIEWED
   MOBILE — HORIZONTAL SLIDER
   ========================================================= */

@media (max-width: 760px) {

  .products-section--recent .products-viewport {
    width: 100%;
    max-width: 100%;

    overflow-x: auto;
    overflow-y: hidden;

    scrollbar-width: none;

    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;

    -webkit-overflow-scrolling: touch;

    overscroll-behavior-x: contain;
  }


  .products-section--recent .products-viewport::-webkit-scrollbar {
    display: none;
  }


  .products-section--recent .products-track {
    display: flex;

    width: max-content;

    gap: 15px;
  }


  .products-section--recent .product-card {
    flex:
      0
      0
      min(295px, 76vw);

    width:
      min(295px, 76vw);

    scroll-snap-align: start;
  }


  .section-footer--recent {
    display: flex;

    align-items: center;

    margin-top: var(--space-heading);
  }


  .section-footer--recent .slider-arrows {
    display: flex;

    align-items: center;

    gap: 18px;
  }

}


/* =========================================================
   RECENTLY VIEWED
   SMALL MOBILE
   ========================================================= */

@media (max-width: 480px) {

  .products-section--recent .product-card {
    flex:
      0
      0
      min(285px, 85vw);

    width:
      min(285px, 85vw);
  }


  .section-footer--recent .slider-arrows {
    gap: 12px;
  }

}

/* =========================================================
   PRODUCT CARD — MOBILE IMAGE SWIPE
   ========================================================= */

@media (max-width: 1024px) {

  .product-card__image[data-card-gallery] {
    /*
     * Вертикальный скролл страницы остается нативным.
     * Горизонтальный жест внутри фото забираем под галерею.
     */
    touch-action: pan-y;
  }


  .product-card__slide {
    transition: opacity 180ms ease;
  }


  .product-card__slide.is-active {
    opacity: 1;
  }


  .product-card__slide:not(.is-active) {
    opacity: 0;
  }


  .product-card__dots span.is-active {
    background: #111;
  }


  .product-card__dots span:not(.is-active) {
    background: rgb(13 13 13 / 28%);
  }

}