/* ==========================================================================
   ebg elements - buttons. Block styles for core/button, picked by the client
   in the editor (Styles panel): is-style-ebg-pill | ebg-pill-dark | ebg-pill-outline
   | ebg-phone. Ported from ebg .tj-primary-btn: label slides up and is
   replaced by a copy rising from below; the arrow disc rotates -45deg -> 0.
   The label copy is a text-shadow, so the button text stays plain editable text.
   ebg clips its copy with a one-line overflow box; core/button has no inner
   span, so the offset (40px) must exceed the pill's half height (26px) + glyph.

   Blocksy draws a hover shadow on every .wp-element-button::before (absolute,
   opacity 0, blur, inherited background). These styles own both pseudo-elements:
   pills switch it off, the phone style resets it to carry the handset glyph.
   ========================================================================== */

@layer components {

	:is(.is-style-ebg-pill, .is-style-ebg-pill-dark, .is-style-ebg-pill-outline) .wp-block-button__link {
		--ebg-btn-bg: var(--ebg-accent);
		--ebg-btn-ink: #FFFFFF;
		--ebg-btn-disc: var(--ebg-surface-anchor);
		--ebg-btn-disc-ink: #FFFFFF;

		position: relative;
		display: inline-flex;
		align-items: center;
		gap: 10px;
		padding: 5px 5px 5px 25px;
		overflow: hidden;
		border: 0;
		border-radius: 50px;
		background: var(--ebg-btn-bg);
		color: transparent;
		font-family: inherit; /* Blocksy's button font var is a system stack outside content (header). */
		font-size: var(--fs-16);
		font-weight: 600;
		line-height: 1;
		text-decoration: none;
		text-shadow: 0 0 var(--ebg-btn-ink), 0 52px var(--ebg-btn-ink);
		transition: 0.4s ease-in-out;
		transition-property: background-color, border-color;
		@media (prefers-reduced-motion: no-preference) { transition-property: text-shadow, background-color, border-color; }

		&::before { content: none; }

		&::after {
			content: "\e916";
			display: inline-flex;
			flex: none;
			align-items: center;
			justify-content: center;
			inline-size: var(--ebg-btn-disc-size, 42px);
			block-size: var(--ebg-btn-disc-size, 42px);
			border-radius: 50%;
			background: var(--ebg-btn-disc);
			color: var(--ebg-btn-disc-ink);
			font-family: "ebg-icons";
			font-size: var(--fs-20);
			font-weight: normal;
			text-shadow: none;
			rotate: -45deg;
			@media (prefers-reduced-motion: no-preference) { transition: rotate 0.3s ease-in-out; }
		}

		&:hover,
		&:focus-visible {
			text-shadow: 0 -52px var(--ebg-btn-ink), 0 0 var(--ebg-btn-ink);
		}

		&:hover::after,
		&:focus-visible::after { rotate: 0deg; }
	}

	.is-style-ebg-pill-dark .wp-block-button__link {
		--ebg-btn-bg: var(--ebg-surface-anchor);
		--ebg-btn-disc: #FFFFFF;
		--ebg-btn-disc-ink: var(--ebg-surface-anchor);
	}

	.is-style-ebg-pill-outline .wp-block-button__link {
		--ebg-btn-bg: transparent;
		--ebg-btn-ink: var(--ebg-ink);

		border: 1px solid var(--ebg-border-strong, #C9D1D1);

		&:hover { border-color: var(--ebg-surface-anchor); }
	}

	/* Phone: handset glyph + number underlined by a 1px line (ebg .header-contact
	   .call-text::after). core/button has no span around the text, so the line is
	   a background sized to the text only: 100% minus icon box and gap. Hover
	   replays ebg-line-redraw (motion.css, ebg linehover). --ebg-phone-icon sets
	   the glyph size (header: --fs-17). */
	.is-style-ebg-phone .wp-block-button__link {
		--ebg-phone-icon: var(--fs-19);
		--ebg-phone-gap: 8px;
		--ebg-line-w: calc(100% - var(--ebg-phone-icon) - var(--ebg-phone-gap));
		--ebg-line-start: calc(var(--ebg-phone-icon) + var(--ebg-phone-gap));

		display: inline-flex;
		align-items: center;
		gap: var(--ebg-phone-gap);
		min-block-size: 0; /* buttons carry a 40px min height: the line sat 9px under the text */
		padding: 0 0 3px; /* line 3px under the line box (user, 2026-11-05; ebg: 1px) */
		border: 0;
		border-radius: 0;
		background: linear-gradient(currentColor, currentColor) right bottom / var(--ebg-line-w) 1px no-repeat;
		color: var(--ebg-ink);
		font-family: inherit;
		font-size: var(--fs-20);
		font-weight: 600;
		line-height: 1;
		text-decoration: none;
		transition: color 0.3s ease-in-out;

		&::before {
			content: "\e919";
			position: static;
			z-index: auto;
			display: inline-block;
			inline-size: var(--ebg-phone-icon);
			border-radius: 0;
			background: none;
			font-family: "ebg-icons";
			font-size: var(--ebg-phone-icon);
			font-weight: normal;
			text-align: center;
			opacity: 1;
			filter: none;
			transition: none;
		}

		&:is(:hover, :focus-visible) {
			color: var(--ebg-accent);
			@media (prefers-reduced-motion: no-preference) { animation: ebg-line-redraw 0.8s linear; }
		}
	}

	/* Text + arrow: ebg .text-btn ("Learn more" links in cards). Label slides
	   up and a copy rises (text-shadow, as the pills); the 30px dark disc turns
	   accent and its arrow rotates -45deg -> 0. The 30px disc sets the box
	   height, so a 30px shadow offset is clipped by overflow. Tune with
	   --ebg-btn-ink (label), --ebg-btn-disc, --ebg-btn-disc-hover. */
	.is-style-ebg-text-arrow .wp-block-button__link {
		--ebg-btn-ink: var(--ebg-heading-ink, var(--ebg-ink));
		--ebg-btn-disc: var(--ebg-surface-anchor);
		--ebg-btn-disc-hover: var(--ebg-accent);

		display: inline-flex;
		align-items: center;
		gap: 10px;
		min-block-size: 0;
		padding: 0;
		overflow: hidden;
		border: 0;
		border-radius: 0;
		background: none;
		color: transparent;
		font-family: inherit;
		font-size: var(--fs-16);
		font-weight: 600;
		line-height: 1;
		text-decoration: none;
		text-shadow: 0 0 var(--ebg-btn-ink), 0 30px var(--ebg-btn-ink);
		@media (prefers-reduced-motion: no-preference) { transition: text-shadow 0.4s ease-in-out; }

		&::before { content: none; }

		&::after {
			content: "\e916";
			display: inline-flex;
			flex: none;
			align-items: center;
			justify-content: center;
			inline-size: 30px;
			block-size: 30px;
			border-radius: 50%;
			background-color: var(--ebg-btn-disc);
			color: #FFFFFF;
			font-family: "ebg-icons";
			font-size: var(--fs-20);
			font-weight: normal;
			text-shadow: none;
			rotate: -45deg;
			transition: 0.3s ease-in-out;
			transition-property: background-color;
			@media (prefers-reduced-motion: no-preference) { transition-property: rotate, background-color; }
		}

		&:is(:hover, :focus-visible) {
			text-shadow: 0 -30px var(--ebg-btn-ink), 0 0 var(--ebg-btn-ink);

			&::after { rotate: 0deg; background-color: var(--ebg-btn-disc-hover); }
		}
	}

}
