/* ============================================================
   RAF — THE LOCAL NAV
   The same bar as /factor-plus (factor-plus/article.css), copied rather than
   shared so neither page can move the other. Loaded after every other RAF
   stylesheet. Script: raf/lnav.js.
   ============================================================ */

/* ============================================================
   THE LOCAL NAV
   Fixed at the top, above the page and below the site nav. Hidden (off the
   top, out of the tab order) until raf/lnav.js adds .is-on. While the site nav is
   showing, it rides one site-nav height lower, on the same curve.
   `visibility: inherit` rather than `visible` when on: while the page is
   locked, <main> is visibility: hidden and this must stay hidden with it.
   ============================================================ */
.v6-lnav {
  --v6-lnav-h: 52px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 90;
  height: var(--v6-lnav-h);
  color: var(--text-primary);
  background: var(--bg-cream);
  background: color-mix(in srgb, var(--bg-cream) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.8) blur(20px);
  backdrop-filter: saturate(1.8) blur(20px);
  border-bottom: 1px solid var(--rule-soft);
  transform: translateY(-100%);
  visibility: hidden;
  transition: transform 0.3s ease, visibility 0s linear 0.3s;
}

.v6-lnav.is-on {
  transform: translateY(0);
  visibility: inherit;
  transition: transform 0.3s ease, visibility 0s;
}

.nav:not(.hidden-bar) ~ main .v6-lnav.is-on { transform: translateY(var(--v6-site-nav, 101px)); }

/* over the dark band, in either theme, the bar goes dark with it */
.v6-lnav.is-dark {
  --text-primary: #f7f4f0;
  --text-body: #ded7cd;
  --text-muted: #cac2b6;
  --text-hover: #ffffff;
  --rule-soft: rgba(255, 255, 255, 0.12);
  background: rgba(18, 10, 7, 0.9);
  background: color-mix(in srgb, #120a07 78%, transparent);
}

.v6-lnav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: 100%;
  padding: 0 var(--wrap-gutter, 24px);
}

.v6-lnav-title {
  font-family: var(--font-sans);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1;
  color: var(--text-primary);
  text-decoration: none;
}

.v6-lnav-list {
  display: flex;
  align-items: stretch;
  gap: clamp(18px, 2.2vw, 32px);
  height: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}

.v6-lnav-list a {
  position: relative;
  display: flex;
  align-items: center;
  height: 100%;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  /* body ink, not muted: the bar is translucent, and over a white capture
     muted ink fell to about 2.4:1. Apple marks the current item the same way,
     by the rule under it rather than by dimming the others. */
  color: var(--text-body);
  text-decoration: none;
  transition: color 0.2s ease;
}

.v6-lnav-list a:hover { color: var(--text-hover); }

.v6-lnav-list a[aria-current="true"] { color: var(--text-primary); }

/* the current chapter, underlined along the bar's bottom edge */
.v6-lnav-list a[aria-current="true"]::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: currentColor;
}

/* focus: a rounded ring around the word, in place of the site's outline,
   which on a full-height link drew a 52px box pressed against the text */
.v6-lnav-title { position: relative; }
.v6-lnav a:focus-visible { outline: none; }
.v6-lnav a:focus-visible::before {
  content: '';
  position: absolute;
  inset: 11px -9px;
  border: 2px solid var(--text-primary);
  border-radius: 8px;
  pointer-events: none;
}
.v6-lnav .v6-lnav-title:focus-visible::before { inset: -8px -10px; }

/* anchor jumps from the bar land below it, not under it */
.cs-body > .pv-chapter[id] { scroll-margin-top: 56px; }

/* fun mode keeps the case study serious; the bar goes with it */
:where(html.fun-mode body[data-case-study] main > .v6-lnav) { --text-muted: #6b6459; }
:where(html.fun-mode.dark-mode body[data-case-study]:not(.theme-locked) main > .v6-lnav) { --text-muted: #90918b; }

@media (max-width: 760px) { .v6-lnav { --v6-lnav-h: 44px; } }

/* the title makes room for the chapters on a phone */
@media (max-width: 560px) {
  .v6-lnav-title { display: none; }
  .v6-lnav-list { flex: 1; justify-content: space-between; gap: 8px; }
  .v6-lnav-list a { font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .v6-lnav, .v6-lnav.is-on, .v6-lnav-list a { transition: none; }
}

/* RAF's band is a cool near-black, not Factor's warm brown; tint the bar to match */
.v6-lnav.is-dark {
  background: rgba(10, 8, 18, 0.9);
  background: color-mix(in srgb, #0a0812 80%, transparent);
}
