/* ============================================================================
   Page layout: the shell grid, the basis rail, section spacing.
   Tokens only — see tokens.css.
   ========================================================================= */

@layer layout {

/* ---------------------------------------------------------------- shell -- */
.shell {
  max-width: calc(var(--content-w) + var(--rail-w) + var(--s7));
  margin: 0 auto;
  padding: 0 var(--s5) var(--s9);
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s7);
}
/* grid/flex children default to min-width:auto, which lets a wide chart push
   the page sideways. The charts scroll inside their own frame instead. */
.shell > *, main, .section, .fig, .fig-plot, figure { min-width: 0; }

/* ------------------------------------------------------------ the rail -- */
/* Signature element: the data basis is never off-screen. */
.rail { position: sticky; z-index: 30; }

.rail-compact {
  top: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--rule-strong);
  margin: 0 calc(-1 * var(--s5));
  padding: var(--s2) var(--s5);
  display: flex; align-items: baseline; gap: var(--s3);
  font-size: var(--fs-small);
}
.rail-compact .eyebrow { flex: none; }
.rail-compact .basis-line {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.rail-full { display: none; }

@media (min-width: 1080px) {
  .shell { grid-template-columns: var(--rail-w) minmax(0, 1fr); align-items: start; }
  .rail-compact { display: none; }
  .rail-full {
    display: block;
    top: var(--s5);
    padding-top: var(--s7);
    grid-column: 1;
  }
  main { grid-column: 2; }
}

.rail-full ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--rule); }
.rail-full li { position: relative; }
.rail-full a {
  display: block;
  padding: var(--s2) 0 var(--s2) var(--s4);
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  letter-spacing: -0.01em;
  color: var(--ink-3);
  text-decoration: none;
}
.rail-full a:hover { color: var(--ink); }
.rail-full li[aria-current="true"] a { color: var(--ink); }
.rail-full li[aria-current="true"]::before {
  content: ""; position: absolute; left: -1px; top: var(--s2); bottom: var(--s2);
  width: 2px; background: var(--ink);
}
.rail-basis {
  margin-top: var(--s4); padding: var(--s3) 0 0;
  border-top: 1px solid var(--rule);
}
.rail-basis .basis-line {
  font-family: var(--font-mono); font-size: var(--fs-small);
  line-height: 1.45; color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.rail-basis .basis-line { transition: opacity 180ms ease; }

/* ------------------------------------------------------------ sections -- */
.section { padding-top: var(--s8); scroll-margin-top: 90px; }
.section + .section { border-top: 1px solid var(--rule); }
.section-head { margin-bottom: var(--s5); }
.section-head h2 {
  font-family: var(--font-mono); font-weight: 500;
  font-size: var(--fs-h2); letter-spacing: -0.02em; line-height: 1.15;
  margin: var(--s2) 0 var(--s3);
}

} /* @layer layout */
