/**
 * Global Link Hover Animation (SRD Site Suite -> General -> Links).
 *
 * SCOPE IS SUBSTITUTABLE. This file is written against the default scope
 *
 *     :where(main, article, .entry-content, .site-content, footer)   all links
 *     :where(main, article, .entry-content, .site-content)           content colour
 *     :where(footer)                                                 footer colour
 *
 * and those three strings are tokens, not selectors to edit in place. When a
 * site fills in Link Scope Selector / Footer Scope Selector, PHP substitutes
 * them throughout and serves the result inline; left blank, the file is served
 * as-is and stays browser-cacheable. Never write either string here meaning
 * anything else, and never hardcode a theme's own wrapper class — a plugin has
 * no way to know what a theme calls its content area, which is exactly why the
 * scope is a setting.
 *
 * The site's header and navigation are deliberately outside the default scope:
 * a hover underline on a nav item is a decision the theme has usually already
 * made, and overriding it from a plugin is the kind of surprise that gets a
 * plugin uninstalled. A site that wants it can say so in the setting.
 *
 * Styled buttons are excluded from every variant's :not() chain — .srd-btn
 * (the suite's own Button Design, inc/features/cta/) and .srd-slide__btn (a
 * slider button from the sibling srd-toolkit plugin, excluded to protect ITS
 * own colour controls from this trick, not because the suite styles it).
 * Without this, :where(...) contributes zero specificity, so a bare
 * a:not(...) at (0,2,2) silently wins over a single-class button rule like
 * .srd-btn--filled at (0,1,0) and overwrites its background — a real bug hit
 * in production, not a hypothetical.
 *
 * Any link carrying .srd-no-linkanim is out too, in a zero-specificity
 * :where(:not(.srd-no-linkanim)) rather than a bare :not(), so adding it
 * changed nothing about which rules these beat.
 *
 * Image links are excluded by :where(:not(:has(img))) on the end of the same
 * chain. Every variant measures the anchor's box, so <a><img></a> got a bar
 * under the image (always visible at rest on Goes out, comes in), and the base
 * rule's width: fit-content shrank a centred block-level image link onto the
 * left edge. Excluding the whole base rule rather than just the bar is what
 * fixes both. A link holding an image AND text is excluded as well — CSS
 * cannot test for text nodes. The guard sits inside :where() for two reasons:
 * it adds no specificity, so site CSS overriding these rules still wins; and a
 * browser without :has() drops only the :where() (those links go unanimated)
 * instead of invalidating the whole rule and taking the .srd-btn--text
 * selector beside it down too. The Link Icon selector in feature.php carries
 * the same guard.
 *
 * Buttons are not left without an animation, though — they get their OWN,
 * which is why every rule below carries a second selector:
 *
 *     body.srd-linkanim--<name> <scope> a<guards>,
 *     body.srd-btnanim--<name>  .srd-btn--text
 *
 * Two independent class families over one set of variant rules. srd-btnanim
 * comes from Button Design's own Button Hover Animation setting
 * (btn_hover_anim, resolved in PHP by srdss_cta_body_classes() — Inherit falls
 * back to the site-wide link_hover_anim there). So Link Hover Animation drives
 * <a>, Button Hover Animation drives buttons, and neither can silently move
 * the other.
 *
 * Only .srd-btn--text takes it: that style has no padding, background or
 * border, so the bar/gradient IS its underline. Filled and outline buttons
 * have chrome the animation would overwrite and are never targeted — that is
 * the production bug described above, and the reason the guard stays a plain
 * :not(.srd-btn) rather than trying to carve an exception out of it.
 *
 * A third family rides the same rules for the same reason:
 *
 *     .srd-post-meta.srd-postmetaanim--<name> a
 *
 * from Post Meta Hover Animation (Posts screen), resolved in PHP by
 * srdss_post_meta_anim_resolved() and printed on the [srdss_post_meta]
 * wrapper rather than <body> — it styles one element the shortcode renders.
 * Its links carry srd-no-linkanim, so the scoped family above never also
 * matches them and two animations cannot stack on one link.
 *
 * The button selector is deliberately unscoped — .srd-btn is a
 * general-purpose class placed anywhere, including surfaces the content and
 * footer scopes never cover.
 *
 * Every variant measures its bar against the anchor's box rather than against
 * the text: the sweep variants pin an ::after with left: 0 / right: 0, and the
 * gradient variants size a background to 100% of it. On an inline link that
 * box hugs the text and reads as an underline; on a block-level link (footer
 * and widget menus) the box is the whole column, so
 * the bar spans the column. Every animated variant therefore carries
 * width: fit-content to shrink-wrap the box back onto the text — Fade in
 * included: text-decoration tracks the text on its own, but not when the
 * anchor wraps its label in a block-level child, which the decoration is then
 * drawn across in full.
 *
 * Any overhang left after that is the link's own horizontal padding: both
 * mechanisms measure the padding box, so padding widens the bar by the same
 * amount at each end. There is nothing generic to do about that here.
 *
 * fit-content rather than display: inline-block deliberately — width does not
 * apply to non-replaced inline elements, so this is a no-op on ordinary
 * paragraph links, which must keep breaking mid-link. inline-block would make
 * every content link an atomic box that can no longer wrap, pushing a long
 * link onto its own line (or overflowing the container), which is a far worse
 * regression than the bar it fixes.
 *
 * Known limit: a shrink-wrapped block box sits at the inline start of its
 * container regardless of text-align, so a centred or right-aligned menu
 * built from block-level links will left-align under any animated variant.
 * The escape is margin-inline: auto in site CSS; there is no CSS way to
 * shrink-wrap a block box and keep it aligned by text-align.
 *
 * Underline Thickness / Underline Offset (SRD Site Suite -> General) arrive as
 * --srd-linkanim-thickness / --srd-linkanim-offset, emitted on :root by
 * srdss_dynamic_css(). Each variant expresses them through whatever property
 * its own mechanism already has: background-size on the gradient variants,
 * text-decoration-thickness + text-underline-offset on Fade in (the one
 * variant with a native property for both), height + bottom on the four
 * sweep variants. Blank keeps each variant's previous value, so a site that
 * never touches these settings renders exactly as before.
 *
 * The gradient variants have no offset property of their own — the gradient
 * is positioned against the padding box, and pushing it below that box with
 * calc() would just be clipped at the border box. The offset is therefore
 * spent as padding-bottom, which on an inline box paints lower without
 * changing line height (it does enlarge the hover target by the same amount).
 * This works only because the unit sanitizer rejects negatives: offset is
 * always >= 0, which keeps padding-bottom valid and keeps the sweep
 * variants' bottom: calc(-1 * …) pointing downward.
 *
 * Fade in measures its offset from the font's own underline position rather
 * than from the bottom of the box, so the same value sits a little higher
 * there than on the other variants. That is what text-underline-offset is
 * defined to do, not a discrepancy to correct.
 */

/* Underline Color (SRD Site Suite -> General -> Content / Footer Underline Color)
   is resolved per scope here rather than by splitting the selector list below
   in two: each scope sets --srd-linkanim-color once and every variant reads
   it. Nesting needs no care — the two scopes resolve by inheritance, so
   whichever is closest to the link wins regardless of source order, and a
   currentColor fallback stays a token until the link uses it, which is what
   keeps "blank" meaning each link's own color rather than one fixed color. */
:where(main, article, .entry-content, .site-content) {
	--srd-linkanim-color: var(--srd-linkanim-color-content, currentColor);
}

:where(footer) {
	--srd-linkanim-color: var(--srd-linkanim-color-footer, currentColor);
}

/* Third scope, same mechanism: a text button sets the variable on ITSELF, so
   it wins over whichever of the two scopes above it happens to sit inside
   (a declaration on the element always beats an inherited one, no matter the
   source order). That is what keeps Button Underline Color independent of
   the Content/Footer colors rather than depending on where the button was
   placed. Blank falls through to currentColor exactly as they do. */
.srd-btn--text {
	--srd-linkanim-color: var(--srd-btnanim-color, currentColor);
}

/* Fourth, the same way: [srdss_post_meta]'s category and tag links. Blank
   falls back to Content Underline Color before currentColor, because these
   links sit in post content and took that colour before they had their own
   family. Two different names, so no self-reference cycle. */
.srd-post-meta a {
	--srd-linkanim-color: var(--srd-post-meta-anim-color, var(--srd-linkanim-color-content, currentColor));
}


body.srd-linkanim--slide :where(main, article, .entry-content, .site-content, footer) a:not(.srd-btn):not(.srd-slide__btn):where(:not(.srd-no-linkanim)):where(:not(:has(img))),
body.srd-btnanim--slide .srd-btn--text,
.srd-post-meta.srd-postmetaanim--slide a {
	position: relative;
	background: linear-gradient(var(--srd-linkanim-color, currentColor), var(--srd-linkanim-color, currentColor)) no-repeat 0% 100% / 0% var(--srd-linkanim-thickness, 1px);
	text-decoration: none;
	padding-bottom: var(--srd-linkanim-offset, 0px);
	width: fit-content; /* bar tracks the text, not the box — see header note */
	transition: background-size var(--srd-linkanim-speed, 0.25s) ease;
}

body.srd-linkanim--slide :where(main, article, .entry-content, .site-content, footer) a:not(.srd-btn):not(.srd-slide__btn):where(:not(.srd-no-linkanim)):where(:not(:has(img))):hover,
body.srd-btnanim--slide .srd-btn--text:hover,
.srd-post-meta.srd-postmetaanim--slide a:hover {
	background-size: 100% var(--srd-linkanim-thickness, 1px);
}

body.srd-linkanim--center :where(main, article, .entry-content, .site-content, footer) a:not(.srd-btn):not(.srd-slide__btn):where(:not(.srd-no-linkanim)):where(:not(:has(img))),
body.srd-btnanim--center .srd-btn--text,
.srd-post-meta.srd-postmetaanim--center a {
	background: linear-gradient(var(--srd-linkanim-color, currentColor), var(--srd-linkanim-color, currentColor)) no-repeat 50% 100% / 0% var(--srd-linkanim-thickness, 1px);
	text-decoration: none;
	padding-bottom: var(--srd-linkanim-offset, 0px);
	width: fit-content; /* bar tracks the text, not the box — see header note */
	transition: background-size var(--srd-linkanim-speed, 0.25s) ease;
}

body.srd-linkanim--center :where(main, article, .entry-content, .site-content, footer) a:not(.srd-btn):not(.srd-slide__btn):where(:not(.srd-no-linkanim)):where(:not(:has(img))):hover,
body.srd-btnanim--center .srd-btn--text:hover,
.srd-post-meta.srd-postmetaanim--center a:hover {
	background-size: 100% var(--srd-linkanim-thickness, 1px);
}

body.srd-linkanim--fade :where(main, article, .entry-content, .site-content, footer) a:not(.srd-btn):not(.srd-slide__btn):where(:not(.srd-no-linkanim)):where(:not(:has(img))),
body.srd-btnanim--fade .srd-btn--text,
.srd-post-meta.srd-postmetaanim--fade a {
	text-decoration-line: underline;
	text-decoration-thickness: var(--srd-linkanim-thickness, auto);
	text-underline-offset: var(--srd-linkanim-offset, auto);
	text-decoration-color: transparent;
	width: fit-content; /* bar tracks the text, not the box — see header note */
	transition: text-decoration-color var(--srd-linkanim-speed, 0.25s) ease;
}

body.srd-linkanim--fade :where(main, article, .entry-content, .site-content, footer) a:not(.srd-btn):not(.srd-slide__btn):where(:not(.srd-no-linkanim)):where(:not(:has(img))):hover,
body.srd-btnanim--fade .srd-btn--text:hover,
.srd-post-meta.srd-postmetaanim--fade a:hover {
	text-decoration-color: var(--srd-linkanim-color, currentColor);
}

/* Slide in - right to left: same technique as Slide in, anchored to the
   right edge instead of the left so the bar grows leftward. */
body.srd-linkanim--slide-rtl :where(main, article, .entry-content, .site-content, footer) a:not(.srd-btn):not(.srd-slide__btn):where(:not(.srd-no-linkanim)):where(:not(:has(img))),
body.srd-btnanim--slide-rtl .srd-btn--text,
.srd-post-meta.srd-postmetaanim--slide-rtl a {
	background: linear-gradient(var(--srd-linkanim-color, currentColor), var(--srd-linkanim-color, currentColor)) no-repeat 100% 100% / 0% var(--srd-linkanim-thickness, 1px);
	text-decoration: none;
	padding-bottom: var(--srd-linkanim-offset, 0px);
	width: fit-content; /* bar tracks the text, not the box — see header note */
	transition: background-size var(--srd-linkanim-speed, 0.25s) ease;
}

body.srd-linkanim--slide-rtl :where(main, article, .entry-content, .site-content, footer) a:not(.srd-btn):not(.srd-slide__btn):where(:not(.srd-no-linkanim)):where(:not(:has(img))):hover,
body.srd-btnanim--slide-rtl .srd-btn--text:hover,
.srd-post-meta.srd-postmetaanim--slide-rtl a:hover {
	background-size: 100% var(--srd-linkanim-thickness, 1px);
}

/* Comes in, stays, goes out: hovering grows the bar in from the left, it stays
   for as long as the pointer does, and leaving shrinks it out to the right —
   so it exits the way it was travelling rather than retracting back.

   A transition, not a keyframe animation: the out half has to run on mouse
   out, which no :hover animation can. Only background-size is transitioned,
   so background-position snaps — to the left edge the moment hover starts
   (grow from the left) and back to the right edge the moment it ends (shrink
   toward the right). The snap happens while the bar is 0% wide and so is
   never seen; leaving mid-grow shows it as a jump to the other end, which is
   the one cost of the technique and matches what the ::after sweeps do.

   The gradient rather than an ::after, like Slide in: a gradient follows an
   inline link across a line break, and ::after stays free for the sweeps. */
body.srd-linkanim--in-stay-out :where(main, article, .entry-content, .site-content, footer) a:not(.srd-btn):not(.srd-slide__btn):where(:not(.srd-no-linkanim)):where(:not(:has(img))),
body.srd-btnanim--in-stay-out .srd-btn--text,
.srd-post-meta.srd-postmetaanim--in-stay-out a {
	background: linear-gradient(var(--srd-linkanim-color, currentColor), var(--srd-linkanim-color, currentColor)) no-repeat 100% 100% / 0% var(--srd-linkanim-thickness, 1px);
	text-decoration: none;
	padding-bottom: var(--srd-linkanim-offset, 0px);
	width: fit-content; /* bar tracks the text, not the box — see header note */
	transition: background-size var(--srd-linkanim-speed, 0.25s) ease;
}

body.srd-linkanim--in-stay-out :where(main, article, .entry-content, .site-content, footer) a:not(.srd-btn):not(.srd-slide__btn):where(:not(.srd-no-linkanim)):where(:not(:has(img))):hover,
body.srd-btnanim--in-stay-out .srd-btn--text:hover,
.srd-post-meta.srd-postmetaanim--in-stay-out a:hover {
	background-position: 0% 100%;
	background-size: 100% var(--srd-linkanim-thickness, 1px);
}

/* Comes in, stays, goes out — right to left: the mirror of the above. */
body.srd-linkanim--in-stay-out-rtl :where(main, article, .entry-content, .site-content, footer) a:not(.srd-btn):not(.srd-slide__btn):where(:not(.srd-no-linkanim)):where(:not(:has(img))),
body.srd-btnanim--in-stay-out-rtl .srd-btn--text,
.srd-post-meta.srd-postmetaanim--in-stay-out-rtl a {
	background: linear-gradient(var(--srd-linkanim-color, currentColor), var(--srd-linkanim-color, currentColor)) no-repeat 0% 100% / 0% var(--srd-linkanim-thickness, 1px);
	text-decoration: none;
	padding-bottom: var(--srd-linkanim-offset, 0px);
	width: fit-content; /* bar tracks the text, not the box — see header note */
	transition: background-size var(--srd-linkanim-speed, 0.25s) ease;
}

body.srd-linkanim--in-stay-out-rtl :where(main, article, .entry-content, .site-content, footer) a:not(.srd-btn):not(.srd-slide__btn):where(:not(.srd-no-linkanim)):where(:not(:has(img))):hover,
body.srd-btnanim--in-stay-out-rtl .srd-btn--text:hover,
.srd-post-meta.srd-postmetaanim--in-stay-out-rtl a:hover {
	background-position: 100% 100%;
	background-size: 100% var(--srd-linkanim-thickness, 1px);
}

/* Comes in, stays, goes out — from the center: grows outward from the middle
   on hover and, on mouse out, splits and leaves through both ends.

   Two layers, each painted in only one half of itself — the left layer's
   left half, the right layer's right half. Centred (hover), the pair is one
   bar growing from the middle: each layer is w wide and centred, so its
   painted half runs from the centre outward by w/2. Anchored to its own edge
   (rest), each layer's painted half hugs that edge and shrinks into it.

   The position swap is again untransitioned, and here it is invisible at both
   ends: hover starts at 0% wide, and mouse out starts at 100% wide, where a
   layer as wide as the box sits in the same place at every position. */
body.srd-linkanim--in-stay-out-center :where(main, article, .entry-content, .site-content, footer) a:not(.srd-btn):not(.srd-slide__btn):where(:not(.srd-no-linkanim)):where(:not(:has(img))),
body.srd-btnanim--in-stay-out-center .srd-btn--text,
.srd-post-meta.srd-postmetaanim--in-stay-out-center a {
	background:
		linear-gradient(to right, var(--srd-linkanim-color, currentColor) 50%, transparent 50%) no-repeat 0% 100% / 0% var(--srd-linkanim-thickness, 1px),
		linear-gradient(to right, transparent 50%, var(--srd-linkanim-color, currentColor) 50%) no-repeat 100% 100% / 0% var(--srd-linkanim-thickness, 1px);
	text-decoration: none;
	padding-bottom: var(--srd-linkanim-offset, 0px);
	width: fit-content; /* bar tracks the text, not the box — see header note */
	transition: background-size var(--srd-linkanim-speed, 0.25s) ease;
}

body.srd-linkanim--in-stay-out-center :where(main, article, .entry-content, .site-content, footer) a:not(.srd-btn):not(.srd-slide__btn):where(:not(.srd-no-linkanim)):where(:not(:has(img))):hover,
body.srd-btnanim--in-stay-out-center .srd-btn--text:hover,
.srd-post-meta.srd-postmetaanim--in-stay-out-center a:hover {
	background-position: 50% 100%, 50% 100%;
	background-size: 100% var(--srd-linkanim-thickness, 1px), 100% var(--srd-linkanim-thickness, 1px);
}

/* Comes in, goes out: hidden at rest — hover plays a one-shot sweep that
   enters from the left, then continues past full width and exits to the
   right. transform-origin flips mid-animation via two keyframe stops 0.01%
   apart, which reads as an instant snap rather than a visible interpolation. */
@keyframes srd-linkanim-comes-in-goes-out {
	0%     { transform: scaleX(0); transform-origin: left; }
	50%    { transform: scaleX(1); transform-origin: left; }
	50.01% { transform-origin: right; }
	100%   { transform: scaleX(0); transform-origin: right; }
}

body.srd-linkanim--comes-in-goes-out :where(main, article, .entry-content, .site-content, footer) a:not(.srd-btn):not(.srd-slide__btn):where(:not(.srd-no-linkanim)):where(:not(:has(img))),
body.srd-btnanim--comes-in-goes-out .srd-btn--text,
.srd-post-meta.srd-postmetaanim--comes-in-goes-out a {
	position: relative;
	text-decoration: none;
	width: fit-content; /* bar tracks the text, not the box — see header note */
}

body.srd-linkanim--comes-in-goes-out :where(main, article, .entry-content, .site-content, footer) a:not(.srd-btn):not(.srd-slide__btn):where(:not(.srd-no-linkanim)):where(:not(:has(img)))::after,
body.srd-btnanim--comes-in-goes-out .srd-btn--text::after,
.srd-post-meta.srd-postmetaanim--comes-in-goes-out a::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	bottom: calc(-1 * var(--srd-linkanim-offset, 0px));
	height: var(--srd-linkanim-thickness, 2px);
	background: var(--srd-linkanim-color, currentColor);
	transform: scaleX(0);
	transform-origin: left;
}

body.srd-linkanim--comes-in-goes-out :where(main, article, .entry-content, .site-content, footer) a:not(.srd-btn):not(.srd-slide__btn):where(:not(.srd-no-linkanim)):where(:not(:has(img))):hover::after,
body.srd-btnanim--comes-in-goes-out .srd-btn--text:hover::after,
.srd-post-meta.srd-postmetaanim--comes-in-goes-out a:hover::after {
	animation: srd-linkanim-comes-in-goes-out var(--srd-linkanim-speed, 0.9s) ease-in-out;
}

/* Comes in, goes out — right to left: the mirror of the above, entering
   from the right and exiting to the left. */
@keyframes srd-linkanim-comes-in-goes-out-rtl {
	0%     { transform: scaleX(0); transform-origin: right; }
	50%    { transform: scaleX(1); transform-origin: right; }
	50.01% { transform-origin: left; }
	100%   { transform: scaleX(0); transform-origin: left; }
}

body.srd-linkanim--comes-in-goes-out-rtl :where(main, article, .entry-content, .site-content, footer) a:not(.srd-btn):not(.srd-slide__btn):where(:not(.srd-no-linkanim)):where(:not(:has(img))),
body.srd-btnanim--comes-in-goes-out-rtl .srd-btn--text,
.srd-post-meta.srd-postmetaanim--comes-in-goes-out-rtl a {
	position: relative;
	text-decoration: none;
	width: fit-content; /* bar tracks the text, not the box — see header note */
}

body.srd-linkanim--comes-in-goes-out-rtl :where(main, article, .entry-content, .site-content, footer) a:not(.srd-btn):not(.srd-slide__btn):where(:not(.srd-no-linkanim)):where(:not(:has(img)))::after,
body.srd-btnanim--comes-in-goes-out-rtl .srd-btn--text::after,
.srd-post-meta.srd-postmetaanim--comes-in-goes-out-rtl a::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	bottom: calc(-1 * var(--srd-linkanim-offset, 0px));
	height: var(--srd-linkanim-thickness, 2px);
	background: var(--srd-linkanim-color, currentColor);
	transform: scaleX(0);
	transform-origin: right;
}

body.srd-linkanim--comes-in-goes-out-rtl :where(main, article, .entry-content, .site-content, footer) a:not(.srd-btn):not(.srd-slide__btn):where(:not(.srd-no-linkanim)):where(:not(:has(img))):hover::after,
body.srd-btnanim--comes-in-goes-out-rtl .srd-btn--text:hover::after,
.srd-post-meta.srd-postmetaanim--comes-in-goes-out-rtl a:hover::after {
	animation: srd-linkanim-comes-in-goes-out-rtl var(--srd-linkanim-speed, 0.9s) ease-in-out;
}

/* Goes out, comes in: a permanently visible underline at rest — hover plays
   a one-shot sweep where it exits to the right first, then re-enters from
   the left, ending back at fully visible (matches the rest state, so there's
   no jump when the hover ends). */
@keyframes srd-linkanim-goes-out-comes-in {
	0%     { transform: scaleX(1); transform-origin: right; }
	50%    { transform: scaleX(0); transform-origin: right; }
	50.01% { transform-origin: left; }
	100%   { transform: scaleX(1); transform-origin: left; }
}

body.srd-linkanim--goes-out-comes-in :where(main, article, .entry-content, .site-content, footer) a:not(.srd-btn):not(.srd-slide__btn):where(:not(.srd-no-linkanim)):where(:not(:has(img))),
body.srd-btnanim--goes-out-comes-in .srd-btn--text,
.srd-post-meta.srd-postmetaanim--goes-out-comes-in a {
	position: relative;
	text-decoration: none;
	width: fit-content; /* bar tracks the text, not the box — see header note */
}

body.srd-linkanim--goes-out-comes-in :where(main, article, .entry-content, .site-content, footer) a:not(.srd-btn):not(.srd-slide__btn):where(:not(.srd-no-linkanim)):where(:not(:has(img)))::after,
body.srd-btnanim--goes-out-comes-in .srd-btn--text::after,
.srd-post-meta.srd-postmetaanim--goes-out-comes-in a::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	bottom: calc(-1 * var(--srd-linkanim-offset, 0px));
	height: var(--srd-linkanim-thickness, 2px);
	background: var(--srd-linkanim-color, currentColor);
	transform: scaleX(1);
	transform-origin: left;
}

body.srd-linkanim--goes-out-comes-in :where(main, article, .entry-content, .site-content, footer) a:not(.srd-btn):not(.srd-slide__btn):where(:not(.srd-no-linkanim)):where(:not(:has(img))):hover::after,
body.srd-btnanim--goes-out-comes-in .srd-btn--text:hover::after,
.srd-post-meta.srd-postmetaanim--goes-out-comes-in a:hover::after {
	animation: srd-linkanim-goes-out-comes-in var(--srd-linkanim-speed, 0.9s) ease-in-out;
}

/* Goes out, comes in — right to left: the mirror of the above, exiting to
   the left first, then re-entering from the right. */
@keyframes srd-linkanim-goes-out-comes-in-rtl {
	0%     { transform: scaleX(1); transform-origin: left; }
	50%    { transform: scaleX(0); transform-origin: left; }
	50.01% { transform-origin: right; }
	100%   { transform: scaleX(1); transform-origin: right; }
}

body.srd-linkanim--goes-out-comes-in-rtl :where(main, article, .entry-content, .site-content, footer) a:not(.srd-btn):not(.srd-slide__btn):where(:not(.srd-no-linkanim)):where(:not(:has(img))),
body.srd-btnanim--goes-out-comes-in-rtl .srd-btn--text,
.srd-post-meta.srd-postmetaanim--goes-out-comes-in-rtl a {
	position: relative;
	text-decoration: none;
	width: fit-content; /* bar tracks the text, not the box — see header note */
}

body.srd-linkanim--goes-out-comes-in-rtl :where(main, article, .entry-content, .site-content, footer) a:not(.srd-btn):not(.srd-slide__btn):where(:not(.srd-no-linkanim)):where(:not(:has(img)))::after,
body.srd-btnanim--goes-out-comes-in-rtl .srd-btn--text::after,
.srd-post-meta.srd-postmetaanim--goes-out-comes-in-rtl a::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	bottom: calc(-1 * var(--srd-linkanim-offset, 0px));
	height: var(--srd-linkanim-thickness, 2px);
	background: var(--srd-linkanim-color, currentColor);
	transform: scaleX(1);
	transform-origin: right;
}

body.srd-linkanim--goes-out-comes-in-rtl :where(main, article, .entry-content, .site-content, footer) a:not(.srd-btn):not(.srd-slide__btn):where(:not(.srd-no-linkanim)):where(:not(:has(img))):hover::after,
body.srd-btnanim--goes-out-comes-in-rtl .srd-btn--text:hover::after,
.srd-post-meta.srd-postmetaanim--goes-out-comes-in-rtl a:hover::after {
	animation: srd-linkanim-goes-out-comes-in-rtl var(--srd-linkanim-speed, 0.9s) ease-in-out;
}
