/* Pass 8: canonical navigation and science-link cleanup. Loaded last. */

/* Keep every public page on the same shared horizontal menu. */
body.page-home .main-nav a:nth-last-child(-n+2) {
  display: inline-flex;
}

.site-header .header-row {
  position: relative;
}

.site-header .main-nav {
  display: flex;
  position: static;
  inset: auto;
  flex-direction: row;
  align-items: center;
  gap: 30px;
  margin: 0 0 0 24px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.site-header .main-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0;
  white-space: nowrap;
}

.site-header .menu-toggle {
  display: none;
}

/* Tablet navigation remains horizontal instead of inheriting the old
   absolute, vertical mobile-dropdown layout. */
@media (max-width: 980px) {
  .site-header .header-row,
  body.page-home .header-row,
  body.page-fidelity5 .header-row {
    height: 64px;
    gap: 12px;
  }

  .site-header .brand img,
  body.page-home .brand img,
  body.page-fidelity5 .brand img {
    width: 72px;
  }

  .site-header .main-nav,
  body.page-home .main-nav,
  body.page-fidelity5 .main-nav {
    display: flex !important;
    position: static !important;
    inset: auto !important;
    flex: 0 1 auto;
    flex-direction: row !important;
    align-items: center !important;
    gap: clamp(10px, 1.7vw, 20px) !important;
    margin: 0 0 0 8px !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  .site-header .main-nav a,
  body.page-home .main-nav a,
  body.page-fidelity5 .main-nav a {
    display: inline-flex !important;
    padding: 0 !important;
    font-size: clamp(.68rem, 1.35vw, .83rem) !important;
    line-height: 1;
  }

  .site-header .main-nav a[aria-current="page"]::after,
  body.page-home .main-nav a[aria-current="page"]::after,
  body.page-fidelity5 .main-nav a[aria-current="page"]::after {
    bottom: 2px;
  }

  .site-header .menu-toggle,
  body.page-home .menu-toggle,
  body.page-fidelity5 .menu-toggle {
    display: none !important;
  }

  .site-header .header-actions {
    gap: 5px;
  }

  .site-header .header-actions .icon-btn {
    width: 36px;
    height: 36px;
  }

  .site-header .header-actions .icon-btn svg {
    width: 18px;
    height: 18px;
  }
}

/* Only truly narrow phones use the expandable menu. It participates in
   document flow, so opening it pushes content down rather than covering it. */
@media (max-width: 640px) {
  .site-header .header-row,
  body.page-home .header-row,
  body.page-fidelity5 .header-row {
    height: auto;
    min-height: 60px;
    flex-wrap: wrap;
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .site-header .brand {
    order: 0;
  }

  .site-header .menu-toggle,
  body.page-home .menu-toggle,
  body.page-fidelity5 .menu-toggle {
    display: grid !important;
    order: 1;
    width: 36px;
    height: 36px;
    margin-left: 2px;
  }

  .site-header .header-actions {
    order: 2;
    margin-left: auto;
  }

  .site-header .main-nav,
  body.page-home .main-nav,
  body.page-fidelity5 .main-nav {
    display: none !important;
    position: static !important;
    order: 3;
    flex: 0 0 100%;
    width: 100%;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0 !important;
    margin: 4px 0 2px !important;
    padding: 6px 0 2px !important;
    border-top: 1px solid #eceaf3 !important;
  }

  .site-header .main-nav.open,
  body.page-home .main-nav.open,
  body.page-fidelity5 .main-nav.open {
    display: grid !important;
  }

  .site-header .main-nav a,
  body.page-home .main-nav a,
  body.page-fidelity5 .main-nav a {
    display: flex !important;
    min-height: 42px;
    padding: 0 8px !important;
    font-size: .82rem !important;
    border-bottom: 1px solid #f1eff6;
  }

  .site-header .main-nav a:last-child {
    border-bottom: 0;
  }

  .site-header .main-nav a[aria-current="page"]::after {
    display: none !important;
  }
}

/* The science cards now expose one vetted paper link only. */
.science7-links {
  justify-content: flex-start;
}
