/**
 * The sticky call-to-action bar.
 *
 * Figma: PAC-Page-Designs, page "Home Page", "Sticky-btm"
 *   1440px  node 2001:1727   bar 1440 x 91
 *   1199px  node 2001:1885   bar 1199 x 91
 *    768px  node 2001:2043   bar  768 x 162, the words wrap and the buttons
 *                            sit at the top of them
 *    390px  node 2245:8564   bar  390 x 52,  words hidden, buttons only
 *
 * Loaded only on pages where the bar is switched on - see inc/sticky-cta.php.
 * It is not a block, so this does not live in blocks/.
 */

.pchs-sticky-cta {
	/*
	 * sticky, not fixed. The bar follows the bottom of the window while the
	 * visitor reads, and when they reach the end of the page it arrives at
	 * its real position - just above the site footer - and stops, instead of
	 * sitting on top of the footer and hiding it.
	 */
	position: sticky;
	bottom: 0;
	z-index: 20;

	display: flex;
	align-items: center;
	justify-content: center;
	gap: var(--wp--preset--spacing--20); /* 20px */
	padding: var(--wp--preset--spacing--8) var(--wp--preset--spacing--12); /* 8/12 */
	background-color: var(--wp--preset--color--blue-500);

	/*
	 * Two shadows in one property: the darker line along the bottom edge,
	 * drawn inside so it costs no height, and the soft shadow cast UPWARDS
	 * over the page the bar is floating above.
	 */
	box-shadow:
		inset 0 -1px 0 var(--wp--preset--color--blue-800),
		0 -4px 4px rgba(0, 0, 0, 0.12);

	transition: opacity 0.2s ease, transform 0.2s ease;
}

/*
 * The bar fades in once the visitor has scrolled past the header, rather
 * than being there the moment the page opens.
 *
 * Written the long way round on purpose: the hidden state applies only once
 * the script has marked the bar as ready. If the script never runs, the bar
 * is simply always visible, which is far better than a call to action nobody
 * can see.
 */
.pchs-sticky-cta--ready:not( .is-visible ) {
	opacity: 0;
	transform: translateY( 100% );
	pointer-events: none;
}


/* ------------------------------------------------------------
   The words

   Hidden on a phone, where the frames show the two buttons on
   their own and the bar is 52px tall instead of 91.
   ------------------------------------------------------------ */

.pchs-sticky-cta__info {
	display: none;
}

.pchs-sticky-cta__heading {
	margin: 0;
	font-family: var(--wp--preset--font-family--title);
	font-size: var(--wp--preset--font-size--lg); /* 20px */
	font-weight: 500;
	/* Whole pixels rather than the 1.16 Figma reports, because Figma lays
	   text out on whole pixels and the leftover fraction would leave the bar
	   taller than its frame. */
	line-height: 23px; /* 20 x 1.16 */
	text-transform: uppercase;
}

.pchs-sticky-cta__description {
	margin: 0;
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--md); /* 16px */
	font-weight: 400;
	line-height: 24px; /* 16 x 1.5 */
}


/* ------------------------------------------------------------
   The buttons

   On a phone they share a 300px row equally. From 768 they take
   the width of their own words and sit beside the text.
   ------------------------------------------------------------ */

.pchs-sticky-cta__actions {
	display: flex;
	width: 300px;
	max-width: 100%;
	align-items: center;
	gap: var(--wp--preset--spacing--20); /* 20px */
}

.pchs-sticky-cta__actions .pchs-button {
	min-width: 0;
	flex: 1 1 0;
	padding: var(--wp--preset--spacing--12) var(--wp--preset--spacing--20); /* 12/20 */
	font-size: var(--wp--preset--font-size--xs); /* 12px */
}

/* 2px on a phone, 1px above it, which is what the two frames draw. */
.pchs-sticky-cta__actions .pchs-button--outline {
	box-shadow: inset 0 0 0 2px currentColor;
}


/* ------------------------------------------------------------
   768px and up
   Figma node 2001:2043.

   The words appear beside the buttons, and the buttons line up
   with the top of them rather than the middle - the frame puts
   both at 20px from the top of a 162px bar.
   ------------------------------------------------------------ */

@media (min-width: 768px) {

	.pchs-sticky-cta {
		align-items: flex-start;
		padding: var(--wp--preset--spacing--20) var(--wp--preset--spacing--40); /* 20/40 */
	}

	.pchs-sticky-cta__info {
		display: flex;
		min-width: 0;
		flex: 1 1 0;
		flex-direction: column;
		gap: var(--wp--preset--spacing--4); /* 4px */
		color: var(--wp--preset--color--white);
	}

	.pchs-sticky-cta__actions {
		width: auto;
		gap: var(--wp--preset--spacing--12); /* 12px */
	}

	.pchs-sticky-cta__actions .pchs-button {
		flex: 0 0 auto;
		padding: var(--wp--preset--spacing--16) var(--wp--preset--spacing--20); /* 16/20 */
		font-size: var(--wp--preset--font-size--sm); /* 14px */
	}

	.pchs-sticky-cta__actions .pchs-button--outline {
		box-shadow: inset 0 0 0 1px currentColor;
	}
}


/* ------------------------------------------------------------
   1024px and up
   Figma nodes 2001:1885 (1199) and 2001:1727 (1440).

   The words fit on two lines, so the buttons centre against
   them instead of sitting at the top, and go back to 20px
   apart.
   ------------------------------------------------------------ */

@media (min-width: 1024px) {

	.pchs-sticky-cta {
		align-items: center;
	}

	.pchs-sticky-cta__actions {
		gap: var(--wp--preset--spacing--20); /* 20px */
	}
}


/* ------------------------------------------------------------
   Wider than the design

   The bar's colour runs the full width of the screen, as every
   section background does, while its contents stop at the page
   cap.
   ------------------------------------------------------------ */

@media (min-width: 1441px) {

	.pchs-sticky-cta {
		padding-inline: calc(var(--wp--preset--spacing--40) + var(--pchs-page-gutter));
	}
}
