/* ==========================================================================
   Help The Poor Initiative — Legal document pages
   Shared by privacy.html and terms.html. Tokens, header, footer, page banner
   and the CTA band all come from css/style.css.

   The job here is readability, not decoration: a policy nobody can read is
   the same as no policy. Measure is capped, hierarchy is loud, and the
   contents list stays on screen so a reader can always tell where they are.
   ========================================================================== */

/* The review notice now lives in style.css as a shared component. */

/* --------------------------------------------------------------------------
   2. Layout — sticky contents beside the document
   -------------------------------------------------------------------------- */
.legal { padding: 46px 0 84px; }

.legal-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 58px;
  align-items: start;
}

.legal-toc {
  position: sticky;
  top: calc(var(--header-h) + 16px);
  padding: 24px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.legal-toc h2 {
  margin-bottom: 14px;
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--green);
}

.legal-toc ol {
  display: grid;
  gap: 2px;
  counter-reset: toc;
}

.legal-toc a {
  display: block;
  padding: 7px 10px 7px 30px;
  position: relative;
  border-radius: 8px;
  font-size: .875rem;
  line-height: 1.4;
  color: var(--muted);
  transition: background-color var(--speed) var(--ease),
              color var(--speed) var(--ease);
}

.legal-toc a::before {
  counter-increment: toc;
  content: counter(toc);
  position: absolute;
  left: 10px;
  font-family: var(--font-display);
  font-size: .75rem;
  font-weight: 700;
  color: color-mix(in srgb, var(--green) 45%, #fff);
}

.legal-toc a:hover {
  background: var(--green-soft);
  color: var(--green);
}

.legal-toc a.is-current {
  background: var(--green-soft);
  color: var(--green);
  font-weight: 600;
}

.legal-toc a.is-current::before { color: var(--green); }

/* --------------------------------------------------------------------------
   3. Document meta + summary
   -------------------------------------------------------------------------- */
.legal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  padding-bottom: 22px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--line);
  font-size: .875rem;
  color: var(--muted);
}

.legal-meta strong {
  font-family: var(--font-display);
  color: var(--ink);
}

/* The plain-English précis. Most readers will read only this, so it has to
   be genuinely honest rather than a softened version of the real terms. */
.legal-summary {
  padding: 26px 28px;
  margin-bottom: 40px;
  border-radius: var(--radius-lg);
  background: var(--green-soft);
  border: 1px solid color-mix(in srgb, var(--green) 18%, transparent);
}

.legal-summary h2 {
  margin-bottom: 12px;
  font-size: 1.0625rem;
  font-weight: 800;
  color: var(--green);
}

.legal-summary ul { display: grid; gap: 10px; }

.legal-summary li {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  font-size: .9375rem;
  line-height: 1.65;
  color: var(--ink);
}

.legal-summary svg { flex: none; margin-top: 3px; color: var(--green); }

/* --------------------------------------------------------------------------
   4. The document body
   -------------------------------------------------------------------------- */
.legal-body { max-width: 68ch; }

.legal-section {
  padding-top: 8px;
  margin-bottom: 40px;
  scroll-margin-top: calc(var(--header-h) + 24px);
}

.legal-section:last-child { margin-bottom: 0; }

.legal-section > h2 {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
  font-size: clamp(1.15rem, 2.2vw, 1.4rem);
  color: var(--ink);
}

.legal-section > h2 .num {
  flex: none;
  font-size: .8125rem;
  font-weight: 800;
  color: var(--orange);
  font-variant-numeric: tabular-nums;
}

.legal-section h3 {
  margin: 24px 0 8px;
  font-size: 1rem;
  font-weight: 800;
  color: var(--ink);
}

.legal-section p {
  margin-bottom: 14px;
  line-height: 1.82;
}

.legal-section p:last-child { margin-bottom: 0; }

.legal-section ul,
.legal-section ol {
  margin: 0 0 16px;
  display: grid;
  gap: 9px;
}

.legal-section li {
  position: relative;
  padding-left: 22px;
  line-height: 1.72;
}

.legal-section li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: .68em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--green) 55%, transparent);
}

.legal-section strong { color: var(--ink); font-weight: 700; }

.legal-section a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* A definition-style table for "what we collect / why" */
.legal-table {
  width: 100%;
  margin: 4px 0 18px;
  border-collapse: collapse;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.legal-table th,
.legal-table td {
  padding: 13px 16px;
  text-align: left;
  font-size: .9375rem;
  line-height: 1.6;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.legal-table thead th {
  font-family: var(--font-display);
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--green);
  background: var(--surface-alt);
}

.legal-table tbody tr:last-child th,
.legal-table tbody tr:last-child td { border-bottom: 0; }

.legal-table tbody th {
  width: 34%;
  font-weight: 700;
  color: var(--ink);
}

.table-wrap {
  overflow-x: auto;
  margin-bottom: 18px;
}

/* Callout for the single most important paragraph in a section */
.legal-callout {
  padding: 16px 20px;
  margin: 4px 0 18px;
  border-left: 3px solid var(--green);
  background: var(--surface-alt);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.legal-callout p { margin: 0; font-size: .9375rem; }

/* Contact block that closes the document */
.legal-contact {
  padding: 26px 28px;
  border-radius: var(--radius-lg);
  background: var(--surface-alt);
  border: 1px solid var(--line);
}

.legal-contact ul { display: grid; gap: 11px; margin: 14px 0 0; }

.legal-contact li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding-left: 0;
  line-height: 1.6;
}

.legal-contact li::before { display: none; }

.legal-contact svg { flex: none; margin-top: 3px; color: var(--green); }

/* --------------------------------------------------------------------------
   5. Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 992px) {
  .legal-layout { grid-template-columns: 1fr; gap: 28px; }

  /* The contents list stops being a sidebar and becomes a card above the
     document; sticky would only steal height from a short screen. */
  .legal-toc { position: static; }
  .legal-toc ol {
    grid-template-columns: repeat(2, 1fr);
    gap: 2px 14px;
  }
  .legal-body { max-width: none; }
}

@media (max-width: 768px) {
  .legal { padding: 34px 0 62px; }
  .legal-summary { padding: 22px 20px; }
  .legal-toc ol { grid-template-columns: 1fr; }
  .legal-table thead { display: none; }
  .legal-table tbody th,
  .legal-table tbody td { display: block; width: auto; border-bottom: 0; }
  .legal-table tbody th { padding-bottom: 2px; }
  .legal-table tbody tr { display: block; border-bottom: 1px solid var(--line); }
  .legal-table tbody tr:last-child { border-bottom: 0; }
}

/* An in-body "Cookie Preferences" trigger. A <button> because it acts on
   this page rather than navigating, styled to read as the link it sits
   inside a sentence as. */
.legal-inline-link {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--green);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.legal-inline-link:hover { color: var(--green-mid); }
