/* -----------------------------------------------------------------------------
   Layout
   ----------------------------------------------------------------------------- */

/* Undo Bond's narrow width on BP pages so content uses full container width. */
@media (min-width: 992px) {
	.site-main .container {
		& .col-lg-8,
		& .narrow-width-block,
		& .page-content > *,
		& .search-header p > * {
			flex: 1 1 auto;
			width: 100%;
			max-width: 100%;
		}
	}
}

.bp-list {
	&::before,
	&::after {
		content: "";
		display: none;
	}
}

.bond-bp-layout {
	display: flex;
	flex-wrap: wrap;
	gap: 4.5rem;
	align-items: flex-start;
}

/* Mobile: sidebar toggle sits directly above group header (no vertical gap). */
@media (max-width: 991.98px) {
	.bond-bp-layout {
		display: block;
		gap: 0;
		overflow-x: clip;
	}

	.bond-bp-content {
		width: 100%;
		max-width: 100%;
		padding-top: 0 !important;
		overflow-x: clip;
	}

	/* BON-186: Compose emoji picker must not be clipped by the mobile layout shell. */
	body.messages .bond-bp-layout:has(.bp-compose-message),
	body.bp-user.messages .bond-bp-layout:has(.bp-compose-message) {
		overflow-x: visible;
	}

	body.messages .bond-bp-layout:has(.bp-compose-message) .bond-bp-content,
	body.bp-user.messages .bond-bp-layout:has(.bp-compose-message) .bond-bp-content {
		overflow-x: visible;
	}
}

/* Desktop (sidebar + content side-by-side): use padding on content instead of a large column gap. */
@media (min-width: 992px) {
	.bond-bp-layout {
		gap: 0;
	}

	/*
	 * No left padding on the content column: group/member cover headers must sit flush to the
	 * sidebar border (Figma). Inset lives on #buddypress children except #item-header.
	 * Exclude BuddyBoss hover cards (#profile-card, #group-card): they are fixed UI appended as
	 * direct children of #buddypress and must not receive this content inset (it doubled the
	 * card’s own padding and offset the avatar).
	 */
	.bond-bp-layout:not(.bond-bp-layout--no-sidebar) .bond-bp-content {
		padding-left: 0;
		padding-right: 48px;
	}

	.bond-bp-layout:not(.bond-bp-layout--no-sidebar) .bond-bp-content #buddypress > *:not(#item-header):not(#profile-card):not(#group-card) {
		padding-left: 48px;
		box-sizing: border-box;
	}
}

/*
 * Bootstrap clamps `.container` to 1140px at >=1200px.
 * On BuddyPress pages we use `.container.bond-bp-layout`; keep that canvas wide
 * at this breakpoint so mid-sized screens don’t “snap” narrower.
 */
@media (min-width: 1200px) {
	.site-main .container.bond-bp-layout {
		max-width: 1400px;
	}
}

/* Allow a wider BuddyPress/BuddyBoss canvas on large desktops only. */
@media (min-width: 1400px) {
	.site-main .container.bond-bp-layout {
		max-width: 1400px;
	}
}

.bond-bp-sidebar {
	flex: 0 0 auto;
	width: 100%;
	min-width: 0;
	min-height: 100%;
	align-self: stretch;
	padding: 2.5rem 1.25rem 1.5rem;
}

.bond-bp-content {
	flex: 1 1 0;
	min-width: 0;
	padding-top: 3rem;
	padding-bottom: 6rem;
}

@media (max-width: 991.98px) {
	/*
	 * Sidebar sits above content on mobile; cancel desktop stretch behavior to prevent
	 * the collapsed sidebar row from growing to the full page height.
	 */
	.bond-bp-sidebar {
		min-height: 0;
		align-self: auto;
	}
}

#bond-global-loading-overlay {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(255, 255, 255, 0.72);
	backdrop-filter: blur(2px);
	-webkit-backdrop-filter: blur(2px);
	pointer-events: auto;

	&[hidden] {
		display: none !important;
	}

	& .bond-global-loading-overlay__spinner {
		color: var(--color-bond-red-darker);
	}
}

body.bond-global-loading-is-active {
	cursor: progress;
}

/* Members-only template when used for BuddyPress/BuddyBoss content */
.members-only-content .entry-content {
	padding-top: 2rem;
}

@media (min-width: 992px) {
	.bond-bp-sidebar {
		width: 280px;
		flex-shrink: 0;
		border-right: 1px solid var(--color-border);
	}
}

@media (prefers-reduced-motion: reduce) {
	#bond-global-loading-overlay {
		& .spinner-border {
			animation-duration: 1.5s;
		}
	}
}
