/* Policies (/terms, /privacy, /risk-disclosure): a calm reading column on a
   vellum sheet, with a rail of the three policies and the current one's
   sections. A rook stands on the rail at the section being read. */

.legal { padding-top: clamp(2.5rem, 6vw, 5rem); overflow-x: clip; }
.legal-grid { display: grid; grid-template-columns: minmax(13rem, 17rem) minmax(0, 50rem); column-gap: clamp(3rem, 6vw, 6.5rem); justify-content: center; align-items: start; }

/* ---------- Head ---------- */
.legal-head { grid-column: 2; padding-bottom: clamp(2.5rem, 5vw, 4rem); }
.legal-head h1 { margin-top: .9rem; font-size: var(--d-1); line-height: 1.18; }
.legal-head .meta { margin-top: 1.25rem; font-size: .9375rem; color: var(--muted); }
.legal-head .meta time { color: var(--fg-2); }

/* ---------- Rail: the policies and, for long documents, their sections ---------- */
.legal-rail { grid-column: 1; grid-row: 2; position: sticky; top: calc(var(--nav-h) + 2rem); padding-top: .25rem; }
.rail-d > summary { display: none; }
.rail-label { font-size: .8125rem; font-variant-caps: all-small-caps; letter-spacing: .08em; font-weight: 500; color: var(--muted); }
.docs { margin-top: .5rem; }
.docs > li + li { border-top: 1px solid var(--line); }
.docs > li > a { display: flex; align-items: center; min-height: 2.75rem; padding-block: .35rem; font-size: .9375rem; line-height: 1.35; color: var(--muted); text-decoration: none; transition: color .3s; }
.docs > li > a:hover { color: var(--fg); }
.docs > li.cur > a { color: var(--fg); font-weight: 500; }

.toc { position: relative; margin: .15rem 0 .9rem; --rail-x: .6rem; }
.toc ol { display: grid; }
.toc a { display: flex; gap: .15rem; align-items: baseline; min-height: 2.25rem; padding: .45rem 0 .45rem 2rem; font-size: .875rem; line-height: 1.4; color: var(--muted); text-decoration: none; transition: color .35s var(--ease); }
.toc a:hover { color: var(--fg-2); }
.toc li.on > a { color: var(--fg); }
.toc .n { flex: none; min-width: 1.9rem; font-family: var(--display); font-size: .75rem; font-variant-numeric: tabular-nums; }
.toc-line { position: absolute; left: var(--rail-x); top: 1rem; bottom: 1rem; width: 1px; background: var(--line); pointer-events: none; }
.toc-fill { position: absolute; inset: 0; background: var(--fg); transform-origin: 50% 0; transform: scaleY(0); }
.toc-rook { position: absolute; left: calc(var(--rail-x) - .75rem); top: 0; width: 1.5rem; height: 1.5rem; z-index: 1; pointer-events: none; display: none; will-change: transform; }
.toc-rook [data-piece] { width: 100%; height: 100%; filter: drop-shadow(0 4px 3px rgba(0,0,0,.16)); }
.toc-live .toc-rook { display: block; }
/* without the script the rail is a plain list: no fill, no rook */
.toc:not(.toc-live) .toc-fill { display: none; }

/* ---------- The document on vellum ---------- */
.legal-body { grid-column: 2; grid-row: 2; position: relative; min-width: 0; }
.legal-body > .drawing { top: -8.5rem; right: -8.5rem; width: 21rem; height: 21rem; --sq: 3.5rem; }
.legal-sheet { position: relative; z-index: 1; padding: clamp(2rem, 5vw, 4.25rem) clamp(1.35rem, 5.5vw, 4.75rem) clamp(2.25rem, 5vw, 4.5rem); --vl: rgba(255, 255, 255, .74); }
html[data-theme="dark"] .legal-sheet { --vl: rgba(30, 30, 30, .7); }

.legal-doc { max-width: 40rem; font-size: 1.0625rem; line-height: 1.75; color: var(--fg-2); overflow-wrap: break-word; }
.legal-doc > p:first-child { font-size: clamp(1.125rem, 1.4vw, 1.25rem); line-height: 1.6; color: var(--fg); }
.legal-doc p + p, .legal-doc p + ul, .legal-doc p + ol, .legal-doc ul + p, .legal-doc ol + p { margin-top: 1.1rem; }
.legal-doc h2 { position: relative; margin-top: clamp(2.25rem, 4vw, 2.75rem); padding-top: clamp(1.75rem, 3vw, 2.25rem);
  font-family: var(--display); font-weight: 400; font-size: clamp(1.05rem, 1.45vw, 1.3rem); line-height: 1.4; letter-spacing: -.005em; color: var(--fg);
  scroll-margin-top: calc(var(--nav-h) + 1.5rem); text-wrap: balance; }
/* the rule above each section draws in as it arrives (--rule: 0 to 1) */
.legal-doc h2::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 1px; background: var(--line); transform-origin: 0 50%; transform: scaleX(var(--rule, 1)); }
.legal-doc h3 { margin-top: 2rem; font-size: 1.0625rem; font-weight: 600; line-height: 1.45; color: var(--fg); scroll-margin-top: calc(var(--nav-h) + 1.5rem); }
.legal-doc h2 + p, .legal-doc h2 + ul, .legal-doc h2 + ol, .legal-doc h3 + p, .legal-doc h3 + ul, .legal-doc h3 + ol { margin-top: 1rem; }
.legal-doc h2 .n { color: var(--muted); margin-right: .35em; font-variant-numeric: tabular-nums; }
/* headings link to themselves; the # appears in the margin on hover or focus */
.legal-doc .self { position: relative; color: inherit; text-decoration: none; }
.legal-doc .self::before { content: "#"; position: absolute; right: 100%; margin-right: .6em; font-family: var(--sans); font-weight: 400; color: var(--muted); opacity: 0; transition: opacity .3s; }
.legal-doc .self:hover::before, .legal-doc .self:focus-visible::before { opacity: 1; }
.legal-doc :target { outline: none; }
.legal-doc ul > li, .legal-doc ol > li { position: relative; padding-left: 1.6rem; }
.legal-doc li + li { margin-top: .65rem; }
.legal-doc ul > li::before { content: ""; position: absolute; left: .2rem; top: .72em; width: 5px; height: 5px; background: var(--line-2); transform: rotate(45deg); }
.legal-doc ol { counter-reset: legal; }
.legal-doc ol > li { counter-increment: legal; }
.legal-doc ol > li::before { content: counter(legal) "."; position: absolute; left: 0; top: .1em; font-family: var(--display); font-size: .75rem; color: var(--muted); }
.legal-doc a:not(.self) { color: var(--fg); text-decoration: underline; text-decoration-color: var(--line-2); text-decoration-thickness: 1px; text-underline-offset: .25em; transition: text-decoration-color .3s; }
.legal-doc a:not(.self):hover { text-decoration-color: currentColor; }
.legal-doc strong, .legal-doc b { font-weight: 600; color: var(--fg); }
.legal-doc blockquote { margin: 1.5rem 0; padding-left: 1.25rem; border-left: 1px solid var(--line-2); color: var(--fg); }
.legal-doc hr { border: 0; height: 1px; background: var(--line); margin: 2.5rem 0; }
.legal-doc table { width: 100%; margin-top: 1.25rem; border-collapse: collapse; font-size: .9375rem; }
.legal-doc th, .legal-doc td { text-align: left; vertical-align: top; padding: .65rem .75rem .65rem 0; border-bottom: 1px solid var(--line); }
.legal-doc th { font-weight: 600; color: var(--fg); }
.legal-doc code { font-size: .9em; }

/* ---------- Next policy ---------- */
.legal-next { display: grid; gap: .35rem; margin-top: clamp(3rem, 6vw, 4.5rem); padding-inline: clamp(1.35rem, 5.5vw, 4.75rem); }
.next-link { display: inline-flex; align-items: center; gap: 1.25rem; min-height: 2.75rem; width: fit-content; text-decoration: none; font-size: clamp(1.15rem, 2vw, 1.6rem); line-height: 1.3; }
.next-link .arrow { position: relative; flex: none; width: 2.5rem; height: 1px; background: currentColor; transition: width .5s var(--ease); }
.next-link .arrow::after { content: ""; position: absolute; right: 0; top: -4px; width: 9px; height: 9px; border-top: 1px solid currentColor; border-right: 1px solid currentColor; transform: rotate(45deg); }
.next-link:hover .arrow { width: 3.75rem; }

/* ---------- Load: the head, rail and sheet arrive together (js/legal.js).
   A failsafe shows them if the motion layer never starts. ---------- */
html.js-motion[data-page="legal"] .legal-head, html.js-motion[data-page="legal"] .legal-rail, html.js-motion[data-page="legal"] .legal-sheet { visibility: hidden; animation: legal-failsafe 0s 2.6s forwards; }
html.js-motion[data-page="legal"].legal-ready .legal-head, html.js-motion[data-page="legal"].legal-ready .legal-rail, html.js-motion[data-page="legal"].legal-ready .legal-sheet { visibility: visible; animation: none; }
@keyframes legal-failsafe { to { visibility: visible; } }

/* ---------- Tablet and phone: one column, the rail becomes a Contents drawer ---------- */
@media (max-width: 1000px) {
  .legal-grid { grid-template-columns: minmax(0, 1fr); }
  .legal-head, .legal-rail, .legal-body { grid-column: 1; grid-row: auto; }
  .legal-rail { position: static; padding-top: 0; margin-bottom: clamp(2rem, 5vw, 3rem); border-block: 1px solid var(--line); }
  .rail-d > summary { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 3.25rem; list-style: none; cursor: pointer; font-weight: 500; font-size: 1rem; }
  .rail-d > summary::-webkit-details-marker { display: none; }
  .rail-d > summary .plus { width: 14px; height: 14px; position: relative; flex: none; }
  .rail-d > summary .plus::before, .rail-d > summary .plus::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: currentColor; transition: transform .5s var(--ease); }
  .rail-d > summary .plus::after { transform: rotate(90deg); }
  .rail-d[open] > summary .plus::after { transform: rotate(0deg); }
  .rail-label { display: none; }
  .docs { margin: 0 0 .75rem; }
  .toc { --rail-x: .35rem; }
  .toc a { padding-left: 1.25rem; min-height: 2.75rem; }
  .toc-line, .toc-rook, .toc-live .toc-rook { display: none; }
  .legal-body > .drawing { top: -5rem; right: -4rem; width: 12rem; height: 12rem; --sq: 3rem; }
  .legal-doc .self::before { display: none; }
  .legal-next { padding-inline: 0; }
}
@media (max-width: 520px) {
  .legal-doc { font-size: 1.03125rem; line-height: 1.72; }
  .legal-sheet { margin-inline: calc(var(--gutter) * -.4); }
}

/* ---------- Print: the document alone ---------- */
@media print {
  .nav, .footer, .progress, .skip, .legal-rail, .legal-next, .legal-body > .drawing, .sheen, body::before { display: none !important; }
  .legal-grid { display: block; }
  .legal-sheet { box-shadow: none; background: none; padding: 0; -webkit-backdrop-filter: none; backdrop-filter: none; }
  .legal-sheet::after { display: none; }
  .legal-doc { max-width: none; color: #000; }
  .legal-doc a:not(.self)::after { content: " (" attr(href) ")"; font-size: .85em; }
}
