/**
 * Grid Background Animations (Bricks) – element + parent styles.
 *
 * The Grid Background element fills its parent as a background layer.
 * Parent / sibling rules use :where() (zero specificity) so anything set in
 * Bricks always wins. ".grid-bgb-parent" is the JS fallback for browsers
 * without :has().
 */

/* The element itself: a full-size layer that takes no layout space. */
.grid-bgb-element {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 0;
	overflow: hidden;
	pointer-events: none;
	z-index: 1;
}

.grid-bgb-element > .grid-bgb-layer {
	position: absolute;
	inset: 0;
	overflow: hidden;
	pointer-events: none;
}

.grid-bgb-element > .grid-bgb-layer canvas {
	display: block;
	width: 100% !important;
	height: 100% !important;
}

/* Parent: positioning context + clipping. */
:where(.grid-bgb-parent, :has(> .grid-bgb-element)) {
	position: relative;
	overflow: hidden;
}

/* Every other child of the parent sits in front of the animation. */
:where(.grid-bgb-parent, :has(> .grid-bgb-element)) > :where(:not(.grid-bgb-element):not(.bricks-background-video-wrapper)) {
	position: relative;
	z-index: 2;
}

/* Bricks background video stays at the very back. */
:where(.grid-bgb-parent, :has(> .grid-bgb-element)) > :where(.bricks-background-video-wrapper) {
	z-index: 0;
}

/* ------------------------------------------------------------------ */
/* Dropping Text Shapes                                                */
/* ------------------------------------------------------------------ */

/* The pills can be dragged, so this type takes pointer input. */
.grid-bgb-element.grid-bgb--drop-text-shapes {
	pointer-events: auto;
}

.grid-bgb-element > .grid-bg-dts-physics-bg {
	position: absolute;
	inset: 0;
	overflow: hidden;
	pointer-events: auto;
	/* Page scrolling stays on: touch is only taken while dragging a pill. */
}

/* Optional visible walls. */
.grid-bgb-dts-wall {
	position: absolute;
	z-index: 3;
	background-color: rgba(127, 127, 127, 0.35);
	pointer-events: none;
}

.grid-bgb-dts-wall--top,
.grid-bgb-dts-wall--bottom {
	left: 0;
	right: 0;
}

.grid-bgb-dts-wall--left,
.grid-bgb-dts-wall--right {
	top: 0;
	bottom: 0;
}

.grid-bgb-dts-wall--top { top: 0; }
.grid-bgb-dts-wall--bottom { bottom: 0; }
.grid-bgb-dts-wall--left { left: 0; }
.grid-bgb-dts-wall--right { right: 0; }

/* Content in front lets the drag reach the pills, except things people
   interact with (links, buttons, form fields). */
:where(.grid-bgb-parent--dts, :has(> .grid-bgb--drop-text-shapes)) > :where(:not(.grid-bgb-element):not(.bricks-background-video-wrapper)) {
	pointer-events: none;
}

:where(.grid-bgb-parent--dts, :has(> .grid-bgb--drop-text-shapes)) > :where(:not(.grid-bgb-element)) :where(a, button, input, textarea, select, label, [role="button"]) {
	pointer-events: auto;
}

/* Builder canvas: keep everything selectable / editable. */
body.grid-bgb-builder .grid-bgb-parent--dts > *,
body.grid-bgb-builder :has(> .grid-bgb--drop-text-shapes) > * {
	pointer-events: auto;
}

body.grid-bgb-builder .grid-bgb-element.grid-bgb--drop-text-shapes,
body.grid-bgb-builder .grid-bgb--drop-text-shapes .grid-bg-dts-physics-bg {
	pointer-events: none !important;
}

.grid-bg-dts-physics-elements {
	position: absolute;
	inset: 0;
	z-index: 2;
	display: flex;
	flex-wrap: wrap;
	align-content: flex-start;
	justify-content: center;
	gap: 14px;
	padding: 24px;
	box-sizing: border-box;
	pointer-events: none;
}

.grid-bg-dts-physics-element {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	white-space: nowrap;
	line-height: 1;
	font-weight: 700;
	padding: 10px 18px;
	border-radius: 999px;
	background: #ffffff;
	color: #111827;
	box-shadow: 0 14px 40px rgba(0, 0, 0, 0.22);
	opacity: 1;
	user-select: none;
	will-change: transform;
	pointer-events: none;
}

.grid-bg-dts-physics-element--icon {
	font-size: 24px;
}

.grid-bg-dts-physics-element--icon svg {
	width: 24px;
	height: 24px;
	fill: currentColor;
}

.grid-bg-dts-physics-bg[data-grid-bg-dts-state="bodies-created"] .grid-bg-dts-physics-elements,
.grid-bg-dts-physics-bg[data-grid-bg-dts-state="first-frame"] .grid-bg-dts-physics-elements,
.grid-bg-dts-physics-bg[data-grid-bg-dts-state="engine-started"] .grid-bg-dts-physics-elements {
	display: block;
	padding: 0;
}

.grid-bg-dts-physics-bg[data-grid-bg-dts-state^="error"] .grid-bg-dts-physics-elements {
	position: relative;
	inset: auto;
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	align-content: flex-start;
	justify-content: center;
	padding: 24px;
}

.grid-bg-dts-physics-bg[data-grid-bg-dts-state^="error"] .grid-bg-dts-physics-element {
	position: relative;
	left: auto !important;
	top: auto !important;
	transform: none !important;
	opacity: 1;
}

/* "Pause in builder": show the pills resting along the bottom, where they land. */
.grid-bg-dts-physics-bg[data-grid-bg-dts-state="paused"] .grid-bg-dts-physics-elements {
	align-content: flex-end;
}
