/* ==========================================================================
   PolarLabs — Legal / policy pages (route-scoped "research dossier" system)
   Loaded ONLY on the legal template (page-templates/template-legal.php, see
   inc/legal.php). Tokens come from main.css :root. Presentation only — this
   stylesheet never authors legal copy; it styles whatever the template renders
   (authored body, the approved provisions, the approved compliance copy, or the
   neutral pending-review state).

   An original controlled-document / policy-archive language, built only from the
   shipped PolarLabs tokens (navy, blue, electric, white, icy neutrals; Manrope /
   Inter; no serif; no new colors). A branded document cover with a factual status
   chip, a built-in numbered contents navigator, chaptered sections, a single
   composed pending-review state, and a deliberate end-of-document transition. All
   classes are legal-scoped (the dossier uses the pldoc prefix) so the global
   stylesheet stays untouched.
   ========================================================================== */

.pldoc { --doc-hair: rgba(255,255,255,.12); }

/* ---- 1. Document cover (masthead) ---------------------------------------- */
.pldoc-cover {
	position: relative;
	isolation: isolate;
	overflow: hidden;
	color: var(--pl-icy);
	background: linear-gradient(168deg, #0A1E38 0%, var(--pl-navy) 60%, var(--pl-navy-900) 100%);
	border-bottom: 2px solid var(--pl-blue);
	padding-block: clamp(30px, 4vw, 52px);
}
/* Extremely restrained blueprint hairline grid, masked to the right so it never
   sits under the reading text; low opacity keeps title contrast untouched. */
.pldoc-cover::before {
	content: "";
	position: absolute; inset: 0; z-index: var(--pl-z-below); pointer-events: none; opacity: .32;
	background-image:
		linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px),
		linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px);
	background-size: 46px 46px;
	-webkit-mask-image: radial-gradient(120% 130% at 100% 0%, #000 0%, transparent 58%);
	mask-image: radial-gradient(120% 130% at 100% 0%, #000 0%, transparent 58%);
}
.pldoc-cover__top {
	display: flex; align-items: center; justify-content: space-between; gap: 16px;
	padding-bottom: 16px; margin-bottom: 22px; border-bottom: 1px solid var(--doc-hair);
}
.pldoc-cover__crumb { font-size: .8rem; color: var(--pl-icy-200); }
.pldoc-cover__crumb a { color: var(--pl-icy-200); text-decoration: none; }
.pldoc-cover__crumb a:hover { color: #fff; }
.pldoc-cover__crumb a:focus-visible { outline: 2px solid var(--pl-icy); outline-offset: 3px; border-radius: 2px; }
.pldoc-cover__crumb .sep { opacity: .5; padding: 0 8px; }

.pldoc-cover__eyebrow {
	display: inline-flex; align-items: center; gap: 12px;
	font-size: .72rem; font-weight: 700; letter-spacing: .2em; text-transform: uppercase;
	color: var(--pl-icy-200); margin: 0;
}
.pldoc-cover__eyebrow::before { content: ""; width: 26px; height: 2px; background: var(--pl-electric); flex: none; }
.pldoc-cover__title {
	font-family: var(--pl-font-heading); font-weight: 800; color: #fff;
	letter-spacing: -.025em; line-height: 1.04;
	font-size: clamp(1.95rem, 1.4rem + 2.4vw, 3.1rem);
	margin: 16px 0 0; max-width: 20ch;
}
.pldoc-cover__lede {
	color: var(--pl-icy-200); font-size: clamp(1rem, .96rem + .3vw, 1.12rem);
	line-height: 1.55; max-width: 60ch; margin: 14px 0 0;
}

/* Factual status chip — palette-only. Meaning is in the label; the dot is a
   secondary cue (filled = public, ring = pending). Never a date/version/entity/
   approval claim. */
.pldoc-status {
	display: inline-flex; align-items: center; gap: 8px; flex: none;
	font-size: .72rem; font-weight: 700; letter-spacing: .04em;
	padding: 6px 12px; border-radius: var(--pl-radius-pill);
	border: 1px solid rgba(255,255,255,.22); color: var(--pl-icy); white-space: nowrap;
}
.pldoc-status__dot { width: 7px; height: 7px; border-radius: 999px; flex: none; }
.pldoc-status--public { background: rgba(40,120,245,.16); }
.pldoc-status--public .pldoc-status__dot { background: var(--pl-electric); box-shadow: 0 0 0 3px rgba(75,150,255,.22); }
.pldoc-status--pending { background: rgba(255,255,255,.05); color: var(--pl-icy-200); }
.pldoc-status--pending .pldoc-status__dot { background: transparent; border: 1.5px solid var(--pl-icy-200); }

/* ---- 2. Reading layout (dossier) ----------------------------------------- */
.pldoc-main { padding-block: clamp(34px, 4.5vw, 64px) clamp(8px, 2vw, 20px); }
.pldoc-grid { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: clamp(40px, 5vw, 76px); align-items: start; }

/* Document navigator — a built-in margin index, not a floating card. */
.pldoc-nav { position: sticky; top: calc(var(--pl-header-h) + 22px); }
.pldoc-nav__label {
	font-size: .72rem; font-weight: 700; letter-spacing: .18em; text-transform: uppercase;
	color: var(--pl-muted); margin: 0 0 14px;
}
.pldoc-nav__list { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--pl-line); }
.pldoc-nav__list li { margin: 0; }
.pldoc-nav__list a {
	display: grid; grid-template-columns: 30px 1fr; align-items: baseline; gap: 4px;
	margin-left: -1px; padding: 9px 12px; min-height: 44px; box-sizing: border-box;
	border-left: 2px solid transparent; text-decoration: none; color: var(--pl-navy-700);
	font-size: .92rem; line-height: 1.35;
}
.pldoc-nav__list .n { font-family: var(--pl-mono); font-weight: 600; font-size: .74rem; color: var(--pl-link); letter-spacing: .04em; }
.pldoc-nav__list a:hover { color: var(--pl-navy); border-left-color: var(--pl-line-strong); }
.pldoc-nav__list a[aria-current="true"] { color: var(--pl-navy); border-left-color: var(--pl-blue); font-weight: 600; }
.pldoc-nav__list a:focus-visible { outline: 2px solid var(--pl-link); outline-offset: 2px; border-radius: 4px; }

/* Mobile contents — native <details> disclosure (no JS), hidden on desktop. */
.pldoc-nav-m { display: none; border: 1px solid var(--pl-line); border-radius: var(--pl-radius); background: var(--pl-surface-2); margin-bottom: 26px; overflow: hidden; }
.pldoc-nav-m > summary {
	list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between;
	gap: 12px; padding: 0 16px; min-height: 48px;
	font-size: .78rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--pl-navy);
}
.pldoc-nav-m > summary::-webkit-details-marker { display: none; }
.pldoc-nav-m > summary::after {
	content: ""; width: 9px; height: 9px; flex: none; transform: rotate(45deg); transition: transform var(--pl-dur) var(--pl-ease);
	border-right: 2px solid var(--pl-muted); border-bottom: 2px solid var(--pl-muted); margin-bottom: 3px;
}
.pldoc-nav-m[open] > summary::after { transform: rotate(-135deg); margin-bottom: -3px; }
.pldoc-nav-m > summary:focus-visible { outline: 2px solid var(--pl-link); outline-offset: -3px; }
.pldoc-nav-m__list { list-style: none; margin: 0; padding: 4px 8px 10px; border-top: 1px solid var(--pl-line); }
.pldoc-nav-m__list a {
	display: grid; grid-template-columns: 30px 1fr; gap: 4px; align-items: baseline;
	padding: 10px 10px; min-height: 44px; box-sizing: border-box; text-decoration: none;
	color: var(--pl-navy-700); font-size: .95rem; border-radius: var(--pl-radius-sm);
}
.pldoc-nav-m__list .n { font-family: var(--pl-mono); font-weight: 600; font-size: .76rem; color: var(--pl-link); }
.pldoc-nav-m__list a:hover { background: #fff; color: var(--pl-navy); }
.pldoc-nav-m__list a:focus-visible { outline: 2px solid var(--pl-link); outline-offset: 2px; }

/* Reading column — comfortable measure (on the shared .pl-prose base). */
.pldoc-read { max-width: 68ch; }
/* Navigator-less pages (Accessibility / RUO / Documentation Release): a centered
   publication column so short documents read as balanced, not left-hugged. */
.pldoc-read--solo { margin-inline: auto; }
.pldoc-read a:focus-visible { outline: 2px solid var(--pl-link); outline-offset: 2px; border-radius: 2px; }

/* Chaptered sections — polarlabs_legal_toc() injects an aria-hidden numbered label
   (.pldoc-sec__num) before each authored/provision H2; it carries the section
   divider and the H2 follows. No section wrapper needed. */
.pldoc-read .pldoc-sec__num {
	display: block; margin: clamp(28px, 3.2vw, 42px) 0 0; padding-top: clamp(28px, 3.2vw, 42px);
	border-top: 1px solid var(--pl-line);
	font-family: var(--pl-mono); font-weight: 600; font-size: .74rem; letter-spacing: .14em; color: var(--pl-link);
}
.pldoc-read h2 {
	font-family: var(--pl-font-heading); font-weight: 800; letter-spacing: -.015em; color: var(--pl-navy);
	font-size: clamp(1.25rem, 1.08rem + .6vw, 1.55rem); margin: 6px 0 0;
	scroll-margin-top: calc(var(--pl-header-h) + 24px);
}

/* Approved provisions (currently /affiliate-terms § 6). The renderer emits
   .pl-legal-provisions__intro (lead) + .pl-legal-provisions__note (closing note). */
.pl-legal-provisions__intro { font-size: clamp(1.08rem, 1rem + .4vw, 1.22rem); line-height: 1.6; color: var(--pl-navy-700); font-weight: 500; margin: 0; }
.pl-legal-provisions__note { margin-top: 2.4em; padding: 15px 18px; border: 1px solid var(--pl-line); border-left: 3px solid var(--pl-blue); border-radius: var(--pl-radius); background: var(--pl-surface-2); color: var(--pl-muted); font-size: .95rem; line-height: 1.55; }

/* ---- 2b. Document information (L1.1) — a compact metadata strip below the
   cover. The template renders it ONLY when owner/counsel-approved Effective date
   / Version values exist (via the polarlabs/legal/meta filter); with none present
   it is omitted entirely, so this never shows an empty label or a "Draft" value. */
.pldoc-metawrap { border-bottom: 1px solid var(--pl-line); background: var(--pl-surface); }
.pldoc-meta { display: flex; flex-wrap: wrap; gap: 8px 40px; margin: 0; padding-block: clamp(13px, 1.5vw, 18px); }
.pldoc-meta__row { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.pldoc-meta dt { margin: 0; font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--pl-muted); }
.pldoc-meta dd { margin: 0; font-family: var(--pl-font-heading); font-weight: 700; color: var(--pl-navy); font-size: .96rem; }

/* ---- 2c. Legal callout (L1.1) — a presentation aid for a VERBATIM clause.
   Authored content places the complete clause inside it (or a verbatim excerpt
   whose full clause still appears in normal document flow). Restrained navy/icy —
   never a warning color, badge, or "verified/approved/safe" label, and it must
   never summarize or separate an exception from the rule it qualifies. */
.pldoc-read .pldoc-callout {
	margin: clamp(22px, 2.6vw, 30px) 0; padding: clamp(18px, 2.2vw, 24px);
	background: var(--pl-blue-050); border: 1px solid var(--pl-line);
	border-left: 3px solid var(--pl-blue); border-radius: var(--pl-radius);
}
.pldoc-read .pldoc-callout > :first-child { margin-top: 0; }
.pldoc-read .pldoc-callout > :last-child { margin-bottom: 0; }
.pldoc-read .pldoc-callout p { color: var(--pl-navy-700); }
.pldoc-callout__label {
	display: block; margin: 0 0 8px; font-family: var(--pl-font-heading);
	font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--pl-link);
}
/* Long legal terms + email/URL fragments wrap safely, never overflowing — incl. the
   largest text (h2 clause titles) and the contents-navigator link text. */
.pldoc-read p, .pldoc-read li, .pldoc-read h2, .pldoc-nav__list a, .pldoc-nav-m__list a { overflow-wrap: anywhere; }

/* ---- 3. Pending policy — one composed document-status state --------------- */
.pldoc-pending {
	position: relative; overflow: hidden;
	border: 1px solid var(--pl-line); border-left: 3px solid var(--pl-blue);
	border-radius: var(--pl-radius-lg); background: var(--pl-surface-2);
	padding: clamp(26px, 3.4vw, 40px); max-width: 62ch; margin-inline: auto;
}
.pldoc-pending__status {
	display: inline-flex; align-items: center; gap: 8px;
	font-size: .72rem; font-weight: 700; letter-spacing: .04em; color: var(--pl-navy);
	border: 1px solid var(--pl-line-strong); background: #fff; border-radius: var(--pl-radius-pill); padding: 6px 12px;
}
.pldoc-pending__status .pldoc-status__dot { background: transparent; border: 1.5px solid var(--pl-blue); }
.pldoc-pending__title { font-family: var(--pl-font-heading); font-weight: 800; color: var(--pl-navy); font-size: 1.3rem; letter-spacing: -.01em; margin: 16px 0 0; }
.pldoc-pending__text { color: var(--pl-muted); font-size: 1.04rem; line-height: 1.6; margin: 10px 0 0; max-width: 52ch; }
.pldoc-pending__text a { color: var(--pl-link); text-decoration: underline; text-underline-offset: 2px; font-weight: 600; }
.pldoc-pending__text a:focus-visible { outline: 2px solid var(--pl-link); outline-offset: 2px; border-radius: 2px; }
.pldoc-pending::after {
	content: ""; position: absolute; right: -30px; top: -30px; width: 150px; height: 150px; z-index: 0; opacity: .5;
	background-image: repeating-linear-gradient(var(--pl-line) 0 1px, transparent 1px 14px);
	-webkit-mask-image: radial-gradient(70% 70% at 100% 0%, #000, transparent 70%);
	mask-image: radial-gradient(70% 70% at 100% 0%, #000, transparent 70%);
}
.pldoc-pending > * { position: relative; z-index: var(--pl-z-base); }

/* Compact pending prenote — for pending pages that DO carry approved compliance
   copy (Research-Use / Documentation Release): the finalizing notice sits above
   the reading copy so nothing reads as finalized. */
.pldoc-prenote {
	display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px;
	border: 1px solid var(--pl-line); border-left: 3px solid var(--pl-blue);
	border-radius: var(--pl-radius); background: var(--pl-surface-2);
	padding: 14px 18px; margin: 0 0 clamp(24px, 3vw, 34px);
}
.pldoc-prenote__status {
	display: inline-flex; align-items: center; gap: 8px; flex: none;
	font-size: .7rem; font-weight: 700; letter-spacing: .04em; color: var(--pl-navy);
	border: 1px solid var(--pl-line-strong); background: #fff; border-radius: var(--pl-radius-pill); padding: 5px 11px;
}
.pldoc-prenote__status .pldoc-status__dot { background: transparent; border: 1.5px solid var(--pl-blue); }
.pldoc-prenote__text { color: var(--pl-muted); font-size: .95rem; line-height: 1.5; margin: 0; }
.pldoc-prenote__text a { color: var(--pl-link); text-decoration: underline; text-underline-offset: 2px; font-weight: 600; }
.pldoc-prenote__text a:focus-visible { outline: 2px solid var(--pl-link); outline-offset: 2px; border-radius: 2px; }

/* ---- 4. Footer transition (end-of-document contact) ----------------------- */
.pldoc-close { border-top: 1px solid var(--pl-line); margin-top: clamp(30px, 4vw, 52px); padding-block: clamp(24px, 3vw, 36px); }
.pldoc-close__row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 26px; }
.pldoc-close__label { font-size: .72rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--pl-muted); margin: 0; }
.pldoc-close__contact { color: var(--pl-muted); font-size: 1rem; margin: 0; }
.pldoc-close__contact a { color: var(--pl-link); text-decoration: underline; text-underline-offset: 2px; font-weight: 600; }
.pldoc-close__contact a:focus-visible { outline: 2px solid var(--pl-link); outline-offset: 2px; border-radius: 2px; }
.pldoc-close__top { display: inline-flex; align-items: center; gap: 8px; color: var(--pl-navy-700); font-weight: 600; font-size: .9rem; text-decoration: none; }
.pldoc-close__top:hover { color: var(--pl-link); }
.pldoc-close__top:focus-visible { outline: 2px solid var(--pl-link); outline-offset: 2px; border-radius: 4px; }

/* ---- 5. Responsive -------------------------------------------------------- */
@media (max-width: 1024px) {
	.pldoc-grid { grid-template-columns: 1fr; gap: 0; }
	.pldoc-nav { display: none; }
	.pldoc-nav-m { display: block; }
	.pldoc-read { max-width: none; }
	.pldoc-cover__title { max-width: none; }
}
@media (max-width: 560px) {
	.pldoc-cover__top { flex-direction: column; align-items: flex-start; gap: 12px; }
	.pldoc-close__row { flex-direction: column; align-items: flex-start; }
}

/* ---- 6. Reduced motion --------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
	.pldoc-nav-m > summary::after { transition: none; }
}

/* ---- 7. Print ------------------------------------------------------------- */
@media print {
	.pldoc-cover { background: none !important; border-bottom: 1px solid #000; color: #000; padding-block: 0 12px; }
	.pldoc-cover::before { display: none; }
	.pldoc-cover__title, .pldoc-cover__lede, .pldoc-cover__eyebrow, .pldoc-cover__crumb, .pldoc-cover__crumb a { color: #000 !important; }
	.pldoc-cover__eyebrow::before { background: #000; }
	.pldoc-status { border-color: #000; color: #000; background: none; }
	.pldoc-status__dot { background: #000 !important; border-color: #000 !important; }
	.pldoc-nav, .pldoc-nav-m, .pldoc-close__top { display: none !important; }
	.pldoc-grid { display: block; }
	.pldoc-read { max-width: none; }
	.pldoc-pending, .pldoc-prenote { border: 1px solid #999; background: none; }
	.pldoc-pending::after { display: none; }
	/* L1.1 print enhancements: drop global chrome + newsletter, expose link
	   destinations in the reading column, and keep headings/clauses off page
	   breaks. Scoped to the legal route (legal.css loads only here). */
	.pl-header, .pl-noticebar, .pl-footer, .pl-newsletter { display: none !important; }
	.pldoc-nav { position: static; }
	.pldoc-metawrap { background: none; border-bottom: 1px solid #000; }
	.pldoc-meta dt, .pldoc-meta dd { color: #000 !important; }
	.pldoc-read .pldoc-callout { background: none; border: 1px solid #999; }
	.pldoc-read a[href^="http"]::after, .pldoc-read a[href^="mailto"]::after { content: " (" attr(href) ")"; font-size: .85em; word-break: break-all; color: #000; }
	.pldoc-read h2, .pldoc-read .pldoc-sec__num { break-after: avoid; break-inside: avoid; }
	.pldoc-read p, .pldoc-read li { orphans: 3; widows: 3; }
}

/* ==========================================================================
   DR-LEGAL-001 additions — coordinate eyebrow, cover print action, extended
   status variants, related-policy ledger. Route-scoped (.pldoc / .pl-legal).
   ========================================================================== */

/* Cover meta cluster (status chip + print) + mono coordinate eyebrow. */
.pldoc-cover__meta { display: flex; align-items: center; gap: 12px; flex: none; flex-wrap: wrap; justify-content: flex-end; }
.pldoc-cover__eyebrow--coord { font-family: var(--pl-mono); letter-spacing: .18em; font-weight: 600; }

.pldoc-print {
	display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
	font-family: var(--pl-font); font-size: .8rem; font-weight: 600; letter-spacing: .02em;
	color: var(--pl-icy); background: rgba(255, 255, 255, .06);
	border: 1px solid rgba(255, 255, 255, .22); border-radius: var(--pl-radius-pill);
	padding: 6px 14px; min-height: 36px;
	transition: background var(--pl-dur) var(--pl-ease), border-color var(--pl-dur) var(--pl-ease);
}
.pldoc-print:hover { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .4); color: #fff; }
.pldoc-print:focus-visible { outline: 2px solid var(--pl-icy); outline-offset: 2px; }
.pldoc-print svg { flex: none; }

/* Extended status variants — available in the design system; the theme currently
   emits only Public / Pending. Never used to claim "attorney approved". */
.pldoc-status--draft { background: rgba(255, 255, 255, .05); color: var(--pl-icy-200); }
.pldoc-status--draft .pldoc-status__dot { background: var(--pl-icy-200); box-shadow: none; }
.pldoc-status--superseded { background: rgba(255, 255, 255, .04); color: var(--pl-icy-200); }
.pldoc-status--superseded .pldoc-status__dot { background: transparent; border: 1.5px solid var(--pl-icy-200); }

/* Related-policy ledger — compact directory of the other canonical legal routes. */
.pldoc-related { border-top: 1px solid var(--pl-line); padding-block: clamp(26px, 3.4vw, 40px); }
.pldoc-related__label { font-size: .72rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--pl-muted); margin: 0 0 clamp(8px, 1.4vw, 14px); }
.pldoc-related__list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 clamp(24px, 4vw, 48px); }
.pldoc-related__list a {
	display: flex; align-items: center; gap: 11px; padding: clamp(11px, 1.6vw, 15px) 0;
	border-top: 1px solid var(--pl-line); text-decoration: none; color: var(--pl-navy);
}
.pldoc-related__list li:first-child a, .pldoc-related__list li:nth-child(2) a { border-top: 0; }
.pldoc-related__dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.pldoc-related__dot--public { background: var(--pl-blue); box-shadow: 0 0 0 3px rgba(40, 120, 245, .14); }
.pldoc-related__dot--pending { background: transparent; border: 1.5px solid var(--pl-line-strong); }
.pldoc-related__name { font-family: var(--pl-font-heading); font-weight: 700; font-size: .98rem; letter-spacing: -.01em; flex: 1 1 auto; min-width: 0; }
.pldoc-related__state { font-family: var(--pl-mono); font-size: .68rem; letter-spacing: .06em; text-transform: uppercase; color: var(--pl-muted); white-space: nowrap; }
.pldoc-related__list a:hover .pldoc-related__name { color: var(--pl-link); }
.pldoc-related__list a:focus-visible { outline: 2px solid var(--pl-link); outline-offset: 2px; border-radius: 4px; }

@media (max-width: 640px) {
	.pldoc-related__list { grid-template-columns: 1fr; }
	.pldoc-related__list li:nth-child(2) a { border-top: 1px solid var(--pl-line); }
	.pldoc-cover__meta { justify-content: flex-start; }
}

@media print {
	/* Print action + related ledger are chrome, not content. */
	.pldoc-print, .pldoc-related { display: none !important; }
	.pldoc-cover__eyebrow--coord { font-family: inherit; color: #000 !important; }
}
