/* TOFTS sign-up forms and popup (mu-plugins/tofts-newsletter.php). Colours are the theme's presets. */

/* The form and its fields take the full width of the section they sit in, like the text around it. */
.tofts-signup {
	margin-block: 1.5rem 0;
}
.tofts-signup label {
	display: block;
	margin-bottom: 0.35rem;
	font-weight: 700;
}
.tofts-signup__hint,
.tofts-signup__privacy {
	margin: 0 0 0.5rem;
	font-size: var(--wp--preset--font-size--small);
}
.tofts-signup__privacy {
	margin-top: 0.75rem;
}
.tofts-signup__error:empty,
.tofts-signup__status:empty {
	display: none;
}
.tofts-signup__error {
	margin: 0 0 0.5rem;
	font-weight: 700;
	color: var(--wp--preset--color--barn-red); /* 6.6:1 on paper and cream */
}
.tofts-signup__status {
	margin: 0.75rem 0 0;
	font-weight: 700;
}
.tofts-signup__row {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem;
	align-items: stretch;
}
.tofts-signup :is(input[type="email"], input[type="text"]) {
	box-sizing: border-box;
	flex: 1 1 16rem;
	min-width: 0;
	min-height: 2.875rem;
	padding: 0.6rem 0.75rem;
	font: inherit;
	color: var(--wp--preset--color--ink);
	background: var(--wp--preset--color--white);
	/* muted on white is 6:1, above the 3:1 needed for control boundaries */
	border: 2px solid var(--wp--preset--color--muted);
	border-radius: 4px;
}
/* First and last name share a line when both fit at 12rem; otherwise they stack. */
.tofts-signup__names {
	display: flex;
	flex-wrap: wrap;
	gap: 0 1rem;
}
.tofts-signup__field--name {
	flex: 1 1 12rem;
	min-width: 0;
	margin-bottom: 1rem;
}
.tofts-signup__field--name input {
	width: 100%;
}
.tofts-signup input[aria-invalid="true"] {
	border-color: var(--wp--preset--color--barn-red);
	border-width: 3px;
}
.tofts-signup button[type="submit"] {
	flex: 0 0 auto;
	min-height: 2.875rem;
	cursor: pointer;
}
/* Honeypot: off screen and out of the accessibility tree for people; bots still fill it in. */
.tofts-signup__hp {
	display: none;
}

/* Dark sections: text follows the section (paper), not the light-background colours above. */
:is(.has-ink-background-color, .has-barn-red-background-color, .has-sage-background-color) .tofts-signup__error {
	color: inherit;
}
:is(.has-ink-background-color, .has-barn-red-background-color, .has-sage-background-color) .tofts-signup :is(input[type="email"], input[type="text"]) {
	border-color: var(--wp--preset--color--white);
}

/* Admins only, while MailerLite isn't set up. */
.tofts-signup-note {
	padding: 0.75rem 1rem;
	border: 2px dashed currentColor;
}

/* ---- Popup ---- */
.tofts-popup {
	box-sizing: border-box;
	width: min(34rem, calc(100% - 2rem));
	max-height: calc(100% - 2rem);
	overflow: auto;
	padding: 2.5rem 1.5rem 1.25rem;
	color: var(--wp--preset--color--body);
	background: var(--wp--preset--color--paper);
	border: 2px solid var(--wp--preset--color--ink);
	border-radius: 8px;
}
.tofts-popup::backdrop {
	background: rgb(27 41 64 / 0.7);
}
.tofts-popup__title {
	margin: 0 0 0.5rem;
	color: var(--wp--preset--color--ink);
	font-size: var(--wp--preset--font-size--large);
}
.tofts-popup .tofts-signup {
	margin-top: 0;
}
.tofts-popup__close {
	position: absolute;
	top: 0.5rem;
	right: 0.5rem;
	display: grid;
	place-items: center;
	width: 2.75rem;
	height: 2.75rem;
	padding: 0;
	font-size: 1.75rem;
	line-height: 1;
	color: var(--wp--preset--color--ink);
	background: transparent;
	border: 2px solid var(--wp--preset--color--muted);
	border-radius: 4px;
	cursor: pointer;
}
.tofts-popup__later {
	margin: 1rem 0 0;
	text-align: right;
}
.tofts-popup__no {
	min-height: 2.75rem;
	padding: 0.5rem 0.25rem;
	font: inherit;
	color: var(--wp--preset--color--ink);
	text-decoration: underline;
	background: none;
	border: 0;
	cursor: pointer;
}
.tofts-popup :is(.tofts-popup__close, .tofts-popup__no):hover {
	color: var(--wp--preset--color--barn-red);
}
@media (prefers-reduced-motion: no-preference) {
	.tofts-popup[open] {
		animation: tofts-popup-in 0.2s ease-out;
	}
	@keyframes tofts-popup-in {
		from { opacity: 0; transform: translateY(0.75rem); }
	}
}
