/* ──────────────────────────────────────────────────────────
   Section rail · the case studies' outline on the web (11 October 2026).
   Notion's page outline, moved to the left and drawn by hand: one wobbly
   dash per heading (longer for a section, shorter for an outcome, problem
   or solution inside it), the current one in full ink. Hover or focus opens
   a sketch-bordered card with the headings; a click jumps there.
   Web only (1025px and up). At 1024px and below the round button
   (#sectionNav) stays as it was, and the swap happens with the window size.
   Built by assets/section-rail.js from each page's own timeline.
   ────────────────────────────────────────────────────────── */

.sr-rail { display: none; }

@media (min-width: 1025px) {
  #sectionNav { display: none !important; }

  .sr-rail {
    display: block;
    position: fixed;
    left: 22px;
    top: max(340px, 42vh);           /* clear of each section's sticky title at the top of the left column */
    z-index: 10000;
    transition: opacity 0.35s ease, transform 0.35s ease;
  }
  .sr-rail.is-hidden { opacity: 0; transform: translateX(-8px); pointer-events: none; }

  /* the dashes: one button for keyboard focus; each dash also jumps on click */
  .sr-dashes {
    display: flex; flex-direction: column; align-items: flex-start; gap: 0;
    padding: 6px 10px 6px 0; margin: 0; border: 0; background: none; cursor: pointer;
  }
  .sr-dash { display: block; height: 12px; line-height: 0; }
  .sr-dash svg { display: block; height: 12px; overflow: visible; transform-origin: left center; transition: transform 0.25s ease, opacity 0.25s ease; }
  .sr-dash path { fill: none; stroke: #1b1712; stroke-width: 1.8; stroke-linecap: round; opacity: 0.4; vector-effect: non-scaling-stroke; transition: opacity 0.25s ease; }
  .sr-dash.is-active path { opacity: 1; }
  .sr-dash.is-active svg { transform: scaleX(1.35); }
  .sr-dashes:focus-visible { outline: 2px solid var(--olive, #485C11); outline-offset: 4px; border-radius: 6px; }

  /* the card: over the dashes, paper with a hand-drawn edge */
  .sr-card {
    position: absolute; left: -10px; top: 50%;
    width: 290px; padding: 14px 10px 12px;
    background: rgba(246, 241, 233, 0.97);
    border-radius: 16px;
    box-shadow: 0 18px 40px rgba(27, 23, 18, 0.14), 0 2px 8px rgba(27, 23, 18, 0.06);
    opacity: 0; visibility: hidden; transform: translate(-6px, -50%);
    transition: opacity 0.18s ease 0.12s, transform 0.18s ease 0.12s, visibility 0s linear 0.3s;
  }
  .sr-card::before {
    content: ''; position: absolute; inset: 0; border-radius: 16px;
    border: 2px solid #1b1712; filter: url(#sketch-filter); pointer-events: none;
  }
  .sr-rail:hover .sr-card,
  .sr-rail:focus-within .sr-card {
    opacity: 1; visibility: visible; transform: translate(0, -50%);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s;
  }

  .sr-eyebrow { font-family: 'Kalam', cursive; font-size: 1rem; color: var(--olive, #485C11); margin: 0 10px 6px; }
  /* the list scrolls inside the card, so the hand-drawn edge and the eyebrow stay put */
  .sr-scroll { position: relative; max-height: min(64vh, 520px); overflow-y: auto; overscroll-behavior: contain; padding: 2px 0; }
  .sr-list { list-style: none; margin: 0; padding: 0; }
  .sr-item {
    position: relative; display: flex; align-items: baseline; gap: 10px; width: 100%;
    padding: 7px 10px; border: 0; background: none; border-radius: 10px; cursor: pointer; text-align: left;
    color: #1b1712; transition: color 0.18s ease, background-color 0.18s ease;
  }
  .sr-item.lvl-1 { font-family: 'Fraunces', Georgia, serif; font-size: 1rem; font-weight: 400; letter-spacing: -0.02em; line-height: 1.25; }
  .sr-item.lvl-2 { font-family: 'Inter', sans-serif; font-size: 0.8125rem; line-height: 1.4; color: #5f5a54; padding-left: 40px; }
  .sr-num { flex: none; width: 20px; font-family: 'Inter', sans-serif; font-size: 0.6875rem; font-weight: 500; letter-spacing: 0.08em; color: #6b665f; }
  .sr-label { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  /* hover: the site's hand-drawn box, as on the old nav's pills */
  .sr-item::before {
    content: ''; position: absolute; inset: 1px 2px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 60' preserveAspectRatio='none' fill='none'%3E%3Cpath d='M4 3C65 1 135 4 196 2C198 17 196 43 197 58C135 56 65 59 4 57C2 43 4 17 4 3Z' stroke='%231b1712' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
    opacity: 0; transition: opacity 0.18s ease; pointer-events: none;
  }
  .sr-item:hover::before { opacity: 0.55; }
  .sr-item:hover { background: rgba(27, 23, 18, 0.04); color: #1b1712; }
  .sr-item.is-active { color: var(--olive, #485C11); }
  .sr-item.is-active .sr-num { color: var(--olive, #485C11); }
  .sr-item:focus-visible { outline: 2px solid var(--olive, #485C11); outline-offset: 1px; }
}

@media (min-width: 1025px) and (prefers-reduced-motion: reduce) {
  .sr-rail, .sr-card, .sr-dash svg, .sr-dash path, .sr-item { transition: none !important; }
}
