/* The quick outline on long pages (lane Site r2): one thin bar that sticks under the header and
   opens a list of the page's sections. Shared by the site's long pages and the Tinkerer's Manual,
   so it uses only the tokens both define (--page, --ink, --muted, --line, --accent). The bar sits
   in the page's flow after the intro, so nothing moves until it is used; the list opens over the
   text only while it is open, and closes by itself. */

.outline {
  position: sticky;
  top: var(--outline-top, 0px);
  z-index: 5;
  margin: 8px 0 12px;
}
.outline-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--page) 90%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  backdrop-filter: saturate(160%) blur(12px);
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
}
.outline-toggle:hover {
  border-color: var(--accent);
}
.outline-toggle:focus-visible,
.outline-panel a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.outline-label {
  flex: none;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.outline-now {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.outline-chevron {
  flex: none;
  color: var(--muted);
  transition: transform 0.18s ease;
}
.outline-toggle[aria-expanded="true"] .outline-chevron {
  transform: rotate(180deg);
}
.outline-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: min(65vh, 440px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel, var(--raised, var(--page)));
  box-shadow: 0 12px 32px -10px rgba(0, 0, 0, 0.35);
}
.outline-panel[hidden] {
  display: none;
}
.outline-panel ol {
  margin: 0;
  padding: 0;
  list-style: none;
}
.outline-panel li {
  margin: 0;
}
.outline-panel a {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.3;
  text-decoration: none;
}
.outline-panel a:hover {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.outline-panel a[aria-current="location"] {
  color: var(--accent);
  font-weight: 700;
}

/* A jump lands the heading below the header and the bar, not under them. */
html.has-outline {
  scroll-padding-top: calc(var(--outline-top, 0px) + var(--outline-h, 56px) + 12px);
}
html.has-outline [data-outline] :is(h2, h3, h4)[id] {
  scroll-margin-top: 0;
}
[data-outline] :is(h2, h3, h4)[id]:focus {
  outline: none;
}

@media (min-width: 900px) {
  .outline {
    max-width: 46em;
  }
}
@media (prefers-reduced-motion: reduce) {
  .outline-chevron {
    transition: none;
  }
}
@media print {
  .outline {
    display: none;
  }
}
