/* Brand property badges next to snack group titles. */

.product-group__head {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 12px 14px;
  margin-bottom: 12px;
  overflow: visible;
  padding-top: 4px;
  /* Label space under the icon row (up to 2 lines) */
  padding-bottom: 1.85rem;
}

.product-group__head .product-group__title {
  flex: 0 1 auto;
  align-self: center;
  line-height: 1;
  min-width: 0;
}

.product-group__badges {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: nowrap;
  align-items: center;
  column-gap: 6px;
  row-gap: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
  list-style: none;
  overflow: visible;
}

.product-group__badges > li {
  position: relative;
  overflow: visible;
}

.product-group__badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 74px;
  height: 74px;
  padding: 6px;
  border-radius: 16px;
  background: transparent;
  cursor: default;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  transition:
    transform 0.22s ease,
    background 0.22s ease,
    box-shadow 0.22s ease;
}

/* Plain-text tooltip under the icon — centered, capped width */
.product-group__badge[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  right: auto;
  top: calc(100% + 4px);
  bottom: auto;
  z-index: 6;
  width: max-content;
  max-width: 6.5rem;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: #1b2430;
  font-family: var(--font-sans, system-ui, sans-serif);
  font-size: 0.625rem;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.015em;
  text-align: center;
  white-space: pre-line;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateX(-50%) translateY(-2px);
  transition:
    opacity 0.16s ease,
    transform 0.16s ease,
    visibility 0.16s ease;
}

.product-group__badge img {
  display: block;
  width: 62px;
  height: 62px;
  object-fit: contain;
  pointer-events: none;
}

.product-group__badge-fallback {
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
}

.product-group__badge:active {
  background: rgba(22, 58, 114, 0.1);
  transform: scale(0.96);
}

@media (hover: hover) and (pointer: fine) {
  .product-group__badge:hover {
    background: rgba(22, 58, 114, 0.08);
    transform: translateY(-2px) scale(1.08);
    box-shadow: 0 10px 20px -14px rgba(20, 36, 64, 0.55);
  }

  .product-group__badge[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
  }

  .product-group__badge[data-tooltip]:focus-visible::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
  }
}

.product-group__badge:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--c-green, #2f7d4a) 70%, transparent);
  outline-offset: 2px;
}

@media (hover: none), (pointer: coarse) {
  .product-group__badge[data-tooltip].is-tooltip-open::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
  }
}

@media (max-width: 767px) {
  .product-group__head {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 14px;
    padding-top: 0;
    padding-bottom: 0;
  }

  .product-group__head .product-group__title {
    align-self: flex-start;
  }

  .product-group__badges {
    flex: none;
    flex-wrap: wrap;
    align-items: flex-start;
    column-gap: 10px;
    /* Room for 2-line tip under icons */
    row-gap: 2rem;
    width: 100%;
    padding-bottom: 2rem;
  }

  .product-group__badge {
    width: 76px;
    height: 76px;
    padding: 4px;
    border-radius: 18px;
  }

  .product-group__badge img {
    width: 68px;
    height: 68px;
  }

  .product-group__badge[data-tooltip]::after {
    font-size: 0.5625rem;
    max-width: 5.25rem;
    top: calc(100% + 3px);
  }
}

/* Tablet / desktop: larger icons, still one row with the brand */
@media (min-width: 768px) {
  .product-group__head {
    gap: 10px 8px;
    /* Use leftover right padding of the catalog panel */
    margin-right: calc(8px - clamp(14px, 2.4vw, 28px));
  }

  .product-group__badges {
    column-gap: 3px;
  }

  .product-group__badge {
    flex: 0 1 auto;
    width: clamp(58px, 6.8vw, 82px);
    height: clamp(58px, 6.8vw, 82px);
    min-width: 52px;
    min-height: 52px;
    padding: 2px;
  }

  .product-group__badge img {
    width: 92%;
    height: 92%;
    max-width: 74px;
    max-height: 74px;
  }

  .product-group__badge[data-tooltip]::after {
    font-size: 0.5625rem;
    max-width: 5rem;
  }
}

@media (min-width: 1100px) {
  .product-group__badge {
    width: clamp(68px, 5.8vw, 84px);
    height: clamp(68px, 5.8vw, 84px);
  }

  .product-group__badge img {
    max-width: 76px;
    max-height: 76px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .product-group__badge {
    transition: none;
  }

  .product-group__badge[data-tooltip]::after {
    transition: none;
  }

  .product-group__badge:active,
  .product-group__badge:hover {
    transform: none;
  }
}

@supports (-webkit-touch-callout: none) {
  @media (max-width: 767px) {
    .product-group__badge {
      min-width: 76px;
      min-height: 76px;
    }
  }
}
