.tm-block-brands {
  container-type: inline-size;
  padding-top: var(--tm-brands-margin-top, 0px);
  padding-bottom: var(--tm-brands-margin-bottom, 20px);
  --tm-brands-columns: 4;
  --tm-brands-gap: 1rem;
  --tm-brands-visible-columns: var(--tm-brands-columns);
}

.tm-block-brands__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .85rem;
  margin: 0 0 1rem;
}

.tm-block-brands__title {
  margin: 0;
  color: #0f172a;
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1.2;
}

.tm-block-brands__nav {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  flex: 0 0 auto;
}

.tm-block-brands__nav-btn {
  display: inline-grid;
  place-items: center;
  width: 2.35rem;
  height: 2.35rem;
  border: 1px solid rgba(15, 23, 42, .14);
  border-radius: 999px;
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 8px 18px rgba(15, 23, 42, .08);
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease;
}

.tm-block-brands__nav-btn span {
  display: block;
  font-size: 1.65rem;
  line-height: 1;
  transform: translateY(-1px);
}

.tm-block-brands__nav-btn:hover:not(:disabled),
.tm-block-brands__nav-btn:focus-visible:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(15, 23, 42, .12);
}

.tm-block-brands__nav-btn:disabled {
  opacity: .38;
  cursor: default;
}

.tm-brands-list {
  display: grid;
  grid-template-columns: repeat(var(--tm-brands-columns), minmax(0, 1fr));
  gap: var(--tm-brands-gap);
  min-width: 0;
}

.tm-block-brands--carousel .tm-brands-list {
  display: flex;
  flex-wrap: nowrap;
  gap: var(--tm-brands-gap);
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.tm-block-brands--carousel .tm-brands-list::-webkit-scrollbar {
  display: none;
}

.tm-brand-card {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  align-items: center;
  gap: .8rem;
  width: 100%;
  min-width: 0;
  padding: .85rem;
  border: 1px solid rgba(15, 23, 42, .08);
  border-radius: .5rem;
  background: #fff;
  box-shadow: 0 6px 18px rgba(15, 23, 42, .05);
  color: #0f172a;
  text-decoration: none;
  transition: transform .18s ease, box-shadow .18s ease;
}

a.tm-brand-card:hover {
  color: #0f172a;
  transform: translateY(-2px);
  box-shadow: 0 12px 26px rgba(15, 23, 42, .09);
}

.tm-block-brands--carousel .tm-brand-card {
  flex: 0 0 calc((100% - (var(--tm-brands-gap) * (var(--tm-brands-visible-columns) - 1))) / var(--tm-brands-visible-columns));
  scroll-snap-align: start;
}

.tm-brand-card__media {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border: 1px solid rgba(15, 23, 42, .07);
  border-radius: .5rem;
  background: #fff;
}

.tm-brand-card__image {
  display: block;
  width: 52px;
  height: 52px;
  object-fit: contain;
}

.tm-brand-card__body {
  display: grid;
  gap: .35rem;
  min-width: 0;
}

.tm-brand-card__name {
  font-size: .95rem;
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.tm-brand-card__count {
  justify-self: start;
  padding: .18rem .55rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--tm-accent) 14%, #ffffff);
  color: #334155;
  font-size: .72rem;
  font-weight: 700;
  line-height: 1.2;
}

.tm-block-brands--image-only .tm-brand-card {
  grid-template-columns: 1fr;
  justify-items: center;
  min-height: 112px;
  padding: 1rem;
}

.tm-block-brands--image-only .tm-brand-card__media {
  width: 86px;
  height: 72px;
  border: 0;
}

.tm-block-brands--image-only .tm-brand-card__image {
  width: 82px;
  height: 68px;
}

.tm-block-brands--image-only .screen-reader-text {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media (max-width: 575.98px) {
  .tm-block-brands {
    --tm-brands-visible-columns: 1;
  }

  .tm-block-brands__header {
    align-items: flex-start;
  }

  .tm-block-brands__title {
    font-size: 1.2rem;
  }

  .tm-brands-list {
    grid-template-columns: 1fr;
  }
}

@container (max-width: 420px) {
  .tm-block-brands {
    --tm-brands-gap: .75rem;
    --tm-brands-visible-columns: 1;
  }

  .tm-brands-list {
    grid-template-columns: 1fr !important;
  }

  .tm-block-brands--carousel .tm-brand-card {
    flex-basis: 100%;
  }

  .tm-brand-card {
    grid-template-columns: 56px minmax(0, 1fr);
    padding: .75rem;
  }

  .tm-brand-card__media {
    width: 56px;
    height: 56px;
  }

  .tm-brand-card__image {
    width: 46px;
    height: 46px;
  }
}

@container (min-width: 421px) and (max-width: 760px) {
  .tm-block-brands {
    --tm-brands-visible-columns: 2;
  }

  .tm-brands-list {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

[data-tm-shop-sidebar] .tm-block-brands {
  --tm-brands-gap: .75rem;
}

[data-tm-shop-sidebar] .tm-block-brands .tm-brands-list {
  grid-template-columns: 1fr !important;
}

[data-tm-shop-sidebar] .tm-block-brands--carousel .tm-brand-card {
  flex-basis: 100%;
}
