/**
 * gp/sticky-bar
 *
 * 80px tall on an almost-white ground with a soft all-round shadow, which is
 * the live bar. z-index sits under the header dropdowns and over the page.
 */
.gp-sticky-bar {
	position: fixed;
	inset-block-end: 0;
	inset-inline: 0;
	z-index: 98;
	box-sizing: border-box;
	background: var(--wp--preset--color--surface-alt);
	box-shadow: 0 0 7px rgba(0, 0, 0, 0.15);

	/* Parked below the fold until view.js adds is-visible. Transform and
	   opacity only, so the reveal runs on the compositor and never reflows the
	   page behind it. visibility is stepped rather than eased: it must be gone
	   the instant the slide out finishes, and present before the slide in
	   starts, or the bar animates while still catching clicks. */
	transform: translateY(100%);
	opacity: 0;
	visibility: hidden;
	transition:
		transform 300ms cubic-bezier(0.22, 0.61, 0.36, 1),
		opacity 220ms ease,
		visibility 0s linear 300ms;
}

.gp-sticky-bar.is-visible {
	transform: translateY(0);
	opacity: 1;
	visibility: visible;
	transition:
		transform 300ms cubic-bezier(0.22, 0.61, 0.36, 1),
		opacity 220ms ease,
		visibility 0s linear 0s;
}

/*
 * The bar spans the window wherever the block is placed.
 *
 * A constrained group gives every direct child "max-width: <content size>;
 * margin-inline: auto", and that applies to a fixed element as readily as to a
 * paragraph — which is what was holding the bar to the 1240px column while
 * left and right were both pinned to 0. Doubled to outrank that rule, since
 * WordPress prints its layout CSS after this file.
 */
.gp-sticky-bar.gp-sticky-bar {
	max-inline-size: none;
	margin-inline: 0;
}

/* The state before the script runs, and the state it stays in if the script
   never does: no bar rather than a bar that can never be dismissed. */
.gp-sticky-bar[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
	.gp-sticky-bar,
	.gp-sticky-bar.is-visible {
		transform: none;
		transition: opacity 120ms linear, visibility 0s linear 120ms;
	}

	.gp-sticky-bar.is-visible { transition: opacity 120ms linear, visibility 0s linear 0s; }
}

/*
 * The live bar is not laid out on the page's container: it runs the full width
 * of the window with 50px of side padding, and the product and the buttons sit
 * together in the middle rather than being pushed to opposite edges.
 */
.gp-sticky-bar__inner {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 20px;
	box-sizing: border-box;
	inline-size: 100%;
	min-block-size: 80px;
	padding-inline: 50px;
	padding-block: 10px;
}

.gp-sticky-bar__product {
	display: flex;
	align-items: center;
	gap: 12px;
	min-inline-size: 0;
}

.gp-sticky-bar__media {
	flex: none;
	inline-size: 48px;
	block-size: 56px;
	overflow: hidden;
	border-radius: 4px;
	background: var(--wp--preset--color--surface-muted);
}

.gp-sticky-bar__image {
	inline-size: 100%;
	block-size: 100%;
	object-fit: cover;
	display: block;
}

.gp-sticky-bar__text {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-inline-size: 0;
}

.gp-sticky-bar__title {
	font-size: var(--wp--preset--font-size--sm);
	font-weight: 600;
	color: var(--wp--preset--color--ink-heading);
	text-decoration: none;
	/* One line: the bar is a reminder of what is being bought, not a card. */
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.gp-sticky-bar__price {
	font-size: var(--wp--preset--font-size--sm);
	font-weight: 600;
	color: var(--wp--preset--color--brand-green);
}

.gp-sticky-bar__price .woocommerce-Price-amount { font-size: inherit; color: inherit; }

.gp-sticky-bar__actions {
	display: flex;
	align-items: center;
	gap: 12px;
	flex: none;
}

.gp-sticky-bar__form { margin: 0; }

.gp-sticky-bar__button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	min-inline-size: 150px;
	block-size: 44px;
	padding: 0 20px;
	border: 2px solid var(--wp--preset--color--brand-green);
	border-radius: 8px;
	font-family: inherit;
	font-size: var(--wp--preset--font-size--sm);
	line-height: 1;
	text-align: center;
	text-decoration: none;
	cursor: pointer;
}

.gp-sticky-bar__button--outline {
	background: var(--wp--preset--color--surface);
	color: #002c22;
}

.gp-sticky-bar__button--solid {
	background: var(--wp--preset--color--brand-green);
	color: var(--wp--preset--color--surface);
}

/* The bar carries the same pair as the buy row, so it takes the same hover. */
.gp-sticky-bar__button--outline:hover {
	background: #121212;
	color: #e3f0e9;
	border-color: #000;
}

.gp-sticky-bar__button--solid:hover {
	background: var(--wp--preset--color--ink);
	color: var(--wp--preset--color--surface);
	border-color: #121212;
}

/* On a phone the bar is the buy row, so the buttons take the width and the
   product line steps out of the way. */
@media (max-width: 640px) {
	.gp-sticky-bar__inner { padding-inline: 15px; }

	.gp-sticky-bar__product { display: none; }

	.gp-sticky-bar__actions { inline-size: 100%; }

	.gp-sticky-bar__form,
	.gp-sticky-bar__button { inline-size: 100%; min-inline-size: 0; }
}

/* The bar's product line is a label, not prose — no rule under it on hover. */
.gp-sticky-bar__title:hover { text-decoration: none; }
