/*
 * Legal document surfaces (UI-004) on the M11-B2 contract. Frozen target:
 * docs/design/ui-references/20260915-m11/index.html (UI-004 markup) — the
 * layered head carries the mono doc-meta strip and the details table of
 * contents; the body keeps the 70ch legal measure with anchored sections,
 * semantic tables and print support. Values resolve to tokens; media
 * conditions use the frozen viewports.
 */

/* ---------- head: doc-meta strip, tools, review flag, toc ---------- */

.doc-meta {
  display: grid;
  grid-template-columns: repeat(4, auto);
  width: fit-content; /* the frame closes after the last filled cell, not at the container edge */
  margin-top: 1.4rem;
  border: 1px solid var(--color-border-strong);
  font-family: var(--font-mono);
  font-size: 0.76rem;
}
.doc-meta > div {
  padding: 0.6rem 0.9rem;
  border-right: 1px solid var(--color-border);
}
.doc-meta > div:last-child { border-right: 0; }
.doc-meta .k {
  display: block;
  color: var(--color-text-muted);
  letter-spacing: 0.1em;
  font-size: 0.7rem;
}
@media (max-width: 1024px) {
  .doc-meta { grid-template-columns: repeat(2, 1fr); }
  .doc-meta > div:nth-child(2n) { border-right: 0; }
}

.legal-tools { margin: 1.4rem 0 0; }

/* Review-pending keeps the 200 page noindex with the frozen stale flag
   (shared .stale-flag) plus the explicit notice beside it. */
.legal-review-notice { margin: 0.4rem 0 0; }

/* On-this-page details toc (the reference composition; the anchors carry the
   44px target below). */
.toc {
  border: 1px solid var(--color-border);
  padding: 1rem 1.2rem;
  margin: 1.6rem 0 0;
}
.toc summary { cursor: pointer; font-weight: var(--weight-semibold); }
.toc ol {
  list-style: none;
  margin: 0.7rem 0 0;
  padding: 0;
}

.legal-toc-link {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem; /* contract minimumTargetPx: 44 */
  padding: var(--space-1) var(--space-2);
  color: var(--color-text-muted);
  text-decoration: underline;
  text-decoration-color: var(--color-border-strong);
  text-underline-offset: 0.2em;
  border-radius: var(--radius-sm);
  font-size: var(--text-label);
  line-height: var(--leading-label);
}

/* VD-R4-02: brand coral is never light-theme text; hover/focus use the
   registered accent-text pair, and dark resolves the bright dark
   accent-text token through the remap. */
.legal-toc-link:hover { color: var(--color-accent-text); text-decoration-color: currentColor; }
.legal-toc-link:focus-visible { color: var(--color-accent-text); text-decoration-color: currentColor; }

/* ---------- document body ---------- */

.legal-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
  max-width: var(--size-measure-legal);
}

.legal-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  scroll-margin-block-start: var(--space-8);
}

.legal-section > h2 {
  margin: 0;
  font-size: var(--text-heading-sm);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-heading);
}

.legal-section > h3 {
  margin: 0;
  font-size: var(--text-heading-xs);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-heading);
}

.legal-section p {
  margin: 0;
  /* Long first-party identifiers in prose (jolvex_analytics_consent_v1=…)
     break instead of widening the column — the same discipline the legal
     table cells already carry (M12 responsive finding F6). */
  overflow-wrap: anywhere;
}

.legal-section ul,
.legal-section ol {
  margin: 0;
  padding-inline-start: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* Component-local scroll region (frozen global rule
   `semanticTableOverflow: bounded-scroll-region-only`): wide tables scroll
   inside this wrapper, never the page, at 320/390/768 and above. */
.legal-table-scroll {
  max-width: 100%;
  overflow-x: auto;
}

.legal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-body);
}

.legal-table caption {
  text-align: start;
  color: var(--color-text-muted);
  padding-block-end: var(--space-2);
  font-size: var(--text-label);
}

.legal-table th,
.legal-table td {
  text-align: start;
  padding: var(--space-2) var(--space-3);
  border-block-end: 1px solid var(--color-border);
  vertical-align: top;
  overflow-wrap: anywhere; /* long tokens (jolvex_admin_session) break instead of widening the page */
}

.legal-table th {
  font-weight: var(--weight-semibold);
  border-block-end-color: var(--color-border-strong);
}

/* Consent reopen control (DS-017): an explicit labelled control inside the
   body flow. */
.legal-consent-control { margin-top: var(--space-4); }

.legal-contact {
  padding: var(--space-5);
  border: 2px solid var(--color-text);
  border-radius: var(--radius-md);
  background: var(--color-bg-subtle);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.legal-contact > p { margin: 0; }
