/*
 * Contents rail: a list of links to pages or headings, used for the notebook's page list and the
 * "On this page" list. It sticks below the header while the prose scrolls.
 *   <nav class="lv-contents" aria-labelledby="toc-title">
 *     <h2 class="lv-contents__title" id="toc-title">On this page</h2>
 *     <ol class="lv-contents__list">
 *       <li><a class="lv-contents__link" href="#unit-economics" aria-current="true">
 *             <span class="lv-contents__number">01</span>Unit economics</a>   ← number optional
 *         <ol class="lv-contents__list">…nested headings (indented)…</ol></li>
 *     </ol>
 *   </nav>
 * The current page/section is aria-current="page" (page list) or aria-current="true" (scroll position):
 * ink text (plus a soft fill for the current page), never green. A link to a page that is not written yet: aria-disabled="true".
 */
@layer components {
  /* --sticky-top is the height of the bars already stuck above (base.css), so the first item is never hidden under them. */
  .lv-contents { position: sticky; top: calc(var(--sticky-top) + var(--space-4)); max-height: calc(100dvh - var(--sticky-top) - var(--space-8)); overflow-y: auto; scrollbar-width: thin; }
  .lv-contents__title { margin: 0 0 var(--space-2); padding-left: var(--space-3); font-size: var(--text-xs); font-weight: var(--weight-semibold); letter-spacing: 0; color: var(--text-muted); }
  .lv-contents__list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 1px; }
  .lv-contents__list .lv-contents__list { margin: 1px 0 var(--space-1) var(--space-3); }
  .lv-contents__link {
    position: relative; display: flex; align-items: baseline; gap: var(--space-2); width: 100%; padding: var(--space-1-5) var(--space-3);
    border-radius: var(--radius-control); font-size: var(--text-ui); line-height: var(--leading-snug); color: var(--text-muted); text-align: left;
    transition: color var(--duration-fast) var(--ease-out), background-color var(--duration-fast) var(--ease-out);
  }
  .lv-contents__link:hover { color: var(--text); background: var(--surface-hover); }
  .lv-contents__link:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
  /* The current item changes colour, never weight, so titles do not re-wrap. */
  .lv-contents__link[aria-current]:not([aria-current="false"]) { color: var(--text); }
  .lv-contents__link[aria-current="page"] { background: var(--selection-soft); }
  .lv-contents__link[aria-disabled="true"] { color: var(--text-faint); pointer-events: none; }
  .lv-contents__number { flex-shrink: 0; min-width: 2ch; font-size: var(--text-s); font-variant-numeric: tabular-nums; color: var(--text-faint); }
  @media (pointer: coarse), (max-width: 760px) {
    .lv-contents__link { min-height: 44px; align-items: center; }
  }
}
