/* ATLAS · components/legal-doc.css
 * Legal & Trust document anatomy (S073).
 * Design decision DD-LEGAL-1 (Wave 0): C + D hybrid —
 *   docs-style chapter flow (big § numerals + flowing sections) WITH a
 *   clause↔plain-language split column for the liability/disclaimer clauses.
 * Sticky left TOC rail (docs pattern). Atlas tokens only.
 *
 * Mandates honoured:
 *   M-1  no left-border-accent boxes — severity/notice encoded via mono eyebrow
 *        + pulsing index dot + FULL hairline frame. Round all four corners.
 *   M-3  premium finish — engraved rules, mono catalog stamps, optical spacing.
 *   M-4  disciplined motion — sections rise+fade on reveal (legal-doc.js),
 *        reduced-motion snaps to end-state.
 *   M-5  every font-size tokenized calc(px*var(--type-scale)); mono floor 11px.
 */

/* ── Page shell ─────────────────────────────────────────────── */
.legal-main {
  padding-top: 96px;
  max-width: 1280px;
  margin-inline: auto;
  padding-inline: 56px;
  padding-bottom: 168px;
}

/* ── Document header ────────────────────────────────────────── */
.legal-head {
  border-bottom: 1px solid var(--line-strong);
  padding: 56px 0 44px;
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 64px;
  align-items: end;
}
.legal-head .eyebrow {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--f-mono); font-weight: var(--fw-label, 700);
  font-size: calc(11px * var(--type-scale)); letter-spacing: 0.24em;
  text-transform: uppercase; color: var(--mute); margin: 0 0 22px;
}
.legal-head .eyebrow .seal-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--gold) 18%, transparent);
  animation: legal-pulse 3s var(--ease-out-settle) infinite;
  flex-shrink: 0;
}
.legal-head h1 {
  font-family: var(--f-display); font-weight: var(--fw-display, 500);
  font-size: clamp(calc(40px * var(--type-scale)), calc(5vw * var(--type-scale)), calc(72px * var(--type-scale)));
  letter-spacing: -0.032em; line-height: 0.98; margin: 0; text-wrap: balance;
}
.legal-head h1 em { font-style: normal; color: var(--ash); }
.legal-head .lede {
  margin: 22px 0 0; max-width: 56ch;
  font-size: calc(16px * var(--type-scale)); line-height: 1.62;
  color: var(--ash); text-wrap: pretty;
}

/* doc-meta — version stamp + key facts. Full hairline frame, no left rule. */
.doc-meta {
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--steel);
  padding: 4px 18px;
  font-family: var(--f-mono);
}
.doc-meta .row {
  display: grid; grid-template-columns: 96px 1fr; gap: 14px;
  padding: 11px 0; border-bottom: 1px solid var(--line);
}
.doc-meta .row:last-child { border-bottom: 0; }
.doc-meta .k {
  font-size: calc(11px * var(--type-scale)); font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--mute);
}
.doc-meta .v {
  font-size: calc(12px * var(--type-scale)); font-weight: 600;
  letter-spacing: 0.04em; color: var(--bone);
}
.doc-meta .v.stamp { color: var(--gold); }

/* ── Two-column body: TOC rail + article ────────────────────── */
.legal-body {
  display: grid; grid-template-columns: 248px 1fr;
  gap: 88px; margin-top: 56px;
}

/* ── TOC rail (left, sticky) ─────────────────────────────────── */
.legal-toc {
  position: sticky; top: 96px; align-self: start;
  max-height: calc(100vh - 128px); overflow-y: auto;
  padding-right: 14px;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
.legal-toc::-webkit-scrollbar { width: 4px; }
.legal-toc::-webkit-scrollbar-thumb { background: var(--line); }
.legal-toc .toc-title {
  font-family: var(--f-mono); font-weight: var(--fw-label, 700);
  font-size: calc(11px * var(--type-scale)); letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--mute); margin: 0 0 18px;
  padding-bottom: 15px; border-bottom: 1px solid var(--line);
}
.legal-toc ol { list-style: none; margin: 0; padding: 0; counter-reset: tocnum; }
.legal-toc li { counter-increment: tocnum; margin-bottom: 3px; }
.legal-toc a {
  display: grid; grid-template-columns: 26px 1fr; align-items: baseline; gap: 8px;
  font-family: var(--f-mono); font-weight: 600;
  font-size: calc(11px * var(--type-scale)); letter-spacing: 0.08em;
  color: var(--ash); text-decoration: none; text-transform: uppercase;
  padding: 7px 0 7px 14px; margin-left: -14px;
  border-left: 1px solid transparent;
  transition: color var(--t-sm) var(--ease-out-expo), border-color var(--t-sm) var(--ease-out-expo);
}
.legal-toc a::before {
  content: counter(tocnum, decimal-leading-zero);
  color: var(--mute); font-size: calc(11px * var(--type-scale)); letter-spacing: 0.14em;
}
.legal-toc a:hover { color: var(--bone); }
.legal-toc a.active { color: var(--bone); border-left-color: var(--gold); }
.legal-toc a.active::before { color: var(--gold); }

/* ── Article (right) — chapter flow ─────────────────────────── */
.legal-article { max-width: 760px; color: var(--bone); }
.legal-article > section {
  padding: 0 0 72px; border-bottom: 1px solid var(--line);
  margin-bottom: 72px; scroll-margin-top: 96px;
}
.legal-article > section:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }

/* big chapter numeral (C — docs chapter flow) */
.legal-article h2 {
  font-family: var(--f-display); font-weight: var(--fw-display, 500);
  font-size: clamp(calc(26px * var(--type-scale)), calc(3.2vw * var(--type-scale)), calc(40px * var(--type-scale)));
  letter-spacing: -0.022em; line-height: 1.06; margin: 0 0 26px; text-wrap: balance;
}
.legal-article h2 em { font-style: normal; color: var(--ash); }
.legal-article h2 .num {
  display: block; margin-bottom: 12px;
  font-family: var(--f-mono); font-weight: 700;
  font-size: calc(12px * var(--type-scale)); letter-spacing: 0.22em;
  color: var(--mute); text-transform: uppercase;
}
.legal-article h3 {
  font-family: var(--f-display); font-weight: var(--fw-display, 500);
  font-size: calc(20px * var(--type-scale)); letter-spacing: -0.012em; line-height: 1.2;
  margin: 44px 0 14px; color: var(--bone); scroll-margin-top: 96px;
}
.legal-article h3 .cl {
  font-family: var(--f-mono); font-weight: 700;
  font-size: calc(11px * var(--type-scale)); letter-spacing: 0.16em;
  color: var(--gold); margin-right: 12px; text-transform: uppercase;
}
.legal-article p {
  font-size: calc(15.5px * var(--type-scale)); line-height: 1.68;
  color: var(--ash); margin: 0 0 15px; text-wrap: pretty;
}
.legal-article p strong { color: var(--bone); font-weight: 700; }
.legal-article p a { color: var(--shield-hi); text-decoration: none; }
.legal-article p a:hover { color: var(--bone); }
.legal-article p code {
  font-family: var(--f-mono); font-size: calc(13px * var(--type-scale)); font-weight: 500;
  color: var(--bone); background: rgba(234, 238, 245, 0.05);
  padding: 1px 6px; border-radius: 4px;
}
.legal-article ul.cl-list { list-style: none; padding: 0; margin: 0 0 16px; }
.legal-article ul.cl-list li {
  position: relative; padding-left: 20px; padding-block: 5px;
  color: var(--ash); font-size: calc(15px * var(--type-scale)); line-height: 1.6;
}
.legal-article ul.cl-list li::before {
  content: ""; position: absolute; left: 0; top: 14px;
  width: 9px; height: 1px; background: var(--mute);
}
.legal-article ul.cl-list li strong { color: var(--bone); font-weight: 700; }

/* ── Clause ↔ plain-language split (D) — for liability/disclaimer ── */
.split {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0;
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
  overflow: hidden; margin: 22px 0 26px; background: var(--steel);
}
.split .legalese, .split .plain { padding: 20px 22px; }
.split .legalese { border-right: 1px solid var(--line); } /* neutral structural seam — M-1 ok */
.split .tag {
  display: block; font-family: var(--f-mono); font-weight: 700;
  font-size: calc(11px * var(--type-scale)); letter-spacing: 0.18em;
  text-transform: uppercase; margin-bottom: 12px;
}
.split .legalese .tag { color: var(--mute); }
.split .plain { background: color-mix(in oklab, var(--steel) 60%, var(--ink)); }
.split .plain .tag { color: var(--gold); }
.split p { font-size: calc(14px * var(--type-scale)); line-height: 1.6; margin: 0 0 10px; }
.split p:last-child { margin-bottom: 0; }
.split .plain p { color: var(--bone); }

/* ── Notice / callout (M-1 compliant: full frame + pulsing dot, no left rule) ── */
.notice {
  position: relative; border: 1px solid var(--line-strong);
  border-radius: var(--r-md); background: var(--steel);
  padding: 18px 20px; margin: 22px 0 26px; overflow: hidden;
}
.notice::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, color-mix(in oklab, var(--n-accent, var(--gold)) 65%, transparent), transparent);
}
.notice .topmark { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.notice .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--n-accent, var(--gold));
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--n-accent, var(--gold)) 20%, transparent);
  animation: legal-pulse 2.8s var(--ease-out-settle) infinite; flex-shrink: 0;
}
.notice .h {
  font-family: var(--f-mono); font-weight: 700;
  font-size: calc(11px * var(--type-scale)); letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--n-accent, var(--gold));
}
.notice .b { color: var(--ash); font-size: calc(14px * var(--type-scale)); line-height: 1.6; }
.notice .b strong { color: var(--bone); font-weight: 700; }
.notice.crit { --n-accent: var(--ember-hi); }
.notice.verify { --n-accent: var(--verify); }

/* ── OWNER / counsel placeholder marker ─────────────────────── */
.owner-flag {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--f-mono); font-weight: 600;
  font-size: calc(11px * var(--type-scale)); letter-spacing: 0.06em;
  color: var(--gold); background: rgba(200, 151, 42, 0.07);
  border: 1px dashed var(--line-gold); border-radius: var(--r-sm);
  padding: 3px 9px; margin: 2px 0;
}
.owner-flag::before { content: "✎"; color: var(--gold-hi); }
p.placeholder { color: var(--mute); font-style: italic; }

/* ── Endpoint / contact chips (security.txt etc) ────────────── */
.legal-chip {
  display: inline-flex; align-items: center; gap: 10px;
  border: 1px solid var(--line-strong); background: var(--steel);
  border-radius: var(--r-sm); padding: 9px 13px; margin: 4px 8px 4px 0;
  font-family: var(--f-mono); font-size: calc(12px * var(--type-scale)); font-weight: 600;
  color: var(--bone); text-decoration: none;
  transition: border-color var(--t-sm) var(--ease-out-expo), background var(--t-sm);
}
.legal-chip:hover { border-color: var(--line-accent); background: var(--steel-2); color: var(--bone); }
.legal-chip .lbl {
  font-size: calc(11px * var(--type-scale)); font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--gold);
}

/* ── Document foot ──────────────────────────────────────────── */
.legal-end {
  margin-top: 80px; padding-top: 28px; border-top: 1px solid var(--line-strong);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 28px;
  font-family: var(--f-mono); font-weight: 600;
  font-size: calc(11px * var(--type-scale)); letter-spacing: 0.14em;
  color: var(--mute); text-transform: uppercase;
}
.legal-end a {
  display: inline-flex; gap: 9px; align-items: center;
  color: var(--ash); text-decoration: none;
  transition: color var(--t-sm) var(--ease-out-expo);
}
.legal-end a:hover { color: var(--bone); }
.legal-end .prev::before { content: "←"; color: var(--gold); }
.legal-end .next::after { content: "→"; color: var(--gold); }
.legal-end .center { justify-self: center; color: var(--gold); }
.legal-end .right { justify-self: end; }

/* ── Motion (M-4) — reveal on scroll via legal-doc.js .reveal/.in ─ */
.legal-article > section.reveal { opacity: 0; transform: translateY(16px); }
.legal-article > section.reveal.in {
  opacity: 1; transform: none;
  transition: opacity var(--t-lg) var(--ease-emerge), transform var(--t-lg) var(--ease-emerge);
}
@keyframes legal-pulse {
  0%, 100% { box-shadow: 0 0 0 4px color-mix(in oklab, var(--n-accent, var(--gold)) 20%, transparent); }
  50%      { box-shadow: 0 0 0 7px color-mix(in oklab, var(--n-accent, var(--gold)) 5%, transparent); }
}

/* ── Focus rings ────────────────────────────────────────────── */
.legal-toc a:focus-visible,
.legal-end a:focus-visible,
.legal-chip:focus-visible,
.legal-article a:focus-visible {
  outline: 2px solid var(--shield-hi); outline-offset: 3px; border-radius: var(--r-sm); color: var(--bone);
}
.legal-article a:focus-visible { outline-color: var(--gold); }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 980px) {
  .legal-main { padding-inline: 24px; }
  .legal-head { grid-template-columns: 1fr; gap: 32px; }
  .legal-body { grid-template-columns: 1fr; gap: 40px; }
  .legal-toc { position: static; max-height: none; }
  .legal-article { max-width: none; }
  .split { grid-template-columns: 1fr; }
  .split .legalese { border-right: 0; border-bottom: 1px solid var(--line); }
  .legal-end { grid-template-columns: 1fr; text-align: center; gap: 16px; }
  .legal-end .right, .legal-end .center { justify-self: center; }
}
@media (prefers-reduced-motion: reduce) {
  .legal-article > section.reveal { opacity: 1 !important; transform: none !important; }
  .legal-head .eyebrow .seal-dot, .notice .dot { animation: none !important; }
}
