/* The left rail: site title, nav, Contents, Visited, and the divider.
 *
 * Deliberately grayscale and serif throughout so it never competes with the
 * prose. Its responsive rules are at the bottom of this file rather than in a
 * shared breakpoint block, so changing the rail means reading one file.
 */
/* --- left rail ---
   A flex column pinned to the viewport, grayscale and serif throughout so it never competes with the prose. The height budget is the point: nav takes what it needs, the TOC takes what is left (scrolling past a cap), and Visited keeps a ~10-row window at the bottom. Without this a 26-heading note would push Visited off-screen entirely. */
.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  padding: var(--rail-pad);
  font-family: var(--font-body);
  overflow: hidden;
}
/* The divider is a pseudo-element, not a border, so it can stop short of both
   edges instead of running the full height of the viewport. */
.rail::after {
  content: "";
  position: absolute;
  right: 0;
  top: 2.5rem;
  bottom: 2.5rem;
  width: 1px;
  background: var(--border);
}

/* Every link in the rail: quiet until hovered, and dotted when it is. */
.rail a {
  text-decoration: none;
  color: var(--rail-fg);
}
.rail a:hover {
  color: var(--fg);
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}

/* Qualified with `.rail` because the title IS an anchor inside the rail, so the
   bare `.rail-title` (0,1,0) lost to `.rail a` (0,1,1) and --rail-title never
   rendered -- the title was silently the same colour as the nav below it. */
.rail a.rail-title {
  font-size: 1.02rem;
  color: var(--rail-title);
  line-height: 1.25;
  flex: 0 0 auto;
}
.rail-nav {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  flex: 0 0 auto;
  padding-left: var(--rail-indent);
}
.rail-nav a {
  font-size: 0.85rem;
  letter-spacing: 0.01em;
  padding: 0.08rem 0;
}
.rail-nav a.active { color: var(--fg); }

.rail-block {
  border-top: 1px solid var(--border);
  padding-top: 0.8rem;
  min-height: 0;          /* lets a flex child actually shrink and scroll */
}
.rail-label {
  margin: 0 0 0.35rem;
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--rail-muted);
}

/* Contents: takes the space the trail doesn't need, scrolls past it. */
.rail-toc {
  flex: 0 1 auto;
  overflow-y: auto;
}
.rail-toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
}
.rail-toc li { margin: 0; }
.rail-toc a {
  display: block;
  font-size: 0.75rem;
  line-height: 1.35;
  padding: 0.14rem 0;
  color: var(--rail-muted);
}
.rail-toc .toc-l3 a { padding-left: 0.8rem; font-size: 0.72rem; }

/* Visited: a ~10-row window at the bottom of the rail, newest at the top. Hidden
   entirely until a note has been visited, so nothing reserves space for an empty
   list. trail.js scrolls the window to keep the cursor row in view. */
.rail-visited {
  flex: 0 0 auto;
  margin-top: auto;
}
.rail-visited[hidden] { display: none; }
.visited-list {
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: calc(10 * var(--rail-line));
  overflow-y: auto;
}
.visited-list li { margin: 0; }
.visited-list a {
  display: block;
  font-size: 0.74rem;
  line-height: var(--rail-line);
  color: var(--rail-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* The cursor: where you are on the path, and so where back resumes from. */
.visited-list .current a { color: var(--rail-fg); font-weight: 600; }

/* --- narrow screens: the rail unpins and becomes a header strip ---
   The page-scoped blocks are hidden rather than stacked: a real mobile answer
   -- probably a collapsible sheet -- is still an open design question, and a
   half-answer that pushes the article below two folded lists is worse. */
@media (max-width: 60rem) {
  .rail {
    position: static;
    height: auto;
    overflow: visible;
    flex-direction: row;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.9rem;
    padding: 1.1rem 1.2rem;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .rail::after { display: none; }
  .rail-nav { flex-direction: row; gap: 0.9rem; padding-left: 0; }
  .rail-toc, .rail-visited { display: none; }
}
