/**
 * The newsletter page (patterns/page-newsletter.php, inc/newsletter.php):
 * the orangutan's photo, its speech bubble (base.css «Sprechblase») and the
 * signup form on a white print. Three states: signup, sent (the form's
 * confirmation is on the page) and welcome (?confirmed=1, chosen on the
 * server).
 */

.suaq-newsletter {
	margin-top: var(--wp--preset--spacing--50) !important;
}

.suaq-newsletter__cols {
	gap: clamp(2.5rem, 5vw, 5rem) !important;
}

.suaq-newsletter__photo .wp-block-image {
	margin: 0;
	transform: rotate(1.5deg);
}

.suaq-newsletter__talk > * + * {
	margin-top: var(--wp--preset--spacing--40);
}

/* The bubble talks from beside the photo: room for the tail on the left. */
.suaq-newsletter .wp-block-group.is-style-speech {
	max-width: 32rem !important;
	margin: 1.5rem 0 0 1.25rem !important;
}

/* States: «sent» shows only while the form's confirmation is on the page. */
.suaq-nl-say--sent,
.suaq-newsletter:has(.gform_confirmation_message) .suaq-nl-say--signup,
.suaq-newsletter:has(.gform_confirmation_message) .suaq-nl-fineprint {
	display: none;
}

.suaq-newsletter:has(.gform_confirmation_message) .suaq-nl-say--sent {
	display: block;
}

.suaq-nl-fineprint {
	max-width: 36rem;
	margin-top: 1rem !important;
	color: var(--wp--preset--color--muted);
	font-size: 0.9375rem;
	line-height: 1.5;
}

/* After sending: the confirmation sits on the same white print as the form. */
.suaq-contact-card .gform_confirmation_wrapper {
	margin-top: 0 !important;
	padding: clamp(20px, 3vw, 36px);
	background: var(--wp--preset--color--paper);
	box-shadow: var(--wp--preset--shadow--print);
}

.gform_confirmation_message.suaq-nl-sent {
	padding: 0;
	background: none;
	border: 0;
	font-size: 1.0625rem;
	line-height: 1.55;
	outline: 0;
}

.suaq-nl-sent > * {
	margin: 0;
}

.suaq-nl-sent > * + * {
	margin-top: 1rem;
}

/* An envelope flies off along a dashed line. */
.suaq-nl-sent__flight {
	position: relative;
	height: 92px;
	max-width: 260px;
	color: var(--wp--preset--color--contrast);
}

.suaq-nl-sent__trail {
	position: absolute;
	inset: 0 40px 0 0;
	width: calc(100% - 40px);
	height: 100%;
	color: var(--wp--preset--color--muted);
}

.suaq-nl-sent__envelope {
	position: absolute;
	top: -8px;
	right: 0;
	width: 58px;
	height: 42px;
	transform: rotate(-12deg);
}

.suaq-nl-sent__title {
	font-family: var(--wp--preset--font-family--display);
	font-size: clamp(1.75rem, 1.3rem + 1.4vw, 2.375rem);
	font-weight: 700;
	line-height: 0.95;
	text-transform: uppercase;
}

.suaq-nl-sent strong {
	overflow-wrap: anywhere;
}

/* Three steps, the first ticked, the second the one to do now. */
.suaq-nl-steps {
	display: grid;
	gap: 12px;
	padding: 18px 0 0 !important;
	border-top: 1.5px dashed var(--wp--preset--color--muted);
	list-style: none;
	counter-reset: suaq-step;
}

.suaq-nl-steps li {
	display: flex;
	align-items: center;
	gap: 14px;
	margin: 0;
	font-family: var(--wp--preset--font-family--display);
	font-size: 1rem;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	counter-increment: suaq-step;
}

.suaq-nl-steps li::before {
	content: counter(suaq-step);
	display: grid;
	flex: none;
	place-items: center;
	width: 34px;
	height: 34px;
	border: 2px solid var(--wp--preset--color--contrast);
	border-radius: 50%;
	background: var(--wp--preset--color--paper);
	font-size: 0.9375rem;
	line-height: 1;
}

.suaq-nl-steps li.is-done {
	color: var(--wp--preset--color--muted);
	text-decoration: line-through;
	text-decoration-thickness: 2px;
}

.suaq-nl-steps li.is-done::before {
	content: "✓";
	border-color: var(--wp--preset--color--primary);
	background: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--paper);
}

.suaq-nl-steps li.is-now::before {
	border-color: var(--wp--preset--color--accent);
	color: var(--wp--preset--color--accent);
	box-shadow: 0 0 0 4px rgb(255 255 255), 0 0 0 6px var(--wp--preset--color--accent);
}

.suaq-nl-sent__hint {
	color: var(--wp--preset--color--muted);
	font-size: 0.9375rem;
	line-height: 1.5;
}

.suaq-nl-sent__hint a {
	color: var(--wp--preset--color--contrast);
	white-space: nowrap;
}

/* Welcome: a rust stamp on a white print, and where to go next. */
.suaq-nl-print {
	padding: clamp(20px, 3vw, 36px);
	background: var(--wp--preset--color--paper);
	box-shadow: var(--wp--preset--shadow--print);
}

.suaq-nl-print > * {
	margin: 0;
}

.suaq-nl-print > * + * {
	margin-top: 1.25rem;
}

.suaq-nl-stamp {
	display: inline-block;
	padding: 8px 16px 6px;
	border: 3px solid var(--wp--preset--color--accent);
	border-radius: 4px;
	color: var(--wp--preset--color--accent);
	font-family: var(--wp--preset--font-family--display);
	font-size: 1.5rem;
	font-weight: 700;
	letter-spacing: 0.14em;
	line-height: 1;
	text-transform: uppercase;
	transform: rotate(-7deg);
	opacity: 0.9;
}

@media (prefers-reduced-motion: no-preference) {
	.suaq-nl-sent__trail {
		animation: suaq-nl-trail 0.9s ease-out both;
	}

	.suaq-nl-sent__envelope {
		animation:
			suaq-nl-fly 0.9s cubic-bezier(0.3, 0.7, 0.4, 1) both,
			suaq-nl-bob 2.4s ease-in-out 1s infinite;
	}

	.suaq-nl-steps li.is-now::before {
		animation: suaq-nl-pulse 1.6s ease-in-out 1s infinite;
	}

	.suaq-nl-stamp {
		animation: suaq-nl-stamp 0.45s cubic-bezier(0.3, 1.6, 0.5, 1) 0.6s both;
	}

	@keyframes suaq-nl-trail {
		from {
			clip-path: inset(0 100% 0 0);
		}

		to {
			clip-path: inset(0 0 0 0);
		}
	}

	@keyframes suaq-nl-fly {
		from {
			opacity: 0;
			transform: translate(-190px, 70px) rotate(14deg) scale(0.7);
		}

		60% {
			opacity: 1;
		}
	}

	@keyframes suaq-nl-bob {
		50% {
			transform: translateY(-5px) rotate(-8deg);
		}
	}

	@keyframes suaq-nl-pulse {
		50% {
			box-shadow: 0 0 0 4px rgb(255 255 255), 0 0 0 9px color-mix(in srgb, var(--wp--preset--color--accent) 35%, transparent);
		}
	}

	@keyframes suaq-nl-stamp {
		from {
			opacity: 0;
			transform: rotate(-16deg) scale(2.2);
		}
	}
}

/* Phones: the photo first, the bubble hangs from its foot, tail up. */
@media (max-width: 781px) {
	.suaq-newsletter__photo .wp-block-image {
		max-width: 78%;
	}

	.suaq-newsletter__cols {
		gap: 0 !important;
	}

	.suaq-newsletter .wp-block-group.is-style-speech {
		margin: -1.5rem var(--suaq-gutter, 16px) 0 8% !important;
	}

	.suaq-newsletter .wp-block-group.is-style-speech::before,
	.suaq-newsletter .wp-block-group.is-style-speech::after {
		bottom: auto;
		top: -40px;
		left: 14%;
		border-width: 0 16px 40px 16px;
		border-color: transparent transparent var(--wp--preset--color--contrast) transparent;
		transform: none;
	}

	.suaq-newsletter .wp-block-group.is-style-speech::after {
		top: -33px;
		left: calc(14% + 3.5px);
		border-width: 0 12.5px 34px 12.5px;
		border-color: transparent transparent var(--wp--preset--color--paper) transparent;
		margin: 0;
	}
}
