/* ── Section nav ribbon — in-page anchor navigation ──────────────────
 * A subtle, frosted, sticky pill bar that lists the current page's sections.
 * Mounted INSIDE <main> (the content column) so it coexists with the nav-shell
 * sidebar grid. Active section is highlighted via scroll-spy (IntersectionObserver).
 */

.section-nav {
  position: sticky;
  /* Default: flush to the top of the content (pages without the nav-shell top bar, e.g. roadmap). */
  top: 0;
  z-index: 80;
  margin: 0 0 var(--space-5);
  /* Full-bleed within the content column so the frosted bar reaches the edges. */
  padding: var(--space-2) 0;
  background: color-mix(in srgb, var(--color-surface, #fff) 78%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid color-mix(in srgb, var(--color-border, #e5e7eb) 70%, transparent);
}

/* When the nav-shell mobile fixed top bar is present, offset below it; it hides ≥768px. */
body.has-sidebar .section-nav { top: var(--topbar-h, 56px); }
@media (min-width: 768px) {
  body.has-sidebar .section-nav { top: 0; }
}

.section-nav__inner {
  display: flex;
  align-items: center;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  /* Fade the right edge to hint at horizontal overflow on narrow widths. */
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 16px, #000 calc(100% - 16px), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 16px, #000 calc(100% - 16px), transparent 100%);
}
.section-nav__inner::-webkit-scrollbar { display: none; }

.section-nav__list {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  list-style: none;
  margin: 0;
  padding: 0.25rem 0.5rem;
  min-width: max-content;
}

.section-nav__item { display: inline-flex; }

.section-nav__link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full, 9999px);
  font-size: 0.8125rem;
  font-weight: 550;
  line-height: 1;
  letter-spacing: -0.005em;
  color: var(--color-text-secondary, #64748b);
  text-decoration: none;
  white-space: nowrap;
  background: transparent;
  border: 1px solid transparent;
  transition: color 0.16s ease, background 0.16s ease, border-color 0.16s ease, transform 0.12s ease;
}

.section-nav__link:hover {
  color: var(--color-text-primary, #0f172a);
  background: color-mix(in srgb, var(--color-text-primary, #0f172a) 6%, transparent);
}

.section-nav__link:active { transform: scale(0.97); }

.section-nav__link:focus-visible {
  outline: 2px solid var(--color-primary, #2563eb);
  outline-offset: 2px;
}

/* Active section — filled pill + soft ring, the clear "you are here" state. */
.section-nav__link--active {
  color: var(--color-primary, #2563eb);
  font-weight: 650;
  background: color-mix(in srgb, var(--color-primary, #2563eb) 12%, transparent);
  border-color: color-mix(in srgb, var(--color-primary, #2563eb) 22%, transparent);
}
.section-nav__link--active:hover {
  color: var(--color-primary, #2563eb);
  background: color-mix(in srgb, var(--color-primary, #2563eb) 16%, transparent);
}

/* Small leading dot that grows on the active pill for extra affordance. */
.section-nav__link::before {
  content: "";
  width: 0;
  height: 6px;
  border-radius: 9999px;
  background: currentColor;
  opacity: 0;
  transition: width 0.18s ease, opacity 0.18s ease;
}
.section-nav__link--active::before { width: 6px; opacity: 1; }

/* Anchor-scroll offset so the sticky ribbon never hides a section heading. */
.section-nav-target { scroll-margin-top: 72px; }
body.has-sidebar .section-nav-target { scroll-margin-top: calc(var(--topbar-h, 56px) + 64px); }
@media (min-width: 768px) {
  body.has-sidebar .section-nav-target { scroll-margin-top: 72px; }
}

/* ── Dark mode ───────────────────────────────────────────────────── */
[data-theme="dark"] .section-nav {
  background: color-mix(in srgb, var(--color-surface, #0f172a) 72%, transparent);
  border-bottom-color: color-mix(in srgb, var(--color-border, #1e293b) 80%, transparent);
}
[data-theme="dark"] .section-nav__link:hover {
  background: color-mix(in srgb, #ffffff 8%, transparent);
  color: var(--color-text-primary, #f1f5f9);
}
[data-theme="dark"] .section-nav__link--active {
  background: color-mix(in srgb, var(--color-primary, #3b82f6) 22%, transparent);
  border-color: color-mix(in srgb, var(--color-primary, #3b82f6) 38%, transparent);
  color: var(--color-primary-on-dark, #93c5fd);
}

/* ── Reduced motion ──────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .section-nav__link,
  .section-nav__link::before { transition: none; }
  .section-nav__link:active { transform: none; }
}
