/* Reading rail (reading-rail.js): the note's outline to scale. Flat hairlines; Ember marks progress only.
   >= 1400px: rail + labels in the left margin, ending 32px before the text column (1100px box, 28px gutter).
   1180-1399px: the rail alone, labels on hover. < 1180px: the same segments as a 2px bar under the nav. */
.rr {
  position: fixed;
  z-index: 40;
  font-family: var(--mono, 'JetBrains Mono', ui-monospace, monospace);
  pointer-events: none;
  opacity: 0;
  transition: opacity .3s ease;
}
.rr.is-ready { opacity: 1; }
.rr-nav { position: static; display: block; }
.rr-list { list-style: none; margin: 0; padding: 0; display: flex; }
.rr-item { position: relative; flex: 1 1 0; min-width: 0; min-height: 0; }
.rr-link { pointer-events: auto; display: block; color: inherit; text-decoration: none; }
.rr-link:focus-visible { outline: 2px solid var(--amber, #ff7852); outline-offset: 2px; border-radius: 2px; }
.rr-seg { position: absolute; background: rgba(240, 242, 246, .16); transition: background-color .2s ease; }
.rr-fill { position: absolute; inset: 0; background: var(--amber, #ff7852); }

main > .hero, main > section.section { scroll-margin-top: calc(var(--rr-top, 80px) + 8px); }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

/* ── Vertical rail ─────────────────────────────────────────────── */
@media (min-width: 1180px) {
  .rr {
    top: calc(var(--rr-top, 80px) + 56px);
    left: max(24px, calc(50vw - 562px));
    width: 2px;
    height: min(560px, calc(100vh - var(--rr-top, 80px) - 112px));
  }
  .rr-meta {
    position: absolute; top: 0; left: 0; margin: 0;
    display: flex; flex-direction: column; gap: 4px;
    font-size: 10px; line-height: 14px; letter-spacing: .1em; text-transform: uppercase; white-space: nowrap;
    color: var(--ink-3, rgba(240, 242, 246, .5));
  }
  .rr-pct { color: var(--amber, #ff7852); font-variant-numeric: tabular-nums; }
  .rr-left { display: none; }
  .rr-list { position: absolute; top: 48px; bottom: 0; left: 0; width: 2px; flex-direction: column; gap: 4px; }
  .rr-link { position: absolute; top: 0; bottom: 0; left: -8px; width: 18px; }
  .rr-seg { top: 0; bottom: 0; left: 8px; width: 2px; }
  .rr-fill { transform: scaleY(var(--p, 0)); transform-origin: top; }
  .rr-link:hover .rr-seg { background: rgba(240, 242, 246, .32); }
  .rr-fig {
    position: absolute; left: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; box-sizing: border-box;
    border: 1px solid rgba(240, 242, 246, .42); background: var(--bg, #0c0d10);
  }
  .rr-fig.is-passed { border-color: var(--amber, #ff7852); background: var(--amber, #ff7852); }
  .rr-now { position: absolute; top: -1px; left: -4px; width: 10px; height: 2px; background: var(--ink, #f0f2f6); }
  .rr-label {
    position: absolute; top: -6px; left: 24px; display: none;
    font-size: 10px; line-height: 14px; letter-spacing: .1em; text-transform: uppercase; white-space: nowrap;
    color: var(--ink-3, rgba(240, 242, 246, .5));
    background: var(--bg-1, #111318); border: 1px solid var(--line, rgba(240, 242, 246, .12)); padding: 2px 6px;
  }
  .rr-link:hover .rr-label, .rr-link:focus-visible .rr-label { display: block; color: var(--ink, #f0f2f6); }
}

/* Room for labels: the rail moves out so the labels end 32px before the text column. */
@media (min-width: 1400px) {
  .rr { left: calc(50vw - 674px); }
  .rr-left { display: block; }
  .rr-meta { left: 10px; }   /* one text column with the labels: 8px clear of the 2px line */
  .rr-label { display: block; top: -2px; left: 18px; padding: 0; border: 0; background: none; color: var(--ink-4, rgba(240, 242, 246, .3)); transition: color .2s ease; }
  .rr-item.is-done .rr-label { color: var(--ink-3, rgba(240, 242, 246, .5)); }
  .rr-item.is-active .rr-label { color: var(--ink, #f0f2f6); }
  .rr-link:hover .rr-label, .rr-link:focus-visible .rr-label { color: var(--amber, #ff7852); }
}

/* ── Bar under the nav ─────────────────────────────────────────── */
@media (max-width: 1179px) {
  .rr { top: var(--rr-top, 64px); left: 0; right: 0; height: 2px; }
  .rr-meta, .rr-label, .rr-now, .rr-fig { display: none; }
  .rr-list { height: 2px; gap: 2px; }
  .rr-link { position: absolute; inset: 0; pointer-events: none; }
  .rr-seg { inset: 0; }
  .rr-fill { transform: scaleX(var(--p, 0)); transform-origin: left; }
}
