/**
 * BB Social Share - floating rail + inline rail
 *
 * Geometry and icon set follow Figma:
 * BuddyBoss-Website / node 1257:7316
 *
 *   container   padding 40px top, 8px sides, 8px bottom; column width 45px
 *   gap         12px
 *   button      48 x 48, radius 24px, 1px solid border token, no fill, no shadow
 *   icon        24 x 24 (envelope: 28px glyph clipped to 24px)
 *
 * COLOURS
 * Every colour in this file resolves through a theme.json preset token, mapped
 * once in the `.bb-share` custom-property block below. The literal after each
 * `var()` is only a fallback for contexts where global styles are not printed
 * (block editor iframe, mu-plugin on a classic theme) and mirrors the current
 * buddyboss-website palette. Change the palette in theme.json, not here.
 *
 * The only literals left in the plugin are the three brand marks (Facebook
 * blue, LinkedIn blue), which are brand assets rather than theme colour.
 */

.bb-share {
	/* Matches --wp--style--global--content-size on buddyboss-website. */
	--bb-share-content: var(--wp--style--global--content-size, 800px);
	--bb-share-gap-x: 40px;   /* space between the content column and the rail */
	--bb-share-size: 48px;
	--bb-share-col: 45px;     /* Figma inner column */
	--bb-share-gap: 12px;     /* Figma gap */

	/* --- theme tokens ------------------------------------------------- */
	--bb-share-fg: var(--wp--preset--color--contrast, #000000);
	--bb-share-bg: var(--wp--preset--color--base, #FFFFFF);
	--bb-share-border: var(--wp--preset--color--border, #E8E8E8);
	--bb-share-border-hover: var(--wp--preset--color--border-neutral, #B2B2B2);
	--bb-share-accent: var(--wp--preset--color--primary, #D7542E);
	--bb-share-accent-hover: var(--wp--preset--color--primary-hover, #FE724A);
	--bb-share-on-accent: var(--wp--preset--color--base, #FFFFFF);
	--bb-share-success: var(--wp--preset--color--success, #1E8E3E);
	--bb-share-toast-bg: var(--wp--preset--color--text-body, #2F2F2F);
	--bb-share-toast-fg: var(--wp--preset--color--base, #FFFFFF);

	position: fixed;
	top: 50%;
	left: max(8px, calc(50% - (var(--bb-share-content) / 2) - var(--bb-share-gap-x) - var(--bb-share-size)));
	transform: translateY(-50%);
	z-index: 90;

	display: flex;
	align-items: center;
	/* Figma container padding. */
	padding: 40px 8px 8px;
	margin: 0;

	opacity: 0;
	visibility: hidden;
	transition: opacity .25s ease, visibility .25s ease;
}

/* Revealed by JS once the reader is actually into the article. */
.bb-share.is-visible {
	opacity: 1;
	visibility: visible;
}

.bb-share .bb-share__list {
	list-style: none;
	margin: 0;
	padding: 0;
	width: var(--bb-share-col);
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: var(--bb-share-gap);
}

.bb-share .bb-share__item {
	margin: 0;
	padding: 0;
	list-style: none;
}

/*
 * The native-share control is a <button>, so it is the one node in the rail a
 * theme's generic button styles can reach. Everything a button inherits by
 * default is reset here, and the selector is kept at (0,2,0) so it outranks
 * `.entry-content button`-style rules without needing !important.
 */
.bb-share .bb-share__link {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	width: var(--bb-share-size);
	height: var(--bb-share-size);
	min-width: 0;
	min-height: 0;
	padding: 12px;               /* Figma: 12px around a 24px icon */
	margin: 0;
	border: 1px solid var(--bb-share-border);
	border-radius: 24px;         /* Figma radius */
	background: transparent;     /* Figma has no fill */
	box-shadow: none;            /* Figma has no shadow */
	color: var(--bb-share-fg);
	font: inherit;
	line-height: 0;
	cursor: pointer;
	text-decoration: none;
	transition: border-color .18s ease, transform .18s ease, background-color .18s ease, color .18s ease;
	-webkit-appearance: none;
	appearance: none;
}

/*
 * No hover state is specified in the Figma node, so this is deliberately
 * restrained: the border firms up and the button lifts 1px. Brand icon
 * colours are left untouched.
 */
.bb-share .bb-share__link:hover,
.bb-share .bb-share__link:focus-visible {
	border-color: var(--bb-share-border-hover);
	background: var(--bb-share-bg);
	transform: translateY(-1px);
	text-decoration: none;
	color: var(--bb-share-fg);
}

.bb-share .bb-share__link:focus-visible {
	outline: 2px solid var(--bb-share-accent);
	outline-offset: 2px;
}

/* Native share sheet: the one filled button, in the theme's primary colour. */
.bb-share .bb-share__link--native {
	background: var(--bb-share-accent);
	border-color: var(--bb-share-accent);
	color: var(--bb-share-on-accent);
}

.bb-share .bb-share__link--native:hover,
.bb-share .bb-share__link--native:focus-visible {
	background: var(--bb-share-accent-hover);
	border-color: var(--bb-share-accent-hover);
	color: var(--bb-share-on-accent);
}

.bb-share__icon {
	display: block;
	flex: none;
}

/* Envelope: 28px glyph in a 24px box with overflow clipped, per Figma. */
.bb-share__glyph {
	display: block;
	position: relative;
	width: 24px;
	height: 24px;
	overflow: hidden;
	flex: none;
}

.bb-share__glyph .bb-share__icon--lined {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
}

/* Copy-link tick swap. Only used if copy is re-enabled via the filter. */
.bb-share__icon-done {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	transform: scale(.7);
	transition: opacity .15s ease, transform .15s ease;
	pointer-events: none;
}

.bb-share__link.is-copied .bb-share__icon-done { opacity: 1; transform: scale(1); }
.bb-share__link.is-copied > .bb-share__icon:first-child { opacity: 0; }

.bb-share .bb-share__link.is-copied {
	background: var(--bb-share-success);
	border-color: var(--bb-share-success);
	color: var(--bb-share-on-accent);
}

.bb-share__toast {
	position: absolute;
	left: calc(100% + 6px);
	bottom: 8px;
	white-space: nowrap;
	font-family: var(--wp--preset--font-family--outfit, inherit);
	font-size: 12px;
	font-weight: 500;
	line-height: 1;
	padding: 7px 10px;
	border-radius: var(--wp--custom--radius--tag, 6px);
	background: var(--bb-share-toast-bg);
	color: var(--bb-share-toast-fg);
	opacity: 0;
	transform: translateX(-4px);
	transition: opacity .2s ease, transform .2s ease;
	pointer-events: none;
}

.bb-share.has-toast .bb-share__toast { opacity: 1; transform: translateX(0); }

/* ---------------------------------------------------------------------------
   Inline variant via [bb_social_share].
   Sits in the article's left column, so it keeps the vertical Figma stack
   rather than collapsing into a row like the floating rail's mobile pill.
   Selectors are (0,2,0)+ so they beat the media-query overrides below
   regardless of source order.
   --------------------------------------------------------------------------- */
.bb-share-inline .bb-share {
	position: static;
	top: auto;
	right: auto;
	bottom: auto;
	left: auto;
	transform: none;
	opacity: 1;
	visibility: visible;
	padding: 0;
	background: transparent;
	border: 0;
	border-radius: 0;
	box-shadow: none;
}

.bb-share-inline .bb-share .bb-share__list {
	flex-direction: column;
	align-items: flex-start;
	width: var(--bb-share-col);
	gap: var(--bb-share-gap);
}

.bb-share-inline .bb-share .bb-share__link:not(.bb-share__link--native) {
	border-color: var(--bb-share-border);
}

.bb-share-inline .bb-share__toast {
	left: calc(100% + 6px);
	right: auto;
	bottom: 8px;
}

/* ---------------------------------------------------------------------------
   Below this width there is no room beside the 800px content column for a
   48px rail plus a 40px gutter, so the FLOATING rail becomes a pill bar.
   800 + 2 * (40 + 48 + 8) = 992, plus breathing room.
   --------------------------------------------------------------------------- */
@media (max-width: 1100px) {
	.bb-share {
		top: auto;
		bottom: 16px;
		left: 50%;
		transform: translate(-50%, 0);
		padding: 6px;
		border-radius: 999px;
		background: var(--bb-share-bg);
		border: 1px solid var(--bb-share-border);
		box-shadow: 0 6px 24px rgba(16, 24, 40, .14);
	}

	.bb-share .bb-share__list {
		flex-direction: row;
		width: auto;
		gap: 6px;
	}

	.bb-share .bb-share__link { border-color: transparent; }
	.bb-share .bb-share__link--native { border-color: var(--bb-share-accent); }
	.bb-share .bb-share__link:hover,
	.bb-share .bb-share__link:focus-visible { transform: none; }

	.bb-share__toast {
		left: 50%;
		bottom: calc(100% + 10px);
		transform: translate(-50%, 4px);
	}
	.bb-share.has-toast .bb-share__toast { transform: translate(-50%, 0); }
}

/* On phones with a native share sheet, collapse to one button. */
@media (max-width: 600px) {
	.bb-share.has-native .bb-share__item:not(.bb-share__item--native) { display: none; }
	.bb-share.has-native .bb-share__item--native { display: block; }
}

@media (prefers-reduced-motion: reduce) {
	.bb-share, .bb-share__link, .bb-share__toast, .bb-share__icon-done { transition: none; }
	.bb-share .bb-share__link:hover { transform: none; }
}

@media print {
	.bb-share { display: none !important; }
}
