/**
 * BFGD sticky calculator bar.
 *
 * Performance contract, and it is a gate not a preference:
 *  - position: fixed, so the bar is OUTSIDE the document flow. It cannot move
 *    anything. CLS is zero by construction, not by measurement.
 *  - NO body padding-bottom anywhere. Adding it to "make room" is exactly what
 *    would cause the layout shift this design avoids.
 *  - transform + opacity only for show/hide. Both are compositor properties, so
 *    they never trigger layout or paint.
 *  - No web font is loaded here. It inherits the theme's Poppins, so the bar
 *    adds no font request and cannot delay LCP.
 *
 * Height: 56px mobile (7% of an 844px viewport, a content-to-chrome ratio of
 * about 13:1, which is the ratio NN/g calls "a reasonable space tradeoff"),
 * 64px desktop. Well inside every published intrusive-interstitial threshold.
 */

.bfgd-calc-bar {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 2147483000; /* above site chrome, below the CookieYes banner */
	display: flex;
	align-items: center;
	gap: 12px;
	box-sizing: border-box;
	/**
	 * Height. Peter asked for 20% off the rendered 81px, so about 65px.
	 *
	 * The binding constraint is the 44x44 touch target on the close button,
	 * which is WCAG 2.1 AA and Apple's minimum and is NOT negotiable. 44 plus
	 * the old 8px padding top and bottom is 60px, so the padding is what gives:
	 * 6px each side puts the floor at 56px and lets the content settle around
	 * 65px. The close button keeps its full 44x44 box.
	 */
	min-height: 52px;
	padding: 8px 12px;
	background: #ffffff;
	border-top: 1px solid #e6e6e6;
	box-shadow: 0 -2px 12px rgba( 0, 0, 0, 0.08 );
	font-family: inherit;
	transform: translateY( 100% );
	opacity: 0;
	transition: transform 220ms ease-out, opacity 220ms ease-out;
	will-change: transform;
}

/* Respect a reader who has asked for less motion. */
@media ( prefers-reduced-motion: reduce ) {
	.bfgd-calc-bar {
		transition: none;
	}
}

.bfgd-calc-bar[hidden] {
	display: none;
}

.bfgd-calc-bar.is-visible {
	transform: translateY( 0 );
	opacity: 1;
}

.bfgd-calc-bar__text {
	flex: 1 1 auto;
	margin: 0;
	font-size: 13px;
	line-height: 1.25;
	color: #1a1a1a;
	/* Two lines maximum on a phone, so the bar can never grow past 56px. */
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/**
 * Brand button corner radius.
 *
 * 4px is NOT a design choice made here. It is the value the site's own brand
 * buttons already use, read from source on 2026-08-02: the calculator CTA
 * callout pattern (post 9797) sets
 * `border-top-left-radius:4px` (and the other three corners) inline, and every
 * post carrying a "Try the Free Calculator" brand button does the same
 * (checked posts 30, 1045, 1302, 1327, 5167).
 *
 * The theme exposes NO radius token: theme.json has no button radius entry and
 * each block hardcodes it inline, so there is no variable to reference. This
 * custom property is the next best thing: one place to change if the brand
 * moves. If a real token ever appears in theme.json, point this at it.
 *
 * The bar previously used 999px, a full pill. That did not match the site.
 */
:root {
	--bfgd-brand-button-radius: 4px;
}

.bfgd-calc-bar__cta {
	flex: 0 0 auto;
	display: inline-block;
	/**
	 * border-box is load-bearing. Without it `min-height: 44px` is the CONTENT
	 * box and the 8px padding is added on top, so the button rendered 60px and
	 * the bar came out at 73px instead of the 65px asked for. With border-box
	 * the 44px IS the rendered height, which is also exactly the touch target
	 * the accessibility minimum requires. Do not remove.
	 */
	box-sizing: border-box;
	padding: 8px 14px;
	border-radius: var( --bfgd-brand-button-radius, 4px );
	background: #18bfcf;
	color: #ffffff;
	font-size: 14px;
	font-weight: 600;
	line-height: 1;
	text-decoration: none;
	white-space: nowrap;
	/* 44px minimum touch target, WCAG 2.1 AA. Do not reduce. */
	min-height: 44px;
	/* Mobile: stack the label so it fills the button. Desktop reverts below. */
	flex-direction: column;
	line-height: 1.08;
	text-align: center;
	/**
	 * column-gap, not a literal space and not &nbsp;.
	 *
	 * The CTA is a flex container, and flex containers DISCARD whitespace-only
	 * text nodes between children. So the space in the markup never rendered in
	 * either direction; mobile only looked correct because the column break
	 * supplied the gap visually. Desktop read "Freecalculator".
	 *
	 * column-gap applies along the inline axis only. In `flex-direction: column`
	 * it does nothing, so mobile keeps a tight two-line stack and cannot gain a
	 * stray space. In `row` on desktop it restores a normal word space.
	 */
	column-gap: 0.3em;
	display: inline-flex;
	align-items: center;
}

.bfgd-calc-bar__cta:hover,
.bfgd-calc-bar__cta:focus {
	background: #13a5b3;
	color: #ffffff;
	text-decoration: none;
}

.bfgd-calc-bar__close {
	flex: 0 0 auto;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	background: transparent;
	color: #6b6b6b;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
}

.bfgd-calc-bar__close:hover,
.bfgd-calc-bar__close:focus {
	color: #1a1a1a;
}

@media ( min-width: 768px ) {
	.bfgd-calc-bar {
		min-height: 56px;
		gap: 16px;
		padding: 10px 24px;
		justify-content: center;
	}

	.bfgd-calc-bar__text {
		flex: 0 1 auto;
		font-size: 15px;
		-webkit-line-clamp: 1;
	}

	/* Desktop: one line again, exactly as before. */
	.bfgd-calc-bar__cta {
		flex-direction: row;
		line-height: 1;
	}
}

/**
 * (10) The back-to-top arrow must clear the bar. Added 2026-09-09 on Peter's
 * instruction: "the little arrow to go to top of page gets hidden underneath
 * the sticky bar. move it up."
 *
 * WHAT WAS WRONG. The arrow is the nook theme's #back-to-top, a fixed 50px
 * circle pinned at bottom: 30px (45px at bottom: 20px under 768px, where a
 * separate mu-plugin hides it outright). Its z-index is 9999; the bar's is
 * 2147483000. So with the bar up the arrow was not merely touching it, it was
 * BEHIND it. Measured on staging at 1440x900 with the bar visible: the arrow
 * spanned y 820 to 870 and the bar's top edge sat at y 835, a 35px overlap.
 *
 * WHY IT LIVES HERE. The bar is the thing that moves, so the bar owns the
 * clearance. This stylesheet is enqueued only where the bar itself loads, and
 * only while the bar has won the interrupt slot, so the rule cannot reach a
 * page that has no bar on it.
 *
 * THE PERFORMANCE CONTRACT AT THE TOP OF THIS FILE IS UNTOUCHED. Nothing here
 * adds body padding and nothing enters the document flow: this moves one
 * already-fixed element, and only while .is-visible is on the bar, so the
 * arrow returns to the theme's own offset the moment the bar goes away.
 *
 * THE HEIGHTS ARE RENDERED HEIGHTS, NOT THE MIN-HEIGHTS ABOVE. The padding and
 * the 44x44 close button push the box past min-height: measured 65px at 1440
 * and 63px at 390. The clearance is 16px on top of that.
 */
:root {
	--bfgd-calc-bar-height: 63px;    /* rendered height, phone */
	--bfgd-calc-bar-clearance: 16px;
}

@media ( min-width: 768px ) {
	:root {
		--bfgd-calc-bar-height: 65px; /* rendered height, desktop */
	}
}

/**
 * Primary rule. The bar and the arrow are both direct children of <body>, with
 * the bar first, so a general sibling selector reaches it with no :has()
 * needed and therefore no browser-support question at all. Verified in the DOM
 * on staging: body child 5 is the bar, body child 8 is the arrow.
 */
.bfgd-calc-bar.is-visible ~ #back-to-top {
	bottom: calc( var( --bfgd-calc-bar-height ) + var( --bfgd-calc-bar-clearance ) );
}

/**
 * Insurance, kept as its OWN rule so that a browser without :has() discards
 * this one and still gets the rule above. It catches the case where a theme
 * update wraps the arrow in a div, which would break the sibling relationship
 * silently.
 */
body:has( .bfgd-calc-bar.is-visible ) #back-to-top {
	bottom: calc( var( --bfgd-calc-bar-height ) + var( --bfgd-calc-bar-clearance ) );
}
