/*
 * Clickable Parent for Bricks: the clickable parent (stretched link) pattern.
 * Zero-specificity :where() wrappers keep every rule easy to override from the Bricks style panel.
 */

/* The parent: the boundary the stretched link fills. isolation keeps our z-index values inside the element. */
:where(.nl-cp) {
	position: relative;
	isolation: isolate;
	cursor: pointer;
}

/* The link: static, so its ::after looks past it and past any heading to the parent. */
.nl-cp [data-nl-cp-link] {
	position: static;
}

/* The stretched click area. */
.nl-cp [data-nl-cp-link]::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
}

/* Everything else that can be clicked stays above the overlay, unless "Cover other links and buttons" is ticked. */
:where(.nl-cp:not([data-nl-cp-cover="all"])) :where(a, button, input, select, textarea, summary, label, [role="button"], [role="link"], [tabindex]):where(:not([data-nl-cp-link])) {
	position: relative;
	z-index: 2;
}

/* A clickable parent inside another one keeps its own click area. */
:where(.nl-cp .nl-cp) {
	z-index: 2;
}

/* Keyboard focus: light up the whole parent, not just the link text. */
@supports selector(:has(a)) {
	.nl-cp:not([data-nl-cp-focus="link"]):has([data-nl-cp-link]:focus-visible) {
		outline: 2px solid var(--nl-cp-focus-color, currentColor);
		outline-offset: var(--nl-cp-focus-offset, 4px);
	}

	.nl-cp:not([data-nl-cp-focus="link"]) [data-nl-cp-link]:focus-visible {
		outline: none;
	}
}
