/*
 * Contact Form 7 styling for the SAPA North West design.
 *
 * Contact Form 7 ships almost no styling of its own and wraps every control in a
 * <span class="wpcf7-form-control-wrap">, which breaks the grid and vertical
 * rhythm the approved design relies on. This file makes a Contact Form 7 form
 * look like the hand-built forms in the static HTML, reusing the same tokens
 * (--color-primary, --color-secondary and friends) rather than new colours.
 *
 * Specificity is kept low and !important is used only where Contact Form 7 sets
 * an inline style or a hard-coded colour of its own.
 */

/* -------------------------------------------------------------------------- */
/* Layout: undo the inline wrappers                                           */
/* -------------------------------------------------------------------------- */

.wpcf7 {
	position: relative;
}

.wpcf7-form-control-wrap {
	display: block;
	position: relative;
}

/* The design spaces fields itself, so remove Contact Form 7's own paragraph margins. */
.wpcf7-form p {
	margin: 0;
}

.sapa-cf7 .wpcf7-form > p + p {
	margin-top: 1.25rem;
}

/* -------------------------------------------------------------------------- */
/* Labels                                                                     */
/* -------------------------------------------------------------------------- */

.wpcf7-form .label,
.wpcf7-form label {
	display: block;
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--color-primary);
	margin-bottom: 0.4rem;
}

/* Checkbox and radio labels sit beside their control, not above it. */
.wpcf7-form .wpcf7-checkbox label,
.wpcf7-form .wpcf7-radio label,
.wpcf7-form .wpcf7-acceptance label {
	display: flex;
	align-items: flex-start;
	gap: 0.65rem;
	font-weight: 400;
	font-size: 0.875rem;
	color: var(--color-text-muted);
	margin-bottom: 0;
	cursor: pointer;
}

.wpcf7-form .sapa-label-inline label {
	display: inline;
	font-weight: 400;
}

/* -------------------------------------------------------------------------- */
/* Text inputs, selects and textareas                                         */
/* -------------------------------------------------------------------------- */

.wpcf7-form-control.wpcf7-text,
.wpcf7-form-control.wpcf7-email,
.wpcf7-form-control.wpcf7-tel,
.wpcf7-form-control.wpcf7-url,
.wpcf7-form-control.wpcf7-number,
.wpcf7-form-control.wpcf7-date,
.wpcf7-form-control.wpcf7-select,
.wpcf7-form-control.wpcf7-textarea {
	width: 100%;
	padding: 0.75rem 1rem;
	font-size: 1rem;
	font-weight: 400;
	line-height: 1.5;
	font-family: inherit;
	color: var(--color-text);
	background-color: #fff;
	border: 1px solid #e5e7eb;
	border-radius: 0.5rem;
	transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
	-webkit-appearance: none;
	appearance: none;
}

.wpcf7-form-control.wpcf7-textarea {
	min-height: 8rem;
	resize: vertical;
	line-height: 1.6;
}

/* Native select arrow, drawn to match the design's inputs. */
.wpcf7-form-control.wpcf7-select {
	background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 1rem center;
	padding-right: 2.75rem;
}

.wpcf7-form-control.wpcf7-select[multiple] {
	background-image: none;
	padding-right: 1rem;
}

.wpcf7-form-control.wpcf7-text:focus-visible,
.wpcf7-form-control.wpcf7-email:focus-visible,
.wpcf7-form-control.wpcf7-tel:focus-visible,
.wpcf7-form-control.wpcf7-url:focus-visible,
.wpcf7-form-control.wpcf7-number:focus-visible,
.wpcf7-form-control.wpcf7-date:focus-visible,
.wpcf7-form-control.wpcf7-select:focus-visible,
.wpcf7-form-control.wpcf7-textarea:focus-visible {
	outline: none;
	border-color: #f17e21;
	box-shadow: 0 0 0 2px rgba(241, 126, 33, 0.35);
}

.wpcf7-form-control::placeholder {
	color: #9ca3af;
}

.wpcf7-form-control:disabled {
	background-color: #f3f4f6;
	cursor: not-allowed;
}

/* -------------------------------------------------------------------------- */
/* Checkboxes and radios                                                      */
/* -------------------------------------------------------------------------- */

.wpcf7-form .wpcf7-list-item {
	display: block;
	margin: 0 0 0.5rem;
}

.wpcf7-form .wpcf7-list-item:last-child {
	margin-bottom: 0;
}

.wpcf7-form .wpcf7-list-item-label {
	line-height: 1.5;
}

.wpcf7-form input[type="checkbox"],
.wpcf7-form input[type="radio"] {
	width: 1rem;
	height: 1rem;
	margin-top: 0.2rem;
	accent-color: #f17e21;
	flex-shrink: 0;
}

/* The design lays checkbox groups out in a row where there is space. */
.wpcf7-form .sapa-inline-options .wpcf7-list-item {
	display: inline-block;
	margin-right: 1.25rem;
}

/* -------------------------------------------------------------------------- */
/* Required field marker                                                      */
/* -------------------------------------------------------------------------- */

.wpcf7-form .sapa-required {
	color: #f17e21;
	font-weight: 700;
}

.sapa-cf7 .sapa-required-note {
	font-size: 0.8125rem;
	color: var(--color-text-muted);
}

/* -------------------------------------------------------------------------- */
/* Submit button                                                              */
/* -------------------------------------------------------------------------- */

.wpcf7-form-control.wpcf7-submit {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	padding: 0.75rem 1.5rem;
	font-size: 1rem;
	font-weight: 500;
	font-family: inherit;
	line-height: 1.5;
	color: #fff;
	background-color: var(--color-primary);
	border: 0;
	border-radius: 0.5rem;
	cursor: pointer;
	transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.1s ease;
	-webkit-appearance: none;
	appearance: none;
}

.wpcf7-form-control.wpcf7-submit:hover {
	background-color: #162d4d;
}

.wpcf7-form-control.wpcf7-submit:focus-visible {
	outline: 2px solid #f17e21;
	outline-offset: 2px;
}

.wpcf7-form-control.wpcf7-submit:active {
	transform: translateY(1px);
}

.wpcf7-form-control.wpcf7-submit:disabled {
	opacity: 0.65;
	cursor: not-allowed;
}

/* An accent submit button, for forms sitting on a dark panel. */
.sapa-cf7--accent .wpcf7-form-control.wpcf7-submit {
	background-color: var(--color-accent);
	border-color: var(--color-accent);
	color: var(--color-primary);
}

.sapa-cf7--accent .wpcf7-form-control.wpcf7-submit:hover {
	background-color: var(--color-accent-light);
	border-color: var(--color-accent-light);
}

/* -------------------------------------------------------------------------- */
/* Loading state                                                              */
/* -------------------------------------------------------------------------- */

.wpcf7-spinner {
	display: inline-block;
	width: 1.25rem;
	height: 1.25rem;
	margin: 0 0 0 0.75rem;
	vertical-align: middle;
	background-color: transparent;
	border: 2px solid rgba(241, 126, 33, 0.25);
	border-top-color: #f17e21;
	border-radius: 9999px;
	opacity: 1;
	animation: sapa-cf7-spin 0.7s linear infinite;
}

/* Contact Form 7's own pulse animation would fight the spinner above. */
.wpcf7-spinner::before {
	display: none;
}

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

@media (prefers-reduced-motion: reduce) {
	.wpcf7-spinner {
		animation-duration: 2s;
	}

	.wpcf7-form-control.wpcf7-submit {
		transition: none;
	}
}

.wpcf7-form.submitting .wpcf7-form-control.wpcf7-submit {
	opacity: 0.7;
	pointer-events: none;
}

/* -------------------------------------------------------------------------- */
/* Validation errors                                                          */
/* -------------------------------------------------------------------------- */

.wpcf7-form-control.wpcf7-not-valid {
	border-color: #dc2626;
	box-shadow: 0 0 0 1px #dc2626;
}

.wpcf7-form-control.wpcf7-not-valid:focus {
	box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
}

.wpcf7-not-valid-tip {
	display: block;
	margin-top: 0.35rem;
	font-size: 0.8125rem;
	font-weight: 500;
	color: #dc2626;
}

/* -------------------------------------------------------------------------- */
/* Response messages                                                          */
/* -------------------------------------------------------------------------- */

.wpcf7-response-output {
	margin: 1.5rem 0 0 !important;
	padding: 0.875rem 1.125rem !important;
	border: 1px solid transparent !important;
	border-radius: 0.5rem;
	font-size: 0.875rem;
	line-height: 1.5;
}

/* Success */
.wpcf7 form.sent .wpcf7-response-output {
	color: var(--color-secondary-dark);
	background-color: rgba(26, 166, 166, 0.1);
	border-color: rgba(26, 166, 166, 0.3) !important;
}

/* Validation failed */
.wpcf7 form.invalid .wpcf7-response-output,
.wpcf7 form.unaccepted .wpcf7-response-output,
.wpcf7 form.payment-required .wpcf7-response-output {
	color: #92400e;
	background-color: #fef3c7;
	border-color: #fcd34d !important;
}

/* Send failed, spam, or an aborted submission */
.wpcf7 form.failed .wpcf7-response-output,
.wpcf7 form.aborted .wpcf7-response-output,
.wpcf7 form.spam .wpcf7-response-output {
	color: #991b1b;
	background-color: #fee2e2;
	border-color: #fca5a5 !important;
}

/* -------------------------------------------------------------------------- */
/* Honeypot and hidden fields                                                 */
/* -------------------------------------------------------------------------- */

.sapa-cf7 .sapa-hidden,
.wpcf7-form .sapa-hidden {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

/* -------------------------------------------------------------------------- */
/* Editor-only configuration notice                                           */
/* -------------------------------------------------------------------------- */

.sapa-cf7-notice {
	padding: 1rem 1.25rem;
	background-color: #fff7ed;
	border: 1px dashed #fdba74;
	border-radius: 0.5rem;
	color: #9a3412;
	font-size: 0.875rem;
}

.sapa-cf7-notice p {
	margin: 0;
}

/* -------------------------------------------------------------------------- */
/* Two-column field rows                                                      */
/* -------------------------------------------------------------------------- */

.sapa-cf7 .sapa-field-row {
	display: grid;
	gap: 1.25rem;
}

@media (min-width: 768px) {
	.sapa-cf7 .sapa-field-row {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.sapa-cf7 .sapa-field-row--three {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

/* -------------------------------------------------------------------------- */
/* Mobile                                                                     */
/* -------------------------------------------------------------------------- */

@media (max-width: 480px) {
	.wpcf7-form-control.wpcf7-text,
	.wpcf7-form-control.wpcf7-email,
	.wpcf7-form-control.wpcf7-tel,
	.wpcf7-form-control.wpcf7-number,
	.wpcf7-form-control.wpcf7-select,
	.wpcf7-form-control.wpcf7-textarea {
		/* 16px stops iOS Safari zooming in when a field is focused. */
		font-size: 1rem;
		padding: 0.7rem 0.9rem;
	}

	.wpcf7-form-control.wpcf7-submit {
		width: 100%;
	}

	.wpcf7-response-output {
		font-size: 0.8125rem;
	}
}
