/*
 * Legal pages (phase 12, CSS only): Privacy Policy, Terms of use, Cookies Policy.
 * Loaded ONLY on those pages (inc/enqueue.php, matched by slug), and every rule is scoped to
 * body.pt-legal, a body class added by the same conditional. Nothing here is global.
 *
 * Two page sources are unified:
 *   A. Native WordPress / Gutenberg page (Privacy Policy): page.php prints
 *        .site-main > article > .container > h1.entry-title + .entry-content (blocks).
 *   B. Elementor page (Terms of use, Cookies Policy): page.php prints the bare
 *        .site-main > article > .entry-content > .elementor > .e-con (first container)
 *        > .e-con-inner > .elementor-widget-text-editor > .elementor-widget-container
 *      and page.php does NOT print a title for Elementor pages (see README / report).
 *
 * Elementor's generated CSS (kit + per-page) sets the text widget to the kit font and grey text colour,
 * so the text-editor rules in section C use !important, only inside body.pt-legal.
 *
 * Units: tokens.css --ms (mobile, font/controls), --d (desktop, capped at 1px at 1440px), --gutter.
 * Reading column: 860px, matching the 800-900px target and the approved article text.
 */

body.pt-legal {
	--lg-read: 860px;
	--lg-ink: rgba(24, 24, 24, 0.88);
	--lg-body: max(16px, calc(17 * var(--ms)));
	--lg-gap: calc(18 * var(--ms));
	--lg-pad-top: calc(24 * var(--ms));
	--lg-pad-bottom: calc(56 * var(--ms));
}

@media (min-width: 768px) {
	body.pt-legal {
		--lg-body: max(16px, calc(19 * var(--d)));
		--lg-gap: calc(22 * var(--d));
		--lg-pad-top: calc(56 * var(--d));
		--lg-pad-bottom: calc(96 * var(--d));
	}
}

/* =====================================================================
 * A. Page frame + title (Gutenberg page; the .container is the page.php wrapper)
 * =================================================================== */
body.pt-legal .site-main > article {
	padding-block: var(--lg-pad-top) var(--lg-pad-bottom);
	background: var(--color-bg);
}

/* Elementor pages carry their own top padding (section C) and end with the dark banner: no extra article padding,
 * and the footer's global margin-top (--section-gap, 120px) is removed here so the banner meets the footer.
 * Scoped to pages whose content is an Elementor document. */
body.pt-legal .site-main > article:has(> .entry-content > .elementor) {
	padding-block: 0;
}

body.pt-legal:has(.entry-content > .elementor) .site-footer {
	margin-top: 0;
}

body.pt-legal .site-main > article > .container {
	width: min(100% - 2 * var(--gutter), var(--lg-read));
}

body.pt-legal .site-main .entry-title {
	margin: 0 0 calc(32 * var(--ms));
	color: var(--color-text-body);
	font-family: var(--font-sans);
	font-size: max(30px, calc(34 * var(--ms)));
	font-weight: var(--fw-medium);
	line-height: 1.1;
	letter-spacing: var(--ls-tight);
	overflow-wrap: anywhere;
}

@media (min-width: 768px) {
	body.pt-legal .site-main .entry-title {
		margin-bottom: calc(48 * var(--d));
		font-size: max(32px, calc(56 * var(--d)));
	}
}

/* =====================================================================
 * B. Shared prose (Gutenberg .entry-content and the Elementor text widget)
 * =================================================================== */
body.pt-legal .entry-content {
	color: var(--lg-ink);
	font-family: var(--font-sans);
	font-size: var(--lg-body);
	line-height: 1.65;
	letter-spacing: -0.01em;
	overflow-wrap: break-word;
}

body.pt-legal .entry-content p {
	margin: 0 0 var(--lg-gap);
	font-size: inherit;
	line-height: inherit;
}

body.pt-legal .entry-content p:last-child {
	margin-bottom: 0;
}

/* Headings (when the author uses real heading blocks / tags). */
body.pt-legal .entry-content :is(h2, h3, h4, h5, h6):not(.elementor-heading-title) {
	margin: calc(40 * var(--ms)) 0 calc(12 * var(--ms));
	color: var(--color-text-body);
	font-family: var(--font-sans);
	font-weight: var(--fw-medium);
	line-height: 1.2;
	letter-spacing: var(--ls-tight);
	overflow-wrap: anywhere;
}

body.pt-legal .entry-content h2:not(.elementor-heading-title) { font-size: max(24px, calc(28 * var(--ms))); }
body.pt-legal .entry-content h3:not(.elementor-heading-title) { font-size: max(20px, calc(22 * var(--ms))); }
body.pt-legal .entry-content h4:not(.elementor-heading-title) { font-size: max(18px, calc(19 * var(--ms))); }
body.pt-legal .entry-content :is(h5, h6):not(.elementor-heading-title) { font-size: var(--lg-body); }

body.pt-legal .entry-content > :first-child {
	margin-top: 0;
}

@media (min-width: 768px) {
	body.pt-legal .entry-content :is(h2, h3, h4, h5, h6):not(.elementor-heading-title) {
		margin: calc(56 * var(--d)) 0 calc(16 * var(--d));
	}

	body.pt-legal .entry-content h2:not(.elementor-heading-title) { font-size: max(24px, calc(36 * var(--d))); }
	body.pt-legal .entry-content h3:not(.elementor-heading-title) { font-size: max(20px, calc(28 * var(--d))); }
	body.pt-legal .entry-content h4:not(.elementor-heading-title) { font-size: max(18px, calc(22 * var(--d))); }
}

/* Links + hover. Long URLs and e-mail addresses wrap instead of overflowing. */
body.pt-legal .entry-content a {
	color: var(--color-action);
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.18em;
	overflow-wrap: anywhere;
}

body.pt-legal .entry-content a:hover {
	color: var(--color-text-brand);
}

body.pt-legal .entry-content a:focus-visible {
	outline: 2px solid var(--color-action);
	outline-offset: 2px;
}

body.pt-legal .entry-content strong,
body.pt-legal .entry-content b {
	color: var(--color-text-body);
	font-weight: var(--fw-medium);
}

/* Lists keep indent and markers (also nested). */
body.pt-legal .entry-content ul,
body.pt-legal .entry-content ol {
	margin: 0 0 var(--lg-gap);
	padding-left: 1.4em;
}

body.pt-legal .entry-content ul { list-style: disc; }
body.pt-legal .entry-content ol { list-style: decimal; }

body.pt-legal .entry-content li {
	margin-block: 0.4em;
	padding-left: 0.2em;
	list-style: inherit;
}

body.pt-legal .entry-content li::marker {
	color: var(--color-action);
}

body.pt-legal .entry-content li > ul,
body.pt-legal .entry-content li > ol {
	margin-block: 0.4em 0;
}

body.pt-legal .entry-content li > ul { list-style: circle; }
body.pt-legal .entry-content li > ol { list-style: lower-alpha; }

/* Blockquotes. */
body.pt-legal .entry-content blockquote {
	margin: 0 0 var(--lg-gap);
	padding: calc(4 * var(--ms)) 0 calc(4 * var(--ms)) calc(20 * var(--ms));
	border-left: 3px solid var(--color-border-strong);
	color: var(--color-text-body);
}

body.pt-legal .entry-content blockquote p:last-child {
	margin-bottom: 0;
}

/* Tables: the table scrolls inside its own box on narrow screens, the page never does. */
body.pt-legal .entry-content table {
	display: block;
	width: 100%;
	max-width: 100%;
	margin: 0 0 var(--lg-gap);
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	border-collapse: collapse;
	border-spacing: 0;
	font-size: 0.9em;
	line-height: 1.45;
}

body.pt-legal .entry-content figure.wp-block-table {
	max-width: 100%;
	margin: 0 0 var(--lg-gap);
	overflow-x: auto;
}

body.pt-legal .entry-content figure.wp-block-table table {
	display: table;
	min-width: 480px;
	margin: 0;
}

body.pt-legal .entry-content th,
body.pt-legal .entry-content td {
	padding: calc(10 * var(--ms)) calc(14 * var(--ms));
	border: 1px solid var(--color-border-soft);
	text-align: left;
	vertical-align: top;
}

body.pt-legal .entry-content th {
	background: var(--color-surface-2);
	color: var(--color-text-body);
	font-weight: var(--fw-medium);
}

/* Separators, images, embeds never overflow the column. */
body.pt-legal .entry-content hr {
	height: 0;
	margin: calc(32 * var(--ms)) 0;
	border: 0;
	border-top: 1px solid var(--color-border-soft);
}

body.pt-legal .entry-content img,
body.pt-legal .entry-content iframe,
body.pt-legal .entry-content video {
	max-width: 100%;
	height: auto;
}

body.pt-legal .entry-content pre {
	max-width: 100%;
	overflow-x: auto;
}

/* =====================================================================
 * C. Elementor pages (Terms of use, Cookies Policy)
 *    Selectors are the real Elementor 3.35 container/widget classes (confirmed in the staging
 *    checkout markup: .elementor > .elementor-element.e-con.e-flex.e-con-boxed.e-parent > .e-con-inner
 *    > .elementor-widget). Only the first container, the one that holds the legal text widget, and
 *    the text widget are touched. The other Elementor containers (old logo/CTA blocks below the
 *    text) and every other widget are left exactly as built.
 * =================================================================== */
body.pt-legal .entry-content > .elementor > .e-con:first-child {
	--padding-top: var(--lg-pad-top);
	--padding-bottom: var(--lg-pad-bottom);
	--padding-left: 0px;
	--padding-right: 0px;
	padding-top: var(--lg-pad-top) !important;
	padding-bottom: var(--lg-pad-bottom) !important;
	padding-inline: 0 !important;
	background: var(--color-bg);
}

/* When the banners follow the text, the text container needs less bottom padding (the banner has its own top margin). */
body.pt-legal .entry-content > .elementor > .e-con:first-child:not(:only-child) {
	--padding-bottom: calc(24 * var(--ms));
	padding-bottom: calc(24 * var(--ms)) !important;
}

body.pt-legal .entry-content > .elementor > .e-con:first-child > .e-con-inner {
	max-width: 100% !important;
	width: 100% !important;
}

/* The text widget = the same reading column as the Privacy Policy page. */
body.pt-legal .elementor-widget-text-editor {
	width: min(100% - 2 * var(--gutter), var(--lg-read)) !important;
	max-width: var(--lg-read) !important;
	margin-inline: auto !important;
	margin-block: 0 !important;
	color: var(--lg-ink) !important;
	font-family: var(--font-sans) !important;
	font-size: var(--lg-body) !important;
	font-weight: var(--fw-regular) !important;
	line-height: 1.65 !important;
	letter-spacing: -0.01em;
	text-align: left !important;
}

body.pt-legal .elementor-widget-text-editor .elementor-widget-container {
	padding: 0 !important;
	color: inherit;
	font: inherit;
}

body.pt-legal .elementor-widget-text-editor p,
body.pt-legal .elementor-widget-text-editor li {
	color: inherit !important;
	font-family: inherit !important;
	font-size: inherit !important;
	line-height: inherit !important;
}

body.pt-legal .elementor-widget-text-editor p {
	margin: 0 0 var(--lg-gap) !important;
}

body.pt-legal .elementor-widget-text-editor p:last-child {
	margin-bottom: 0 !important;
}

body.pt-legal .elementor-widget-text-editor a {
	color: var(--color-action) !important;
}

body.pt-legal .elementor-widget-text-editor a:hover {
	color: var(--color-text-brand) !important;
}

body.pt-legal .elementor-widget-text-editor strong,
body.pt-legal .elementor-widget-text-editor b {
	color: var(--color-text-body) !important;
}

/* Elementor's own widget spacing must not add a gap under the text. */
body.pt-legal .elementor-widget-text-editor:not(:last-child) {
	--kit-widget-spacing: 0px;
	margin-bottom: 0 !important;
}

/* Elementor pages without any other wrapper overflow: legacy blocks never create a horizontal scrollbar. */
body.pt-legal .entry-content > .elementor {
	max-width: 100%;
	overflow-x: clip;
}

/* =====================================================================
 * D. Existing Elementor banners below the text (Terms of use, Cookies Policy). Kept, restyled only.
 *
 * Source: _elementor_data of both pages (staging DB dump). They are two independent COPIES (different
 * element IDs per page), not a shared Elementor template. Order inside .elementor: 1 legal text,
 * 2 light-blue brand block, 3 dark "Join the Research Community" block.
 *
 *                      Terms of use (2096)      Cookies Policy (2091)
 *   light container    6cb7f96                  518046b
 *     logo widget      50174fa                  e14406f           (NOT touched)
 *     description      cd8af0c                  9bc19b2
 *   dark container     1d8e92f                  4829d3a
 *     text column      4e71f26                  2470006
 *     heading / text   4b8f2c7 / e049291        6a06eb2 / f2fb672
 *     button           0a1d431                  af07e65
 *
 * Banner containers are matched by those IDs AND by content (the light one holds an image widget, the dark one a
 * button widget), so a re-saved page with new IDs still matches. Widgets inside are matched by widget CLASS and sibling order,
 * never by ID. The IDs are staging content IDs; the structure is from the data and must be confirmed in
 * DevTools (see the diagnostic snippet in the report).
 * !important overrides Elementor's per-element CSS (.elementor-NNN .elementor-element.elementor-element-ID ...).
 * ================================================================= */

/* ---- D1. Light-blue brand block: Inter, readable description, tighter spacing. ---- */
body.pt-legal :is(.elementor-element-6cb7f96, .elementor-element-518046b, .entry-content > .elementor > .e-con:has(.elementor-widget-image)) {
	--padding-top: calc(40 * var(--ms));
	--padding-bottom: calc(40 * var(--ms));
	--margin-top: calc(40 * var(--ms));
	padding-top: calc(40 * var(--ms)) !important;
	padding-bottom: calc(40 * var(--ms)) !important;
	margin-top: calc(40 * var(--ms)) !important;
}

/* Content stays vertically balanced inside the (kept) minimum height. */
body.pt-legal :is(.elementor-element-6cb7f96, .elementor-element-518046b, .entry-content > .elementor > .e-con:has(.elementor-widget-image)) > .e-con-inner {
	margin-block: auto;
}

/* One centreline: the column holding the logo centres its children, the logo box keeps its width (22% / 42%),
 * the description wrapper (data width 93.9%) is full width and centres its constrained text box. */
body.pt-legal :is(.elementor-element-6cb7f96, .elementor-element-518046b, .entry-content > .elementor > .e-con:has(.elementor-widget-image)) .e-con:has(> .elementor-widget-image) {
	align-items: center !important;
}

body.pt-legal :is(.elementor-element-6cb7f96, .elementor-element-518046b, .entry-content > .elementor > .e-con:has(.elementor-widget-image)) .elementor-widget-image {
	align-self: center !important;
	margin-inline: auto !important;
	text-align: center !important;
}

body.pt-legal :is(.elementor-element-6cb7f96, .elementor-element-518046b, .entry-content > .elementor > .e-con:has(.elementor-widget-image)) .e-con:has(> .e-con > .elementor-widget-heading) {
	justify-content: center !important;
	width: 100% !important;
}

body.pt-legal :is(.elementor-element-6cb7f96, .elementor-element-518046b, .entry-content > .elementor > .e-con:has(.elementor-widget-image)) .e-con:has(> .elementor-widget-heading) {
	width: min(100%, 640px) !important;
	margin-inline: auto !important;
}

body.pt-legal :is(.elementor-element-6cb7f96, .elementor-element-518046b, .entry-content > .elementor > .e-con:has(.elementor-widget-image)) .elementor-widget-heading {
	width: 100% !important;
	margin: 0 !important;
}

body.pt-legal :is(.elementor-element-6cb7f96, .elementor-element-518046b, .entry-content > .elementor > .e-con:has(.elementor-widget-image)) .elementor-widget-heading .elementor-heading-title {
	font-family: var(--font-sans) !important;
	font-size: max(16px, calc(18 * var(--d))) !important;
	font-weight: var(--fw-regular) !important;
	line-height: 1.5 !important;
	letter-spacing: -0.01em !important;
	color: var(--color-text-body) !important;
	text-align: center !important;
	overflow-wrap: break-word;
}

/* ---- D2. Dark "Join the Research Community" block: same typography as the approved Checkout banner. ---- */
/* Vertical position: Elementor sets the text column to align-self:flex-end with padding-top:127px on top of the
 * section's 50px, so the group sits low. The wrappers between the section and the column now fill its height and
 * the column centres itself with auto block margins (works for a row or a column parent), inside equal section
 * padding that keeps the group clear of the edges. Horizontal placement (align-self / width) is untouched. */
body.pt-legal :is(.elementor-element-1d8e92f, .elementor-element-4829d3a, .entry-content > .elementor > .e-con:has(.elementor-widget-button)) {
	--padding-top: calc(48 * var(--ms));
	--padding-bottom: calc(48 * var(--ms));
	padding-top: calc(48 * var(--ms)) !important;
	padding-bottom: calc(48 * var(--ms)) !important;
}

body.pt-legal :is(.elementor-element-1d8e92f, .elementor-element-4829d3a, .entry-content > .elementor > .e-con:has(.elementor-widget-button)) > .e-con-inner {
	flex-grow: 1 !important;
	align-self: stretch !important;
}

body.pt-legal :is(.elementor-element-1d8e92f, .elementor-element-4829d3a, .entry-content > .elementor > .e-con:has(.elementor-widget-button)) .e-con:has(.e-grid):not(:has(> .e-grid)) {
	flex-grow: 1 !important;
	align-self: stretch !important;
}

body.pt-legal :is(.elementor-element-4e71f26, .elementor-element-2470006, .entry-content > .elementor > .e-con:has(.elementor-widget-button) .e-con:has(> .e-grid)) {
	margin-block: auto !important;
	padding-top: 0 !important;
	padding-bottom: 0 !important;
}

body.pt-legal :is(.elementor-element-1d8e92f, .elementor-element-4829d3a, .entry-content > .elementor > .e-con:has(.elementor-widget-button)) .elementor-widget-heading,
body.pt-legal :is(.elementor-element-1d8e92f, .elementor-element-4829d3a, .entry-content > .elementor > .e-con:has(.elementor-widget-button)) .elementor-widget-button {
	margin: 0 !important;
	width: 100% !important;
	text-align: center !important;
}

body.pt-legal :is(.elementor-element-1d8e92f, .elementor-element-4829d3a, .entry-content > .elementor > .e-con:has(.elementor-widget-button)) .e-grid {
	gap: 0 !important;
	row-gap: 0 !important;
	justify-items: center;
}

/* Heading. */
body.pt-legal :is(.elementor-element-1d8e92f, .elementor-element-4829d3a, .entry-content > .elementor > .e-con:has(.elementor-widget-button)) .elementor-widget-heading .elementor-heading-title {
	font-family: var(--font-sans) !important;
	font-size: var(--fs-display-sm) !important;
	font-weight: var(--fw-medium) !important;
	line-height: 1.15 !important;
	letter-spacing: -0.035em !important;
	color: var(--color-on-action) !important;
	text-align: center !important;
	overflow-wrap: break-word;
}

/* Supporting description = the heading widget that directly follows the first one. 16px under the heading. */
body.pt-legal :is(.elementor-element-1d8e92f, .elementor-element-4829d3a, .entry-content > .elementor > .e-con:has(.elementor-widget-button)) .elementor-widget-heading + .elementor-widget-heading {
	margin-top: 16px !important;
}

body.pt-legal :is(.elementor-element-1d8e92f, .elementor-element-4829d3a, .entry-content > .elementor > .e-con:has(.elementor-widget-button)) .elementor-widget-heading + .elementor-widget-heading .elementor-heading-title {
	font-size: 16px !important;
	font-weight: var(--fw-regular) !important;
	line-height: 1.5 !important;
	letter-spacing: -0.01em !important;
	color: rgba(255, 255, 255, 0.85) !important;
}

/* Contact button: leaves Elementor's absolute offset, sits 24px under the description, auto-width outlined pill. */
body.pt-legal :is(.elementor-element-1d8e92f, .elementor-element-4829d3a, .entry-content > .elementor > .e-con:has(.elementor-widget-button)) .elementor-widget-button {
	position: relative !important;
	inset: auto !important;
	top: auto !important;
	left: auto !important;
	right: auto !important;
	width: auto !important;
	max-width: 100% !important;
	align-self: center !important;
	justify-self: center !important;
	margin: 24px auto 0 !important;
}

body.pt-legal :is(.elementor-element-1d8e92f, .elementor-element-4829d3a, .entry-content > .elementor > .e-con:has(.elementor-widget-button)) .elementor-button-wrapper {
	display: flex !important;
	justify-content: center !important;
	width: auto !important;
}

body.pt-legal :is(.elementor-element-1d8e92f, .elementor-element-4829d3a, .entry-content > .elementor > .e-con:has(.elementor-widget-button)) .elementor-widget-button .elementor-button {
	display: inline-flex !important;
	align-items: center !important;
	justify-content: center !important;
	flex: 0 0 auto !important;
	width: auto !important;
	min-width: 160px !important;
	min-height: 52px !important;
	padding: 14px 40px !important;
	border: 1px solid var(--color-on-action) !important;
	border-radius: var(--radius-pill) !important;
	background: transparent !important;
	color: var(--color-on-action) !important;
	font-family: var(--font-sans) !important;
	font-size: 16px !important;
	font-weight: var(--fw-medium) !important;
	line-height: 1.2 !important;
	text-decoration: none !important;
	transition: background-color 0.2s, color 0.2s !important;
}

body.pt-legal :is(.elementor-element-1d8e92f, .elementor-element-4829d3a, .entry-content > .elementor > .e-con:has(.elementor-widget-button)) .elementor-widget-button .elementor-button:hover {
	background: var(--color-on-action) !important;
	color: var(--color-action) !important;
}

body.pt-legal :is(.elementor-element-1d8e92f, .elementor-element-4829d3a, .entry-content > .elementor > .e-con:has(.elementor-widget-button)) .elementor-widget-button .elementor-button:focus-visible {
	outline: 2px solid var(--color-on-action);
	outline-offset: 3px;
}

/* ---- D3. Narrow screens ---- */
@media (max-width: 767px) {
	body.pt-legal :is(.elementor-element-6cb7f96, .elementor-element-518046b, .entry-content > .elementor > .e-con:has(.elementor-widget-image)) .elementor-widget-heading .elementor-heading-title {
		font-size: 16px !important;
	}

	/* The 42%-wide desktop text column would be ~160px on a phone: full width with the page gutters instead. */
	body.pt-legal :is(.elementor-element-1d8e92f, .elementor-element-4829d3a, .entry-content > .elementor > .e-con:has(.elementor-widget-button)) .e-con:has(> .e-grid) {
		width: 100% !important;
		padding-inline: var(--gutter) !important;
		align-self: stretch !important;
	}

	body.pt-legal :is(.elementor-element-1d8e92f, .elementor-element-4829d3a, .entry-content > .elementor > .e-con:has(.elementor-widget-button)) .elementor-widget-heading .elementor-heading-title {
		font-size: 28px !important;
	}

	body.pt-legal :is(.elementor-element-1d8e92f, .elementor-element-4829d3a, .entry-content > .elementor > .e-con:has(.elementor-widget-button)) .elementor-widget-heading + .elementor-widget-heading .elementor-heading-title {
		font-size: 14px !important;
	}
}
