/* ==========================================================================
   legal.css — readable text pages (Privacy Policy, Terms & Conditions)
   ========================================================================== */

.legal-hero {
  padding-block: clamp(3rem, 6vw, 4.5rem) var(--space-6);
  background: linear-gradient(180deg, #ffffff 0%, var(--color-bg-alt) 100%);
  border-bottom: 1px solid var(--color-border);
}
.legal-hero h1 { font-size: var(--fs-h1); margin-top: var(--space-2); }
.legal-hero .updated { margin-top: var(--space-3); color: var(--color-text-muted); font-size: var(--fs-small); }

.legal-layout { max-width: 820px; margin-inline: auto; }

/* Table of contents */
.legal-toc {
  padding: var(--space-5);
  border-radius: var(--radius-md);
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  margin-bottom: var(--space-8);
}
.legal-toc h2 { font-size: var(--fs-h3); margin-bottom: var(--space-3); }
.legal-toc ol { columns: 2; column-gap: var(--space-6); }
.legal-toc li { margin-bottom: var(--space-2); break-inside: avoid; }
.legal-toc a { color: var(--color-text); }
.legal-toc a:hover { color: var(--color-primary); }
@media (max-width: 560px) { .legal-toc ol { columns: 1; } }

/* Prose */
.legal-prose h2 {
  font-size: var(--fs-h3);
  margin-top: var(--space-8);
  padding-top: var(--space-4);
  scroll-margin-top: 90px; /* offset for sticky header on anchor jump */
}
.legal-prose h2:first-of-type { margin-top: 0; }
.legal-prose p { margin-top: var(--space-3); color: var(--color-text); max-width: none; }
.legal-prose ul { margin-top: var(--space-3); padding-left: var(--space-5); list-style: disc; }
.legal-prose ul li { margin-top: var(--space-2); color: var(--color-text); }
.legal-prose a { text-decoration: none; font-weight: var(--fw-semibold); }

.legal-note {
  margin-top: var(--space-8);
  padding: var(--space-5);
  border-radius: var(--radius-md);
  background: var(--color-bg-alt);
  border-left: 4px solid var(--color-accent);
  font-size: var(--fs-small);
  color: var(--color-text-muted);
}

/* ==========================================================================
   Legal pages v2 — tables, callouts, the Do Not Sell form, related links.
   ========================================================================== */
.legal-updated { color: var(--color-text-muted); font-size: var(--fs-small); margin-top: var(--space-3); }
.legal-intro {
  font-size: 1.15rem;
  line-height: var(--lh-body);
  color: var(--color-text);
  padding: var(--space-5);
  border-left: 3px solid var(--color-accent);
  background: var(--color-bg-alt);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  margin-bottom: var(--space-8);
}
.legal-body h2 { scroll-margin-top: 100px; }
.legal-note { font-size: var(--fs-small); color: var(--color-text-muted); }
.legal-warning {
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: #fff6e5;
  border-left: 3px solid #d99100;
  color: #7a5200;
  font-size: var(--fs-small);
}

/* Tables (cookies, sub-processors) — scroll inside their own box on mobile. */
.legal-table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-5) 0;
  display: block;
  overflow-x: auto;
  white-space: nowrap;
}
@media (min-width: 700px) { .legal-table { display: table; white-space: normal; } }
.legal-table th, .legal-table td {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  text-align: left;
  font-size: var(--fs-small);
  vertical-align: top;
}
.legal-table thead th { background: var(--color-bg-alt); color: var(--color-text); font-weight: var(--fw-semibold); }
.legal-table td { color: var(--color-text-muted); }

/* Do Not Sell form */
.dns-form {
  padding: var(--space-6);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  background: #fff;
  box-shadow: var(--shadow-md);
  margin: var(--space-5) 0;
}
.dns-form__row { margin-bottom: var(--space-5); }
.dns-form__row label { display: block; font-weight: var(--fw-semibold); margin-bottom: 0.4rem; }
.dns-form__row .hint-inline { font-weight: var(--fw-regular); color: var(--color-text-muted); }
/* Scoped to .dns-form__row on purpose. Styling `.dns-form input[type=text]`
   directly (specificity 0,2,1) BEAT .visually-hidden (0,1,0) and stretched the
   honeypot field to full width — which broke the page layout and, worse, showed
   the spam trap to real people. The honeypot lives outside .dns-form__row. */
.dns-form__row input[type="email"],
.dns-form__row input[type="text"],
.dns-form__row textarea {
  width: 100%;
  padding: 0.8rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  font: inherit;
  color: var(--color-text);
  background: #fff;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.dns-form__row input:focus, .dns-form__row textarea:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 4px rgba(91, 52, 240, 0.12);
}
.dns-form .hint { font-size: var(--fs-small); color: var(--color-text-muted); margin-top: 0.4rem; }
.dns-form__status { margin-top: var(--space-4); font-size: var(--fs-small); font-weight: var(--fw-medium); }
.dns-form__status.is-ok { color: #1f7a4d; }
.dns-form__status.is-error { color: #b13636; }
.dns-form__status.is-pending { color: var(--color-text-muted); }

/* Related legal pages */
.legal-related { margin-top: var(--space-10); padding-top: var(--space-6); border-top: 1px solid var(--color-border); }
.legal-related ul {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-2);
  margin-top: var(--space-4);
}
.legal-related a {
  display: block;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  color: var(--color-primary);
  font-size: var(--fs-small);
  font-weight: var(--fw-medium);
  transition: all var(--dur-fast) var(--ease-out);
}
.legal-related a:hover { border-color: var(--color-accent); background: var(--color-bg-alt); transform: translateX(3px); }

/* ==========================================================================
   Legal pages v3 — the layout fix.

   ROOT CAUSE of the alignment/positioning problems: the original rules in this
   file target `.legal-layout` and `.legal-prose`, but scripts/gen_legal.php
   emits `.legal-body`. So NONE of them applied, and the pages fell back to the
   global reset in base.css — which sets `ul, ol { list-style: none }` and
   `p { max-width: 65ch }`. That is why the bulleted rights lists rendered as an
   unreadable wall with no markers, why body text stopped dead at ~600px inside a
   1200px container, and why headings sat straight on top of the paragraph above.
   ========================================================================== */

/* 1. One measure for the whole document, so every block lines up on the left
      and shares the same right edge. */
.legal-body {
  max-width: 820px;
  margin-inline: auto;
}

/* 2. Undo the global 65ch cap INSIDE the legal column — the column itself is
      now the measure, so the cap only made the right edge ragged. */
.legal-body p,
.legal-body li {
  max-width: none;
  color: var(--color-text-muted);
  line-height: var(--lh-body);
}
.legal-body p { margin-bottom: var(--space-4); }
.legal-body strong { color: var(--color-text); }

/* 3. Give sections room to breathe. Headings were colliding with the paragraph
      above them because nothing set a top margin. */
.legal-body h2 {
  margin-top: var(--space-10);
  margin-bottom: var(--space-4);
  padding-top: var(--space-5);
  border-top: 1px solid var(--color-border);
  font-size: var(--fs-h3);
  color: var(--color-primary);
  scroll-margin-top: 100px;
}
.legal-body .legal-intro + .legal-toc { margin-top: 0; }
.legal-body > h2:first-of-type { border-top: 0; }

/* 4. Restore list markers. base.css strips them site-wide (correct for nav and
      card grids, wrong for a legal document, where the list IS the content). */
.legal-body ul,
.legal-body ol {
  list-style: revert;
  padding-left: var(--space-6);
  margin: var(--space-4) 0 var(--space-5);
}
.legal-body ul { list-style-type: disc; }
.legal-body ol { list-style-type: decimal; }
.legal-body li { margin-bottom: var(--space-3); padding-left: var(--space-2); }
.legal-body li::marker { color: var(--color-accent); }

/* 5. The table of contents is a numbered index, not prose. */
.legal-toc { margin-bottom: var(--space-8); }
.legal-toc ol {
  list-style: decimal;
  padding-left: var(--space-6);
  columns: 2;
  column-gap: var(--space-8);
  margin: 0;
}
.legal-toc li { margin-bottom: var(--space-2); break-inside: avoid; padding-left: 0; }
.legal-toc a { color: var(--color-text); text-decoration: none; }
.legal-toc a:hover { color: var(--color-accent); text-decoration: underline; }
@media (max-width: 640px) { .legal-toc ol { columns: 1; } }

/* 6. The intro callout should span the column, matching the TOC box below it. */
.legal-intro { max-width: none; }
.legal-intro p { margin-bottom: 0; }

/* 7. A button in the middle of prose needs air around it, and must not be
      swallowed by the next heading. */
.legal-body .btn { margin: var(--space-3) 0 var(--space-6); }

/* 8. Long links (emails, URLs) must wrap rather than push the column wide. */
.legal-body a { word-break: break-word; }
.legal-body a:not(.btn) { color: var(--color-accent); font-weight: var(--fw-semibold); text-decoration: none; }
.legal-body a:not(.btn):hover { color: var(--color-primary); }

/* 9. Callouts sit flush with the column. */
.legal-note, .legal-warning { max-width: none; margin: var(--space-4) 0; }

/* 10. The TOC heading is inside .legal-body, so the section-divider rule above
       was drawing a rule and a 5rem gap INSIDE the Contents box. Exclude it. */
.legal-toc h2 {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
  font-size: var(--fs-h3);
}

/* ==========================================================================
   Legal pages v4 — the "Other legal pages" cards and the contents links.

   TWO BUGS, both from rules of mine leaking further than intended:

   1. `.legal-body ul { list-style: disc }` (added in v3 to restore markers in
      the rights lists) has the SAME specificity as the older
      `.legal-related ul { list-style: none }` and sits LATER in the file — so it
      won the cascade and stamped a bullet next to every card in the related-
      pages grid. It also inherited the 3rem padding-left, which is why the
      cards sat indented and misaligned.

   2. `.legal-body a:not(.btn) { text-decoration: underline }` underlined the
      card links and the contents links, which are buttons and an index — not
      running prose.
   ========================================================================== */

/* 1. The related-pages grid is a card list, not a bulleted list. */
.legal-body .legal-related ul {
  list-style: none;
  padding-left: 0;
  margin: var(--space-4) 0 0;
  align-items: stretch;          /* equal-height cards, so the rows line up */
}
.legal-body .legal-related li {
  margin-bottom: 0;
  padding-left: 0;
  display: flex;                 /* let the <a> fill the cell */
}
.legal-body .legal-related li::marker { content: none; }
.legal-body .legal-related a {
  flex: 1;
  display: flex;
  align-items: center;
  text-decoration: none;
  font-weight: var(--fw-semibold);
  color: var(--color-primary);
}
.legal-body .legal-related a:hover { color: var(--color-accent); }

/* 2. The contents index is navigation, not prose — no underline. */
.legal-body .legal-toc a,
.legal-body .legal-toc a:hover {
  text-decoration: none;
  font-weight: var(--fw-medium);
}
