/*
 * PairRail v2 legal pages (/legal/*): long-form reading on the quiet baseline.
 * Requires tokens.css, components.css and pages.css (.pr-prose, .pr-toc).
 * Legal text is kept verbatim; only the presentation changed.
 */

/* Document switcher: the current document is marked, not coloured. */
/* The document switcher changes page, so it reads as tabs, not as in-page chips. */
.pr-toc--docs a { border-radius: var(--radius-control); }
.pr-page-head .pr-toc a[aria-current="page"] {
  border-color: var(--color-ink);
  color: var(--color-ink);
  font-weight: 500;
}

/* Contents beside the text on wide screens; above it on narrow ones. */
.pr-legal { display: grid; gap: var(--space-7); }
.pr-legal__toc > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 32px;
  margin-bottom: var(--space-3);
  color: var(--color-ink-muted);
  font-family: var(--font-mono);
  font-size: var(--type-eyebrow-size);
  font-weight: var(--type-eyebrow-weight);
  letter-spacing: var(--type-eyebrow-tracking);
  text-transform: uppercase;
  list-style: none;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
.pr-legal__toc > summary::-webkit-details-marker { display: none; }
.pr-legal__toc > summary:focus-visible { outline: var(--focus-ring); outline-offset: 2px; border-radius: 4px; }
/* Chevron, drawn: points down when closed, up when open. */
.pr-legal__toc > summary::after {
  content: "";
  width: 7px;
  height: 7px;
  margin-right: 4px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform var(--motion-ui) var(--motion-ease-out);
}
.pr-legal__toc[open] > summary::after { transform: translateY(2px) rotate(225deg); }
.pr-legal__toc ol { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; font-variant-numeric: tabular-nums; }
.pr-legal__toc a[aria-current="location"] { color: var(--color-ink); font-weight: 500; }
.pr-legal__toc > summary:active { color: var(--color-ink); }
.pr-legal__toc a {
  display: block;
  padding: 6px 0;
  color: var(--color-ink-secondary);
  font-size: var(--type-small-size);
  line-height: 22px;
  text-decoration: none;
  transition: color var(--motion-ui) var(--motion-ease-out);
}
.pr-legal__toc a:focus-visible { outline: var(--focus-ring); outline-offset: 2px; border-radius: 2px; }
.pr-legal__toc a:active { color: var(--color-ink); }
@media (hover: hover) and (pointer: fine) {
  .pr-legal__toc a:hover { color: var(--color-ink); }
}
@media (min-width: 1024px) {
  .pr-legal { grid-template-columns: 240px minmax(0, 1fr); gap: var(--space-8); align-items: start; }
  .pr-legal__nav { position: sticky; top: var(--space-6); max-height: calc(100vh - var(--space-9)); max-height: calc(100dvh - var(--space-9)); overflow: auto; overscroll-behavior: contain; }
  /* Always open beside the text: the summary is a plain label here. */
  .pr-legal__toc > summary { pointer-events: none; }
  .pr-legal__toc > summary::after { display: none; }
}
@media (max-width: 1023.98px) {
  /* On narrow screens the contents collapses (components.js closes it), so the text comes first. */
  .pr-legal__nav { padding-bottom: var(--space-4); border-bottom: var(--hairline); }
  .pr-legal__toc > summary { min-height: 44px; margin-bottom: 0; }
  .pr-legal__toc[open] > ol { padding-bottom: var(--space-2); }
  .pr-legal__toc ol { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); column-gap: var(--space-5); }
}
@media (pointer: coarse) {
  .pr-legal__toc a { min-height: 44px; display: flex; align-items: center; padding: 0; }
}

/* In-page jumps keep your place in a long document; instant under reduced motion. */
@media (prefers-reduced-motion: no-preference) {
  html:has(.pr-legal) { scroll-behavior: smooth; }
}

.pr-legal__back { margin-top: var(--space-8); }
#contents { scroll-margin-top: var(--space-6); }
@media (max-width: 1023.98px) {
  .pr-block:has(> .pr-container > .pr-legal) { padding-top: var(--space-6); }
}
@media (min-width: 1024px) {
  .pr-legal__back { display: none; } /* the contents are always beside the text here */
}

/* Print: just the document. */
@media print {
  pr-nav, pr-footer, .pr-skip-link, .pr-page-head .pr-toc, .pr-legal__nav, .pr-legal__back { display: none !important; }
  .pr-legal { display: block; }
  .pr-block { padding: 0; border: 0; }
  .pr-prose { max-width: none; }
  .pr-prose a { text-decoration: none; }
}

/* Anchored headings clear the top edge. */
.pr-legal .pr-prose h2:first-of-type { margin-top: var(--space-7); }
.pr-legal .pr-prose > :first-child { margin-top: 0; }
.pr-prose .pr-table-scroll:focus-visible { outline: var(--focus-ring); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  .pr-legal__toc a,
  .pr-legal__toc > summary::after { transition: none; }
}
