/* Neutral layout only; colours, fonts and borders come from the theme. */

/* Layout rules below set display, which would otherwise override the hidden attribute. */
.essentialswp-form [hidden] {
	display: none !important;
}
.essentialswp-form__fields {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 1em;
	margin-bottom: 1em;
}

.essentialswp-field {
	display: flex;
	flex-direction: column;
	gap: 0.35em;
}

.essentialswp-field__optional {
	opacity: 0.7;
	font-size: 0.9em;
}

.essentialswp-field--wide {
	grid-column: 1 / -1;
}

.essentialswp-field input,
.essentialswp-field textarea {
	width: 100%;
	box-sizing: border-box;
	font: inherit;
}

.essentialswp-checkbox {
	--essentialswp-checkbox-size: 0.85em;
	display: flex;
	align-items: flex-start;
	gap: 0.6em;
	margin: 0.5em 0;
	cursor: pointer;
}

/* Drawn box: border in the text colour, an inset square when checked. Themes may set
   --essentialswp-checkbox-accent to colour the fill. */
.essentialswp-checkbox input[type="checkbox"] {
	appearance: none;
	-webkit-appearance: none;
	position: relative;
	flex-shrink: 0;
	box-sizing: border-box;
	width: var(--essentialswp-checkbox-size);
	height: var(--essentialswp-checkbox-size);
	/* Inherit the label's font so 1lh is the text's line height, not the control's. */
	font: inherit;
	line-height: inherit;
	margin: 0.3em 0 0;
	/* Centre the box on the first text line, whatever line-height the theme sets. */
	margin-top: calc((1lh - var(--essentialswp-checkbox-size)) / 2);
	padding: 0;
	border: 1.5px solid currentColor;
	border-radius: 0;
	background: transparent;
	color: inherit;
	cursor: pointer;
}

.essentialswp-checkbox input[type="checkbox"]::before {
	content: "";
	position: absolute;
	inset: 2px;
	background: var(--essentialswp-checkbox-accent, currentColor);
	transform: scale(0);
	transition: transform 0.15s ease-out;
}

.essentialswp-checkbox input[type="checkbox"]:checked::before {
	transform: scale(1);
}

.essentialswp-checkbox input[type="checkbox"]:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.essentialswp-checkbox input[type="checkbox"]:disabled,
.essentialswp-checkbox input[type="checkbox"]:disabled + span {
	cursor: not-allowed;
	opacity: 0.5;
}

@media (prefers-reduced-motion: reduce) {
	.essentialswp-checkbox input[type="checkbox"]::before {
		transition: none;
	}
}

/* High-contrast modes repaint backgrounds; keep the native control there. */
@media (forced-colors: active) {
	.essentialswp-checkbox input[type="checkbox"] {
		appearance: auto;
		-webkit-appearance: checkbox;
	}
	.essentialswp-checkbox input[type="checkbox"]::before {
		content: none;
	}
}

.essentialswp-form__actions {
	margin-top: 1em;
}

.essentialswp-form__response {
	margin-top: 1em;
	padding: 0.75em 1em;
	border-left: 4px solid currentColor;
}

.essentialswp-form__response.is-error {
	color: #b32d2e;
}

.essentialswp-form__response.is-pending {
	/* The button's spinner is the visible state; "Sending…" stays for screen readers. */
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.essentialswp-form__submit.is-busy::after {
	content: "";
	display: inline-block;
	width: 1em;
	height: 1em;
	border: 2px solid currentColor;
	border-right-color: transparent;
	border-radius: 50%;
	animation: essentialswp-spin 0.8s linear infinite;
	flex-shrink: 0;
}

.essentialswp-form__submit.is-busy {
	cursor: progress;
}

.essentialswp-form__submit.is-busy::after {
	margin-left: 0.5em;
	vertical-align: -0.15em;
}

@keyframes essentialswp-spin {
	to {
		transform: rotate(360deg);
	}
}

@media (prefers-reduced-motion: reduce) {
	.essentialswp-form__submit.is-busy::after {
		animation-duration: 2.4s;
	}
}

@media (max-width: 600px) {
	.essentialswp-form__fields {
		grid-template-columns: 1fr;
	}
}

/* Newsletter: email and button on one row, as a compact sign-up. */
.essentialswp-newsletter-form .essentialswp-form__fields {
	display: flex;
	gap: 0.5em;
	align-items: stretch;
	grid-template-columns: none;
	margin-bottom: 0.5em;
}

.essentialswp-newsletter-form .essentialswp-form__fields input[type="email"] {
	flex: 1 1 auto;
	min-width: 0;
	font: inherit;
}

.essentialswp-form__captcha-note {
	font-size: 0.85em;
	opacity: 0.8;
}
