/**
 * Smart Contact Form - front-end styles.
 *
 * Uses logical properties so it works in left-to-right and right-to-left
 * languages without a separate RTL file. Override any --smart-contact-form-* variable
 * in your theme to restyle the form, for example:
 *
 *   .smart-contact-form { --smart-contact-form-accent: #7a1fa2; }
 */

.smart-contact-form {
	--smart-contact-form-accent: #2563eb;
	--smart-contact-form-accent-contrast: #fff;
	--smart-contact-form-text: inherit;
	--smart-contact-form-muted: #5b6472;
	--smart-contact-form-border: #c7ccd4;
	--smart-contact-form-bg: #fff;
	--smart-contact-form-error: #b42318;
	--smart-contact-form-error-bg: #fef3f2;
	--smart-contact-form-success: #067647;
	--smart-contact-form-success-bg: #ecfdf3;
	--smart-contact-form-radius: 8px;
	--smart-contact-form-gap: 1.1rem;

	max-inline-size: 40rem;
	color: var(--smart-contact-form-text);
	font: inherit;
}

.smart-contact-form *,
.smart-contact-form *::before,
.smart-contact-form *::after {
	box-sizing: border-box;
}

.smart-contact-form__title {
	margin-block: 0 0.75rem;
}

.smart-contact-form__form {
	display: grid;
	gap: var(--smart-contact-form-gap);
	margin: 0;
}

.smart-contact-form__hint {
	margin: 0;
	font-size: 0.875em;
	color: var(--smart-contact-form-muted);
}

.smart-contact-form__req {
	color: var(--smart-contact-form-error);
}

.smart-contact-form__field {
	display: grid;
	gap: 0.35rem;
	margin: 0;
}

.smart-contact-form__field > label {
	font-weight: 600;
}

.smart-contact-form input[type="text"],
.smart-contact-form input[type="email"],
.smart-contact-form textarea {
	inline-size: 100%;
	padding: 0.7rem 0.85rem;
	border: 1px solid var(--smart-contact-form-border);
	border-radius: var(--smart-contact-form-radius);
	background: var(--smart-contact-form-bg);
	color: inherit;
	font: inherit;
	line-height: 1.5;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.smart-contact-form textarea {
	min-block-size: 8rem;
	resize: vertical;
}

.smart-contact-form input:focus-visible,
.smart-contact-form textarea:focus-visible,
.smart-contact-form button:focus-visible {
	outline: 3px solid color-mix(in srgb, var(--smart-contact-form-accent) 45%, transparent);
	outline-offset: 2px;
	border-color: var(--smart-contact-form-accent);
}

.smart-contact-form input[aria-invalid="true"],
.smart-contact-form textarea[aria-invalid="true"] {
	border-color: var(--smart-contact-form-error);
	background: var(--smart-contact-form-error-bg);
}

.smart-contact-form__error {
	min-block-size: 0;
	font-size: 0.875em;
	color: var(--smart-contact-form-error);
}

.smart-contact-form__error:empty {
	display: none;
}

/* Consent row: checkbox beside its label. */
.smart-contact-form__field--consent,
.smart-contact-form__field--copy {
	grid-template-columns: auto 1fr;
	align-items: start;
	column-gap: 0.6rem;
}

.smart-contact-form__field--consent > label,
.smart-contact-form__field--copy > label {
	font-weight: 400;
}

.smart-contact-form__field--consent input,
.smart-contact-form__field--copy input {
	inline-size: 1.15rem;
	block-size: 1.15rem;
	margin-block-start: 0.2rem;
	accent-color: var(--smart-contact-form-accent);
}

.smart-contact-form__field--consent .smart-contact-form__error {
	grid-column: 1 / -1;
}

/* Spelling and grammar panel. */
.smart-contact-form__grammar {
	display: grid;
	gap: 0.4rem;
	font-size: 0.9em;
}

.smart-contact-form__grammar[hidden] {
	display: none;
}

.smart-contact-form__grammar-button,
.smart-contact-form__grammar-apply,
.smart-contact-form__grammar-ignore {
	justify-self: start;
	padding: 0.35rem 0.8rem;
	border: 1px solid var(--smart-contact-form-border);
	border-radius: var(--smart-contact-form-radius);
	background: var(--smart-contact-form-bg);
	color: inherit;
	font: inherit;
	cursor: pointer;
}

.smart-contact-form__grammar-button:hover,
.smart-contact-form__grammar-apply:hover,
.smart-contact-form__grammar-ignore:hover {
	border-color: var(--smart-contact-form-accent);
}

.smart-contact-form__grammar-button:focus-visible,
.smart-contact-form__grammar-apply:focus-visible,
.smart-contact-form__grammar-ignore:focus-visible {
	outline: 2px solid var(--smart-contact-form-accent);
	outline-offset: 2px;
}

.smart-contact-form__grammar-button[disabled] {
	opacity: 0.6;
	cursor: wait;
}

.smart-contact-form__grammar-note {
	color: var(--smart-contact-form-muted);
	font-size: 0.9em;
}

.smart-contact-form__grammar-results:empty {
	display: none;
}

.smart-contact-form__grammar-count {
	margin: 0;
	font-weight: 600;
}

.smart-contact-form__grammar-list {
	display: grid;
	gap: 0.5rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.smart-contact-form__grammar-item {
	display: grid;
	gap: 0.3rem;
	padding: 0.5rem 0.65rem;
	border: 1px solid var(--smart-contact-form-border);
	border-radius: var(--smart-contact-form-radius);
}

.smart-contact-form__grammar-item mark {
	justify-self: start;
	padding: 0 0.2em;
	background: var(--smart-contact-form-error-bg);
	color: var(--smart-contact-form-error);
	text-decoration: underline wavy;
	overflow-wrap: anywhere;
}

.smart-contact-form__grammar-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
}

.smart-contact-form__submit {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.75rem 1.5rem;
	border: 0;
	border-radius: var(--smart-contact-form-radius);
	background: var(--smart-contact-form-accent);
	color: var(--smart-contact-form-accent-contrast);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	transition: filter 0.15s ease, transform 0.05s ease;
}

.smart-contact-form__submit:hover {
	filter: brightness(1.08);
}

.smart-contact-form__submit:active {
	transform: translateY(1px);
}

.smart-contact-form__submit[disabled] {
	opacity: 0.7;
	cursor: progress;
}

.smart-contact-form__submit[aria-busy="true"]::before {
	content: "";
	inline-size: 1em;
	block-size: 1em;
	border: 2px solid currentColor;
	border-inline-end-color: transparent;
	border-radius: 50%;
	animation: smart-contact-form-spin 0.8s linear infinite;
}

@keyframes smart-contact-form-spin {
	to {
		transform: rotate(360deg);
	}
}

.smart-contact-form__notice {
	padding: 0.85rem 1rem;
	border-radius: var(--smart-contact-form-radius);
	border-inline-start: 4px solid currentColor;
}

.smart-contact-form__notice:focus {
	outline: none;
}

.smart-contact-form__notice.is-success {
	color: var(--smart-contact-form-success);
	background: var(--smart-contact-form-success-bg);
}

.smart-contact-form__notice.is-error {
	color: var(--smart-contact-form-error);
	background: var(--smart-contact-form-error-bg);
}

/* Honeypot: off-screen rather than display:none, which some bots detect. */
.smart-contact-form__hp {
	position: absolute !important;
	inset-inline-start: -9999px !important;
	inline-size: 1px;
	block-size: 1px;
	overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
	.smart-contact-form *,
	.smart-contact-form *::before {
		animation: none !important;
		transition: none !important;
	}
}
