/*
 * Unified fixed header, mega navigation and search layer.
 * The header shell and its panels share one positioning context so they cannot
 * drift apart while the page is scrolled.
 */
:root {
  --ofn-admin-offset: 0px;
  --ofn-header-top-gap: 12px;
  --ofn-header-shell-height: 76px;
  --ofn-header-panel-gap: 12px;
  --ofn-header-reserved-height: calc(
    var(--ofn-header-top-gap) + var(--ofn-header-shell-height) + 12px
  );
}

body.admin-bar {
  --ofn-admin-offset: 32px;
}

html.ofn-overlay-open,
body.ofn-overlay-open {
  overflow: hidden !important;
  overscroll-behavior: none;
}

.site-header {
  position: fixed !important;
  z-index: 900 !important;
  top: var(--ofn-admin-offset) !important;
  right: 0;
  left: 0;
  padding: var(--ofn-header-top-gap) 0 0 !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  pointer-events: none;
}

.site-header-stage {
  position: relative;
  width: min(var(--container), calc(100% - (var(--gutter) * 2)));
  height: var(--ofn-header-shell-height);
  margin-inline: auto;
  pointer-events: auto;
}

.site-header-spacer {
  display: block;
  height: var(--ofn-header-reserved-height);
}

.site-header .header-shell {
  width: 100% !important;
  height: var(--ofn-header-shell-height) !important;
  min-height: var(--ofn-header-shell-height) !important;
  margin: 0 !important;
  padding: 8px 10px 8px 18px;
  border: 1px solid rgba(0, 45, 94, 0.09);
  border-radius: var(--radius-pill);
  background: #fff;
  box-shadow: 0 5px 18px rgba(0, 45, 94, 0.07);
  transition: opacity 0.18s ease, visibility 0.18s ease, box-shadow 0.18s ease;
}

.site-header.is-scrolled .header-shell {
  border-color: rgba(0, 45, 94, 0.12);
  box-shadow: 0 7px 22px rgba(0, 45, 94, 0.09);
}

.site-header.has-open-layer .header-shell {
  box-shadow: none;
}

body.ofn-search-open .site-header .header-shell {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.nav-backdrop,
.search-backdrop {
  position: fixed !important;
  z-index: 880 !important;
  inset: 0 !important;
  background: rgba(18, 28, 37, 0.76) !important;
  backdrop-filter: none !important;
}

/* Mega menus are attached to the fixed header stage. */
.site-header .mega-menu {
  position: absolute !important;
  z-index: 2 !important;
  top: calc(100% + var(--ofn-header-panel-gap)) !important;
  left: 0 !important;
  width: 100% !important;
  max-height: calc(
    100dvh - var(--ofn-admin-offset) - var(--ofn-header-top-gap) -
      var(--ofn-header-shell-height) - var(--ofn-header-panel-gap) - 16px
  ) !important;
  margin: 0 !important;
  overflow: auto !important;
  transform: translateY(-8px) !important;
  border: 1px solid rgba(0, 45, 94, 0.08);
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 16px 38px rgba(0, 45, 94, 0.12);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
  overscroll-behavior: contain;
}

.site-header .mega-menu.is-open {
  transform: translateY(0) !important;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Search replaces the normal header row and uses one single field outline. */
.site-header .search-panel {
  position: absolute !important;
  z-index: 3 !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  max-height: calc(100dvh - var(--ofn-admin-offset) - var(--ofn-header-top-gap) - 16px) !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: visible !important;
  transform: translateY(-8px) !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
}

.site-header .search-panel.is-open {
  transform: translateY(0) !important;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.site-header .search-top {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) 46px;
  min-height: var(--ofn-header-shell-height);
  align-items: center;
  gap: 14px;
  padding: 8px 10px 8px 18px;
  border: 1px solid rgba(0, 45, 94, 0.09);
  border-radius: var(--radius-pill);
  background: #fff;
  box-shadow: 0 5px 18px rgba(0, 45, 94, 0.07);
}

.site-header .search-top .site-logo-mark {
  display: block;
  width: 54px;
  height: 54px;
  object-fit: contain;
}

.site-header .global-search-form {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 54px;
  align-items: center;
  overflow: hidden;
  border: 2px solid var(--blue);
  border-radius: var(--radius-pill);
  background: #fff;
  transition: border-color 0.16s ease;
}

.site-header .global-search-form:focus-within {
  border-color: var(--yellow);
  box-shadow: none;
}

.site-header .global-search-form > .icon {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 18px;
  width: 22px;
  height: 22px;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.site-header .global-search-form input[type="search"] {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  min-height: 50px !important;
  margin: 0;
  padding: 10px 10px 10px 52px !important;
  border: 0 !important;
  border-radius: 0 !important;
  outline: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--ink);
  font-size: 1rem;
}

.site-header .global-search-form input[type="search"]:focus,
.site-header .global-search-form input[type="search"]:focus-visible {
  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;
}

.site-header .global-search-form .btn {
  position: static !important;
  flex: 0 0 44px;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  margin: 0 5px 0 0;
  padding: 0;
  border-radius: 50%;
}

.site-header .search-top > .icon-button {
  width: 44px;
  height: 44px;
  background: var(--beige-dark);
}

.site-header .search-body {
  max-height: calc(
    100dvh - var(--ofn-admin-offset) - var(--ofn-header-top-gap) -
      var(--ofn-header-shell-height) - var(--ofn-header-panel-gap) - 16px
  );
  margin-top: var(--ofn-header-panel-gap);
  overflow: auto;
  padding: clamp(26px, 3.5vw, 44px);
  border: 1px solid rgba(0, 45, 94, 0.08);
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 16px 38px rgba(0, 45, 94, 0.12);
  overscroll-behavior: contain;
}

.site-header .search-result > span {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

.site-header .search-card-type,
.site-header .search-result strong {
  display: block;
}

.site-header .search-result strong {
  line-height: 1.3;
}

/* Keep the account popover connected to the fixed header shell. */
.site-header .member-menu {
  top: calc(100% + 10px);
  z-index: 5;
}

@media (max-width: 1180px) {
  :root {
    --ofn-header-shell-height: 72px;
  }

  .site-header .mega-menu {
    display: none !important;
  }
}

@media (max-width: 782px) {
  :root {
    --ofn-header-top-gap: 9px;
    --ofn-header-shell-height: 72px;
    --ofn-header-panel-gap: 9px;
    --ofn-header-reserved-height: calc(
      var(--ofn-header-top-gap) + var(--ofn-header-shell-height) + 9px
    );
  }

  body.admin-bar {
    --ofn-admin-offset: 46px;
  }

  .site-header-stage {
    width: calc(100% - 20px);
  }

  .site-header .header-shell {
    height: var(--ofn-header-shell-height) !important;
    min-height: var(--ofn-header-shell-height) !important;
    padding: 7px 8px 7px 12px;
    border-radius: 24px;
  }

  .site-header .search-panel {
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    max-height: calc(100dvh - var(--ofn-admin-offset) - var(--ofn-header-top-gap) - 10px) !important;
  }

  .site-header .search-top {
    grid-template-columns: minmax(0, 1fr) 42px;
    min-height: var(--ofn-header-shell-height);
    gap: 8px;
    padding: 7px 8px;
    border-radius: 24px;
  }

  .site-header .search-top .site-logo-mark {
    display: none;
  }

  .site-header .global-search-form {
    min-height: 54px;
  }

  .site-header .global-search-form > .icon {
    left: 15px;
    width: 20px;
    height: 20px;
  }

  .site-header .global-search-form input[type="search"] {
    min-height: 50px !important;
    padding-left: 45px !important;
    font-size: 0.96rem;
  }

  .site-header .global-search-form .btn {
    flex-basis: 42px;
    width: 42px;
    min-width: 42px;
    height: 42px;
    min-height: 42px;
    margin-right: 4px;
  }

  .site-header .search-top > .icon-button {
    width: 40px;
    height: 40px;
  }

  .site-header .search-body {
    max-height: calc(
      100dvh - var(--ofn-admin-offset) - var(--ofn-header-top-gap) -
        var(--ofn-header-shell-height) - var(--ofn-header-panel-gap) - 10px
    );
    padding: 22px 18px;
    border-radius: 22px;
  }

  .site-header .search-suggestions {
    grid-template-columns: 1fr;
    gap: 28px;
  }
}

@media (max-width: 480px) {
  .site-header-stage {
    width: calc(100% - 16px);
  }

  .site-header .global-search-form input[type="search"] {
    padding-right: 6px !important;
  }

  .site-header .search-body {
    padding: 20px 16px;
  }

  .site-header .search-result {
    grid-template-columns: 64px minmax(0, 1fr) auto;
  }

  .site-header .search-result img {
    width: 64px;
    height: 58px;
  }
}
