/* ==========================================================================
   ebg elements - motion: shared keyframes and hover effects.

   Keyframes (use the name, do not redeclare per section):
   ebg-rise         opacity 0 + 24px below -> in place (translate). Entrance for
                    stacked content; stagger children 120ms (heroes h01 / h03).
   ebg-fade-up      opacity 0 + translateY(20px) -> in place (transform). ebg
                    wow fadeInUp; 1s.
   ebg-fade         opacity 0 -> 1. ebg wow fadeIn.
   ebg-pulse-ring   ring grows 0 -> 8px and fades; --ebg-pulse-ink (default
                    accent at 40%). Live dot, 1.5s linear infinite.
   ebg-gelatine     squash and stretch (ebg gelatine); 0.6s on an icon.
   ebg-line-redraw  1px background underline retracts to the end, then redraws
                    from the start (ebg linehover); 0.8s linear. Reads
                    --ebg-line-w (line width) and --ebg-line-start (start
                    offset, e.g. past an icon).

   ebg-affordance   border and shadow warm to --ebg-affordance-ink (default
                    accent) and back. "This can be clicked", 3.2s loop.
   ebg-breathe      scale 1 -> 1.1 and back, colour to accent. Icon inside a
                    waiting choice, 3.2s loop, in step with ebg-affordance.
   ebg-vt-out / ebg-vt-in   page cross-fade during a view transition.

   Utilities:
   .ebg-affordance      slow pulse on a choice that waits for a click (needs a
                        border). .ebg-breathe on its icon. Both only under
                        prefers-reduced-motion: no-preference.
   .ebg-morph-from      on a card's image: when the card's link is followed, the
   .ebg-morph-to        image grows into the next page's .ebg-morph-to element
                        (one per page: its hero image). Forward navigation only.
                        Needs page transitions on: theme mod ebg_view_transitions
                        (php/view-transitions.php) and js/ebg-morph.js. Without
                        them, or in a browser without cross-document view
                        transitions, pages load as usual. Tune --ebg-morph-radius.
   .ebg-line-hover      on a link or on a text span inside one: 1px underline
                        that redraws on hover / focus (header phone, links).
   .ebg-hover-gelatine  icon (i, svg) inside wobbles on hover / focus.
   .ebg-reveal-children on a group: each direct child rises 20px and fades in
                        when it scrolls into view, staggered 0/100/200/300ms
                        along a row of four (legacy e-Business.gr data-reveal).
                        Tune on the group: --ebg-reveal-from (start offset,
                        "0 20px"; "-40px 0" slides in from the start, ebg
                        fadeInLeft) and --ebg-reveal-step (100ms).
                        --ebg-reveal-turn adds a start rotation ("y -20deg" with
                        perspective on the group and transform-origin on the
                        children: ebg right-swipe).
                        ebg-reveal.js arms it, so without JS, in the editor and
                        under reduced motion everything simply shows. After the
                        rise the child gets .is-revealed and its own transitions
                        (hover lifts) apply again.
   Entrance animations stay inside @media (prefers-reduced-motion: no-preference)
   in the section CSS; the hover effects here switch off under reduce.
   ========================================================================== */

@layer components {

	@keyframes ebg-rise { from { opacity: 0; translate: 0 24px; } }

	@keyframes ebg-fade-up { from { opacity: 0; transform: translateY(20px); } }

	@keyframes ebg-fade { from { opacity: 0; } }

	@keyframes ebg-pulse-ring {
		from { box-shadow: 0 0 0 0 var(--ebg-pulse-ink, color-mix(in oklab, var(--ebg-accent) 40%, transparent)); }
		to { box-shadow: 0 0 0 8px transparent; }
	}

	@keyframes ebg-gelatine {
		from, to { transform: scale(1, 1); }
		25% { transform: scale(0.9, 1.1); }
		50% { transform: scale(1.1, 0.9); }
		75% { transform: scale(0.95, 1.05); }
	}

	@keyframes ebg-line-redraw {
		0% { background-position: right bottom; background-size: var(--ebg-line-w, 100%) 1px; }
		50% { background-position: right bottom; background-size: 0 1px; }
		50.01% { background-position: var(--ebg-line-start, 0px) bottom; background-size: 0 1px; }
		100% { background-position: var(--ebg-line-start, 0px) bottom; background-size: var(--ebg-line-w, 100%) 1px; }
	}

	@keyframes ebg-affordance {
		50% {
			border-color: color-mix(in oklab, var(--ebg-affordance-ink, var(--ebg-accent)) 38%, transparent);
			box-shadow: 0 4px 14px color-mix(in oklab, var(--ebg-affordance-ink, var(--ebg-accent)) 10%, transparent);
		}
	}

	@keyframes ebg-breathe {
		50% { scale: 1.1; color: var(--ebg-affordance-ink, var(--ebg-accent)); }
	}

	@keyframes ebg-vt-out { to { opacity: 0; } }

	@keyframes ebg-vt-in { from { opacity: 0; } }

	/* Page transitions. Inert until @view-transition is switched on (php/view-transitions.php). */
	.ebg-morph-to {
		view-transition-name: ebg-morph;
		view-transition-class: ebg-morph;
	}

	::view-transition-group(ebg-morph),
	::view-transition-group(.ebg-morph) {
		animation-duration: 0.35s;
		animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
		overflow: hidden;
		border-radius: var(--ebg-morph-radius, 12px);
	}

	::view-transition-old(ebg-morph),
	::view-transition-old(.ebg-morph) {
		animation: 0.35s cubic-bezier(0.16, 1, 0.3, 1) both ebg-vt-out;
		width: 100%;
		height: 100%;
		object-fit: cover;
	}

	::view-transition-new(ebg-morph),
	::view-transition-new(.ebg-morph) {
		animation: 0.35s cubic-bezier(0.16, 1, 0.3, 1) both ebg-vt-in;
		width: 100%;
		height: 100%;
		object-fit: cover;
	}

	::view-transition-old(root) {
		animation: 0.25s cubic-bezier(0.16, 1, 0.3, 1) both ebg-vt-out;
	}

	::view-transition-new(root) {
		animation: 0.25s cubic-bezier(0.16, 1, 0.3, 1) both ebg-vt-in;
	}

	.ebg-line-hover {
		padding-block-end: 3px;
		background: linear-gradient(currentColor, currentColor) right bottom / var(--ebg-line-w, 100%) 1px no-repeat;
		text-decoration: none;
	}

	@media (prefers-reduced-motion: no-preference) {
		:is(a, button):is(:hover, :focus-visible) .ebg-line-hover,
		a.ebg-line-hover:is(:hover, :focus-visible) { animation: ebg-line-redraw 0.8s linear; }

		.ebg-hover-gelatine:is(:hover, :focus-visible) :is(i, svg) { animation: ebg-gelatine 0.6s; }

		.ebg-affordance { animation: ebg-affordance 3.2s ease-in-out infinite; }

		.ebg-breathe { animation: ebg-breathe 3.2s ease-in-out infinite; }

		/* The transition sits on the in-view state only: arming hides at once (no
		   fade-out flash for cards already on screen), the reveal animates. */
		.ebg-reveal-children.is-armed > .is-inview:not(.is-revealed) {
			transition: opacity 0.4s var(--ease-snap, cubic-bezier(0.16, 1, 0.3, 1)), translate 0.4s var(--ease-snap, cubic-bezier(0.16, 1, 0.3, 1)), rotate 0.4s var(--ease-snap, cubic-bezier(0.16, 1, 0.3, 1));
			transition-delay: calc(var(--ebg-reveal-i, 0) * var(--ebg-reveal-step, 100ms));
		}

		.ebg-reveal-children.is-armed > :not(.is-inview) {
			opacity: 0.001;
			translate: var(--ebg-reveal-from, 0 20px);
			rotate: var(--ebg-reveal-turn, none);
		}
	}
}
