/*
 * Tomegah — bright-tomegah-core/contact-form styling.
 *
 * The block (wp-content/plugins/bright-tomegah-core/includes/
 * contact-form-block.php) owns markup and behaviour only; every visual
 * rule for it lives here, per this project's plugin/theme split. Loaded
 * only on pages that actually contain the block — see
 * tomegah_enqueue_contact_form_assets() in functions.php.
 *
 * Phase E: restyled to the approved Claude Design ("Send a message" form
 * spec) using only the plugin's existing markup and classes. On wide
 * screens the short fields pair up two per row; everything stacks below
 * 600px. Field borders use the theme's field-border token (#91836A, at
 * least 3:1 against field, ivory and sand — WCAG 1.4.11); error text is
 * terracotta (5.2:1 on ivory) and every error is also announced in the
 * summary with role="alert" and tied to its field by aria-describedby in
 * the plugin markup.
 */

.btc-contact-form-block {
	max-width: 40rem;
	padding-top: 28px;
	border-top: 1px solid var(--wp--preset--color--charcoal);
	font-size: 1rem;
}

.btc-contact-form-block > * {
	margin-block: 0;
}

.btc-contact-form-block > * + * {
	margin-top: 22px;
}

/* Shown to visitors while public submissions are off. */
.btc-contact-form__notice {
	color: var(--wp--preset--color--muted);
	font-style: italic;
}

/* Administrator preview and "not saved" notices. */
.btc-contact-form__preview-notice {
	padding: 12px 16px;
	border-left: 3px solid var(--wp--preset--color--terracotta);
	background-color: var(--wp--preset--color--sand);
	font-size: 0.875rem;
	line-height: 1.55;
}

.btc-contact-form__success {
	padding: 16px 20px;
	border-radius: 2px;
	background-color: var(--wp--preset--color--forest);
	color: var(--wp--preset--color--ivory);
}

/* Error summary. */
.btc-contact-form__errors {
	padding: 16px 20px;
	border: 1px solid var(--wp--preset--color--terracotta);
	border-left-width: 3px;
	border-radius: 2px;
	background-color: var(--wp--preset--color--field);
	font-size: 0.9375rem;
}

.btc-contact-form__errors p {
	margin: 0 0 8px;
	font-weight: 600;
}

.btc-contact-form__errors ul {
	margin: 0;
	padding-left: 1.2em;
}

.btc-contact-form__errors a {
	color: var(--wp--preset--color--terracotta);
}

/* Fields: two per row for the short ones on wide screens. */
.btc-contact-form {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 22px 20px;
}

.btc-contact-form > * {
	grid-column: 1 / -1;
	margin: 0;
}

.btc-contact-form > .btc-contact-form__field:has(input[type="text"]),
.btc-contact-form > .btc-contact-form__field:has(input[type="email"]),
.btc-contact-form > .btc-contact-form__field:has(select) {
	grid-column: auto;
}

/* Hidden inputs and the honeypot take no grid cell. */
.btc-contact-form > input[type="hidden"] {
	display: none;
}

.btc-contact-form__field {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.btc-contact-form__field label {
	font-size: 0.875rem;
	font-weight: 600;
}

.btc-contact-form__required {
	color: var(--wp--preset--color--terracotta);
}

.btc-contact-form__field input[type="text"],
.btc-contact-form__field input[type="email"],
.btc-contact-form__field select,
.btc-contact-form__field textarea {
	box-sizing: border-box;
	width: 100%;
	max-width: 100%;
	min-height: 48px;
	padding: 0 14px;
	border: 1px solid var(--wp--custom--color--field-border);
	border-radius: 2px;
	background-color: var(--wp--preset--color--field);
	color: var(--wp--preset--color--charcoal);
	font-family: inherit;
	font-size: 1rem;
}

.btc-contact-form__field textarea {
	min-height: 160px;
	padding: 12px 14px;
	line-height: 1.6;
	resize: vertical;
}

.btc-contact-form__field input:focus,
.btc-contact-form__field select:focus,
.btc-contact-form__field textarea:focus {
	border-color: var(--wp--preset--color--forest);
}

.btc-contact-form__field.has-error input,
.btc-contact-form__field.has-error select,
.btc-contact-form__field.has-error textarea {
	border-width: 2px;
	border-color: var(--wp--preset--color--terracotta);
}

.btc-contact-form__error {
	color: var(--wp--preset--color--terracotta);
	font-size: 0.8125rem;
	font-weight: 500;
}

/* Consent. */
/* The label holds the checkbox, a text run and a link; a grid would split
   those into separate cells, so the text is indented beside the box. */
.btc-contact-form__field--consent label {
	display: block;
	position: relative;
	padding-left: 32px;
	color: var(--wp--preset--color--muted);
	font-size: 0.875rem;
	font-weight: 400;
	line-height: 1.55;
}

.btc-contact-form__field--consent input[type="checkbox"] {
	position: absolute;
	top: 1px;
	left: 0;
	width: 20px;
	height: 20px;
	margin: 0;
	accent-color: var(--wp--preset--color--forest);
}

.btc-contact-form__field--consent a {
	color: var(--wp--preset--color--forest);
}

/*
 * Honeypot: visually hidden without display:none/visibility:hidden, both
 * of which some bots specifically detect and skip. Off-screen positioning
 * keeps it invisible and untabbable (paired with tabindex="-1" in the
 * markup) while remaining a normal, fillable field to anything that
 * doesn't render CSS.
 */
.btc-contact-form__honeypot {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
}

.btc-contact-form__submit button {
	min-height: 48px;
	padding: 0 28px;
	border: 0;
	border-radius: 2px;
	background-color: var(--wp--preset--color--forest);
	color: var(--wp--preset--color--ivory);
	font-family: inherit;
	font-size: 0.9375rem;
	font-weight: 500;
	cursor: pointer;
}

.btc-contact-form__submit button:hover {
	background-color: var(--wp--preset--color--forest-deep);
}

@media (max-width: 599px) {

	.btc-contact-form {
		grid-template-columns: minmax(0, 1fr);
		gap: 18px;
	}

	.btc-contact-form__submit button {
		width: 100%;
		min-height: 50px;
	}
}
