/* Match the desktop navigation's container, 10px item margin and 10px link inset. */
@media (min-width: 992px) {
  #header #_top_main_menu .top-menu .sub-menu.collapse {
    padding-inline: 0;
  }
  #header #_top_main_menu .sub-menu > .container > .top-menu[data-depth="1"] {
    padding-inline: 20px;
  }
  #header #_top_main_menu .sub-menu a[data-depth="1"] {
    display: flex;
    align-items: center;
  }
  #header #_top_main_menu .sub-menu a[data-depth="1"]::before {
    flex: 0 0 23px;
    width: 23px;
    height: 23px;
    margin: 0 6px 0 0;
  }
}

/* Keep native release and keyboard order: top to bottom within each column. */
#header #_top_main_menu :is(#category-13, #category-37) > .collapse > .container,
#header #sidevertical_menu :is(#cpcategory-13, #cpcategory-37) > .collapse {
  width: 100%;
  max-width: none;
  min-width: 0;
  padding: 0;
}
#header #_top_main_menu :is(#category-13, #category-37) > .collapse > .container > .top-menu,
#header #sidevertical_menu :is(#cpcategory-13, #cpcategory-37) > .collapse > .top-menu {
  display: block;
  column-count: 1;
  column-gap: 16px;
  width: 100%;
  margin: 0;
  padding: 0;
}
#header #_top_main_menu :is(#category-13, #category-37) .top-menu[data-depth="2"] > li,
#header #sidevertical_menu :is(#cpcategory-13, #cpcategory-37) .top-menu[data-depth="2"] > li {
  display: block;
  float: none;
  width: auto;
  min-width: 0;
  max-width: none;
  break-inside: avoid;
  margin: 0 0 4px;
  padding: 0;
}
#header #_top_main_menu :is(#category-13, #category-37) .top-menu[data-depth="2"] > li > a,
#header #sidevertical_menu :is(#cpcategory-13, #cpcategory-37) .top-menu[data-depth="2"] > li > a {
  display: flex;
  align-items: center;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  max-width: none;
  min-height: 44px;
  height: auto;
  margin: 0;
  padding: 6px 8px;
  font-size: 15px;
  line-height: 1.35;
  white-space: normal;
  overflow: visible;
  overflow-wrap: anywhere;
  text-overflow: clip;
  text-transform: none;
}
#header #_top_main_menu :is(#category-13, #category-37) .top-menu[data-depth="2"] > li > a::before,
#header #sidevertical_menu :is(#cpcategory-13, #cpcategory-37) .top-menu[data-depth="2"] > li > a::before {
  position: static;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  margin: 0 9px 0 0;
}
#header #_top_main_menu #category-4 a:focus-visible,
#header #sidevertical_menu #cpcategory-4 a:focus-visible {
  outline: 2px solid #e60012;
  outline-offset: -2px;
}

/* The existing side-menu toggle and collapse controls keep their behaviour. */
#header #cp_sidevertical_menu_top {
  box-sizing: border-box;
  width: min(440px, calc(100vw - 16px));
  max-width: calc(100vw - 16px);
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-gutter: stable;
}

@media (min-width: 600px) {
  #header #cp_sidevertical_menu_top {
    width: min(760px, calc(100vw - 24px));
  }
  #header #sidevertical_menu :is(#cpcategory-13, #cpcategory-37) > .collapse > .top-menu {
    column-count: 2;
  }
}

@media (min-width: 992px) {
  #header #_top_main_menu #category-4 > .sub-menu {
    max-height: min(640px, calc(100vh - 220px));
    max-height: min(640px, calc(100dvh - 220px));
    padding-block: 16px 20px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scrollbar-gutter: stable;
    justify-content: flex-start;
    visibility: hidden;
    pointer-events: none;
  }
  #header #_top_main_menu #category-4:hover > .sub-menu,
  #header #_top_main_menu #category-4:focus-within > .sub-menu {
    opacity: 1;
    transform: scale(1);
    visibility: visible;
    pointer-events: auto;
  }
  #header #_top_main_menu #category-4 > .sub-menu > .container,
  #header #_top_main_menu #category-4 > .sub-menu > .container > .top-menu[data-depth="1"] {
    width: 100%;
    max-width: none;
    min-width: 0;
  }
  #header #_top_main_menu #category-4 > .sub-menu > .container {
    max-width: 1440px;
    margin-inline: auto;
  }
  #header #_top_main_menu #category-4 > .sub-menu > .container > .top-menu[data-depth="1"] {
    display: block;
  }
  #header #_top_main_menu :is(#category-13, #category-37) {
    display: block;
    float: none;
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
    max-width: none;
    margin: 0;
    padding: 0;
  }
  #header #_top_main_menu :is(#category-13, #category-37) > .collapse > .container > .top-menu,
  #header #sidevertical_menu :is(#cpcategory-13, #cpcategory-37) > .collapse > .top-menu {
    column-count: 3;
  }
  #header #cp_sidevertical_menu_top {
    width: min(1060px, calc(100vw - 40px));
  }
}

@media (min-width: 1400px) {
  #header #_top_main_menu :is(#category-13, #category-37) > .collapse > .container > .top-menu,
  #header #sidevertical_menu :is(#cpcategory-13, #cpcategory-37) > .collapse > .top-menu {
    column-count: 4;
  }
  #header #cp_sidevertical_menu_top {
    width: min(1200px, calc(100vw - 48px));
  }
}

/* Progressive enhancement: compact series accordions in the Sets menu only. */
#header #_top_main_menu #category-4.kl-set-menu-ready .kl-menu-series,
#header #sidevertical_menu #cpcategory-4.kl-set-menu-ready .kl-menu-series {
  box-sizing: border-box;
  width: 100%;
  margin: 0 0 10px;
  padding: 0;
  border: 1px solid #e2e7ec;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}
#header .kl-menu-series > .kl-series-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  box-sizing: border-box;
  width: 100%;
  min-height: 58px;
  padding: 14px 18px;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: #f7f8fa;
  color: #001430;
  font: inherit;
  font-size: 17px;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
}
#header .kl-menu-series > .kl-series-toggle:hover { background: #edf1f5; }
#header .kl-series-toggle:focus-visible { outline: 2px solid #e60012; outline-offset: -3px; }
#header .kl-series-label { flex: 1 1 auto; font-weight: 600; min-width: 0; }
#header .kl-series-count { flex: 0 0 auto; font-size: 13px; color: #647184; white-space: nowrap; }
#header .kl-series-icon { flex: 0 0 28px; width: 28px; height: 28px; background-position: center; background-repeat: no-repeat; background-size: contain; }
#header .kl-series-chevron { flex: 0 0 8px; width: 8px; height: 8px; margin: 0 3px 4px; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg); transition: transform .15s ease; }
#header .kl-series-toggle[aria-expanded="true"] .kl-series-chevron { transform: rotate(225deg); margin-top: 6px; }
#header .kl-set-menu-ready .kl-series-panel[hidden] { display: none!important; }
#header .kl-set-menu-ready .kl-series-panel:not([hidden]) {
  display: block!important;
  position: static;
  box-sizing: border-box;
  width: 100%;
  height: auto!important;
  padding: 12px 14px 14px;
  margin: 0;
  border-top: 1px solid #e2e7ec;
  visibility: visible;
  opacity: 1;
  overflow: visible;
  transform: none;
}
#header .kl-series-panel > .kl-series-overview {
  display: block!important;
  width: 100%;
  min-height: 44px;
  margin: 10px 0 0;
  padding: 12px 8px 2px;
  border-top: 1px solid #e2e7ec;
  color: #001430;
  font-size: 14px;
  font-weight: 600;
  text-decoration: underline;
  text-transform: none;
}
#header .kl-series-overview::before { content: none!important; }
@media (min-width: 992px) {
  #header #_top_main_menu #category-4.kl-set-menu-ready > .sub-menu > .container {
    width: var(--kl-series-menu-width, 1120px);
    max-width: calc(100% - var(--kl-series-menu-left, 0px));
    margin-inline: var(--kl-series-menu-left, auto) 0;
    padding-inline: 20px;
  }
  #header #_top_main_menu #category-4 .kl-series-toggle { gap: var(--kl-series-gap, 12px); }
}
@media (max-width: 599px) {
  #header .kl-menu-series > .kl-series-toggle { gap: 9px; padding: 13px 12px; font-size: 16px; }
  #header .kl-series-count { font-size: 12px; }
  #header .kl-set-menu-ready .kl-series-panel:not([hidden]) { padding: 8px 6px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  #header .kl-series-chevron,
  #header #_top_main_menu #category-4 > .sub-menu { transition: none; }
}

/* Same grey surface as the category breadcrumb strip. */
#header #_top_main_menu > .top-menu > li > .sub-menu,
#header #_top_main_menu #category-4.kl-set-menu-ready .kl-menu-series {
  background-color: #f2f5f7;
}
