/* ═══════════════════════════════════════════════════════════════════════════
   MANYFOLD — legal & policy pages.

   Layered ON TOP of styles.css: this file adds long-form prose typography and
   nothing else. Every colour, font, and radius is inherited from the §TOKENS
   block in styles.css — no new palette, no second source of truth.

   Long-form reading wants a wider measure and a quieter voice than the landing
   page, so .legal-wrap overrides --maxw locally rather than globally.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── §SHELL ──────────────────────────────────────────────────────────────── */
.legal-wrap {
  width: min(100% - 2 * var(--pad), 46rem);
  margin-inline: auto;
  padding-block: 3rem 5rem;
}

.legal-head { margin-bottom: 2.5rem; }
.legal-head h1 {
  font-size: clamp(2rem, 7vw, 3.2rem);
  margin: 0.7rem 0 0.8rem;
}
.legal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.4rem;
  font-size: 0.85rem;
  color: var(--text-mute);
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
.legal-meta strong { color: var(--text-soft); font-weight: 600; }

/* The one-paragraph plain-language summary that opens every policy. Legalese is
   necessary; leading with it is not. */
.legal-tldr {
  background: var(--glass);
  border: 1px solid var(--line-lit);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius);
  padding: 1.15rem 1.35rem;
  margin: 2rem 0 2.5rem;
  color: var(--text-soft);
}
.legal-tldr p + p { margin-top: 0.7rem; }
.legal-tldr strong { color: var(--text); }

/* ── §PROSE ──────────────────────────────────────────────────────────────── */
.legal-body { color: var(--text-soft); }

.legal-body h2 {
  font-size: clamp(1.3rem, 4vw, 1.7rem);
  color: var(--text);
  margin: 3rem 0 0.9rem;
  padding-top: 1.6rem;
  border-top: 1px solid var(--line);
  scroll-margin-top: 5rem; /* sticky nav clearance for #anchors */
}
.legal-body h2:first-child { margin-top: 0; padding-top: 0; border-top: 0; }

.legal-body h3 {
  font-family: var(--body);
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--text);
  margin: 1.9rem 0 0.5rem;
  letter-spacing: -0.005em;
}

.legal-body p { margin-bottom: 1rem; }
.legal-body strong { color: var(--text); font-weight: 600; }
.legal-body em { color: var(--taken); font-style: italic; }

.legal-body a {
  color: var(--brand-bright);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--line-lit);
  transition: text-decoration-color 0.18s ease;
}
.legal-body a:hover { text-decoration-color: var(--brand-bright); }

.legal-body ul,
.legal-body ol { margin: 0 0 1.15rem 1.3rem; }
.legal-body li { margin-bottom: 0.5rem; padding-left: 0.2rem; }
.legal-body li::marker { color: var(--brand); }
.legal-body ul ul,
.legal-body ol ol { margin-top: 0.5rem; margin-bottom: 0.4rem; }

.legal-body code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.1em 0.4em;
  color: var(--taken);
}

/* Callout for the things a reader must not miss — age limits, deletion
   irreversibility, refund rules. Deliberately louder than surrounding prose. */
.legal-note {
  background: rgba(124, 92, 255, 0.07);
  border: 1px solid var(--line-lit);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin: 1.5rem 0;
}
.legal-note.is-warn {
  background: rgba(215, 139, 255, 0.07);
  border-color: rgba(215, 139, 255, 0.32);
}
.legal-note p:last-child { margin-bottom: 0; }

/* ── §TABLES — the data-disclosure grids ─────────────────────────────────── */
/* Wide tables scroll inside their own container; the page body never does. */
.legal-table-scroll {
  overflow-x: auto;
  margin: 1.3rem 0 1.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  -webkit-overflow-scrolling: touch;
  /* The table is 34rem wide, so on a phone it always overflows this box. Nothing
     previously signalled that, so the cut-off right edge just looked like a broken
     layout. This gradient sits at the right edge and disappears once scrolled to the
     end (background-attachment: local on the scroller does the work), giving the
     "there's more this way" affordance without any JS. */
  background:
    linear-gradient(to right, var(--surface) 30%, transparent) left / 2.5rem 100% no-repeat local,
    linear-gradient(to left, var(--surface) 30%, transparent) right / 2.5rem 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, 0.45), transparent) left / 1rem 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, 0.45), transparent) right / 1rem 100% no-repeat scroll;
}
/* Screen-reader + keyboard access to the scroller: a focusable region with a name, so a
   keyboard user can reach and scroll it instead of it being mouse/touch only. */
.legal-table-scroll:focus-visible { outline: 2px solid var(--taken); outline-offset: 2px; }
.legal-table {
  width: 100%;
  min-width: 34rem;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.legal-table th,
.legal-table td {
  text-align: left;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.legal-table thead th {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.legal-table tbody tr:last-child td { border-bottom: 0; }
.legal-table tbody tr:hover { background: rgba(124, 92, 255, 0.045); }
.legal-table .no { color: var(--text-mute); }
.legal-table .yes { color: var(--taken); }

/* ── §TOC ────────────────────────────────────────────────────────────────── */
.legal-toc {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.3rem;
  margin-bottom: 2.5rem;
}
.legal-toc h2 {
  font-family: var(--body);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--brand-bright);
  margin: 0 0 0.7rem;
  padding: 0;
  border: 0;
}
.legal-toc ol {
  margin: 0;
  padding-left: 1.1rem;
  columns: 1;
  font-size: 0.92rem;
}
.legal-toc li { margin-bottom: 0.35rem; }
.legal-toc a { color: var(--text-soft); text-decoration: none; }
.legal-toc a:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }

/* ── §CROSS-LINKS — the sibling-policy strip at the foot of each doc ─────── */
.legal-siblings {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 3rem;
  padding-top: 1.6rem;
  border-top: 1px solid var(--line);
}
.legal-siblings a {
  display: inline-block;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--line-lit);
  border-radius: 999px;
  font-size: 0.85rem;
  color: var(--text-soft);
  text-decoration: none;
  transition: border-color 0.18s ease, color 0.18s ease;
}
.legal-siblings a:hover { border-color: var(--brand-bright); color: var(--text); }
.legal-siblings a[aria-current='page'] {
  border-color: var(--brand);
  color: var(--text);
  background: rgba(124, 92, 255, 0.12);
}

/* ── §CONTACT CARD ───────────────────────────────────────────────────────── */
.legal-contact {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.2rem 1.35rem;
  margin: 1.5rem 0;
}
.legal-contact dl { display: grid; gap: 0.55rem 1rem; grid-template-columns: auto 1fr; }
.legal-contact dt { color: var(--text-mute); font-size: 0.87rem; }
.legal-contact dd { color: var(--text); font-size: 0.92rem; margin: 0; }

/* ── §RESPONSIVE ─────────────────────────────────────────────────────────── */
@media (min-width: 700px) {
  .legal-wrap { padding-block: 4rem 6rem; }
  .legal-toc ol { columns: 2; column-gap: 2rem; }
  .legal-contact dl { grid-template-columns: 12rem 1fr; }
}

/* ── §PRINT — reviewers and lawyers print these ──────────────────────────── */
@media print {
  .nav, .spine, .footer, .legal-siblings, .legal-toc { display: none !important; }
  body { background: #fff; color: #000; }
  .legal-body, .legal-head h1, .legal-meta { color: #000; }
  .legal-tldr, .legal-note, .legal-contact {
    background: none;
    border: 1px solid #999;
  }
  .legal-body a { color: #000; text-decoration: underline; }
  .legal-body a::after { content: ' (' attr(href) ')'; font-size: 0.8em; color: #555; }
  .legal-table-scroll { overflow: visible; }
}
