.article-navigation-wrapper {
  padding: 0 1rem 1rem;
  background-color: rgb(var(--colour-white));
}

[data-theme="dark"] .article-navigation-wrapper {
  background-color: rgb(var(--colour-dark));
}

.article-navigation {
  padding: 1rem 1.5rem;
  border-radius: 0.5rem;
  background-color: rgba(var(--colour-main) / 0.2);
}

[data-theme="dark"] .article-navigation {
  background-color: rgb(var(--colour-light-dark));
}

.article-navigation-label {
  white-space: nowrap;
  font-size: 1.2rem;
  font-weight: 500;
}

[data-theme="dark"] .article-navigation-label {
  color: #e6e6e6;
}

.article-navigation-list {
  margin-left: 0.9rem;
}

.article-navigation-list-item {
  color: rgb(var(--colour-dark-text-main));
}

[data-theme="dark"] .article-navigation-list-item {
  color: currentColor;
}

@media (min-width: 700px) {
  .article-navigation-wrapper,
  .article-navigation-tail {
    --page-nav-pad: 1rem;
  }

  .article-navigation-wrapper {
    padding: 0;
  }

  .article-navigation {
    display: flex;
    padding: var(--page-nav-pad) 1rem;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    background-color: rgba(var(--colour-main) / 0.53);
  }

  .article-navigation-label {
    line-height: 1.5;
    color: rgb(var(--colour-darker-main));
  }

  .article-navigation .article-navigation-list {
    display: flex;
    flex-wrap: wrap;
  }

  .article-navigation .article-navigation-list-item:not(:last-child) {
    margin-right: 1rem;
  }
}

@media (min-width: 900px) {
  .article-navigation-wrapper,
  .article-navigation-tail {
    --page-nav-pad: 1.5rem;
  }

  .article-navigation {
    padding: var(--page-nav-pad) 2rem;
  }

  .article-navigation .article-navigation-list-item:not(:last-child) {
    margin-right: 2rem;
  }
}

@media (min-width: 1250px) {
  .article-navigation-wrapper,
  .article-navigation-tail {
    --page-nav-pad: 3.1875rem;
  }

  .article-navigation {
    padding: var(--page-nav-pad) 4.5rem;
  }
}

/*
 * Sticky, with the `stickyPageContent` app setting: the links stay at the top of the
 * window while the page scrolls. The bar's upper padding scrolls out of the window before
 * the bar stays, and its lower padding is a tail that scrolls away under it. So what
 * stays is a slim bar, and nothing in the page moves when it does.
 *
 * On a narrow screen the links are a list, one to a line, which would cover much of the
 * window. There they scroll with the page, as they do without postdoc/js/base.js, which
 * marks the bar as ready and measures it.
 */
@media (min-width: 700px) {
  .article-navigation-wrapper.is-sticky,
  .article-navigation-tail {
    --page-nav-stuck-pad: 0.5rem;
    /* The bar's colour over the page's, as one colour that nothing shows through. */
    --page-nav-bg: color-mix(in srgb, rgb(var(--colour-main)) 53%, var(--color-beige));
  }

  [data-theme="dark"] .article-navigation-wrapper.is-sticky,
  [data-theme="dark"] .article-navigation-tail {
    --page-nav-bg: rgb(var(--colour-light-dark));
  }

  .article-navigation-wrapper.is-sticky.is-ready {
    position: sticky;
    top: calc(var(--page-nav-stuck-pad) - var(--page-nav-pad));
    z-index: 5;
  }

  .is-sticky .article-navigation {
    padding-bottom: var(--page-nav-stuck-pad);
    background-color: var(--page-nav-bg);
    transition: box-shadow 0.2s;
  }

  .article-navigation-tail {
    height: calc(var(--page-nav-pad) - var(--page-nav-stuck-pad));
    background-color: var(--page-nav-bg);
  }

  /*
   * base.js adds is-stuck while the bar is over the page. The links are then on one
   * line, however many there are, and the ones that don't fit scroll sideways. The room
   * for the focus ring of the first link comes out of the list's margin.
   */
  .is-sticky.is-stuck .article-navigation {
    box-shadow: 0 10px 16px -12px rgb(0 0 0 / 0.45);
  }

  .is-sticky.is-stuck .article-navigation-list {
    flex-wrap: nowrap;
    min-width: 0;
    margin-left: 0.6rem;
    padding: 0 0.3rem;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: thin;
  }

  /* The lines that the bar gave up go to its tail, so the page under it doesn't move.
     base.js measures them. */
  .is-sticky.is-stuck + .article-navigation-tail {
    height: calc(var(--page-nav-pad) - var(--page-nav-stuck-pad) + var(--page-nav-extra, 0px));
  }

  /* Headings that a link jumps to, and what takes the keyboard focus, stop below the
     bar. Until base.js has measured the bar, this is the height of its one line. */
  html:has(.article-navigation-wrapper.is-sticky) {
    scroll-padding-top: calc(var(--page-nav-height, 3rem) + 0.75rem);
  }

  /* A storymap's map stays below the bar too. */
  .article-navigation-wrapper.is-sticky.is-ready ~ .main-content-block .storymap {
    --storymap-sticky-top: calc(var(--page-nav-height, 3rem) + 0.5rem);
  }
}
