/* "On this page" navigator, shared by every article. Loaded after the page's own styles.
   Story pages (article.story): the navigator sits in the left gutter, beside the 700px column.
   Standalone pages (no .story): the navigator is fixed to the left of the reading column, wide screens only. */

/* keep anchor jumps clear of nothing: headings land a little below the top */
article.story h2, article.story h3, main h2[id], main h3[id] { scroll-margin-top: 96px; }

/* ---- story pages ---- */
.ds-toc-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 700px) minmax(0, 1fr); }
.ds-toc-layout > .story { grid-column: 2; grid-row: 1; min-width: 0; }
.ds-toc-layout > .ds-toc.ds-toc-side {
  grid-column: 1; grid-row: 1; justify-self: end; align-self: start;
  position: sticky; top: 96px; width: 180px; margin: 48px 24px 0 0; max-height: calc(100vh - 120px); overflow: auto;
}
@media (max-width: 1179px) {
  .ds-toc-layout { display: block; }
  .ds-toc-layout > .ds-toc.ds-toc-side { position: static; width: 100%; max-width: 100%; justify-self: stretch; max-height: none; margin: 32px 0 0; }
  .ds-toc-layout > .story { grid-column: auto; }
}

/* ---- shared navigator ---- */
.ds-toc { font: 14px/1.4 var(--sans, system-ui, -apple-system, sans-serif); color: var(--muted, #6b6b6b); }
/* no visible scrollbar: the list still scrolls (wheel, and to keep the current section in view) */
.ds-toc { scrollbar-width: none; -ms-overflow-style: none; }
.ds-toc::-webkit-scrollbar { display: none; }
.ds-toc-title { margin: 0 0 10px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; opacity: .75; }
.ds-toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line, rgba(127, 127, 127, .25)); }
.ds-toc li { margin: 0; }
.ds-toc a {
  display: block; padding: 5px 0 5px 12px; margin-left: -1px; border-left: 2px solid transparent;
  color: inherit; text-decoration: none; line-height: 1.35;
}
.ds-toc li.ds-toc-sub a { padding-left: 24px; font-size: 13px; }
.ds-toc a:hover { color: var(--text, inherit); }
.ds-toc a[aria-current="true"] { color: var(--accent, #2563eb); border-left-color: var(--accent, #2563eb); font-weight: 600; }

/* ---- standalone pages (no .story): fixed to the left of the reading column ---- */
.ds-toc.ds-toc-fixed { display: none; }
@media (min-width: 1240px) {
  .ds-toc.ds-toc-fixed {
    display: block; position: fixed; top: 96px; left: calc(50% - 600px); width: 200px;
    max-height: calc(100vh - 120px); overflow: auto; z-index: 5;
  }
}

/* desktop only: the navigator steps aside while a wide chart is on screen, so the chart is never covered */
@media (min-width: 1180px) {
  .ds-toc-layout > .ds-toc.ds-toc-side { transition: opacity .15s ease; }
  .ds-toc-layout > .ds-toc.ds-toc-side.ds-toc-hidden { opacity: 0; pointer-events: none; }
}

/* ---- full view for wide charts ---- */
.chart-expand {
  display: block; margin: 0 0 10px auto; padding: 6px 12px; cursor: pointer;
  font: 13px/1.2 var(--sans, system-ui, sans-serif); color: var(--text, inherit);
  background: var(--surface, transparent); border: 1px solid var(--line, #ccc); border-radius: 8px;
}
.chart-expand:hover { background: var(--accent-soft, transparent); color: var(--accent, inherit); }
.chart-expand:focus-visible { outline: 2px solid var(--accent, #2563eb); outline-offset: 2px; }
html.chart-full-open { overflow: hidden; }
.chart-full {
  position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column;
  background: var(--bg, #fff); color: var(--text, inherit);
}
.chart-full-bar { display: flex; justify-content: flex-end; padding: 12px 20px; border-bottom: 1px solid var(--line, #ccc); }
.chart-full-bar .chart-expand { margin: 0; }
.chart-full-body { flex: 1; overflow: auto; padding: 16px 20px 40px; }
/* inside the panel the chart fills the width; the page's story-column rules no longer apply */
.chart-full-body figure.chart-fig { max-width: none; width: 100%; margin: 0; position: static; left: auto; transform: none; }
.chart-full-body .chart-expand { display: none; }
/* a wide embed (table or map) opened in full view fills the panel below the bar */
.chart-full-body iframe.ds-full-embed { display: block; width: 100%; height: calc(100vh - 110px); border: 0; background: transparent; }
