/**
 * FVN Share Buttons — front end.
 *
 * Inherits the theme's --text / --border / --surface custom properties when
 * they exist, and falls back to sane values when they don't, so the plugin
 * looks right on this theme without being welded to it.
 */

.fvnsb {
	--fvnsb-gap: 8px;
	--fvnsb-fg: var(--text, #111);
	--fvnsb-line: var(--border, #e0e0e0);
	--fvnsb-surface: var(--surface, #fff);
	--fvnsb-brand: #4b5563;

	/* Native button colours — overridden in the dark-mode block below. */
	--fvnsb-native-bg: #111827;
	--fvnsb-native-fg: #ffffff;

	position: relative;
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: var(--fvnsb-gap);
	font-family: var(--font-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
}

.fvnsb--top { margin: 0 0 18px; }
.fvnsb--bottom { margin: 24px 0 8px; padding-top: 18px; border-top: 1px solid var(--fvnsb-line); }

.fvnsb__label {
	font-size: 13px;
	font-weight: 700;
	letter-spacing: .03em;
	text-transform: uppercase;
	color: var(--text-muted, #666);
	margin-right: 4px;
}

.fvnsb__list {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: var(--fvnsb-gap);
}

/* ── Buttons ───────────────────────────────────────── */
.fvnsb__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 7px;
	padding: 8px 14px;
	border: 1px solid transparent;
	background: var(--fvnsb-brand);
	color: #fff;
	font-family: inherit;
	font-size: 13.5px;
	font-weight: 600;
	line-height: 1;
	text-decoration: none;
	cursor: pointer;
	white-space: nowrap;
	transition: filter .18s, transform .18s, background .18s, color .18s;
	-webkit-appearance: none;
	appearance: none;
}

.fvnsb__btn:hover { filter: brightness(1.08); color: #fff; }
.fvnsb__btn:active { transform: translateY(1px); }
.fvnsb__btn:focus-visible {
	outline: 2px solid var(--accent, #2463d1);
	outline-offset: 2px;
}

.fvnsb__btn[hidden] { display: none !important; }

.fvnsb-icon {
	width: 17px;
	height: 17px;
	flex-shrink: 0;
	display: block;
}

/* ── Shapes ────────────────────────────────────────── */
.fvnsb--shape-pill    .fvnsb__btn { border-radius: 999px; }
.fvnsb--shape-rounded .fvnsb__btn { border-radius: 6px; }
.fvnsb--shape-square  .fvnsb__btn { border-radius: 0; }
.fvnsb--shape-circle  .fvnsb__btn { border-radius: 50%; }

/* ── Colour modes ──────────────────────────────────── */
.fvnsb--color-mono .fvnsb__btn {
	background: var(--fvnsb-fg);
	color: var(--fvnsb-surface);
}
.fvnsb--color-mono .fvnsb__btn:hover { opacity: .85; }

.fvnsb--color-outline .fvnsb__btn {
	background: transparent;
	color: var(--fvnsb-brand);
	border-color: currentColor;
}
.fvnsb--color-outline .fvnsb__btn:hover {
	background: var(--fvnsb-brand);
	color: #fff;
}

/* ── Label visibility ──────────────────────────────── */
.fvnsb--style-icon .fvnsb__text {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}
.fvnsb--style-icon .fvnsb__btn { padding: 10px; }
.fvnsb--style-icon.fvnsb--shape-circle .fvnsb__btn,
.fvnsb--style-icon.fvnsb--shape-pill .fvnsb__btn {
	width: 38px;
	height: 38px;
	padding: 0;
}

.fvnsb--style-label .fvnsb-icon { display: none; }

/* ── Native share takeover ─────────────────────────── */
/* When native mode is "replace" and the sheet is available, every fallback
   button is hidden and only the native one remains. */
.fvnsb--native-active .fvnsb__btn:not(.fvnsb__btn--native) { display: none; }

/* ── Native share button ───────────────────────────── */
/* Deliberately does NOT use the theme's --accent: that variable changes
   with the palette and can land on a light value in dark mode, which put
   white text on a white button. The pair below is always contrasting. */
.fvnsb__btn--native {
	background: var(--fvnsb-native-bg);
	color: var(--fvnsb-native-fg);
}

.fvnsb__btn--native:hover,
.fvnsb__btn--native:focus {
	color: var(--fvnsb-native-fg);
}

.fvnsb--color-outline .fvnsb__btn--native {
	background: transparent;
	color: var(--fvnsb-native-bg);
	border-color: currentColor;
}

.fvnsb--color-outline .fvnsb__btn--native:hover {
	background: var(--fvnsb-native-bg);
	color: var(--fvnsb-native-fg);
}

/* ── Count badge ───────────────────────────────────── */
.fvnsb__count {
	font-size: 13px;
	color: var(--text-muted, #666);
	margin-left: 2px;
	white-space: nowrap;
}
.fvnsb__count strong { color: var(--fvnsb-fg); }

/* ── Copy confirmation ─────────────────────────────── */
.fvnsb__btn.is-done { background: #16a34a; }

.fvnsb__toast {
	position: absolute;
	bottom: calc(100% + 6px);
	left: 0;
	background: #111;
	color: #fff;
	font-size: 12px;
	font-weight: 600;
	padding: 6px 12px;
	border-radius: 4px;
	opacity: 0;
	transform: translateY(4px);
	pointer-events: none;
	transition: opacity .2s, transform .2s;
	white-space: nowrap;
	z-index: 5;
}
.fvnsb__toast.is-visible { opacity: 1; transform: translateY(0); }

/* ── Sticky mobile bar ─────────────────────────────── */
.fvnsb--sticky {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 900;
	margin: 0;
	padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
	background: var(--fvnsb-surface);
	border-top: 1px solid var(--fvnsb-line);
	box-shadow: 0 -4px 18px rgba(0, 0, 0, .10);
	justify-content: center;
}

.fvnsb--sticky .fvnsb__list { width: 100%; justify-content: center; }
.fvnsb--sticky .fvnsb__label { display: none; }

/* The sticky bar is a phone affordance — hide it on wider screens. */
@media (min-width: 701px) {
	.fvnsb--sticky { display: none; }
}

@media (max-width: 700px) {
	.fvnsb--sticky ~ .site-footer { padding-bottom: 64px; }

	/* Icon-only on narrow screens keeps five buttons on one row. */
	.fvnsb--style-icon_label .fvnsb__btn { padding: 9px 12px; font-size: 13px; }
	.fvnsb--style-icon_label .fvnsb__text { display: none; }
	.fvnsb--style-icon_label.fvnsb--shape-circle .fvnsb__btn,
	.fvnsb--style-icon_label.fvnsb--shape-pill .fvnsb__btn {
		width: 40px;
		height: 40px;
		padding: 0;
	}
}

/* ── Dark mode ─────────────────────────────────────── */
/* The theme switches palettes two ways: a body.dark-mode class set by JS,
   and a prefers-color-scheme fallback that body.light-mode opts out of.
   Both are matched here so the buttons never drift out of step with the page.

   In dark mode the native button inverts to a light surface with dark text —
   still the highest-contrast element in the bar, which is what you want for
   the primary action. */

body.dark-mode .fvnsb {
	--fvnsb-native-bg: #f2f2f4;
	--fvnsb-native-fg: #111214;
}

@media (prefers-color-scheme: dark) {
	body:not(.light-mode) .fvnsb {
		--fvnsb-native-bg: #f2f2f4;
		--fvnsb-native-fg: #111214;
	}
}

/* Brand-coloured buttons keep white text in both modes: every brand colour
   in the registry is dark enough to carry it. */
body.dark-mode .fvnsb--color-brand .fvnsb__btn:not(.fvnsb__btn--native),
body.dark-mode .fvnsb--color-brand .fvnsb__btn:not(.fvnsb__btn--native):hover {
	color: #fff;
}

/* The X icon is black-on-black in dark mode — lift it to a visible surface. */
body.dark-mode .fvnsb--color-brand .fvnsb__btn--x {
	background: #2f2f2f;
}

@media (prefers-color-scheme: dark) {
	body:not(.light-mode) .fvnsb--color-brand .fvnsb__btn--x {
		background: #2f2f2f;
	}
}

/* Toast is near-black by default; flip it so it reads on a dark page. */
body.dark-mode .fvnsb__toast {
	background: #f2f2f4;
	color: #111214;
}

/* ── Print ─────────────────────────────────────────── */
@media print {
	.fvnsb { display: none !important; }
}

/* ── Reduced motion ────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
	.fvnsb__btn,
	.fvnsb__toast { transition: none; }
}
