/**
 * Blog reactions (ported from Centry Engine; docs/blog-reactions.md).
 *
 * Every selector starts with `body`: the block sits inside the article, where Elementor's kit
 * styles every `button` and `h2` at the same specificity (`.elementor-kit-N button`). This
 * stylesheet loads after the kit's, so a tie goes to it.
 *
 * Loaded only on a page that renders the block. Every color and measure is a custom property
 * with a theme-token fallback, so the Elementor style controls have one thing to set and the
 * block inherits the site's palette when they set nothing.
 */

body .bnia-reactions {
	--bnia-reaction-direction: row;
	--bnia-reaction-align: flex-start;
	--bnia-reaction-gap: 0.75rem;
	--bnia-reaction-radius: 999px;
	--bnia-reaction-icon-size: 1.25rem;
	--bnia-reaction-bg: var(--bnia-color-surface, #fff);
	--bnia-reaction-bg-hover: var(--bnia-brand-50, #eef4fb);
	/* Brand-700 with white text: 11.47:1, so the selected state is the most legible one. */
	--bnia-reaction-bg-active: var(--bnia-color-primary, #163a66);
	--bnia-reaction-border: var(--bnia-color-border-strong, #cad5e2);
	--bnia-reaction-text: var(--bnia-color-text, #0f172b);
	--bnia-reaction-text-active: var(--bnia-color-on-dark, #fff);
	--bnia-reaction-count: var(--bnia-color-text-muted, #45556c);

	margin: 2.5rem 0 0;
	padding: 2rem;
	border: 1px solid var(--bnia-color-border, #e2e8f0);
	border-radius: var(--bnia-radius-xl, 0.75rem);
	background: var(--bnia-color-background, #f8fafc);
}

/* `!important`: the block sits inside the article, whose heading rules in main.css
 * (`:is(…, body.page:not(.elementor-page) .page-content) h2`) take the specificity of their
 * most specific selector and would size this as an article heading. */
body .bnia-reactions .bnia-reactions__title {
	margin: 0 0 0.5rem !important;
	font-size: var(--bnia-type-heading4-size, 1.125rem) !important;
	line-height: var(--bnia-type-heading4-leading, 1.3) !important;
}

body .bnia-reactions__lead {
	margin: 0 0 1rem;
	color: var(--bnia-reaction-count);
}

body .bnia-reactions__list {
	display: flex;
	flex-direction: var(--bnia-reaction-direction);
	flex-wrap: wrap;
	justify-content: var(--bnia-reaction-align);
	gap: var(--bnia-reaction-gap);
	margin-top: 1rem;
}

body .bnia-reaction {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	/* 44px tall at the default font size, so the target passes on a phone. */
	min-height: 2.75rem;
	padding: 0.5rem 1rem;
	border: 1px solid var(--bnia-reaction-border);
	border-radius: var(--bnia-reaction-radius);
	background: var(--bnia-reaction-bg);
	color: var(--bnia-reaction-text);
	font: inherit;
	line-height: 1.2;
	cursor: pointer;
	transition:
		background-color 120ms ease,
		border-color 120ms ease;
}

body .bnia-reaction:hover {
	background: var(--bnia-reaction-bg-hover);
}

body .bnia-reaction:focus-visible {
	outline: 2px solid var(--bnia-reaction-bg-active);
	outline-offset: 2px;
}

/*
 * The selected state is a color change and a border change and the label goes semibold.
 * Color alone would leave it indistinguishable to anyone who cannot see the difference,
 * and aria-pressed covers the screen reader but not the sighted reader who is color blind.
 */
body .bnia-reaction.is-selected {
	border-color: var(--bnia-reaction-bg-active);
	background: var(--bnia-reaction-bg-active);
	color: var(--bnia-reaction-text-active);
}

body .bnia-reaction.is-selected .bnia-reaction__label {
	font-weight: 600;
}

body .bnia-reaction.is-selected .bnia-reaction__count {
	color: inherit;
}

body .bnia-reaction__icon {
	font-size: var(--bnia-reaction-icon-size);
	line-height: 1;
}

body .bnia-reaction__count {
	color: var(--bnia-reaction-count);
	font-size: 0.875em;
	font-variant-numeric: tabular-nums;
}

/*
 * The description is read, not shown. Inside the pill it turned four buttons into four
 * paragraphs and lost the compact row the design calls for; as part of the button's content
 * it still reaches a screen reader, which is who the extra sentence was for.
 */
body .bnia-reaction__desc {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

body .bnia-reactions__thanks {
	margin: 1rem 0 0;
	color: var(--bnia-reaction-count);
}

body .bnia-reactions.has-error .bnia-reactions__thanks {
	color: var(--bnia-color-error, #c10007);
}

body .bnia-reactions.is-busy .bnia-reactions__list {
	opacity: 0.6;
	pointer-events: none;
}

body .bnia-reactions__cta {
	margin-top: 2rem;
	padding-top: 1rem;
	border-top: 1px solid var(--bnia-reaction-border);
}

body .bnia-reactions__cta-title {
	margin: 0 0 0.75rem;
	font-weight: 600;
}

body .bnia-reactions__cta-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem;
}

body .bnia-reactions__cta-link {
	display: inline-flex;
	align-items: center;
	min-height: 2.75rem;
	padding: 0.5rem 1.25rem;
	border: 1px solid var(--bnia-reaction-bg-active);
	border-radius: var(--bnia-reaction-radius);
	color: var(--bnia-reaction-text);
	text-decoration: none;
}

body .bnia-reactions__cta-link:hover,
body .bnia-reactions__cta-link:focus-visible {
	background: var(--bnia-reaction-bg-active);
	color: var(--bnia-reaction-text-active);
}

@media (prefers-reduced-motion: reduce) {
	body .bnia-reaction {
		transition: none;
	}
}
