/* Article variant of the shared section nav (static/css/section_nav.css).
 *
 * The shared rail only unfolds at 1640px, where a centred page has a gutter
 * wide enough for its labels. Blog posts run edge-to-edge, so this variant
 * unfolds earlier and hangs the labels over the page instead: a column of dots
 * in the left margin that reveals a floating label on hover or focus, the way
 * the dam-levels page does. Below the breakpoint the shared bottom sheet and
 * its "On this page" button are used unchanged.
 */

.section-nav--article {
  --section-nav-button: #0f172a;
  --section-nav-active-text: #0e7490;
  --section-nav-dot-active: #0e7490;
}

/* Headings are the scroll targets, so they need the same clearance under the
 * fixed site header that .section-nav-target gives sectioned pages. */
#content-body h2[id],
#content-body h3[id] {
  scroll-margin-top: calc(var(--ecpt-content-offset, 64px) + 16px);
}

@media (min-width: 1200px) {
  body.section-nav-open { overflow: auto; }

  .section-nav--article .section-nav__trigger,
  .section-nav--article .section-nav__backdrop,
  .section-nav--article .section-nav__sheet-head { display: none; }

  .section-nav--article .section-nav__sheet {
    position: fixed;
    top: 50%;
    right: auto;
    bottom: auto;
    left: 0.75rem;
    z-index: 40;
    visibility: visible;
    max-height: calc(100vh - 7rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0;
    transform: translateY(-50%);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    scrollbar-width: none;
  }

  .section-nav--article .section-nav__sheet::-webkit-scrollbar { display: none; }

  .section-nav--article .section-nav__links {
    position: relative;
    gap: 0.45rem;
    padding: 0.6rem 0;
  }

  /* Track behind the dots. */
  .section-nav--article .section-nav__links::before {
    content: "";
    position: absolute;
    top: 0.9rem;
    bottom: 0.9rem;
    left: 0.65rem;
    width: 2px;
    border-radius: 1px;
    background: linear-gradient(180deg, #0e7490 0%, #0f172a 100%);
    opacity: 0.25;
  }

  .section-nav--article .section-nav__item {
    position: relative;
    min-height: 0;
    padding: 0.2rem 0.3rem;
    border: 0;
    border-radius: 0.5rem;
    color: var(--section-nav-muted);
    font-size: 0.78rem;
  }

  .section-nav--article .section-nav__dot {
    width: 0.7rem;
    height: 0.7rem;
    border-color: rgba(15, 23, 42, 0.35);
    background: #fff;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.1);
    transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
  }

  .section-nav--article .section-nav__item:hover .section-nav__dot { transform: scale(1.2); }
  .section-nav--article .section-nav__item.is-active .section-nav__dot { transform: scale(1.25); }
  .section-nav--article .section-nav__item:hover { color: var(--section-nav-active-text); }

  /* Narrow gutter (default): dots only, with a floating chip that appears
   * when a dot is hovered or focused. No opacity transition — a fade here
   * gets stuck mid-flight inside the fixed, scrollable rail on some engines,
   * leaving the label permanently invisible. Instant reveal is reliable. */
  .section-nav--article .section-nav__label {
    position: absolute;
    right: auto;
    left: calc(100% + 0.4rem);
    max-width: min(15rem, var(--article-label-max, 15rem));
    overflow: hidden;
    opacity: 0;
    padding: 0.2rem 0.7rem;
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.12);
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .section-nav--article .section-nav__links:hover .section-nav__label,
  .section-nav--article .section-nav__item:hover .section-nav__label,
  .section-nav--article .section-nav__item:focus-visible .section-nav__label { opacity: 1; }

  /* Roomy gutter (.section-nav--roomy, set by section_nav.js when the measured
   * space fits titles): the rail becomes a full contents list — every section
   * title is shown as static text beside its dot, wrapping within the space
   * the gutter actually has. A fixed breakpoint can't know this, because posts
   * with a sidebar push the content column far left. */
  .section-nav--article.section-nav--roomy .section-nav__item {
    align-items: flex-start;
    gap: 0.55rem;
    padding: 0.18rem 0.3rem;
  }

  .section-nav--article.section-nav--roomy .section-nav__dot { margin-top: 0.28rem; }

  .section-nav--article.section-nav--roomy .section-nav__label {
    position: static;
    max-width: min(16rem, var(--article-label-max, 16rem));
    padding: 0;
    overflow: visible;
    opacity: 1;
    background: transparent;
    box-shadow: none;
    line-height: 1.25;
    white-space: normal;
  }

  .section-nav--article.section-nav--roomy .section-nav__item.is-active .section-nav__label {
    color: var(--section-nav-active-text);
    font-weight: 600;
  }
}

@media (min-width: 1200px) and (prefers-reduced-motion: reduce) {
  .section-nav--article .section-nav__dot { transition: none; }
}
