/* ==========================================================================
   Головна: банери (слайдер + дві пропозиції), категорії, ряди товарів, банер «Підбір за VIN».
   Банери — готові зображення (фото + фірмове поле під текст), текст — HTML поверх.
   Картки товарів — .pcard з catalog.css; заголовки секцій — .section-head з news.css
   ========================================================================== */

/* Ритм (П4): між секціями і від заголовка до контенту — той самий крок --section-gap */
.page.home {
  gap: var(--section-gap);
}

/* Права колонка на головній — частина контенту (банери на всю ширину) */
.shell--home .main {
  grid-column: 2 / -1;
}

.hsection {
  display: flex;
  flex-direction: column;
  gap: var(--section-gap);
  min-width: 0;
}

.hsection[hidden] {
  display: none;
}

/* --------------------------------------------------------------------------
   Банери: слайдер (2/3) + дві пропозиції (1/3) — однакова висота ряду
   -------------------------------------------------------------------------- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: var(--layout-gap);
}

.hero__slider {
  position: relative;
  aspect-ratio: 1760 / 800;
  overflow: hidden;
  border-radius: var(--r-2xl);
  background: var(--c-primary);
  box-shadow: var(--sh-sm);
  isolation: isolate;
  container-type: inline-size;
}

/* Слайди лежать один на одному; зміна — плавним проявом, фото повільно «наближається» */
.hslide {
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity 700ms var(--ease), visibility 0s linear 700ms;
}

.hslide.is-active {
  z-index: 1;
  opacity: 1;
  visibility: visible;
  transition: opacity 700ms var(--ease), visibility 0s;
}

.hslide__media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.06);
  transform-origin: 70% 50%;
  transition: transform 0s linear 700ms;
}

.hslide.is-active .hslide__media img {
  transform: none;
  transition: transform 8s cubic-bezier(0.2, 0.6, 0.3, 1);
}

/* Увесь слайд — посилання; текст і кнопки — над ним */
.hslide__link {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.hslide__body {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: var(--s-3);
  max-width: 54%;
  padding: 5.5cqi 0 calc(5.5cqi + 20px) 6cqi;
  color: var(--c-text-inv);
  pointer-events: none;
}

.hslide__body a,
.hslide__body button {
  pointer-events: auto;
}

.hslide__title {
  font-size: clamp(20px, 3.5cqi, 36px);
  font-weight: var(--fw-bold);
  line-height: 1.15;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.hslide__text {
  max-width: 440px;
  color: rgba(255, 255, 255, 0.74);
  font-size: clamp(13px, 1.7cqi, 16px);
  line-height: 1.5;
  text-wrap: pretty;
}

.hslide__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-top: var(--s-2);
}

/* Поява тексту активного слайда — каскадом знизу */
.hslide.is-active .hslide__body > * {
  animation: hero-in 620ms var(--ease) both;
}

.hslide.is-active .hslide__body > :nth-child(2) { animation-delay: 70ms; }
.hslide.is-active .hslide__body > :nth-child(3) { animation-delay: 140ms; }

@keyframes hero-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}

/* Напівпрозора кнопка на темному фото (другорядна дія, стрілки) */
.btn--glass {
  background: rgba(255, 255, 255, 0.14);
  color: var(--c-text-inv);
}

.btn--glass:hover {
  background: rgba(255, 255, 255, 0.24);
}

.btn__logo {
  flex: none;
  width: 16px;
  height: 16px;
}

/* Керування: точки з прогресом зліва, стрілки справа */
.hero__controls {
  position: absolute;
  right: 3cqi;
  bottom: 3cqi;
  left: 6cqi;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  pointer-events: none;
}

.hero__controls > * {
  pointer-events: auto;
}

.hero__dots {
  display: flex;
  gap: 6px;
}

.hero__dot {
  display: grid;
  align-items: center;
  width: 36px;
  height: 20px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.hero__dot span {
  position: relative;
  height: 4px;
  overflow: hidden;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.28);
  transition: background-color var(--t-fast);
}

.hero__dot:hover span {
  background: rgba(255, 255, 255, 0.45);
}

.hero__dot span::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--c-text-inv);
  transform: scaleX(0);
  transform-origin: left;
}

.hero__dot.is-active span::after {
  transform: none;
}

.hero__dot.is-running span::after {
  animation: hero-progress var(--hero-delay, 6500ms) linear both;
}

@keyframes hero-progress {
  from {
    transform: scaleX(0);
  }
}

.hero__arrows {
  display: flex;
  gap: var(--s-2);
}

/* --- Пропозиції праворуч --- */
.hero__side {
  display: grid;
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: var(--layout-gap);
  min-height: 0;
}

.promo {
  position: relative;
  display: flex;
  min-height: 0;
  overflow: hidden;
  border-radius: var(--r-2xl);
  background: #0c0e14;
  box-shadow: var(--sh-sm);
  color: var(--c-text-inv);
  isolation: isolate;
  container-type: inline-size;
  transition: box-shadow var(--t) var(--ease);
}

.promo:hover {
  box-shadow: var(--sh-md);
}

.promo--light {
  background: var(--c-surface);
  color: var(--c-text);
}

.promo__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: right center;
}

.promo__link {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.promo__body {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 6px;
  max-width: 56%;
  padding: 0 0 0 7cqi;
  pointer-events: none;
}

.promo__title {
  font-size: clamp(15px, 4.6cqi, 20px);
  font-weight: var(--fw-bold);
  line-height: 1.25;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

.promo__go {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: var(--s-1);
  color: #ff9a5c;
  font-size: var(--fs-14);
  font-weight: var(--fw-semibold);
}

.promo--light .promo__go {
  color: var(--c-accent-text);
}

.promo__go svg.lucide {
  transition: transform var(--t) var(--ease);
}

.promo:hover .promo__go svg.lucide {
  transform: translateX(3px);
}

/* --------------------------------------------------------------------------
   Категорії
   -------------------------------------------------------------------------- */
.section-head__actions {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

/* Стрілки — білі кнопки на сірому фоні, як «Увесь каталог»; на краю стрічки — вимкнені */
.strip__nav:disabled {
  opacity: 0.45;
  pointer-events: none;
}

/* Стрічка з прокруткою; запас padding — щоб тіні плиток не обрізались */
.hcats {
  display: flex;
  gap: var(--s-3);
  margin: -8px -8px -20px;
  padding: 8px 8px 20px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding: 0 8px;
  scrollbar-width: none;
}

.hcats::-webkit-scrollbar {
  display: none;
}

/* Плитка: фото товару зліва, назва і кількість справа — усе по центру висоти */
.hcat {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  align-items: center;
  gap: var(--s-3);
  flex: 1 0 240px; /* заповнює ряд, якщо плиток мало; інакше — стрічка з прокруткою */
  padding: 10px 14px 10px 10px;
  border-radius: var(--r-xl);
  background: var(--c-surface);
  box-shadow: var(--sh-sm);
  scroll-snap-align: start;
  transition: box-shadow var(--t) var(--ease);
}

.hcat:hover {
  box-shadow: var(--sh-md);
}

.hcat__media {
  position: relative;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  overflow: hidden;
  border-radius: var(--r-lg);
  background: var(--c-media);
}

.hcat__media img {
  width: 82%;
  height: 82%;
  object-fit: contain;
  mix-blend-mode: multiply;
}

.hcat__media .sk {
  position: absolute;
  inset: 0;
}

.hcat__text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.hcat__name {
  display: -webkit-box;
  overflow: hidden;
  font-size: var(--fs-15);
  font-weight: var(--fw-semibold);
  line-height: 1.3;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  transition: color var(--t-fast);
}

.hcat:hover .hcat__name {
  color: var(--c-accent-text);
}

/* Кількість — звичайним сірим текстом, без фону */
.hcat__count {
  overflow: hidden;
  color: var(--c-text-3);
  font-size: var(--fs-13);
  line-height: 1.4;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* --------------------------------------------------------------------------
   Бренди: стрічка логотипів (та сама механіка прокрутки, що в категорій)
   -------------------------------------------------------------------------- */
.hbrands {
  display: flex;
  gap: var(--s-3);
  margin: -8px -8px -20px;
  padding: 8px 8px 20px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding: 0 8px;
  scrollbar-width: none;
}

.hbrands::-webkit-scrollbar {
  display: none;
}

.hbrand {
  display: grid;
  place-items: center;
  flex: 0 0 172px;
  height: 92px;
  padding: 0 22px;
  border-radius: var(--r-xl);
  background: var(--c-surface);
  box-shadow: var(--sh-sm);
  scroll-snap-align: start;
  transition: box-shadow var(--t) var(--ease);
}

.hbrand:hover {
  box-shadow: var(--sh-md);
}

.hbrand img {
  max-width: 100%;
  max-height: 40px;
  object-fit: contain;
}

.hbrand .sk {
  width: 100%;
  height: 32px;
}

/* --------------------------------------------------------------------------
   Банер «Підбір за VIN»
   -------------------------------------------------------------------------- */
.vinb {
  position: relative;
  display: flex;
  align-items: center;
  aspect-ratio: 2400 / 560;
  overflow: hidden;
  border-radius: var(--r-2xl);
  background: var(--c-primary);
  box-shadow: var(--sh-sm);
  color: var(--c-text-inv);
  isolation: isolate;
  container-type: inline-size;
}

.vinb__media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.vinb__body {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--s-3);
  max-width: 50%;
  padding: 0 0 0 4.5cqi;
}

.vinb__title {
  font-size: clamp(20px, 2.5cqi, 32px);
  font-weight: var(--fw-bold);
  line-height: 1.15;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.vinb__text {
  max-width: 520px;
  color: rgba(255, 255, 255, 0.74);
  font-size: clamp(13px, 1.2cqi, 16px);
  line-height: 1.5;
  text-wrap: pretty;
}

/* --------------------------------------------------------------------------
   Адаптивність
   -------------------------------------------------------------------------- */
/* Вузький слайдер: опис ховається, щоб заголовок і кнопки вільно вміщались */
@container (max-width: 720px) {
  .hslide__text,
  .hslide__actions .btn--glass {
    display: none;
  }
}

@container (max-width: 980px) {
  .vinb__body {
    max-width: 60%;
  }

  .vinb__text {
    display: none;
  }
}

@media (max-width: 1279px) {
  .shell--home .main {
    grid-column: auto;
  }

  .hero {
    grid-template-columns: minmax(0, 1fr);
  }

  .hero__side {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: none;
  }

  .promo {
    aspect-ratio: 1000 / 460;
  }
}

@media (max-width: 767px) {
  /* Слайдер: фото зверху, текст на темному полі знизу (окремі зображення для телефона) */
  /* Слайдер — впритул до шапки й від краю до краю екрана */
  .shell--home {
    padding-top: 0;
  }

  .hero__slider {
    margin: calc(var(--header-h) * -1) calc(var(--gutter) * -1) 0;
    aspect-ratio: 1080 / 960;
    border-radius: 0;
    box-shadow: none;
    touch-action: pan-y;
  }

  .hslide__body {
    justify-content: flex-end;
    gap: var(--s-2);
    max-width: none;
    padding: var(--s-4) var(--s-4) 40px;
  }

  .hslide__title {
    font-size: var(--fs-20);
  }

  .hslide__actions {
    margin-top: var(--s-1);
  }

  .hslide__actions .btn--glass {
    display: none;
  }

  .hero__controls {
    right: var(--s-4);
    bottom: 12px;
    left: var(--s-4);
  }

  .hero__dot {
    width: 28px;
  }

  .hero__arrows {
    display: none;
  }

  /* Пропозиції — стрічкою зі свайпом */
  .hero__side {
    display: flex;
    gap: var(--s-3);
    margin: -8px calc(var(--gutter) * -1) -20px;
    padding: 8px var(--gutter) 20px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding: 0 var(--gutter);
  }

  .promo {
    flex: 0 0 86%;
    scroll-snap-align: start;
  }

  .promo__title {
    font-size: var(--fs-16);
  }

  /* Категорії: стрічка від краю до краю екрана, свайп; стрілок немає */
  .hcats {
    margin: -8px calc(var(--gutter) * -1) -20px;
    padding: 8px var(--gutter) 20px;
    scroll-padding: 0 var(--gutter);
  }

  .strip__nav {
    display: none;
  }

  .hbrands {
    margin: -8px calc(var(--gutter) * -1) -20px;
    padding: 8px var(--gutter) 20px;
    scroll-padding: 0 var(--gutter);
  }

  .hbrand {
    flex-basis: 132px;
    height: 72px;
    padding: 0 16px;
  }

  .hbrand img {
    max-height: 30px;
  }

  .hcat {
    grid-template-columns: 52px minmax(0, 1fr);
    gap: 10px;
    flex: 0 0 200px;
    padding: 8px 12px 8px 8px;
  }

  .hcat__media {
    width: 52px;
    height: 52px;
  }

  .hcat__name {
    font-size: var(--fs-14);
  }


  /* Банер VIN: темний фон, запчастини в правому куті (окреме зображення), дві кнопки в ряд */
  .vinb {
    align-items: stretch;
    aspect-ratio: auto;
    min-height: 0;
  }

  .vinb__media img {
    object-position: right top;
  }

  .vinb__body {
    gap: var(--s-2);
    max-width: none;
    padding: var(--s-4);
  }

  .vinb__title {
    max-width: 66%;
    font-size: var(--fs-20);
  }

  .vinb__text {
    display: block;
    max-width: 64%;
    font-size: var(--fs-13);
  }

  .vinb .hslide__actions {
    width: 100%;
    margin-top: var(--s-2);
  }

  .vinb .hslide__actions .btn {
    flex: 1;
    padding: 0 12px;
  }

  .vinb__long {
    display: none;
  }

  /* Telegram — фірмовий колір месенджера */
  .vinb .btn--glass {
    display: inline-flex;
    background: #26a5e4;
  }

  .vinb .btn--glass:hover {
    background: #1e93cd;
  }
}

/* Телефон: поки видно банер, шапка прозора й лежить над ним (клас is-over ставить home.js);
   під нею — розмиття фону, що плавно розсіюється донизу,
   кнопки й пошук — темне напівпрозоре скло з білими іконками; далі — звичайна біла шапка.
   Відкритий пошук (is-search-full) — завжди у звичайному вигляді */
@media (max-width: 767px) {
  .page-home .header {
    transition: background-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
  }

  .page-home .header__burger,
  .page-home .vehicle-btn,
  .page-home .hdr-act--fav,
  .page-home .search__input,
  .page-home .search__wrap > .input-wrap__icon {
    transition: background-color var(--t) var(--ease), color var(--t) var(--ease), box-shadow var(--t) var(--ease);
  }

  body.page-home:not(.is-search-full) .header.is-over {
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  /* Шар розмиття: трохи нижчий за шапку, низ розчиняється маскою — без різкої межі */
  .page-home .header::before {
    content: "";
    position: absolute;
    inset: 0 0 -28px;
    z-index: -1;
    background: rgba(14, 19, 30, 0.22);
    backdrop-filter: blur(14px) saturate(1.4);
    -webkit-backdrop-filter: blur(14px) saturate(1.4);
    -webkit-mask-image: linear-gradient(to bottom, #000 55%, transparent);
    mask-image: linear-gradient(to bottom, #000 55%, transparent);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t) var(--ease);
  }

  body:not(.is-search-full) .header.is-over::before {
    opacity: 1;
  }

  body:not(.is-search-full) .header.is-over .header__burger,
  body:not(.is-search-full) .header.is-over .vehicle-btn,
  body:not(.is-search-full) .header.is-over .hdr-act--fav,
  body:not(.is-search-full) .header.is-over .search__input {
    background: rgba(14, 19, 30, 0.38);
    box-shadow: none;
    color: var(--c-text-inv);
  }

  body:not(.is-search-full) .header.is-over .search__input::placeholder {
    color: rgba(255, 255, 255, 0.82);
  }

  body:not(.is-search-full) .header.is-over .search__wrap > .input-wrap__icon {
    color: rgba(255, 255, 255, 0.82);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hslide,
  .hslide.is-active,
  .hslide__media img,
  .hslide.is-active .hslide__media img {
    transition: none;
    transform: none;
  }

  .hslide.is-active .hslide__body > * {
    animation: none;
  }
}
