.mc-logo-listing{
  display:grid;
  grid-template-columns: repeat(var(--mc-cols-desktop, 6), minmax(0, 1fr));
  gap: var(--mc-gap, 30px);
  align-items: center;
}

.mc-logo-listing__item{
  display:flex;
  align-items:center;
  justify-content:center;
  min-width:0;
}

.mc-logo-listing__link{
  display:flex;
  align-items:center;
  justify-content:center;
  width:100%;
  text-decoration:none;
}

/*
  Wrapper-based sizing (more robust than sizing the <img> directly):
  - The wrapper caps the logo box by max-width/max-height (from settings),
    but also naturally shrinks to the grid cell width (prevents mobile overlap).
  - The image scales inside the box, preserving aspect ratio.
*/
.mc-logo-listing__inner{
  display:flex;
  align-items:center;
  justify-content:center;
  width:100%;
  max-width: var(--mc-logo-max-w, 160px);
  /*
    IMPORTANT:
    Percent-based max-height on the <img> only works reliably when the parent
    has an explicit height. Using only max-height here can allow the image
    to exceed the cap (leading to overlap).
  */
  height: var(--mc-logo-max-h, 80px);
  max-height: var(--mc-logo-max-h, 80px);
  margin: 0 auto;
  min-width:0;
}

.mc-logo-listing__img,
.fl-builder-content .mc-logo-listing__img{
  display:block;
  max-width: 100% !important;
  max-height: 100% !important;
  width:auto !important;
  height:auto !important;
  object-fit:contain;
}

/* Mobile */
@media (max-width: 767px){
  .mc-logo-listing{
    grid-template-columns: repeat(var(--mc-cols-mobile, 2), minmax(0, 1fr));
  }

  /*
    On mobile, don't force a fixed logo-box height.
    We still cap the *image* height using the setting, but allow shorter logos
    to take up less vertical space so rows can tighten up.
  */
  .mc-logo-listing__inner{
    height: auto;
    max-height: none;
  }

  .mc-logo-listing__img,
  .fl-builder-content .mc-logo-listing__img{
    max-height: var(--mc-logo-max-h, 80px) !important;
  }
}
