/* ==========================================================================
   LEGAL DOCUMENTS — Terms of Use, Terms of Business, Community Charter,
   Privacy, Cookies, Disclaimer, AI Policy.

   Horizontal measure follows the site: .art-wrap puts the left edge at the
   same x as the nav and every other page. The rail reuses the Insights
   ledger-filter treatment. Loaded via $page_css from includes/legal-page.php.
   ========================================================================== */

.legal-head { padding-top: clamp(24px, 3vw, 40px); }
.legal-title {
  font-size: clamp(34px, 5.4vw, 48px);
  font-weight: var(--weight-medium);
  letter-spacing: -0.018em;
  line-height: 1.1;
  color: var(--ink);
  margin-top: 16px;
  max-width: 780px;
  text-wrap: balance;
}
.legal-subtitle { margin-top: 18px; max-width: 640px; }
.legal-meta {
  font-size: 13px;
  color: var(--muted);
  margin-top: 22px;
  padding-bottom: 20px;
  border-bottom: var(--border-width) solid var(--hairline);
}

/* --- Layout --------------------------------------------------------------- */
.legal-layout {
  display: grid;
  grid-template-columns: minmax(0, 268px) minmax(0, 1fr);
  gap: 56px;
  align-items: start;
  padding-top: clamp(28px, 4vw, 48px);
  padding-bottom: clamp(48px, 6vw, 80px);
}
@media (max-width: 1023px) {
  .legal-layout { grid-template-columns: minmax(0, 1fr); gap: 28px; }
}
.legal-rail, .legal-doc { min-width: 0; }
.legal-rail { display: flex; flex-direction: column; gap: 28px; }
@media (min-width: 1024px) { .legal-rail { position: sticky; top: 104px; } }

/* --- Rail: same treatment as the Insights ledger filters ------------------ */
.legal-rail__group { display: flex; flex-direction: column; gap: 2px; }
.legal-rail__heading {
  font-size: 11px;
  font-weight: var(--weight-bold);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 12px 10px;
}
.legal-rail__list { display: flex; flex-direction: column; gap: 2px; }
.legal-rail__doc {
  display: block;
  font-size: 14px;
  font-weight: var(--weight-medium);
  line-height: 1.4;
  color: var(--body);
  padding: 12px;
  min-height: 44px;
  box-sizing: border-box;
  border-left: 2px solid transparent;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.legal-rail__doc:hover { background: var(--surface-soft); color: var(--ink); }
.legal-rail__doc.is-active {
  background: var(--accent-tint);
  border-left-color: var(--accent-deep);
  color: var(--ink);
  font-weight: var(--weight-semibold);
}

/* --- Contents within the document ---------------------------------------- */
.legal-toc { border-top: var(--border-width) solid var(--hairline); padding-top: 16px; }
.legal-toc__head {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px 10px;
}
.legal-toc__head::-webkit-details-marker { display: none; }
.legal-toc__head::after { content: '+'; font-size: 15px; font-weight: var(--weight-light); }
.legal-toc[open] .legal-toc__head::after { content: '−'; }
@media (min-width: 1024px) { .legal-toc__head::after { display: none; } }
.legal-toc__list { display: flex; flex-direction: column; gap: 2px; max-height: 46vh; overflow-y: auto; }
.legal-toc__list a {
  display: block;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
  padding: 9px 12px;
  border-left: 2px solid var(--hairline);
  transition: color 0.15s ease, border-color 0.15s ease;
}
.legal-toc__list a:hover { color: var(--ink); border-left-color: var(--accent-deep); }
.legal-toc__list a.is-current { color: var(--ink); font-weight: var(--weight-semibold); border-left-color: var(--accent-deep); }

/* --- The document itself -------------------------------------------------- */
.legal-doc { max-width: 760px; }
.legal-doc h2 {
  font-size: 22px;
  font-weight: var(--weight-semibold);
  letter-spacing: -0.005em;
  line-height: 1.3;
  color: var(--ink);
  margin-top: 48px;
  padding-top: 28px;
  border-top: var(--border-width) solid var(--hairline);
  scroll-margin-top: 100px;
}
.legal-doc > h2:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.legal-doc h3 { font-size: 17px; font-weight: var(--weight-semibold); color: var(--ink); margin-top: 30px; }
.legal-doc p { font-size: 16px; line-height: 1.75; color: var(--body); margin-top: 16px; }
.legal-doc strong { color: var(--ink); font-weight: var(--weight-medium); }
.legal-doc a { color: var(--accent-deep); border-bottom: 1px solid var(--hairline); }
.legal-doc a:hover { border-bottom-color: var(--accent-deep); }
.legal-doc ul, .legal-doc ol { margin: 16px 0 0; padding-left: 24px; }
.legal-doc li { font-size: 16px; line-height: 1.75; color: var(--body); margin-top: 10px; }
.legal-doc li::marker { color: var(--muted); }
.legal-doc hr { border: none; border-top: var(--border-width) solid var(--hairline); margin: 40px 0 0; }
.legal-doc hr + hr { display: none; }
/* An <hr> straight before a heading doubles up with the heading's own rule. */
.legal-doc hr + h2 { border-top: none; padding-top: 0; margin-top: 34px; }
/* Headerless tables: markdown emits an empty thead which renders as a blank band. */
.legal-doc thead:empty { display: none; }
.legal-doc blockquote {
  border-left: 2px solid var(--accent);
  padding: 4px 0 4px 24px;
  margin-top: 24px;
}
.legal-doc blockquote p:first-child { margin-top: 0; }

.legal-doc table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 22px;
  font-size: 15px;
  background: var(--paper);
}
.legal-doc th, .legal-doc td {
  text-align: left;
  vertical-align: top;
  padding: 14px 16px;
  border: var(--border-width) solid var(--hairline);
  line-height: 1.6;
}
.legal-doc thead th { background: var(--surface); font-weight: var(--weight-semibold); color: var(--ink); }
.legal-doc td { color: var(--body); }
.legal-doc code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
}

@media (max-width: 700px) {
  .legal-doc h2 { font-size: 20px; margin-top: 38px; padding-top: 24px; }
  .legal-doc table { display: block; overflow-x: auto; white-space: nowrap; }
  .legal-doc th, .legal-doc td { white-space: normal; min-width: 160px; }
}

/* Touch targets on phones and tablets. */
@media (max-width: 1023px) {
  .legal-toc__list a { padding: 13px 12px; min-height: 44px; box-sizing: border-box; }
  .legal-toc__head { min-height: 44px; padding: 10px 12px; }
  .legal-toc__list { max-height: none; }
}
