/* Docs navigation helpers: heading anchors, the "On this page" rail, previous/next links and the docs
   home. Loaded after dashboard.css on the docs pages only. Everything else keeps its existing styling. */

html { scroll-padding-top: 88px; }
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

.docs-layout {
  --d-line: var(--border-soft);
  --d-line-strong: rgba(255, 255, 255, 0.16);
  --d-ease: 160ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

.docs-layout :focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
  border-radius: 8px;
}

/* ---------- article with a rail on the right ---------- */
.docs-layout .docs-main.has-rail {
  display: grid;
  grid-template-columns: minmax(0, 860px) 232px;
  gap: 56px;
  align-items: start;
}
.docs-layout .docs-main.has-rail .legal-doc { max-width: none; }

/* ---------- heading anchors: hang into the left margin, visible on hover or focus ---------- */
.docs-main .legal-doc h2 { position: relative; }
.doc-anchor {
  position: absolute;
  left: -1.35em;
  top: 0;
  width: 1.1em;
  text-align: center;
  color: var(--muted-2);
  font-weight: 500;
  text-decoration: none;
  opacity: 0;
  transition: opacity var(--d-ease), color var(--d-ease);
}
.legal-doc h2:hover .doc-anchor,
.doc-anchor:focus-visible { opacity: 1; }
.doc-anchor:hover { color: var(--accent-2); }

/* ---------- on this page ---------- */
.doc-toc {
  position: sticky;
  top: 96px;
  max-height: calc(100dvh - 120px);
  overflow-y: auto;
  padding-top: 12px;
}
.doc-toc-title { margin: 0 0 12px; font-size: 0.8125rem; font-weight: 600; color: var(--fg); }
.doc-toc ul { margin: 0; padding: 0; list-style: none; border-left: 1px solid var(--d-line); }
.doc-toc a {
  display: block;
  margin-left: -1px;
  padding: 5px 0 5px 14px;
  border-left: 2px solid transparent;
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--muted-2);
  transition: color var(--d-ease), border-color var(--d-ease);
}
.doc-toc a:hover { color: var(--fg); }
.doc-toc a.is-active { color: var(--accent-2); border-left-color: var(--accent-2); font-weight: 600; }

/* ---------- previous / next ---------- */
.doc-pager {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 72px;
  padding-top: 32px;
  border-top: 1px solid var(--d-line);
}
.doc-pager a {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 20px;
  border: 1px solid var(--d-line-strong);
  border-radius: 14px;
  text-decoration: none;
  transition: border-color var(--d-ease), background var(--d-ease), transform var(--d-ease);
}
.doc-pager a:hover { border-color: var(--accent-2); background: var(--accent-soft); }
.doc-pager a:active { transform: scale(0.985); }
.doc-pager-next { grid-column: 2; text-align: right; align-items: flex-end; }
.doc-pager-prev { grid-column: 1; }
.doc-pager-label { font-size: 0.8125rem; color: var(--muted-2); }
.doc-pager-name { font-size: 1.0625rem; font-weight: 600; color: var(--fg); }

/* ---------- docs home ---------- */
.docs-home { max-width: 920px; padding: 8px 0 0; }
.docs-home h1 {
  margin: 0 0 16px;
  font-size: clamp(2rem, 3.4vw, 2.75rem);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -0.03em;
  text-wrap: balance;
}
.doc-lead {
  max-width: 62ch;
  margin: 0 0 48px;
  font-size: 1.1875rem;
  line-height: 1.6;
  text-wrap: pretty;
  color: var(--muted);
}

.home-group { margin-bottom: 48px; }
.home-group h2 { margin: 0 0 16px; font-size: 1.25rem; font-weight: 700; letter-spacing: -0.015em; }
.home-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.home-list a {
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: 100%;
  padding: 16px 18px;
  border: 1px solid var(--d-line-strong);
  border-radius: 14px;
  background: var(--panel);
  transition: border-color var(--d-ease), background var(--d-ease), transform var(--d-ease);
}
.home-list a:hover { border-color: var(--accent-2); background: var(--accent-soft); }
.home-list a:active { transform: scale(0.99); }
.home-list strong {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--fg);
}
.home-list strong .doc-icon { color: var(--accent-2); transition: transform var(--d-ease); }
.home-list a:hover strong .doc-icon { transform: translateX(3px); }
.home-desc { font-size: 0.9375rem; line-height: 1.5; font-weight: 400; color: var(--muted); }

.doc-icon { display: block; flex: none; width: 1.125rem; height: 1.125rem; }

/* ---------- narrow screens ---------- */
@media (max-width: 1280px) {
  .docs-layout .docs-main.has-rail { display: block; }
  .doc-toc { display: none; }
}

@media (max-width: 900px) {
  .doc-anchor { display: none; }
  .docs-main code { white-space: normal; overflow-wrap: anywhere; }
}

@media (max-width: 700px) {
  .home-list { grid-template-columns: minmax(0, 1fr); }
  .doc-pager { grid-template-columns: minmax(0, 1fr); }
  .doc-pager-next, .doc-pager-prev { grid-column: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .docs-layout * { transition: none !important; }
}

/* "or" between alternative results in the recycling tables */
.doc-or { margin: 0 6px 0 2px; font-size: 0.8125rem; color: var(--muted-2); }
