.categories {
  width: min(var(--container-max), calc(100% - (var(--page-gutter) * 2)));
  margin: 58px auto 62px;
}

.categories__heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.categories h2 {
  margin: 0;
  color: #12362c;
  font-family: var(--font-display);
  font-size: clamp(28px, 2.2vw, 36px);
  font-weight: 600;
  letter-spacing: -.025em;
  line-height: 1.1;
}

.categories__all-link {
  color: #14533f;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transition: color 180ms ease;
}

.categories__all-link:hover,
.categories__all-link:focus-visible {
  color: #0b3f2f;
  text-decoration: none;
}

.categories__grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.categories__card {
  position: relative;
  display: block;
  aspect-ratio: 1.6;
  overflow: hidden;
  border: 1px solid rgba(67, 52, 35, .08);
  border-radius: 16px;
  background: #eae5dc;
  color: #12362c;
  text-decoration: none;
}

.categories__card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
  transition: transform 420ms cubic-bezier(.2, .8, .2, 1), filter 220ms ease;
}

.categories__card:hover img {
  filter: saturate(1.04);
  transform: none;
}

.categories__name {
  position: absolute;
  right: auto;
  bottom: 12px;
  left: 12px;
  z-index: 2;
  max-width: calc(100% - 24px);
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 253, 249, .94);
  color: #12362c;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
  box-shadow: 0 4px 12px rgba(35, 55, 46, .10);
  text-shadow: none;
}

.categories__card small {
  display: none;
}

@media (max-width: 900px) {
  .categories__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .categories {
    margin-top: 16px;
    margin-bottom: 48px;
  }

  .categories__heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 9px;
    margin-bottom: 16px;
  }

  .categories h2 {
    max-width: 100%;
    font-size: clamp(24px, 7vw, 29px);
    white-space: nowrap;
  }

  .categories__all-link {
    font-size: 12px;
  }

  .categories__grid {
    gap: 10px;
  }

  .categories__card {
    aspect-ratio: 1.32;
    border-radius: 12px;
  }

  .categories__name {
    right: auto;
    bottom: 8px;
    left: 8px;
    max-width: calc(100% - 16px);
    padding: 6px 7px;
    border-radius: 8px;
    font-size: 12px;
  }
}
