.ferrus-catalog-sections-v3,
.ferrus-catalog-sections-v3 * {
  box-sizing: border-box;
}

.ferrus-catalog-sections-v3 {
  --fcs-text: #191c1e;
  --fcs-text-soft: #5f6777;
  --fcs-radius: 14px;
  --fcs-shadow: 0 16px 32px rgba(15, 23, 42, 0.08);
}

.ferrus-catalog-sections-v3 .container {
  width: min(1440px, calc(100% - 32px));
  margin-inline: auto;
}

.ferrus-catalog-sections-v3 .heading {
  margin-bottom: 28px;
  text-align: left;
}

.ferrus-catalog-sections-v3 .heading-main {
  border-bottom: 1px solid rgba(95, 103, 119, 0.24);
  padding-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.ferrus-catalog-sections-v3 .heading h1 {
  margin: 0 0 10px;
  color: var(--fcs-text);
  font-size: clamp(2rem, 6vw, 3.8rem);
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: -0.04em;
}

.ferrus-catalog-sections-v3 .heading p {
  margin: 0;
  max-width: 760px;
  color: var(--fcs-text-soft);
  font-size: 16px;
  font-weight: 400;
}

.ferrus-catalog-sections-v3 .search-box {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(100%, 360px);
  min-width: 0;
  max-width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  background: #e7ebef;
  color: var(--fcs-text-soft);
}

.ferrus-catalog-sections-v3 .search-box .icon {
  width: 1.2rem;
  height: 1.2rem;
  fill: currentColor;
  stroke: none;
  flex: 0 0 auto;
}

.ferrus-catalog-sections-v3 .search-box input {
  width: 100%;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--fcs-text);
}

.ferrus-catalog-sections-v3 .categories {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 20px;
  justify-content: flex-start;
  align-items: stretch;
}

/* Плавное уменьшение колонок: 5 -> 4 -> 3 -> 2.
   Минимум всегда 2 в ряд (вплоть до самых узких экранов). */

/* Большие десктопы поуже */
@media (max-width: 1399px) {
  .ferrus-catalog-sections-v3 .categories {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* Планшеты в альбомной / небольшие ноутбуки.
   Селекторы намеренно усилены через `.categories`, т.к. базовые правила
   .category-card / .overlay объявлены ниже по файлу. */
@media (max-width: 1100px) {
  .ferrus-catalog-sections-v3 .categories {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
  }

  .ferrus-catalog-sections-v3 .categories .overlay {
    padding: 16px;
  }

  .ferrus-catalog-sections-v3 .categories .overlay .go {
    display: none;
  }
}

/* Планшеты в портрете и крупные телефоны — уходим на 2 в ряд,
   чтобы карточки не становились узкими «полосками» */
@media (max-width: 767px) {
  .ferrus-catalog-sections-v3 {
    padding-top: 20px;
  }

  .ferrus-catalog-sections-v3 .categories {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }

  /* чуть менее вытянутые карточки на мобильном */
  .ferrus-catalog-sections-v3 .categories .category-card {
    aspect-ratio: 3 / 4;
  }

  .ferrus-catalog-sections-v3 .categories .overlay {
    padding: 14px;
  }

  .ferrus-catalog-sections-v3 .categories .overlay h3 {
    font-size: 1rem;
    line-height: 1.18;
  }

  .ferrus-catalog-sections-v3 .categories .overlay p {
    font-size: 0.74rem;
  }
}

/* Узкие телефоны: остаёмся на 2 в ряд, поджимаем отступы и прячем описание */
@media (max-width: 479px) {
  .ferrus-catalog-sections-v3 .categories {
    gap: 10px;
  }

  .ferrus-catalog-sections-v3 .categories .overlay {
    padding: 10px;
  }

  .ferrus-catalog-sections-v3 .categories .overlay h3 {
    font-size: 0.86rem;
    line-height: 1.2;
  }

  .ferrus-catalog-sections-v3 .categories .overlay p,
  .ferrus-catalog-sections-v3 .categories .overlay .go {
    display: none;
  }
}

.ferrus-catalog-sections-v3 .category-card {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  border-radius: var(--fcs-radius);
  overflow: hidden;
  box-shadow: var(--fcs-shadow);
}

.ferrus-catalog-sections-v3 .category-card img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1);
  transition: transform 0.6s ease;
}

.ferrus-catalog-sections-v3 .category-card:hover img {
  transform: scale(1.08);
}

.ferrus-catalog-sections-v3 .overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.82), rgba(0, 0, 0, 0.15));
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-start;
  color: #fff;
  padding: 24px;
  text-align: left;
  overflow: hidden;
}

.ferrus-catalog-sections-v3 .overlay span {
  margin-bottom: 4px;
  font-size: 0.62rem;
  font-weight: 400;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  opacity: 0.72;
  display: none;
}

.ferrus-catalog-sections-v3 .overlay h3 {
  margin: 0;
  color: #fff;
  font-size: clamp(1rem, 2.2vw, 1.7rem);
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
}

.ferrus-catalog-sections-v3 .overlay p {
  margin: 8px 0 0;
  font-size: clamp(0.7rem, 1.1vw, 0.8rem);
  font-weight: 400;
  opacity: 0.75;
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
}

.ferrus-catalog-sections-v3 .go {
  margin-top: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 700;
}

.ferrus-catalog-sections-v3 .go .icon {
  width: 1.1rem;
  height: 1.1rem;
  fill: currentColor;
  stroke: none;
  flex: 0 0 auto;
}

.ferrus-catalog-sections-v3 .category-card > a {
  position: absolute;
  inset: 0;
}

@media (min-width: 768px) {
  .ferrus-catalog-sections-v3 .heading-main {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
  }

  .ferrus-catalog-sections-v3 .search-box {
    width: min(100%, 340px);
    min-width: 0;
  }
}
