/* ==========================================================
   Sections
   ========================================================== */
section {
  padding: 40px 0 8px;
}

.section__head {
  position: relative;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 16px;
  margin-bottom: 18px;
  text-align: center;
}

.section__head h2 {
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 700;
}

.section__head a {
  position: absolute;
  right: 0;
  bottom: 2px;
  font-size: 14px;
  color: var(--ink-2);
  border-bottom: 1px solid var(--line);
  padding-bottom: 2px;
  white-space: nowrap;
  transition: color 0.2s, border-color 0.2s;
}

.section__head a:hover {
  color: var(--ink);
  border-color: var(--ink);
}

@media (max-width: 640px) {
  .section__head {
    flex-direction: column;
    gap: 8px;
  }
  .section__head a {
    position: static;
  }
}

/* ==========================================================
   Rails (carousels) — shared base
   ========================================================== */
.rail-wrap {
  position: relative;
}

.rail {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 220px;
  gap: 12px;
  align-items: stretch;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  padding-bottom: 6px;
  scrollbar-width: none;
}

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

.rail-btn {
  position: absolute;
  top: 34%;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--line);
  display: none;
  place-items: center;
  font-size: 18px;
  line-height: 1;
  color: var(--ink);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .08);
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
  z-index: 2;
}

.rail-btn:hover {
  border-color: var(--ink);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .12);
}

.rail-btn:active {
  transform: scale(0.92);
}

.rail-btn:disabled {
  opacity: 0.35;
  pointer-events: none;
}

.rail-btn.prev { left: -14px; }
.rail-btn.next { right: -14px; }

@media (hover: hover) and (min-width: 900px) {
  .rail-btn { display: grid; }
}

/* "Flat" rails (brands, categories) center their arrows differently
   since items aren't full-height product cards */
.rail-wrap--flat .rail-btn {
  top: calc(50% - 19px);
}

/* ==========================================================
   Brands
   ========================================================== */
.rail--brands {
  grid-auto-columns: 220px;
}

.brand {
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0px 18px;
  background: var(--bg-soft);
  border: 0.5px solid var(--line);
  border-radius: var(--radius);
  white-space: nowrap;
  text-align: center;
  overflow: hidden;
  font-weight: 600;
  transition: border-color 0.2s, background-color 0.2s;
}

.brand:hover {
  border-color: var(--ink);
  background: var(--bg);
}

.brand-image-wrapper {
    background-color: #ffffffe0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
    min-width: 760px;
}
.brand-image-wrapper img {
    max-width: 760px;
    max-height: 300px;
    object-fit: contain; /* не искажается */
    display: block; 
    mix-blend-mode: multiply; /* делает чтобы убрался белый фон */
}

.brand-card-caption {
    text-align: center;
    font-size: 15px;
    color: var(--inc);
    display: block; /* делаем span блочным чтобы правильно работали отступы */
    padding: 16px;
    word-break: break-all;
}

/* ==========================================================
   Categories
   ========================================================== */
.rail--cats {
  /* Задаем фиксированную ширину карточки в карусели */
  grid-auto-columns: 220px;
  gap: 16px;
  align-items: start;
}

.cat {
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  background: transparent;
  border: none;
  padding: 0;
}

/* Контейнер для изображения с закругленными углами и светлым фоном */
.category-image-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4; /* Портретное соотношение сторон как на фото */
  border-radius: 12px; /* Мягкие закругленные углы */
  background: #f0f0f0; /* Серый нейтральный фон */
  overflow: hidden;
  margin-bottom: 12px;
}

.cat__bg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
  transition: transform 0.3s ease;
}

/* Эффект лёгкого увеличения при наведении */
.cat:hover .cat__bg {
  transform: scale(1.03);
}

/* Подпись под карточкой */
.category-card-caption {
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink, #111);
  text-align: center;
  word-break: break-word;
}

/* ==========================================================
   Product cards
   ========================================================== */
.card {
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  height: 100%;
  transition: border-color 0.2s;
}

.card:hover {
  border-color: var(--ink);
}

.card__media {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  background: var(--bg);
  border-radius: calc(var(--radius) - 4px);
  margin-bottom: 10px;
  overflow: hidden;
  display: block;
}

.card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s;
}

.card:hover .card__media img {
  transform: scale(1.04);
}

.tag {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 1;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  background: var(--ink);
  color: var(--bg);
}

.tag--new {
  background: var(--accent);
  color: #fff;
}

.card__title {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex-grow: 1;
}

.card__title:hover {
  color: var(--ink-2);
}

.prices {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.price {
  font-weight: 700;
  font-size: 15px;
}

.price--old {
  font-size: 12px;
  color: var(--ink-2);
  text-decoration: line-through;
}

.disc {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

.add {
  width: 100%;
  padding: 8px 12px;
  background: var(--ink);
  color: var(--bg);
  border-radius: calc(var(--radius) - 4px);
  font-weight: 600;
  font-size: 13px;
  transition: opacity 0.2s;
}

.add:hover {
  opacity: 0.85;
}

.add:active {
  opacity: 0.7;
}

/* ==========================================================
   Small screens
   ========================================================== */
@media (max-width: 480px) {
  .rail {
    grid-auto-columns: 160px;
  }
  .rail--cats {
    grid-auto-columns: 150px;
  }
  .card__title {
    font-size: 13px;
  }
}
/* Пустой каталог: ни брендов, ни товаров */
.home-empty {
  padding: 80px 0;
  text-align: center;
}

.home-empty h2 {
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 700;
  margin-bottom: 8px;
}

.home-empty p {
  color: var(--ink-2);
}
