/*
 * Legal Policy pages — editorial reading layout.
 *
 * Loaded only on pages whose slug matches a registered policy (see
 * inc/legal-policy/bootstrap.php). The layout is a two-column grid:
 * a sticky table-of-contents rail next to a constrained body column.
 * On narrow viewports the rail collapses into a <details> at the top.
 *
 * All physical metrics use logical properties so the AR rendering
 * (default language) gets the correct mirroring for free.
 */

:where(.asi-policy) {
	--policy-fg: #0F172A;
	--policy-muted: #64748B;
	--policy-accent: #0155B7;
	--policy-rule: color-mix(in srgb, #0F172A 10%, transparent);
	--policy-rule-strong: color-mix(in srgb, #0F172A 18%, transparent);
	--policy-surface: #F8FAFC;
	--policy-toc-width: 18rem;
	--policy-gap: clamp(2rem, 5vw, 4rem);
	--policy-measure: 42rem;
}

/*
 * Width breakout — match the cart / category 1280px envelope.
 *
 * The page.html template wraps everything in an `is-layout-constrained`
 * <main>, which caps its non-aligned children at 768px. We can't use
 * `.alignwide` to opt out because a site-wide WPCode "Title Layout"
 * snippet styles `.is-layout-constrained > .alignwide` with
 * `text-align:center; font-size:40px; font-weight:600` — which inflates
 * every paragraph in the policy. Instead, on policy pages only, we
 * override the constrained-layout max-width on the post-content
 * container itself with a higher-specificity, body-scoped selector
 * (same pattern as the cart widening at custom.css line 17695+).
 */
html body.asi-policy-page main.wp-block-group.is-layout-constrained > .wp-block-post-content {
	max-width: 80rem;
}

/*
 * The post-content block ALSO has `is-layout-constrained`, which would
 * cap its non-aligned children at 768px again — clipping our .asi-policy
 * wrapper back inside the wider envelope we just opened up. Let it fill.
 */
html body.asi-policy-page .wp-block-post-content.is-layout-constrained > .asi-policy {
	max-width: none;
}

.asi-policy {
	color: var(--policy-fg);
	font-size: 1.0625rem;
	font-weight: 400;
	text-align: start;
	line-height: 1.75;
	margin-block: clamp(2rem, 6vw, 4rem);
	letter-spacing: -0.005em;
}

/* ── HEAD STRIP ────────────────────────────────────────────────── */

.asi-policy__head {
	border-block-end: 1px solid var(--policy-rule);
	padding-block-end: clamp(1.25rem, 3vw, 2rem);
	margin-block-end: clamp(2rem, 5vw, 3rem);
}

.asi-policy__kicker {
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--policy-muted);
	margin: 0 0 0.75rem;
}

.asi-policy__title {
	font-size: clamp(1.875rem, 3vw + 1rem, 3.25rem);
	font-weight: 600;
	line-height: 1.1;
	letter-spacing: -0.02em;
	margin: 0;
	color: var(--policy-fg);
}

.asi-policy__meta {
	color: var(--policy-muted);
	font-size: 0.875rem;
	margin: 1rem 0 0;
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem 1.5rem;
}

.asi-policy__meta span {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
}

.asi-policy__meta span + span::before {
	content: "";
	width: 4px;
	height: 4px;
	border-radius: 50%;
	background: var(--policy-rule-strong);
	margin-inline-end: 1rem;
	display: inline-block;
}

:lang(ar) .asi-policy__meta span + span::before {
	margin-inline-end: 0;
	margin-inline-start: 0;
}

/* ── LAYOUT GRID ───────────────────────────────────────────────── */

.asi-policy__layout {
	display: grid;
	gap: var(--policy-gap);
	grid-template-columns: 1fr;
	/*
	 * Intentionally NO `align-items: start`: we want each grid cell to
	 * stretch to the row's tallest sibling. Otherwise the TOC's grid cell
	 * collapses to the TOC's own height (~540px), and `position: sticky`
	 * on the TOC slides out of view long before the reader reaches the
	 * bottom of the (much taller) body article.
	 */
}

@media (min-width: 64rem) {
	.asi-policy__layout {
		grid-template-columns: var(--policy-toc-width) minmax(0, 1fr);
	}
}

/* ── TOC RAIL ──────────────────────────────────────────────────── */

.asi-policy__toc {
	font-size: 0.875rem;
}

@media (min-width: 64rem) {
	.asi-policy__toc {
		position: sticky;
		inset-block-start: 6rem;
		align-self: start;
		max-block-size: calc(100vh - 8rem);
		overflow-y: auto;
		padding-inline-end: 0.5rem;
	}
}

.asi-policy__toc summary {
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--policy-muted);
	cursor: pointer;
	list-style: none;
	padding-block: 0.5rem;
	border-block-end: 1px solid var(--policy-rule);
	margin-block-end: 1rem;
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.asi-policy__toc summary::-webkit-details-marker {
	display: none;
}

.asi-policy__toc summary::after {
	content: "+";
	font-size: 1.25rem;
	line-height: 1;
	color: var(--policy-muted);
	font-weight: 400;
}

.asi-policy__toc[open] summary::after,
@media (min-width: 64rem) {
	.asi-policy__toc summary::after {
		content: none;
	}
}

@media (min-width: 64rem) {
	.asi-policy__toc summary {
		pointer-events: none;
	}
}

.asi-policy__toc ol {
	list-style: none;
	padding: 0;
	margin: 0;
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
	counter-reset: none;
}

.asi-policy__toc li {
	margin: 0;
}

.asi-policy__toc a {
	display: flex;
	gap: 0.625rem;
	padding-block: 0.4rem;
	padding-inline: 0.75rem;
	color: var(--policy-fg);
	text-decoration: none;
	border-radius: 0.375rem;
	border-inline-start: 2px solid transparent;
	line-height: 1.4;
}

.asi-policy__toc a:hover,
.asi-policy__toc a:focus-visible {
	background: var(--policy-surface);
	color: var(--policy-accent);
	border-inline-start-color: var(--policy-rule-strong);
}

.asi-policy__toc-num {
	color: var(--policy-muted);
	font-variant-numeric: tabular-nums;
	font-weight: 500;
	flex-shrink: 0;
	min-inline-size: 1.75rem;
}

.asi-policy__toc a:hover .asi-policy__toc-num,
.asi-policy__toc a:focus-visible .asi-policy__toc-num {
	color: var(--policy-accent);
}

/* ── BODY COLUMN ───────────────────────────────────────────────── */

.asi-policy__body {
	max-inline-size: var(--policy-measure);
}

.asi-policy__section + .asi-policy__section {
	margin-block-start: clamp(2.5rem, 5vw, 3.5rem);
}

.asi-policy__section {
	scroll-margin-block-start: 5rem;
}

.asi-policy__section h2 {
	font-size: clamp(1.375rem, 1.5vw + 0.75rem, 1.75rem);
	font-weight: 600;
	line-height: 1.25;
	letter-spacing: -0.015em;
	margin: 0 0 1.25rem;
	color: var(--policy-fg);
	padding-block-start: 0.5rem;
}

.asi-policy__section h3 {
	font-size: 1.0625rem;
	font-weight: 600;
	line-height: 1.4;
	margin: 1.75rem 0 0.5rem;
	color: var(--policy-fg);
}

.asi-policy__section p {
	margin: 0 0 1rem;
	color: var(--policy-fg);
}

.asi-policy__section p:last-child {
	margin-block-end: 0;
}

.asi-policy__section ul {
	margin: 0.5rem 0 1.25rem;
	padding-inline-start: 1.25rem;
	list-style: none;
}

.asi-policy__section li {
	position: relative;
	margin: 0 0 0.5rem;
	padding-inline-start: 0.75rem;
}

.asi-policy__section li::before {
	content: "";
	position: absolute;
	inset-inline-start: -0.5rem;
	inset-block-start: 0.7em;
	inline-size: 4px;
	block-size: 4px;
	border-radius: 50%;
	background: var(--policy-accent);
}

.asi-policy__section li:last-child {
	margin-block-end: 0;
}

.asi-policy__section a {
	color: var(--policy-accent);
	text-decoration: underline;
	text-underline-offset: 3px;
	text-decoration-thickness: 1px;
}

.asi-policy__section a:hover {
	text-decoration-thickness: 2px;
}

.asi-policy__section strong {
	font-weight: 600;
}

/* Contact lines look nicer when emails / phones don't break mid-token. */
.asi-policy__contact {
	white-space: nowrap;
}

/* ── SIBLINGS / FOOTER ─────────────────────────────────────────── */

.asi-policy__siblings {
	margin-block-start: clamp(3rem, 8vw, 5rem);
	padding-block-start: clamp(1.5rem, 4vw, 2.5rem);
	border-block-start: 1px solid var(--policy-rule);
}

.asi-policy__siblings-label {
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--policy-muted);
	margin: 0 0 0.875rem;
}

.asi-policy__sibling-list {
	list-style: none;
	padding: 0;
	margin: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem 0.75rem;
}

.asi-policy__sibling-list li {
	margin: 0;
}

.asi-policy__sibling-list a {
	display: inline-block;
	padding: 0.5rem 0.875rem;
	border: 1px solid var(--policy-rule-strong);
	border-radius: 999px;
	color: var(--policy-fg);
	text-decoration: none;
	font-size: 0.9375rem;
	line-height: 1.2;
	transition: none;
}

.asi-policy__sibling-list a:hover,
.asi-policy__sibling-list a:focus-visible {
	border-color: var(--policy-accent);
	color: var(--policy-accent);
	background: var(--policy-surface);
}

.asi-policy__sibling-list a[aria-current="page"] {
	background: var(--policy-fg);
	color: #fff;
	border-color: var(--policy-fg);
}

/* ── AR / RTL TUNING ───────────────────────────────────────────── */

.asi-policy:lang(ar) {
	/* Tajawal needs a touch more line-height so the ascenders/descenders
	   don't crowd. Same trick used in cart-vault.css for AR surfaces. */
	line-height: 1.85;
}

.asi-policy:lang(ar) .asi-policy__title {
	letter-spacing: 0;
	line-height: 1.2;
}

.asi-policy:lang(ar) .asi-policy__section h2 {
	letter-spacing: 0;
}

/* ── PRINT ─────────────────────────────────────────────────────── */

@media print {
	.asi-policy__toc,
	.asi-policy__siblings {
		display: none;
	}

	.asi-policy__layout {
		grid-template-columns: 1fr;
	}

	.asi-policy__body {
		max-inline-size: none;
	}

	.asi-policy__title {
		font-size: 1.75rem;
	}
}
