.branded-header {
  --branded-header-height: 64px;
  --branded-header-gutter: 20px;
  --branded-header-rule: rgba(31, 21, 17, 0.25);

  position: sticky;
  top: var(--drupal-displace-offset-top, 0px);
  z-index: 999;
  border-bottom: 1px solid transparent;
  background: var(--brand-off-white);
  color: var(--brand-retro-black);
  font-family: var(--font-ideal-sans-regular);
  transition: background-color 0.2s ease, color 0.2s ease;
}

.branded-header.is-scrolled {
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.has-overlay-header .branded-header {
  margin-bottom: calc(-1 * var(--branded-header-height));
}

.has-overlay-header .branded-header.is-top:not(:hover, :focus-within, .is-menu-open) {
  background: transparent;
  border-bottom-color: rgb(255, 253, 250, 0.16);
  color: #fff;
}

/* Dark fade behind the header over the hero (the site's `header_gradient`). */
.has-overlay-header .branded-header.branded-header--gradient.is-top:not(:hover, :focus-within, .is-menu-open) {
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.64) 0%, rgba(0, 0, 0, 0) 100%) no-repeat;
}

.branded-header__inner {
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--branded-header-height);
  padding-inline: var(--branded-header-gutter);
}

.branded-header__brand {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
  margin-right: auto;
}

.branded-header__brand-link {
  display: flex;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.branded-header__logo {
  display: block;
  width: auto;
  height: 34px;
}

.branded-header__second-logo {
  display: block;
  width: auto;
  height: 22px;
}

/* The off-white pill behind the second logo. Its padding is cancelled by
   negative margins, so the logo sits in the same place with or without it
   and the brand gap is measured to the logo, not to the pill edge. Only
   visible over the hero: on the off-white header it would blend in. */
.branded-header__second-logo-link {
  --second-logo-pad-x: 8px;
  --second-logo-pad-y: 6px;

  padding: var(--second-logo-pad-y) var(--second-logo-pad-x);
  margin-inline: calc(-1 * var(--second-logo-pad-x));
  border-radius: 5px;
  background-color: transparent;
  transition: background-color 0.2s ease;
}

.has-overlay-header .branded-header.is-top:not(:hover, :focus-within, .is-menu-open) .branded-header__second-logo-link {
  background-color: var(--brand-off-white);
}

.branded-header__name {
  font-family: var(--font-ideal-sans-semibold);
  font-size: 24px;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

/* Text wordmark (the site's `brand_text`), e.g. two stacked lines. */
.branded-header__name--text {
  font-size: 16px;
  line-height: 0.95;
}

.branded-header a:hover {
  color: inherit;
}

.branded-header a:focus-visible,
.branded-header__toggle:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* Hamburger */
.branded-header__toggle {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px 0;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

.branded-header__toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: currentColor;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.branded-header__toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.branded-header__toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.branded-header__toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* Full-screen nav below the bar, which stays visible (cream) above it with
   the logos and the close button. */
.branded-header__nav {
  position: fixed;
  inset: calc(var(--drupal-displace-offset-top, 0px) + var(--branded-header-height)) 0 0 0;
  z-index: 1;
  padding-bottom: 32px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--brand-off-white);
  color: var(--brand-retro-black);
  border-top: 1px solid var(--branded-header-rule);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0s linear 0.2s;
}

.branded-header__nav.is-open {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.2s ease, visibility 0s;
}

.menu__item a {
  color: var(--brand-retro-black);
  text-decoration: none;
}

/* Stop the page scrolling behind the open menu. */
@media (max-width: 1079.98px) {
  body:has(.branded-header__nav.is-open) {
    overflow: hidden;
  }
}

.branded-header__nav .menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  background: none;
}

.branded-header__nav .menu li {
  margin: 0;
}

/* Mobile rows, same as the main header's top-level links. */
.branded-header__nav .menu__item,
.branded-header__nav .branded-header__hub-link {
  display: flex;
  align-items: center;
  padding: 18px var(--branded-header-gutter);
  border-bottom: 1px solid rgb(31 21 17 / 40%);
  color: inherit;
  font-family: var(--font-ideal-sans-semibold);
  font-size: 1.03rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.branded-header__nav .menu__item,
.branded-header__nav .branded-header__hub-link {
  text-decoration: none;
  color: inherit;
}

/* Last top-level menu item as a button (the site's `is_last_button`): blue on
   the cream header, white while the header is transparent over the hero. */
.branded-header--last-button .branded-header__nav .menu > .menu__item:last-child > .menu__link {
  display: inline-flex;
  align-items: center;
  padding: 16px 32px;
  background: var(--brand-cerulean-blue);
  color: #fff;
  text-decoration: none;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.branded-header--last-button .branded-header__nav .menu > .menu__item:last-child > .menu__link:hover {
  background: var(--brand-cerulean-blue);
  color: #fff;
}

.has-overlay-header .branded-header--last-button.is-top:not(:hover, :focus-within, .is-menu-open) .branded-header__nav .menu > .menu__item:last-child > .menu__link {
  background: #fff;
  color: var(--brand-retro-black);
}

/* ---------------------------------------------------------------------------
 * Desktop
 * ------------------------------------------------------------------------- */
@media (min-width: 1080px) {
  .branded-header {
    --branded-header-height: 88px;
    --branded-header-gutter: 35px;
  }

  .branded-header.branded-header--aspire,
  .branded-header.branded-header--rumi {
    background: var(--brand-floral-white);
  }

  .branded-header__inner {
    gap: 56px;
  }

  .branded-header__brand {
    margin-right: 0;
    gap: 32px;
  }

  .branded-header__logo {
    height: 64px;
  }

  .branded-header__second-logo {
    height: 42px;
  }

  .branded-header__second-logo-link {
    --second-logo-pad-x: 15px;
    --second-logo-pad-y: 11px;
    border-radius: 10px;
  }

  .branded-header__toggle {
    display: none;
  }

  .branded-header__name--text {
    font-size: 20px;
  }

  /* Menu sits next to the brand; "Visit Hub4R" is pushed to the far right. */
  .branded-header__nav {
    position: static;
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: space-between;
    gap: 40px;
    padding: 0;
    overflow: visible;
    background: none;
    color: inherit;
    border-top: 0;
    opacity: 1;
    visibility: visible;
    transition: none;
  }

  /* Sites with menu_align 'right' (the default): menu (and "Visit Hub4R",
     if shown) sit together on the right. */
  .branded-header--menu-right .branded-header__nav {
    justify-content: flex-end;
  }

  .branded-header__nav .menu {
    flex-direction: row;
    gap: 40px;
  }

  .branded-header__nav .menu__item,
  .branded-header__nav .branded-header__hub-link {
    width: auto;
    padding: 4px 0;
    border-bottom: 0;
    font-family: var(--font-ideal-sans-regular);
    font-size: 1.125rem;
    letter-spacing: normal;
    text-transform: none;
    white-space: nowrap;
  }

  .branded-header__nav .menu__item a,
  .branded-header__nav .branded-header__hub-link {
    text-decoration: none;
    color: inherit;
  }

  .branded-header__nav a.is-active {
    font-family: var(--font-ideal-sans-regular);
  }

  /* APWSI: the last menu link is the "Join the Initiative" button. Dark on
     the cream header, light while the header is transparent over the hero. */
  .branded-header--apwsi .branded-header__nav .menu > li:last-child > a {
    display: inline-block;
    padding: 20px 32px;
    border-radius: 0;
    background: var(--brand-cerulean-blue);
    color: #fff;
    font-family: var(--font-ideal-sans-medium);
    font-weight: 500;
    line-height: 1;
    transition: background-color 0.2s ease, color 0.2s ease;
  }

  .has-overlay-header .branded-header--apwsi.is-top:not(:hover, :focus-within, .is-menu-open) .branded-header__nav .menu > li:last-child > a {
    background: var(--brand-off-white);
    color: var(--brand-retro-black);
  }

  .branded-header--apwsi .branded-header__nav .menu > li:last-child > a:hover {
    background: var(--brand-cerulean-blue);
    color: #fff;
  }
}

@media (min-width: 1280px) {
  .branded-header {
    --branded-header-gutter: 64px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .branded-header,
  .branded-header__nav,
  .branded-header__toggle span,
  .branded-header--last-button .branded-header__nav .menu > .menu__item:last-child > .menu__link {
    transition: none;
  }
}
