/* Docs-style shell for /academy pages — injected by tools/academy_shell.py.
 *
 * The problem this solves is not decoration. Search and AI assistants deep-link
 * readers straight into one article, and until now that one article was the whole
 * site as far as that reader was concerned: no way to see that sixteen others
 * exist or how they relate. The left rail makes the archive reachable from any
 * page, the right rail makes a long article skimmable.
 *
 * Colours come from the :root block already inlined in every academy page, so
 * this file adds layout only and stays in sync with the theme automatically.
 */

.doc {
  display: grid;
  grid-template-columns: 252px minmax(0, 760px) 208px;
  gap: 34px;
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 22px;
  align-items: start;
}

/* .wrap centres itself at 760px site-wide; inside the grid the column already
 * positions it, so the auto margins have to go or the article drifts right. */
.doc > .wrap {
  max-width: none;
  margin: 0;
  padding: 0;
  min-width: 0;
}

/* ---- left rail: the whole archive ---------------------------------------- */

.docnav {
  position: sticky;
  top: 62px;
  max-height: calc(100vh - 78px);
  overflow-y: auto;
  padding: 52px 0 40px;
  font-size: 13px;
  overscroll-behavior: contain;
}

.docnav .rail-head {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  letter-spacing: .16em;
  color: var(--muted);
  margin: 0 0 14px;
}

/* Group headings are the BRIGHT layer and carry a number — the six sections are a
 * reading order, not six unrelated buckets, and the number is what says so. Items
 * sit below them in weight and tick off a short stub. */
.docnav .grp,
.docnav-mobile .grp {
  display: flex;
  gap: 9px;
  align-items: baseline;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  margin: 24px 0 9px;
  line-height: 1.35;
  letter-spacing: -.005em;
}

.docnav .grp:first-of-type { margin-top: 0; }

.docnav .grp i,
.docnav-mobile .grp i {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-style: normal;
  color: var(--accent);
  opacity: .75;
  flex: none;
}

.docnav a,
.docnav-mobile a {
  display: block;
  color: #93a2b8;
  text-decoration: none;
  padding: 5px 0 5px 22px;
  line-height: 1.4;
  position: relative;
}

.docnav a::before,
.docnav-mobile a::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 14px;
  width: 5px;
  height: 1px;
  background: #3b4a5f;
}

.docnav a:hover,
.docnav-mobile a:hover { color: var(--ink); }

.docnav a[aria-current="page"] {
  color: var(--accent);
  font-weight: 500;
}

.docnav a[aria-current="page"]::before {
  background: var(--accent);
  width: 9px;
  left: 6px;
}


/* ---- right rail: this page --------------------------------------------- */

.doctoc {
  position: sticky;
  top: 62px;
  max-height: calc(100vh - 78px);
  overflow-y: auto;
  padding: 52px 0 40px;
  font-size: 12.5px;
  overscroll-behavior: contain;
}

.doctoc .rail-head {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  letter-spacing: .16em;
  color: var(--muted);
  margin: 0 0 12px;
}

.doctoc a {
  display: block;
  color: var(--muted);
  text-decoration: none;
  padding: 4px 0 4px 11px;
  border-left: 2px solid var(--line);
  line-height: 1.45;
}

.doctoc a:hover { color: var(--ink); border-left-color: var(--accent); }

/* ---- article meta line -------------------------------------------------- */

.docmeta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: .04em;
  color: var(--muted);
  margin: 0 0 22px;
}

.docmeta .tag {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 9px;
  color: #9fb0c6;
}

/* Scope line: which market the figures on this page were measured on. Sits directly under the
 * meta line so it is read before the findings, not after them — a reader who takes a number away
 * from this page should already know what it was measured on. Styled as a quiet note rather than
 * a warning banner: the research is sound, its range is simply finite. */
.scopenote {
  border-left: 2px solid var(--line);
  padding: 8px 0 8px 12px;
  margin: 0 0 26px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
}

/* Anchor links sit next to each h2 so a reader — or a model citing the page —
 * can point at a specific section rather than the whole article. */
.doc h2 { scroll-margin-top: 74px; }

.doc h2 .anchor {
  opacity: 0;
  margin-left: 9px;
  font-size: 15px;
  font-weight: 400;
  text-decoration: none;
  color: var(--muted);
}

.doc h2:hover .anchor { opacity: 1; }
.doc h2 .anchor:focus { opacity: 1; }

/* ---- archive page: card meta and the plain machine-facing list ---------- */

.cardmeta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  letter-spacing: .05em;
  color: var(--muted);
  margin: 8px 0 0 !important;
}

.plainlist {
  columns: 2;
  column-gap: 30px;
  padding-left: 18px;
  margin: 0 0 8px;
}

.plainlist li { break-inside: avoid; margin: 0 0 7px; font-size: 14px; color: var(--muted); }

@media (max-width: 620px) { .plainlist { columns: 1; } }

/* ---- wide tables scroll themselves, never the page ---------------------- */

.tablewrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 0 16px;
}

.tablewrap > table { margin-bottom: 0; }

/* ---- collapsed archive, shown only when the left rail is gone ----------- */

.docnav-mobile { display: none; margin: 26px 0 4px; }

.docnav-mobile > summary {
  cursor: pointer;
  list-style: none;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 14px;
  color: var(--ink);
}

.docnav-mobile > summary::-webkit-details-marker { display: none; }
.docnav-mobile > summary::after { content: " ▾"; color: var(--muted); }
.docnav-mobile[open] > summary::after { content: " ▴"; }
.docnav-mobile .inner { padding: 4px 2px 0; }

/* ---- responsive --------------------------------------------------------- */

/* The right rail goes first: it is the least load-bearing of the three. */
@media (max-width: 1240px) {
  .doc { grid-template-columns: 252px minmax(0, 760px); max-width: 1040px; }
  .doctoc { display: none; }
}

/* Below this the left rail cannot hold a readable article beside it. The
 * archive must not simply vanish though — a reader who arrived on this page
 * from a search result would then have no way to reach the other sixteen. It
 * becomes a collapsed block above the article instead. */
@media (max-width: 980px) {
  .doc { grid-template-columns: minmax(0, 1fr); max-width: 760px; gap: 0; }
  .docnav { display: none; }
  .docnav-mobile { display: block; }
}

/* ---- skip link ---------------------------------------------------------- */

/* Every page now puts the topbar and a 17-item rail ahead of the article in DOM
 * order. Without this a keyboard or screen-reader user tabs through the whole
 * archive before reaching the text they came for — on all 17 pages. */
.skiplink {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 60;
  background: var(--accent);
  color: #06101c;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 0 0 8px 0;
  text-decoration: none;
}

.skiplink:focus { left: 0; }

/* ---- track chips: which market a note was measured on -------------------
   Two tracks (Futures / ETFs) sit orthogonal to the reading-order sections. A
   note carries the tag of the data it is built from, never of the topic it
   mentions, and a note measured on both sides renders both chips. The chip has
   no link: tracks are facets of one archive, not pages of their own, so every
   note keeps exactly one canonical URL. */
.track {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 2px 7px;
  margin-left: 8px;
  border-radius: 3px;
  border: 1px solid var(--line);
  color: var(--muted);
  vertical-align: 1px;
}
.track-etf { color: var(--accent); border-color: rgba(77, 163, 255, .38); }
.eyebrow .track { margin-left: 10px; vertical-align: 2px; }
