/* =====================================================================
   Fly To Cart Turbo (front end)
   Blocks: ftct-flyer (the flying product image, moved by fly-to-cart.js
   with the Web Animations API) and ftct-notice (the "Added to cart" card
   that appears when it lands).
   Colours are custom properties (tokens), so a theme can restyle the
   notice by setting them on .ftct-notice. Colour schemes:
   - default (light tokens) and ftct-notice--dark
   - ftct-notice--auto follows the device's light/dark setting
   - "Stand out" (the default setting) picks --dark on a light page and
     the light tokens on a dark page; fly-to-cart.js checks the page each
     time, so a site dark mode switch is followed
   Everything is rem, including the sizes and positions fly-to-cart.js
   writes for the flyer.
   ===================================================================== */

/* ---------- Block: ftct-flyer ---------- */
.ftct-flyer {
	position: fixed;
	box-sizing: border-box;
	margin: 0;
	padding: 0;
	overflow: hidden;
	pointer-events: none;
	transform-origin: 50% 50%;
	will-change: transform, opacity, border-radius;
	backface-visibility: visible;
}
.ftct-flyer--card {
	border: 0.0625rem solid rgb(0 0 0 / 8%);
	background-color: #fff;
}
.ftct-flyer--trail {
	filter: blur(0.0625rem) saturate(0.8);
}
.ftct-flyer .ftct-flyer__img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	object-fit: contain;
	border-radius: inherit;
}
/* On the white card the photo sits a little in from the edge (margins in %
   follow the flyer's own width, unlike padding on a fixed element) */
.ftct-flyer--card .ftct-flyer__img {
	width: 88%;
	height: 88%;
	margin: 6%;
}

/* ---------- Block: ftct-notice ---------- */
.ftct-notice {
	--ftct-accent: #00a32a;
	--ftct-surface: #fff;
	--ftct-text: #1d2327;
	--ftct-muted: #50575e;
	--ftct-line: #dcdcde;
	--ftct-button: #1d2327;
	--ftct-on-button: #fff;
	--ftct-shadow: 0 1.25rem 3rem rgb(0 0 0 / 18%), 0 0.25rem 0.75rem rgb(0 0 0 / 10%);
	--ftct-notice-ms: 5000ms;

	position: fixed;
	box-sizing: border-box;
	display: grid;
	grid-template-columns: auto minmax(0, 1fr) auto;
	grid-template-areas:
		"img body close"
		"actions actions actions";
	align-items: center;
	gap: 0.75rem 0.875rem;
	width: min(23rem, calc(100vw - 1.5rem));
	margin: 0;
	padding: 0.875rem 0.875rem 1.125rem;
	overflow: hidden;
	border: 0.0625rem solid var(--ftct-line);
	border-top: 0.25rem solid var(--ftct-accent);
	border-radius: 1rem;
	background-color: var(--ftct-surface);
	box-shadow: var(--ftct-shadow);
	font-family: inherit;
	font-size: 1rem;
	line-height: 1.35;
	color: var(--ftct-text);
	opacity: 0;
	transform: translateY(-0.5rem) scale(0.98);
	transition: opacity 0.25s ease, transform 0.25s ease;
}
.ftct-notice--open {
	opacity: 1;
	transform: none;
}

.ftct-notice--dark {
	--ftct-surface: #1d2327;
	--ftct-text: #f0f0f1;
	--ftct-muted: #c3c4c7;
	--ftct-line: #3c434a;
	--ftct-button: #f0f0f1;
	--ftct-on-button: #1d2327;
}
@media (prefers-color-scheme: dark) {
	.ftct-notice--auto {
		--ftct-surface: #1d2327;
		--ftct-text: #f0f0f1;
		--ftct-muted: #c3c4c7;
		--ftct-line: #3c434a;
		--ftct-button: #f0f0f1;
		--ftct-on-button: #1d2327;
	}
}

/* Positions (near-cart sets top/right from the cart's place) */
.ftct-notice--top-right,
.ftct-notice--near-cart { top: 1rem; right: 1rem; }
.ftct-notice--top-left { top: 1rem; left: 1rem; }
.ftct-notice--top-center { top: 1rem; left: 50%; translate: -50% 0; }
.ftct-notice--bottom-right { bottom: 1rem; right: 1rem; }
.ftct-notice--bottom-left { bottom: 1rem; left: 1rem; }
.ftct-notice--bottom-center { bottom: 1rem; left: 50%; translate: -50% 0; }
.ftct-notice--bottom-right:not(.ftct-notice--open),
.ftct-notice--bottom-left:not(.ftct-notice--open),
.ftct-notice--bottom-center:not(.ftct-notice--open) {
	transform: translateY(0.5rem) scale(0.98);
}
/* Admin live preview: inside the stage instead of the window */
.ftct-notice--in-stage {
	position: absolute;
	width: min(20rem, calc(100% - 1.5rem));
}
.admin-bar .ftct-notice--top-right:not(.ftct-notice--in-stage),
.admin-bar .ftct-notice--top-left:not(.ftct-notice--in-stage),
.admin-bar .ftct-notice--top-center:not(.ftct-notice--in-stage) {
	top: calc(var(--wp-admin--admin-bar--height, 2rem) + 1rem);
}

.ftct-notice .ftct-notice__img {
	grid-area: img;
	width: 3.5rem;
	height: 3.5rem;
	max-width: none;
	margin: 0;
	object-fit: contain;
	border: 0.0625rem solid var(--ftct-line);
	border-radius: 0.625rem;
	background-color: #fff;
}
.ftct-notice__body {
	grid-area: body;
	min-width: 0;
}
.ftct-notice__title {
	display: flex;
	align-items: center;
	gap: 0.375rem;
	margin: 0;
	font-size: 1rem;
	font-weight: 800;
	color: var(--ftct-text);
}
.ftct-notice__check {
	flex: none;
	box-sizing: content-box;
	width: 0.875rem;
	height: 0.875rem;
	padding: 0.1875rem;
	border-radius: 50%;
	background-color: var(--ftct-accent);
	fill: none;
	stroke: #fff;
	stroke-width: 3.2;
	stroke-linecap: round;
	stroke-linejoin: round;
}
.ftct-notice__name {
	margin: 0.1875rem 0 0;
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--ftct-text);
	overflow-wrap: anywhere;
}
.ftct-notice__meta {
	margin: 0.0625rem 0 0;
	font-size: 0.8125rem;
	color: var(--ftct-muted);
}

.ftct-notice__actions {
	grid-area: actions;
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 0.5rem;
}
.ftct-notice__link,
.ftct-notice__button {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 2.5rem;
	padding: 0.5rem 0.875rem;
	border: 0.125rem solid var(--ftct-button);
	border-radius: 2rem;
	font-size: 0.875rem;
	font-weight: 700;
	line-height: 1.2;
	text-decoration: none;
	transition: background-color 0.2s ease, color 0.2s ease;
}
.ftct-notice__link {
	background-color: transparent;
	color: var(--ftct-button);
}
.ftct-notice__button {
	background-color: var(--ftct-button);
	color: var(--ftct-on-button);
}
.ftct-notice__link:hover,
.ftct-notice__link:focus-visible {
	background-color: var(--ftct-button);
	color: var(--ftct-on-button);
}
.ftct-notice__button:hover,
.ftct-notice__button:focus-visible {
	border-color: var(--ftct-accent);
	background-color: var(--ftct-accent);
	color: #fff;
}
.ftct-notice a:focus-visible,
.ftct-notice button:focus-visible {
	outline: 0.1875rem solid var(--ftct-accent);
	outline-offset: 0.125rem;
}

.ftct-notice__close {
	grid-area: close;
	align-self: start;
	display: grid;
	place-items: center;
	width: 2rem;
	height: 2rem;
	margin: -0.25rem -0.25rem 0 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--ftct-muted);
	cursor: pointer;
}
.ftct-notice__close:hover {
	background-color: color-mix(in srgb, var(--ftct-muted) 15%, transparent);
	color: var(--ftct-text);
}
.ftct-notice__close svg {
	width: 1rem;
	height: 1rem;
	fill: none;
	stroke: currentColor;
	stroke-width: 2.4;
	stroke-linecap: round;
}

/* Time left, as a line shrinking along the bottom (full while paused) */
.ftct-notice__timer {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	height: 0.1875rem;
	background-color: var(--ftct-accent);
	transform-origin: left center;
}
.ftct-notice--run .ftct-notice__timer {
	animation: ftct-notice-timer var(--ftct-notice-ms) linear forwards;
}
@keyframes ftct-notice-timer {
	from { transform: scaleX(1); }
	to { transform: scaleX(0); }
}

@media (prefers-reduced-motion: reduce) {
	.ftct-notice { transition: none; transform: none; }
}

@media (max-width: 47.9375rem) {
	.ftct-notice:not(.ftct-notice--in-stage) {
		left: 0.75rem;
		right: 0.75rem;
		width: auto;
		translate: none;
	}
}
