/* ACE v1.5.8.287.102: use the available header width before collapsing the menu.
 * Limited to ACE Foundation; no alteration to the homepage/content width.
 * The menu remains accessible when genuine text/translation overflow occurs.
 */
@media (min-width: 861px) {
  body.acef .site-header .wrap.header-inner {
    width: calc(100% - 40px) !important;
    max-width: none !important;
    margin-inline: auto !important;
    padding: 12px 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: clamp(12px, 1vw, 22px) !important;
    box-sizing: border-box;
  }
  body.acef .site-header .brand {
    flex: 0 0 auto !important;
    min-width: 0 !important;
    max-width: clamp(180px, 17vw, 270px) !important;
  }
  body.acef .site-header .brand .custom-logo-link { max-width: 100% !important; }
  body.acef .site-header .brand .custom-logo {
    width: auto;
    height: auto;
    max-width: 100% !important;
    max-height: 62px;
    object-fit: contain;
  }
  body.acef .site-header #site-nav {
    flex: 1 1 auto;
    min-width: 0;
    margin-left: auto;
  }
  body.acef .site-header #site-nav .nav__list {
    display: flex;
    flex-direction: row;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: nowrap !important;
    column-gap: clamp(5px, .5vw, 10px) !important;
    row-gap: 0 !important;
  }
  body.acef .site-header #site-nav .nav__list > li { flex: 0 0 auto; }
  body.acef .site-header #site-nav .nav__list > li > a {
    white-space: nowrap !important;
    font-size: clamp(.85rem, .79vw, .99rem) !important;
    line-height: 1.25;
    padding: 7px 3px !important;
  }
  /* Phase 2: compact typography, but only when the full-width row still needs it. */
  html.ace-header-compact body.acef .site-header .brand {
    max-width: clamp(160px, 14vw, 220px) !important;
  }
  html.ace-header-compact body.acef .site-header .wrap.header-inner { gap: 10px !important; }
  html.ace-header-compact body.acef .site-header #site-nav .nav__list {
    column-gap: 3px !important;
  }
  html.ace-header-compact body.acef .site-header #site-nav .nav__list > li > a {
    font-size: clamp(.79rem, .71vw, .9rem) !important;
    padding: 6px 2px !important;
  }
  /* Measuring phase: make the preferred one-line width measurable even when
     ACE Foundation's earlier breakpoint has hidden the real navigation. */
  html.ace-header-measuring body.acef .site-header #site-nav {
    display: block !important;
    position: absolute !important;
    left: -100000px !important;
    top: 0 !important;
    right: auto !important;
    width: max-content !important;
    max-width: none !important;
    min-width: max-content !important;
    height: auto !important;
    visibility: hidden !important;
    pointer-events: none !important;
    padding: 0 !important;
    margin: 0 !important;
    transform: none !important;
  }
  html.ace-header-measuring body.acef .site-header #site-nav .nav__list {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    width: max-content !important;
    max-width: none !important;
    align-items: center !important;
  }
  html.ace-header-measuring body.acef .site-header #site-nav .nav__list > li > a {
    white-space: nowrap !important;
  }
  /* Phase 3: show the ordinary accessible hamburger only if links really don't fit.
     The stronger selector intentionally wins over the theme's old 1180px breakpoint. */
  html.ace-header-fit body.acef .site-header #site-nav,
  html.ace-header-fit.nav-collapsed body.acef .site-header #site-nav {
    display: block !important;
    position: static !important;
    visibility: visible !important;
    width: auto !important;
    max-width: none !important;
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
  }
  html.ace-header-fit body.acef .site-header #site-nav .nav__list,
  html.ace-header-fit.nav-collapsed body.acef .site-header #site-nav .nav__list {
    display: flex !important;
    flex-direction: row !important;
    justify-content: flex-end !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
  }
  html.ace-header-fit body.acef .site-header .nav-toggle,
  html.ace-header-fit.nav-collapsed body.acef .site-header .nav-toggle { display: none !important; }
  html.ace-header-overflow body.acef .site-header #site-nav { display: none !important; }
  html.ace-header-overflow body.acef .site-header .nav-toggle {
    display: inline-flex !important;
    flex: 0 0 44px;
    margin-left: auto;
  }
  html.ace-header-overflow body.acef .site-header #site-nav.is-open {
    display: block !important;
    position: absolute !important;
    left: 0 !important;
    right: 0 !important;
    top: calc(100% + 6px) !important;
    width: auto !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 12px !important;
    border: 1px solid var(--acef-border, #ddd) !important;
    border-radius: 14px !important;
    background: var(--acef-surface, #fff) !important;
    box-shadow: var(--acef-shadow, 0 12px 30px #0002) !important;
    max-height: calc(100vh - 130px);
    overflow-y: auto;
    z-index: 9999;
  }
  html.ace-header-overflow body.acef .site-header #site-nav.is-open .nav__list {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 5px !important;
  }
  html.ace-header-overflow body.acef .site-header #site-nav.is-open .nav__list > li > a {
    display: flex !important;
    width: 100%;
    white-space: normal !important;
    font-size: 1rem !important;
    padding: 11px 12px !important;
  }
}
/* At phone sizes retain ACE Foundation's familiar centred logo and toggle. */
@media (min-width: 861px) and (max-width: 1180px) {
  html.ace-header-measuring body.acef .site-header #site-nav li.ace-mobile-menu-only,
  html.ace-header-fit body.acef .site-header #site-nav li.ace-mobile-menu-only {
    display: none !important;
  }
}
