/* Live-safe chip text + mobile shell fit.
   Load AFTER pack + polish. Scoped to category quicknav only.
   Mobile collapsed = up to 8 chips (4×2) + „Näita veel“ (= 5th row). */

body#category .hl-category-quicknav .subcategory__link--with-image,
body#category .hl-category-quicknav .hl-category-quicknav__toggle {
  height: 54px !important;
  min-height: 54px !important;
  max-height: 54px !important;
}

body#category .hl-category-quicknav .subcategory__link--with-image {
  padding: 6px 10px 7px 6px !important;
  gap: 7px !important;
  align-items: center !important;
  overflow: hidden !important;
}

body#category .hl-category-quicknav .subcategory__link--with-image .subcategory__thumbnail,
body#category .hl-category-quicknav a.subcategory__link--with-image > img.subcategory__thumbnail {
  width: 22px !important;
  height: 22px !important;
  flex: 0 0 22px !important;
}

body#category .hl-category-quicknav .subcategory__link--with-image .subcategory__name,
body#category .hl-catintro__chips.hl-category-quicknav .subcategory__link--with-image .subcategory__name {
  font-size: 12.5px !important;
  line-height: 1.3 !important;
  padding: 1px 2px 2px 0 !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
  -webkit-line-clamp: 2 !important;
  line-clamp: 2 !important;
}

/* Desktop collapsed: 2 chip rows */
@media (min-width: 768px) {
  body#category .hl-category-quicknav .hl-category-quicknav__list:not(.is-expanded):has(> a.subcategory__link--with-image:nth-child(13)) {
    max-height: calc(54px * 2 + 8px) !important;
    min-height: calc(54px * 2 + 8px) !important;
    height: calc(54px * 2 + 8px) !important;
  }
}

@media (max-width: 767.98px) {
  /* Breathing room before search/toolbar */
  body#category .hl-category-quicknav,
  body#category .hl-category-quicknav__wrap {
    margin-bottom: 12px !important;
    overflow: visible !important;
  }

  body#category .hl-category-quicknav .hl-category-quicknav__list,
  body#category .hl-category-quicknav .subcategory__list--with-images {
    overflow-x: hidden !important;
    overflow-y: visible !important;
  }

  /*
   * Collapsed mobile: 8 chips (4 rows) + toggle (5th row).
   * Old 4×48px shell clipped the bottom chip row once height became 54px.
   * Only when there are enough children to need the clamp (≥9).
   */
  /* Beat polish/list-after 4×48px clamp (same selector, later file). */
  body#category .hl-category-quicknav .hl-category-quicknav__list:not(.is-expanded):has(> a.subcategory__link--with-image:nth-child(9)),
  body#category .hl-category-quicknav .subcategory__list--with-images:not(.is-expanded):has(> a.subcategory__link--with-image:nth-child(9)) {
    max-height: calc(54px * 5 + 8px * 4 + 8px) !important;
    min-height: calc(54px * 5 + 8px * 4 + 8px) !important;
    height: calc(54px * 5 + 8px * 4 + 8px) !important;
    padding-bottom: 2px !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
    overflow-y: hidden !important;
  }

  /* Expanded (10–15+): full natural height, no clip */
  body#category .hl-category-quicknav .hl-category-quicknav__list.is-expanded,
  body#category .hl-category-quicknav .subcategory__list--with-images.is-expanded {
    max-height: none !important;
    min-height: 0 !important;
    height: auto !important;
    overflow: visible !important;
  }
}
