/*
Theme Name:  BuddyX Child
Description: Child theme for BuddyX. Holds the MyGiftDreams template overrides (activity entry, member header) so they survive parent theme updates. Site-specific custom CSS can also go in this file.
Template:    buddyx
Version:     1.0.0
Text Domain: buddyx-child
*/

/* Site-specific CSS overrides go below this line. */

/*
 * Hide the Messages (envelope) icon in the header.
 *
 * Unlike the search icon there is no theme setting for this one: the parent
 * hard-codes <div class="bp-msg"> in template-parts/header/buddypress-profile.php:46
 * whenever bp_is_active('messages'), with no hook or theme_mod around it.
 * bp-better-messages only fills in the unread counter, it does not add the icon.
 *
 * The template part renders twice (mobile .buddyx-mobile-icon and desktop
 * .buddypress-icons-wrapper), both inside #masthead, so one rule covers both.
 * display:none also drops it from tab order and screen readers.
 */
.site-header .bp-msg {
	display: none;
}

/*
 * Log Out icon in the header icon row — markup comes from the
 * buddyx_site_menu_icon() override in functions.php.
 *
 * .buddypress-icons-wrapper is display:flex, so `order` parks the icon after
 * the avatar instead of before the bell, which is where the parent puts that
 * row. Two selectors because the desktop header wraps it in .desktop-icons
 * while the mobile header outputs .menu-icons-wrapper directly.
 * Drop the order rule to move the icon back in front of the bell.
 */
.buddypress-icons-wrapper > .desktop-icons,
.buddypress-icons-wrapper.buddyx-mobile-icon > .menu-icons-wrapper {
	order: 1;
}

.menu-icons-wrapper .buddyx-logout {
	position: relative;
	display: flex;
	align-items: center;
	margin: 0 10px;
}

/*
 * Header: raise the logo so the foot of the gift box sits level with the foot
 * of the "M" in the site title.
 *
 * Nothing about the title is touched — not its margins, not the flex alignment
 * of .site-branding — because every one of those changes the height of the
 * branding row, and the title is centred in that row, so it would move with it.
 * `transform` is the one way to shift the logo without reflowing anything: the
 * layout keeps the box exactly where the parent theme puts it, and only the
 * pixels move.
 *
 * Where 11.3px comes from, for whoever has to nudge it (all at the theme's
 * defaults: Open Sans, 16px/1.6 body, .site-title 38px/1.2, _header.css:75-82):
 *
 *   logo item     64px image + 6.6px of descender space under the inline <img>
 *                 = 70.6px, the tallest item, so it starts at the row's top
 *   artwork foot  64 - 64 x 22/250 = 58.4px down (the PNG keeps 22 of its 250
 *                 rows transparent below the artwork)
 *   title item    45.6px line box + 6px margin = 51.6px, centred in the 70.6px
 *                 row, so its baseline lands 9.5 + 37.5 = 47.0px down
 *   difference    58.4 - 47.0 = 11.3px, which is how far the logo hangs below
 *                 the "M" today
 *
 * The shift eats into the PNG's own 5.6px of transparent headroom, so the
 * artwork ends up flush with the top of the header rather than overflowing it.
 * Replace the logo, or change its height or the title's size, and this number
 * wants recomputing — it is the only one to touch.
 */
.site-branding {
	--mgd-logo-baseline-shift: 11.3px;
}

.site-branding .custom-logo {
	transform: translateY(calc(-1 * var(--mgd-logo-baseline-shift)));
}

/*
 * Mobile drawer: the member nav (Dream Gifts … Settings) appended to the primary
 * menu. Markup comes from buddyx_child_mobile_member_nav_items() in
 * functions.php; it lands inside #primary-menu, so the list styling, the
 * .5em/1em link padding and the hover background are all the parent's
 * (_navigation.css:256) and nothing here has to restate them.
 *
 * No media query and no desktop rule: the parent keeps
 * .main-navigation .buddyx-mobile-menu at display:none until 767px
 * (_navigation.css:75, :90), and the injection is scoped to the drawer's render
 * of the menu, so these items exist in exactly one place in the document.
 */
.buddyx-mobile-menu #primary-menu .mgd-member-menu-item > a {
	display: flex;
	align-items: center;
	justify-content: flex-start;
	gap: 14px;
	text-align: left;
}

.buddyx-mobile-menu #primary-menu .mgd-member-menu-item.current-menu-item > a {
	font-weight: 600;
}

/*
 * Counter pill. Deliberately the same shape and colour BuddyPress nav counts
 * get from the parent (buddypress.css:546) — same number, same badge, whether
 * the member reads it here or on their profile tabs.
 */
.buddyx-mobile-menu .mgd-menu-count {
	flex: 0 0 auto;
	min-width: 22px;
	padding: 2px 7px;
	border-radius: 100px;
	background-color: var(--color-theme-primary);
	color: #fff;
	font-size: 11px;
	font-weight: 600;
	line-height: 16px;
	letter-spacing: -0.26px;
	text-align: center;
}

/*
 * Following/Followers print their total even when it is nought — there the
 * number is a size, not an alert, so a zero must not wear the same badge an
 * unread message does.
 */
.buddyx-mobile-menu .mgd-menu-count--zero {
	background-color: rgba(0, 0, 0, .08);
	color: #6b6f76;
}

/*
 * Mobile: drop the profile tab column altogether. On one's own profile those
 * eight destinations live in the hamburger (see
 * buddyx_child_mobile_member_nav_items() in functions.php), and printing them
 * twice on a phone-width screen costs a scroll before any actual content
 * appears.
 *
 * 767px is deliberately the parent's own hamburger breakpoint
 * (_navigation.css:77): the column may only disappear where the drawer that
 * replaces it exists. Note the theme turns this nav into a 230px sidebar from
 * 749px up (buddypress.css:2966, user_nav_display=1 in bp_nouveau_appearance),
 * so between 749 and 767px the rule hides a sidebar rather than a pill row —
 * intended; #item-body is flex:1 and simply takes the freed width.
 *
 * Someone else's profile is covered by the same rule. That nav carries THAT
 * member's Gifts / Activity / Following / Followers and my-gifts-bp's "Back to
 * My Profile", none of which the drawer can hold — the drawer only ever lists
 * the logged-in user's own links — so until recently it was the only way
 * through and the rule was scoped to `body.my-account` to spare it. The two
 * links that matter now sit in the header itself, right under the action
 * buttons (buddyx_child_visited_member_nav() in functions.php), so the column
 * is redundant there too.
 *
 * display:none rather than visibility:hidden so the row is gone, not merely
 * invisible: #object-nav is a direct child of .bp-wrap, which is a plain
 * full-width block on a phone, so taking it out of flow closes the gap with no
 * further rule needed.
 *
 * The subnav (#subnav, inside #item-body) is untouched — Gift Box / Most
 * Wanted / Saved Gifts / Dreams Come True have no equivalent anywhere else.
 */
@media (max-width: 767px) {
	.member-home #object-nav {
		display: none;
	}
}

/*
 * Mobile header ("1b"): one 56px row.
 *
 *   [logo 34px] MyGiftDreams…  ..........  (members) (bell) (burger)
 *
 * .site-branding takes the free width (flex:1, min-width:0) and the name is
 * cut with an ellipsis before anything wraps, so 320-430px phones stay on one
 * line: 14 + 34 + 8 + name + 4 + 3 x 40 + 8 leaves the name ~132px at 320px,
 * and the title size scales so the full name fits in it (see .site-title).
 * The nav (icons + burger) keeps its natural width; the burger is last by the
 * parent's own order:2. Log Out left this row and is the last drawer item
 * (template-parts/header/navigation.php).
 *
 * The drawer is the parent's (custom.js: Esc, backdrop tap, focus moves in and
 * is trapped) restyled: 260px, from the right, 200ms. aria-expanded on the
 * burger is kept in sync by buddyx_child_mobile_header_a11y() in functions.php.
 */
@media (max-width: 767px) {
	/* --- The bar: white, 56px, 1px #eee rule, 14px / 8px side gutters. --- */
	.site-header-wrapper {
		padding-top: 0;
		padding-bottom: 0;
		min-height: 56px;
		background: #fff;
		border-bottom: 1px solid #eee;
		box-shadow: none;
	}

	.sticky-header .site-header-wrapper.has-sticky-header {
		box-shadow: none;
	}

	.site-header-wrapper > .container {
		width: 100%;
		max-width: none;
		padding-left: 14px;
		padding-right: 8px;
	}

	.site-header {
		flex-wrap: nowrap;
		height: 56px;
	}

	/* --- Brand: 34px logo, 8px gap, the name; the name gives way first. --- */
	.site-branding {
		--mgd-title-size: clamp(18px, 5.4vw, 22px);
		flex: 1;
		min-width: 0;
		gap: 8px;
	}

	.site-logo-wrapper {
		flex: 0 0 auto;
	}

	.site-logo-wrapper > a,
	.site-logo-wrapper .custom-logo-link {
		display: block;
		margin-right: 0;
	}

	.site-branding img,
	.site-branding .custom-logo {
		display: block;
		width: 34px;
		height: 34px;
		max-height: none;
		object-fit: contain;
		/*
		 * Foot of the gift on the title's baseline (the foot of the "M").
		 * Both items are centred in the row, so the shift is the gap between
		 * the two points measured from the common centre line:
		 *
		 *   logo   the PNG's last opaque row is 227 of 250, so the artwork
		 *          foot sits 34 x 228/250 = 31px down, 14px below centre
		 *   title  Open Sans (ascent 1.069em, descent 0.293em) in a 1.2em
		 *          line box puts the baseline 0.988em down, 0.388em below
		 *          centre
		 *
		 * shift = 0.388em - 14px: about -7px at 18px, -5.5px at 22px (up).
		 * It follows the title size, so the two stay level at every width.
		 * Recompute if the logo image, its size or the title font changes.
		 */
		transform: translateY(calc(var(--mgd-title-size) * 0.388 - 14px));
	}

	.site-branding-inner {
		min-width: 0;
	}

	/*
	 * Font and colour stay the theme's (Open Sans 700). The size scales with the
	 * screen so the whole name fits beside the three 40px buttons: the theme's
	 * fixed 24px (38px above 480px) needs ~160px, more than a 320-375px phone
	 * leaves. "MyGiftDreams" is ~6.7em wide, so 5.4vw keeps it inside the room
	 * left at any width (18px = ~120px at 320px; capped at 22px). The ellipsis
	 * stays only as a safety net. !important beats the parent's
	 * `.site-title a { font-size: 24px !important }` (_navigation.css:984).
	 */
	.site-branding .site-title,
	.site-branding .site-title a {
		font-size: var(--mgd-title-size) !important;
		line-height: 1.2;
	}

	.site-branding .site-title {
		margin: 0;
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
	}

	.site-branding .site-description {
		display: none;
	}

	/* --- Right cluster: Members, bell, burger — 40px round buttons. --- */
	.main-navigation {
		flex: 0 0 auto;
		display: flex;
		align-items: center;
		margin-left: 4px;
	}

	.buddypress-icons-wrapper.buddyx-mobile-icon {
		margin-left: 0;
		float: none;
	}

	.buddyx-mobile-icon .mgd-members-icon,
	.buddyx-mobile-icon .user-notifications {
		margin: 0;
		padding: 0;
		height: auto;
	}

	.buddyx-mobile-icon .mgd-members-icon > .bp-icon-wrap,
	.buddyx-mobile-icon .user-notifications > .bp-icon-wrap,
	.nav--toggle-small .menu-toggle {
		position: relative;
		display: flex;
		align-items: center;
		justify-content: center;
		width: 40px;
		height: 40px;
		padding: 0 !important; /* parent: 10px !important */
		border-radius: 50%;
		background: transparent;
		line-height: 1 !important;
		transition: background-color .15s ease;
	}

	.buddyx-mobile-icon .mgd-members-icon > .bp-icon-wrap:hover,
	.buddyx-mobile-icon .user-notifications > .bp-icon-wrap:hover,
	.nav--toggle-small .menu-toggle:hover,
	.buddyx-mobile-icon .mgd-members-icon > .bp-icon-wrap:focus-visible,
	.buddyx-mobile-icon .user-notifications > .bp-icon-wrap:focus-visible,
	.nav--toggle-small .menu-toggle:focus-visible {
		background: #f2f2f4;
	}

	.buddyx-mobile-icon .mgd-members-icon .fa {
		font-size: 17px;
	}

	.buddyx-mobile-icon .user-notifications .fa-bell {
		font-size: 18px;
	}

	.nav--toggle-small .menu-toggle {
		order: 2; /* after the icons, at the right edge */
		float: none;
	}

	.nav--toggle-small .menu-toggle .fa {
		font-size: 20px;
		pointer-events: none; /* clicks land on the button, not the glyph */
	}

	/* Unread counter on the bell. */
	.buddypress-icons-wrapper.buddyx-mobile-icon .user-notifications sup.count {
		position: absolute;
		top: 4px;
		right: 3px;
		box-sizing: border-box;
		min-width: 16px;
		width: auto;
		height: 16px;
		padding: 0 3px;
		border: 2px solid #fff;
		border-radius: 8px;
		background: #ef4444;
		color: #fff;
		font-size: 10px;
		font-weight: 700;
		line-height: 12px;
		text-align: center;
		letter-spacing: 0;
	}

	/* --- Drawer: 260px from the right edge over a light backdrop. --- */
	.main-navigation .primary-menu-container {
		right: 0;
		left: auto;
		width: 260px;
		transition: transform .2s ease, opacity .2s ease, visibility .2s;
	}

	/*
	 * Only the closed state is restated. The parent opens the panel with
	 * `transform: none` on .mobile-menu-opened (_navigation.css:144) at the same
	 * specificity as its closed rule; :not() keeps this rule out of the open
	 * state and outweighs the parent's closed one.
	 */
	body:not(.mobile-menu-opened) .main-navigation .primary-menu-container {
		transform: translate3d(100%, 0, 0);
	}

	.mobile-menu-opened .main-navigation .primary-menu-container {
		transition: transform .2s ease;
	}

	/*
	 * Backdrop over the whole page, header included. The header wrapper is its
	 * own stacking context (z-index 9999), which would keep the bar bright
	 * above the backdrop; while the drawer is open it steps back to auto, so the
	 * drawer (9999) sits over the backdrop (9998) and both over everything else.
	 */
	.mobile-menu-close,
	.has-sticky-header .mobile-menu-close {
		z-index: 9998;
		background-color: rgba(0, 0, 0, .35);
	}

	body.mobile-menu-opened .site-header-wrapper {
		z-index: auto !important;
	}

	/* Drawer items: icon 18px #666, 14px gap, 15px/600 text, 13px 20px. */
	.main-navigation .buddyx-mobile-menu ul.menu {
		padding: 0;
		margin: 0;
	}

	.main-navigation .buddyx-mobile-menu ul.menu li a {
		display: flex;
		align-items: center;
		gap: 14px;
		padding: 13px 20px;
		border-radius: 0;
		font-size: 15px;
		font-weight: 600;
		text-align: left;
	}

	.main-navigation .buddyx-mobile-menu ul.menu li a:hover,
	.main-navigation .buddyx-mobile-menu ul.menu li a:focus-visible {
		background: #f5f5f7;
	}

	.buddyx-mobile-menu .mgd-menu-icon {
		flex: 0 0 18px;
		width: 18px;
		text-align: center;
		color: #666;
		font-size: 16px;
	}
}

/*
 * Members icon in the mobile header row — markup from
 * buddyx_child_members_menu_icon() in functions.php.
 *
 * Same spacing the parent gives the bell and the envelope
 * (_navigation.css:788), restated rather than shared because that rule lists its
 * three selectors literally and a child stylesheet cannot add a fourth to it.
 * Keep the two in step if the parent ever changes that block.
 *
 * No breakpoint here: the icon is only ever printed inside .buddyx-mobile-icon,
 * which the parent hides above 767px.
 */
.buddypress-icons-wrapper .mgd-members-icon {
	display: flex;
	align-items: center;
	height: 100%;
	margin: 0 10px;
	padding: 10px 0;
}

/*
 * Reclaim the avatar gutter in the profile header on phones.
 *
 * buddypress.css:2643 indents #item-header-content by 152px to clear the avatar
 * floated beside it, and platform.css only resets that to 0 inside
 * @media (min-width: 783px). Below 783px the avatar stops floating and is
 * centred above the content instead (platform.css:1249), so the indent goes on
 * reserving room for something that is no longer there — on a 390px phone it
 * leaves the name, the meta and the stats row about 205px to live in.
 *
 * That is what kept the Gifts / Followers / Following row from holding its
 * three counts on one line: they need ~288px. Dropping the indent hands the
 * header back the full width, so the row breaks only before Chip In.
 *
 * Scoped to .users-header: group headers carry their own 152px rule
 * (buddypress.css:3144) and their own layout, and are left alone.
 */
@media screen and (max-width: 782px) {
	#buddypress div#item-header.users-header #item-header-cover-image #item-header-content {
		margin-left:  0;
		padding-left: 0;
	}
}

/*
 * Visited member's Profile / Activity, under the header buttons — markup from
 * buddyx_child_visited_member_nav() in functions.php.
 *
 * Mobile only, and printed at every width so this one rule decides where the
 * cut is. Above 767px #object-nav is a visible row of tabs immediately under
 * this header, so repeating two of its entries here would only say the same
 * thing twice. Below it, that nav is the one thing the hamburger drawer does
 * not carry — the drawer lists the *logged-in* member's links (see the
 * body.my-account block above) — and on someone else's profile it sits at the
 * foot of the cover-image header, a whole screen of scrolling away.
 *
 * Centred because the buttons this sits under centre themselves below 782px
 * (platform.css:1323); left-aligning here would leave the two rows unaligned
 * on every phone.
 */
.mgd-visited-member-nav {
	display: none;
}

@media (max-width: 767px) {
	.mgd-visited-member-nav {
		display: block;
		margin-top: 10px;
	}

	/*
	 * Two equal columns, one row — the bottom half of the 2x2 block in
	 * wp-content/profile-header-2a.html. The gap matches the grid above it, and
	 * `margin-top: 10px` on the nav itself supplies the row gap between the two
	 * lists, which are separate elements and so cannot share one grid.
	 */
	/*
	 * #buddypress in front only to outweigh content.min.css's
	 * `.entry-content ul { margin-left: 1.05em }`, which loads after this file
	 * and would otherwise indent the pair out of line with the buttons above.
	 */
	#buddypress .mgd-visited-member-nav .mgd-visited-member-nav__list {
		display:               grid;
		grid-template-columns: 1fr 1fr;
		gap:                   var(--mgd-ph-gap, 10px);
		margin:                0;
		padding:               0;
		list-style:            none;
	}

	.mgd-visited-member-nav__item {
		margin: 0;
	}

	.mgd-visited-member-nav__item a {
		display:         flex;
		align-items:     center;
		justify-content: center;
		width:           100%;
		min-height:      48px;
		padding:         8px 12px;
		border:          1px solid var(--mgd-ph-border, rgba(0, 0, 0, .14));
		border-radius:   var(--mgd-ph-radius, 12px);
		background:      #fff;
		font-size:       14.5px;
		font-weight:     600;
		line-height:     1.2;
		color:           var(--mgd-ph-ink, #17150f);
		text-align:      center;
		text-decoration: none;
	}

	/*
	 * The mockup draws the current tab exactly like the other one, so the red
	 * outline this pair used to carry on the page you are already on is gone.
	 * Restore it by giving .is-current a back a border-color if that cue is
	 * wanted again.
	 */
	.mgd-visited-member-nav__item a:hover,
	.mgd-visited-member-nav__item a:focus {
		background: var(--mgd-ph-tint, #f5f3ee);
		color:      var(--mgd-ph-ink, #17150f);
	}
}

/*
 * Mobile: no Unfollow button in another member's profile header.
 *
 * buddypress-followers prints one button on the bp_member_header_actions hook
 * (bp-follow-hooks.php:134) and it is already skipped on your own profile, so
 * this only ever fires on someone else's. Only the Unfollow state goes — Follow
 * stays, or there would be no way to follow anyone from a phone.
 *
 * Unfollowing itself is not lost — it stays on the Following list, and on this
 * header at desktop width. What the phone gets back is the row: Public Message,
 * Private Message and Chip In already wrap onto two lines under the centred
 * buttons, and Unfollow was the entry pushing the visited member's Profile /
 * Activity links (.mgd-visited-member-nav, above) further down still.
 *
 * This rule is the viewport half of the job. A phone never receives the button
 * in the first place — buddyx_child_drop_profile_unfollow_on_mobile() in
 * functions.php drops it from the markup on wp_is_mobile() — but that reads the
 * user agent, which says nothing about how wide the window is. A narrow desktop
 * window, and the Customizer's Mobile preview (a 320px iframe, desktop UA),
 * reach only this rule. Keep the two in step if the breakpoint ever moves.
 *
 * No #buddypress in the selector and !important on the declarations: nothing in
 * the loaded stylesheets sets display here, so neither is needed against today's
 * CSS — they are here so the rule survives a page that skips BuddyPress's
 * theme-compat wrapper and an inline display left behind by bp-follow.js's
 * fadeIn, should this header ever gain the #item-buttons id that script binds
 * to.
 */
@media (max-width: 767px) {

	/*
	 * Keyed on the link, not on the wrapper's state class. In this site's
	 * Customizer preview the wrapper turned out to carry `follow-button` without
	 * the `following` half that bp-follow-templatetags.php:179 composes, so a
	 * rule written against `.follow-button.following` matched nothing while the
	 * button was plainly there. `unfollow` is the link's own class (same file,
	 * :160) and it is what actually distinguishes this button from Follow, whose
	 * link is `.follow` and which must stay reachable on a phone.
	 */
	.member-header-actions a.unfollow {
		display: none !important;
	}

	/*
	 * …and take the wrapper with it, so the flex row does not keep a gap where
	 * the button was. Its own rule because a browser without :has() must still
	 * apply the rule above rather than drop the whole selector list; the wrapper
	 * would then sit there empty, which the link rule already makes harmless.
	 */
	.member-header-actions .follow-button:has(a.unfollow) {
		display: none !important;
	}
}

/* =========================================================================
 * Mobile profile header — stats row, Chip In and the action buttons.
 *
 * Layout per the mockup in wp-content/profile-header-2a.html: the three counts
 * become a bordered three-column block with the number above an uppercase
 * label, Chip In becomes a full-width filled button under it, and the four
 * links below pair off into a 2x2 grid — Private Message filled, the rest
 * outlined. Appearance only: every element keeps its markup, its href and its
 * handler, so Chip In still opens bp-payment-info's dialog and the counts still
 * link to Gifts / Followers / Following.
 *
 * Mobile only. Above 767px all four blocks keep the inline, text-like look the
 * plugins give them, which is what the desktop header is built around.
 *
 * Where the pieces come from:
 *   .mgb-profile-stats        my-gifts-bp, mgb_render_profile_stats()
 *   .bppi-chipin              bp-payment-info, hooked into that row
 *   .member-header-actions    the header buttons (this theme's templates)
 *   .mgd-visited-member-nav   buddyx_child_visited_member_nav(), styled above
 * ========================================================================= */
@media (max-width: 767px) {

	/*
	 * The mockup's palette and metrics in one place. Declared on the header's
	 * content box so all four blocks — including the nav styled further up this
	 * file — inherit them.
	 *
	 * The two accents are the mockup's oklch() colours, each preceded by the
	 * sRGB hex it converts to, so a browser without oklch() support still gets
	 * the right red rather than no declaration at all.
	 */
	.users-header #item-header-content {
		--mgd-ph-ink:          #17150f;
		--mgd-ph-muted:        #6b655b;
		--mgd-ph-rule:         rgba(0, 0, 0, .08);
		--mgd-ph-rule-soft:    rgba(0, 0, 0, .06);
		--mgd-ph-border:       rgba(0, 0, 0, .14);
		--mgd-ph-tint:         #f5f3ee;
		--mgd-ph-cell-tint:    #faf9f6;
		--mgd-ph-accent:       #d55753;
		--mgd-ph-accent:       oklch(.62 .16 25);
		--mgd-ph-accent-hover: #bd413f;
		--mgd-ph-accent-hover: oklch(.55 .16 25);
		--mgd-ph-ink-hover:    #302b22;
		--mgd-ph-radius:       12px;
		--mgd-ph-gap:          10px;
	}

	/* ---- Gifts / Followers / Following ---------------------------------- */

	/*
	 * Three equal columns. The row's own children are the Gifts cell, a wrapper
	 * holding the other two, and Chip In; `display: contents` on that wrapper
	 * lets Followers and Following sit in this grid directly, so the three cells
	 * share one set of column tracks without the markup changing.
	 */
	.mgb-profile-stats {
		display:               grid;
		grid-template-columns: repeat(3, 1fr);
		gap:                   0;
		width:                 100%;
		margin-top:            20px;
	}

	.mgb-profile-follow-counts {
		display: contents;
	}

	/*
	 * The rules run along the cells rather than the container so that Chip In,
	 * which shares this grid, stays outside them — in the mockup the lines close
	 * over the counts and the button sits below, clear of both.
	 */
	.mgb-profile-stats .mgb-profile-gift-count,
	.mgb-profile-stats .mgb-profile-followers-count,
	.mgb-profile-stats .mgb-profile-following-count {
		display:       flex;
		align-items:   stretch;
		margin:        0;
		padding:       0;
		border-top:    1px solid var(--mgd-ph-rule);
		border-bottom: 1px solid var(--mgd-ph-rule);
		font-size:     inherit;
		line-height:   1.2;
	}

	.mgb-profile-stats .mgb-profile-gift-count,
	.mgb-profile-stats .mgb-profile-followers-count {
		border-right: 1px solid var(--mgd-ph-rule-soft);
	}

	/* The gift pictogram has no counterpart in the other two cells. */
	.mgb-profile-stats .mgb-profile-gift-icon {
		display: none;
	}

	/*
	 * column-reverse, because the markup is label-then-count
	 * (my-gifts-bp.php:1446) while the mockup stacks them count-first.
	 * Reversing the visual order of two siblings is what it is for; the DOM
	 * order, and so the reading order of "Gifts 13", is untouched.
	 */
	.mgb-profile-stats .mgb-profile-gift-link,
	.mgb-profile-stats .mgb-profile-followers-link,
	.mgb-profile-stats .mgb-profile-following-link {
		display:         flex;
		flex:            1;
		flex-direction:  column-reverse;
		align-items:     center;
		justify-content: center;
		gap:             2px;
		padding:         14px 4px;
		color:           inherit;
		text-decoration: none !important;
	}

	.mgb-profile-stats .mgb-profile-gift-link:hover,
	.mgb-profile-stats .mgb-profile-followers-link:hover,
	.mgb-profile-stats .mgb-profile-following-link:hover,
	.mgb-profile-stats .mgb-profile-gift-link:focus,
	.mgb-profile-stats .mgb-profile-followers-link:focus,
	.mgb-profile-stats .mgb-profile-following-link:focus {
		background:      var(--mgd-ph-cell-tint);
		text-decoration: none !important;
	}

	.mgb-profile-stats .mgb-profile-gift-number,
	.mgb-profile-stats .mgb-profile-followers-number,
	.mgb-profile-stats .mgb-profile-following-number {
		font-size:   20px;
		font-weight: 700;
		color:       var(--mgd-ph-ink);
	}

	.mgb-profile-stats .mgb-profile-gift-link strong,
	.mgb-profile-stats .mgb-profile-followers-link strong,
	.mgb-profile-stats .mgb-profile-following-link strong {
		font-size:      11.5px;
		font-weight:    500;
		letter-spacing: .06em;
		text-transform: uppercase;
		color:          var(--mgd-ph-muted);
	}

	/* ---- Chip In -------------------------------------------------------- */

	/*
	 * Second row of the same grid, all three columns wide. my-gifts-bp gives it
	 * `flex-basis: 100%` at this width for the same purpose under the old flex
	 * layout (my-gifts-bp.css:1621); that declaration is inert here.
	 *
	 * No `position` here: the dialog inside is absolutely positioned against
	 * .item-header-cover-image-wrapper, and giving this wrapper a position would
	 * make it the containing block instead and collapse the dialog onto the
	 * button.
	 */
	.mgb-profile-stats .bppi-chipin {
		display:     block;
		grid-column: 1 / -1;
		width:       100%;
		margin-top:  18px;
	}

	/*
	 * bp-payment-info deliberately strips this button back to a text link, with
	 * !important on every declaration, to survive BuddyX's blanket styling of
	 * buttons in the header (bp-payment-info.css:637-671). Reversing that needs
	 * the same weight plus one more class than its strongest selector
	 * (#buddypress #item-header-content .bppi-chipin-trigger), which is what
	 * .mgb-profile-stats adds.
	 */
	#buddypress #item-header-content .mgb-profile-stats .bppi-chipin-trigger {
		display:          flex;
		align-items:      center;
		justify-content:  center;
		gap:              10px;
		width:            100%;
		min-height:       52px;
		padding:          10px 16px !important;
		border:           0 !important;
		border-radius:    var(--mgd-ph-radius) !important;
		background:       var(--mgd-ph-accent) !important;
		background-color: var(--mgd-ph-accent) !important;
		color:            #fff !important;
		font-size:        16px !important;
		font-weight:      600 !important;
		line-height:      1.2 !important;
		text-align:       center;
	}

	#buddypress #item-header-content .mgb-profile-stats .bppi-chipin-trigger:hover,
	#buddypress #item-header-content .mgb-profile-stats .bppi-chipin-trigger:focus-visible {
		background:       var(--mgd-ph-accent-hover) !important;
		background-color: var(--mgd-ph-accent-hover) !important;
		color:            #fff !important;
	}

	/* The label's underline-on-hover belongs to the text-link look this replaces. */
	#buddypress #item-header-content .mgb-profile-stats .bppi-chipin-trigger:hover .bppi-chipin-trigger-label,
	#buddypress #item-header-content .mgb-profile-stats .bppi-chipin-trigger:focus-visible .bppi-chipin-trigger-label {
		text-decoration: none !important;
	}

	/*
	 * The mockup's leading "+" disc. A pseudo-element because the button's
	 * markup belongs to the plugin; it carries no information of its own, and
	 * the label beside it still reads "Chip In" to a screen reader.
	 */
	#buddypress #item-header-content .mgb-profile-stats .bppi-chipin-trigger::before {
		content:         "+";
		flex:            0 0 auto;
		display:         flex;
		align-items:     center;
		justify-content: center;
		width:           22px;
		height:          22px;
		border-radius:   50%;
		background:      rgba(255, 255, 255, .22);
		font-size:       15px;
		font-weight:     700;
		line-height:     1;
	}

	/* The gift artwork is what that disc replaces. */
	#buddypress #item-header-content .mgb-profile-stats .bppi-chipin-gift {
		display: none !important;
	}

	/*
	 * Owner viewing their own profile: the button is for checking their own
	 * payment details, not for giving — so it reads "Chip In details" and is an
	 * outline (no fill, no "+" disc) rather than the filled call to action.
	 */
	#buddypress #item-header-content .mgb-profile-stats .bppi-chipin--own .bppi-chipin-trigger,
	#buddypress #item-header-content .mgb-profile-stats .bppi-chipin--own .bppi-chipin-trigger:hover,
	#buddypress #item-header-content .mgb-profile-stats .bppi-chipin--own .bppi-chipin-trigger:focus-visible {
		background:       transparent !important;
		background-color: transparent !important;
		border:           1.5px solid #ccc !important;
		color:            #111 !important;
	}

	#buddypress #item-header-content .mgb-profile-stats .bppi-chipin--own .bppi-chipin-trigger::before {
		content: none;
		display: none;
	}

	#buddypress #item-header-content .mgb-profile-stats .bppi-chipin--own .bppi-chipin-trigger-label {
		display: none !important;
	}

	#buddypress #item-header-content .mgb-profile-stats .bppi-chipin--own .bppi-chipin-trigger-label--own {
		display: inline !important;
	}

	/* ---- Private Message / Public Message ------------------------------- */

	/*
	 * my-gifts-bp owns this row's looks (my-gifts-bp.css:43-124): a right-aligned
	 * flex line of small grey pills, laid down with !important on the layout and
	 * on every paint property of the links. So each declaration below that
	 * contests one of those carries !important back — the selectors here are
	 * already the stronger ones (two ids against that file's classes), but
	 * !important beats specificity outright and has to be answered in kind.
	 */
	#buddypress #item-header-content .member-header-actions-wrap {
		display: block;
		width:   100%;
	}

	/*
	 * Two columns, the top half of the 2x2 block. The row is a <ul> whose items
	 * are <li>s for the message buttons and a <div> for Follow — grid does not
	 * care which, so one rule lays out both.
	 */
	#buddypress #item-header-content .member-header-actions {
		display:               grid !important;
		grid-template-columns: 1fr 1fr;
		gap:                   var(--mgd-ph-gap);
		width:                 100%;
		margin:                var(--mgd-ph-gap) 0 0;
		padding:               0;
		list-style:            none;
	}

	#buddypress #item-header-content .member-header-actions > li,
	#buddypress #item-header-content .member-header-actions > .generic-button {
		display: block !important;
		width:   100%;
		margin:  0 !important;
	}

	/*
	 * Follow — shown when the viewer does not follow this member yet, and the
	 * one button in this row with no partner to pair with (Unfollow is dropped
	 * on mobile, further up this file), so it takes the full width.
	 */
	#buddypress #item-header-content .member-header-actions > .follow-button {
		grid-column: 1 / -1;
	}

	/*
	 * BuddyX styles every link inside a .generic-button as a filled pill, with
	 * !important on the radius (buddypress.css:171). Two ids and two classes
	 * outrank that selector; the radius still needs the same weight back.
	 */
	#buddypress #item-header-content .member-header-actions > li > a,
	#buddypress #item-header-content .member-header-actions > .generic-button > a {
		display:         flex;
		align-items:     center;
		justify-content: center;
		width:           100%;
		min-height:      50px;
		margin:          0 !important;
		padding:         8px 12px !important;
		border:          1px solid var(--mgd-ph-border) !important;
		border-radius:   var(--mgd-ph-radius) !important;
		background:      #fff !important;
		color:           var(--mgd-ph-ink) !important;
		font-size:       14.5px !important;
		font-weight:     600;
		line-height:     1.2 !important;
		text-align:      center;
		text-decoration: none !important;
	}

	#buddypress #item-header-content .member-header-actions > li > a:hover,
	#buddypress #item-header-content .member-header-actions > .generic-button > a:hover,
	#buddypress #item-header-content .member-header-actions > li > a:focus,
	#buddypress #item-header-content .member-header-actions > .generic-button > a:focus {
		border-color: var(--mgd-ph-border) !important;
		background:   var(--mgd-ph-tint) !important;
		color:        var(--mgd-ph-ink) !important;
	}

	/* Private Message is the one filled button of the four. */
	#buddypress #item-header-content .member-header-actions > #send-private-message > a {
		border-color: transparent !important;
		background:   var(--mgd-ph-ink) !important;
		color:        #fff !important;
	}

	#buddypress #item-header-content .member-header-actions > #send-private-message > a:hover,
	#buddypress #item-header-content .member-header-actions > #send-private-message > a:focus {
		border-color: transparent !important;
		background:   var(--mgd-ph-ink-hover) !important;
		color:        #fff !important;
	}
}

/*
 * Footer bottom bar: Copyright · Privacy Policy · Terms of Service, on one row.
 *
 * template-parts/footer/info.php gives .site-info two children — the copyright
 * inside a .container, and the two legal anchors, which
 * buddyx_child_append_terms_of_service_link() (functions.php) wraps in
 * .mgd-footer-legal so they have an element of their own. The .container is a
 * block with a fixed width per breakpoint (970/1170px, assets/css/_grid.css),
 * so the two children stack no matter how short the text is; turning .site-info
 * into a centred flex row and letting that .container shrink to its content is
 * what pulls them onto one line.
 *
 * The separator before the links is generated rather than printed, because
 * there is no element between the two children to hang it on — and being
 * generated, it is also what disappears cleanly when the row stacks on a phone.
 *
 * Scoped to .site-info so the .container override cannot leak: that class is
 * the theme's global grid wrapper, used on every page.
 */
.site-info {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 0.25em 0.75em;
	/* The parent sets `padding: 2em 0` and relied on the .container inside for
	 * side gutters; that container no longer spans the bar, so the gutters move
	 * here — same 15px the grid uses. */
	padding-left: 15px;
	padding-right: 15px;
}

.site-info > .container {
	width: auto;
	max-width: none;
	margin: 0;
	padding: 0;
}

.site-info .mgd-footer-legal {
	display: inline-flex;
	flex-wrap: nowrap;
	align-items: baseline;
	gap: 0.75em;
}

.site-info .mgd-footer-legal a {
	white-space: nowrap;
}

.site-info .mgd-footer-legal::before {
	content: "·";
}

.site-info .mgd-footer-legal::before,
.site-info .mgd-footer-legal-sep {
	opacity: 0.6;
}

/*
 * On a phone the three items do not fit across, and a wrapped row would leave
 * the links hanging under a leading separator. Stack them instead, which is
 * what the footer did before this rule anyway.
 */
@media (max-width: 767px) {
	.site-info {
		display: block;
	}

	.site-info .mgd-footer-legal {
		margin-top: 0.6em;
	}

	.site-info .mgd-footer-legal::before {
		content: none;
	}
}

/*
 * The users glyph in front of "Members" in the menu bar.
 *
 * Printed by buddyx_child_members_menu_item_icon() (functions.php) inside the
 * item's own <a>, so it inherits the link's colour and hover state and needs
 * nothing but spacing. The glyph sits slightly high against the label at the
 * theme's menu font size, hence the small nudge rather than a line-height rule
 * that would change the bar's height.
 */
.mgd-menu-item-icon {
	margin-right: 0.45em;
	font-size: 0.95em;
	position: relative;
	top: 1px;
}

/*
 * Better Messages: round avatars in the chat, the conversations list and the
 * on-site notices, like the rest of the site.
 *
 * All of them read this one variable. Its Customizer control (Avatars Roundness,
 * inc/customize.php:152) only offers 0-25px, too little to guarantee a circle at
 * any avatar size, and it would no longer have any effect while this rule is
 * here. html:root outranks the plugin's own :root declarations whatever the load
 * order, so nothing in the plugin has to change.
 */
html:root {
	--bm-avatar-radius: 50%;
}

/* =========================================================================
 * Mobile profile Activity feed (Personal / Following / Mentions) — frameless,
 * like the Dream Gifts vertical feed (my-gifts-bp .mgb-lb-post).
 *
 * The posts run edge to edge on white and are told apart only by the 8px grey
 * band the gift feed uses between its posts (.mgb-lb-post + .mgb-lb-post).
 * Photos — post photos, gift images, the wishlist collage — fill the full width
 * with no frame, the gift feed's grey letterbox behind uncropped images.
 *
 * Frames that stay, on purpose:
 *   - the "What's new" box             #bp-nouveau-activity-form
 *   - the "— Everything —" filter      #subnav-filters
 *   - the repost frame, whatever it holds (.bpal-repost-frame is never touched
 *     here, and every image rule below is scoped to the post's own
 *     .activity-content > child, so nothing inside a repost changes)
 *   - the ⋮ menu button                .bpal-post-menu-btn (not touched)
 *
 * Scope: body.bp-user.activity is the member profile's Activity tab and all its
 * subtabs; the site-wide /activity/ directory and the front page are untouched.
 * Desktop is untouched.
 * ========================================================================= */
@media (max-width: 767px) {

	/* The profile's white content card goes, so the feed can reach the screen
	   edges. Subnav, What's new and the filter keep their own frames and now
	   line up with the profile header card above. */
	body.bp-user.activity #buddypress #item-body {
		padding:       0;
		border:        0;
		border-radius: 0;
		background:    transparent;
		box-shadow:    none;
	}

	/* Bleed past .container's 15px side gutter to the screen edges. */
	body.bp-user.activity #buddypress #activity-stream {
		margin-left:  -15px;
		margin-right: -15px;
		background:   #fff;
	}

	/* One post = one plain white block; 8px grey band between posts. */
	body.bp-user.activity #buddypress #activity-stream .activity-list > li {
		margin:        0;
		border:        0;
		border-radius: 0 !important; /* theme sets var(--global-border-radius) !important */ 
		box-shadow:    none;
		background:    #fff;
	}

	body.bp-user.activity #buddypress #activity-stream .activity-list > li + li {
		border-top: 8px solid #f1f3f5; /* --mgb-gray-100, the gift feed's band */
	}

	/* The "Activity" label strip with its rule under it. */
	body.bp-user.activity #buddypress #activity-stream .activity-card-head {
		display: none;
	}

	body.bp-user.activity #buddypress #activity-stream .activity-item-head {
		padding: 12px 15px 10px;
	}

	/* Icon bar keeps the 15px text gutter instead of the old card's edge. */
	body.bp-user.activity #buddypress #activity-stream .bpal-actions {
		padding: 6px 15px 8px;
	}

	/* --- Post photo: full width, uncropped, gift-feed letterbox. --- */
	body.bp-user.activity #buddypress #activity-stream .activity-content > .bpal-activity-photo {
		width:         100%;
		margin:        10px 0 0;
		border-radius: 0;
		background:    rgba(77, 92, 109, .1);
	}

	/* --- Gift in the post: the card's frame goes, the image fills the width. --- */
	body.bp-user.activity #buddypress #activity-stream .activity-content > .bpal-gift-card {
		margin:        10px 0 0;
		border:        0;
		border-radius: 0;
		background:    transparent;
	}

	body.bp-user.activity #buddypress #activity-stream .activity-content > .bpal-gift-card .bpal-gift-img-wrap {
		width:         100%;
		margin:        0;
		border-radius: 0;
		background:    rgba(77, 92, 109, .1);
	}

	body.bp-user.activity #buddypress #activity-stream .activity-content > .bpal-activity-photo .bpal-activity-photo-img,
	body.bp-user.activity #buddypress #activity-stream .activity-content > .bpal-gift-card .bpal-gift-card-img {
		width:         100%;
		height:        auto;
		aspect-ratio:  auto;
		max-height:    60vh; /* as .mgb-lb-img */
		object-fit:    contain;
		border-radius: 0;
		background:    transparent;
	}

	body.bp-user.activity #buddypress #activity-stream .activity-content > .bpal-gift-card .bpal-gift-card-body {
		padding: 10px 15px 4px;
	}

	/* --- Wishlist: the collage fills the width, its text keeps the gutter. --- */
	body.bp-user.activity #buddypress #activity-stream .activity-content > .mwl-feed-card {
		width:  100%;
		margin: 10px 0 4px;
	}

	body.bp-user.activity #buddypress #activity-stream .activity-content > .mwl-feed-card .mwl-feed-media {
		border-radius: 0;
		box-shadow:    none;
	}

	body.bp-user.activity #buddypress #activity-stream .activity-content > .mwl-feed-card > :not(.mwl-feed-media) {
		margin-left:  15px;
		margin-right: 15px;
	}
}
