/*
  Accessibility and responsive-layout overrides for the self-contained
  research editions. This file is loaded after each article's local styles.
*/

:focus-visible {
  outline: 3px solid #006fd6;
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  left: 1rem;
  top: -5rem;
  z-index: 1000;
  background: #fff;
  padding: 0.7rem 0.9rem;
}

.skip-link:focus {
  top: 1rem;
  color: #111 !important;
  outline: 3px solid #006fd6;
  outline-offset: 3px;
}

.table-wrap,
.table-scroll {
  -webkit-overflow-scrolling: touch;
  scroll-margin-block: 1rem;
}

.table-wrap[tabindex]:focus-visible,
.table-scroll[tabindex]:focus-visible {
  outline: 3px solid #006fd6;
  outline-offset: 3px;
}

.table-wrap caption,
.table-scroll caption {
  padding: 0.8rem 1rem;
  text-align: left;
  font: 800 0.86rem/1.35 system-ui, sans-serif;
}

.research-site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.9rem;
  margin-top: 1rem;
  font: 700 0.82rem/1.3 system-ui, sans-serif;
}

.research-site-nav a {
  text-decoration: none;
}

.site-hero .research-site-nav a,
.site-strip .research-site-nav a {
  color: inherit;
}

/* The precious-metals paper originally put its table of contents inside the
   article, leaving an empty desktop rail and placing the TOC after the first
   table on small screens. Keep a single visible TOC in the actual rail. */
.research-layout > .article {
  grid-column: 1;
  grid-row: 1;
}

.research-layout > .research-toc-shortcut {
  grid-column: 2;
  grid-row: 1;
  position: sticky;
  top: 1.25rem;
  align-self: start;
}

.research-layout .research-toc-shortcut .toc {
  position: static;
  max-height: calc(100vh - 2.5rem);
  overflow: auto;
}

.research-layout .article > .toc {
  display: none;
}

@media (max-width: 960px) {
  .site-bar-inner,
  .sitebar-inner {
    flex-wrap: wrap;
  }

  .site-bar .site-nav,
  .sitebar .sitebar-inner > nav {
    display: flex !important;
    width: 100%;
    flex-wrap: wrap;
    gap: 0.2rem 0.75rem;
    margin-top: 0.45rem;
  }

  .site-bar .site-nav a,
  .sitebar .sitebar-inner > nav a {
    display: inline-block !important;
    margin-left: 0 !important;
    padding: 0.35rem 0.1rem;
  }

  .research-layout {
    display: flex;
    flex-direction: column;
  }

  .research-layout > .research-toc-shortcut {
    position: static;
    order: -1;
    width: 100%;
    margin-bottom: 1.5rem;
  }

  .research-layout .research-toc-shortcut .toc {
    max-height: min(26rem, 58vh);
    overflow: auto;
  }

  /* The silver paper's TOC is a sibling after the article in source order. */
  .article-grid {
    display: flex !important;
    flex-direction: column;
    max-width: 100%;
  }

  .article-shell,
  .article-grid > * {
    max-width: 100%;
    min-width: 0;
  }

  .article-grid > .article-body {
    width: 100%;
    margin-inline: 0;
  }

  .article-grid > .toc {
    order: -1;
    max-height: min(26rem, 58vh);
    overflow: auto;
  }

  .page-shell > .toc {
    max-height: min(26rem, 58vh);
    overflow: auto;
  }
}

@media (max-width: 640px) {
  .research-site-nav {
    gap: 0.25rem 0.7rem;
    font-size: 0.78rem;
  }

  .site-bar-inner,
  .sitebar-inner {
    padding-inline: 1rem;
  }

  .page-shell {
    overflow-x: clip;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
