/* ============================================================
   legal.css — shared layout for /terms.html and /privacy.html.
   Colours and spacing come from /theme.css; this is layout only.
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 var(--s-5); }

/* ---- Top bar, deliberately minimal ---- */
.legal-nav {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(16px) saturate(150%);
  border-bottom: 1px solid var(--border);
}
.legal-nav .wrap { display: flex; align-items: center; gap: var(--s-4); height: 60px; }
.legal-nav .brand { display: flex; align-items: center; gap: var(--s-2); }
.legal-nav .brand .wordmark { font-size: 16px; }
.legal-nav .spacer { flex: 1; }
.legal-nav .back {
  font-size: 13.5px; color: var(--text-dim);
  display: inline-flex; align-items: center; gap: 6px;
}
.legal-nav .back:hover { color: var(--accent); text-decoration: none; }
.legal-nav .back svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---- Document ---- */
.doc { padding: var(--s-7) 0 var(--s-9); }

/* Contents rail on the left, prose on the right. The rail is sticky so it
   stays available through a long document; below 900px it folds back above
   the text, where a fixed rail would eat the screen. */
.doc-body {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  gap: var(--s-7);
  align-items: start;
}
/* The sticky rail can only travel as far as this grid row. Without a tail the
   row ends while the rail still needs room, and the rail visibly slides up out
   of place over the last screenful. This is the clearance it needs — enough to
   stay pinned through the end of the prose, small enough not to read as a gap. */
.doc-main { padding-bottom: 200px; }
@media (max-width: 900px) { .doc-main { padding-bottom: 0; } }
@media (max-width: 900px) {
  .doc-body { grid-template-columns: 1fr; gap: var(--s-5); }
  .doc-rail { position: static; max-height: none; }
  .toc { max-height: none; }
}
.doc-head { margin-bottom: var(--s-6); padding-bottom: var(--s-5); border-bottom: 1px solid var(--border); }
.doc-head .eyebrow {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--accent); margin-bottom: var(--s-3);
}
.doc-head h1 { font-size: clamp(30px, 4.6vw, 42px); line-height: 1.1; letter-spacing: -0.03em; font-weight: 600; }
.doc-meta { display: flex; flex-wrap: wrap; gap: var(--s-4); margin-top: var(--s-4); font-size: 13px; color: var(--text-faint); }
.doc-meta b { color: var(--text-dim); font-weight: 500; }

/* ---- Table of contents ---- */
.doc-rail {
  position: sticky;
  top: 84px;
  display: flex;
}
/* The whole list is shown — no inner scroll. Only a viewport too short to
   hold it (below) lets the rail scroll, and even then with no visible bar. */
.toc {
  flex: 1;
  min-height: 0;
  overflow: visible;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-4);
}
.toc h2 {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-faint); margin-bottom: var(--s-3);
}
.toc ol { list-style: none; counter-reset: toc; display: grid; gap: 1px; }
.toc li { counter-increment: toc; }
.toc li { font-size: 13px; line-height: 1.4; }
/* The prose rule `.doc li { margin-bottom: 7px }` reaches the contents list
   too; across 18 rows that is 126px the rail does not need. */
.toc ol li { margin: 0; }   /* beats the later .doc li on specificity */
.toc a {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 2px;
  padding: 5px 8px;
  border-radius: var(--r-sm);
  color: var(--text-dim);
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
/* Zero-padded so 1-9 and 10+ share a column edge. */
.toc a::before {
  content: counter(toc, decimal-leading-zero);
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.toc a:hover { color: var(--text); background: var(--bg-hover); text-decoration: none; }

/* The section the reader is currently in, tracked by the page script. */
.toc a.current {
  color: var(--accent);
  font-weight: 600;
  background: var(--accent-bg);
  box-shadow: inset 2px 0 0 var(--accent);
}
.toc a.current::before { color: var(--accent); }

.toc { scrollbar-width: none; }
.toc::-webkit-scrollbar { display: none; }
@media (max-height: 700px) and (min-width: 901px) {
  .doc-rail { max-height: calc(100vh - 100px); }
  .toc { overflow-y: auto; overscroll-behavior: contain; }
}

/* ---- Body ---- */
.doc section { margin-bottom: var(--s-7); scroll-margin-top: 88px; }
.doc h2.sec {
  font-size: 21px; font-weight: 600; letter-spacing: -0.02em;
  margin-bottom: var(--s-4); padding-top: var(--s-2);
}
.doc h3 { font-size: 15.5px; font-weight: 600; margin: var(--s-5) 0 var(--s-2); letter-spacing: -0.01em; }
.doc p { margin-bottom: var(--s-3); color: var(--text-dim); }
/* Emphasis is the brightest thing in the prose — pure white in dark, the
   darkest ink in light — so a scanned bold actually jumps. */
.doc strong, .doc b { color: var(--text-strong); font-weight: 600; }
.doc ul, .doc ol.body { margin: 0 0 var(--s-3) var(--s-5); }
.doc li { margin-bottom: 7px; color: var(--text-dim); }
.doc code {
  font-family: var(--mono); font-size: 0.88em;
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 5px; padding: 1px 5px; color: var(--accent);
}

/* ---- Callouts ---- */
.note {
  border-left: 3px solid var(--accent);
  background: var(--accent-bg);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  padding: var(--s-4) var(--s-5);
  margin: var(--s-4) 0;
}
.note p { color: var(--text-dim); }
.note p:last-child { margin-bottom: 0; }
.note.warn { border-left-color: var(--warn); background: color-mix(in srgb, var(--warn) 10%, transparent); }
.note.danger { border-left-color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.note .t {
  font-size: 11px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--text); margin-bottom: 6px;
}

/* ---- Data table ---- */
.tbl-scroll { overflow-x: auto; margin: var(--s-4) 0; }
table {
  width: 100%; border-collapse: collapse; font-size: 13.5px;
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--bg-elev);
}
th {
  text-align: left; font-size: 10.5px; font-weight: 600; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--text-faint);
  padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--bg-soft);
  white-space: nowrap;
}
td { padding: 11px 14px; border-bottom: 1px solid var(--border); color: var(--text-dim); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td:first-child { color: var(--text); font-weight: 500; }

/* ---- Footer ---- */
.doc-foot {
  border-top: 1px solid var(--border);
  padding-top: var(--s-5); margin-top: var(--s-7);
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-4);
  font-size: 13px; color: var(--text-faint);
}
.doc-foot .spacer { flex: 1; }
