/**
 * Contact Form 7: Charis form styles.
 *
 * Same Figma "Basic input" look as the HubSpot forms (charis-blocks
 * src/shared/_hubspot-form.scss): Body/S label 6px above a 48px field,
 * 1px Lavender border r8, Periwinkle placeholder, Indigo 600 value, Purple
 * border on hover, Tangerine while typing, Red for errors; 32px checkboxes;
 * the CTA red submit. Loaded only when the plugin is active, after its own
 * sheet (dependency `contact-form-7`). Values come from theme.json presets.
 */

.wpcf7 {
	--charis-cf7-gap: var(--wp--preset--spacing--60);

	color: var(--wp--preset--color--brand-indigo);
}

.wpcf7-form {
	margin: 0;
}

.wpcf7-form > p,
.wpcf7-form > div:not(.wpcf7-response-output),
.wpcf7-form > fieldset:not(.hidden-fields-container) {
	margin: 0 0 var(--charis-cf7-gap);
}

.wpcf7-form fieldset {
	min-width: 0;
	padding: 0;
	border: 0;
}

/* Field label: Body/S, 6px above the field. CF7 puts a <br> after the label
 * text; the wrap below gives the gap instead. */
.wpcf7-form label {
	display: block;
	color: var(--wp--preset--color--brand-indigo);
	font-size: var(--wp--preset--font-size--fs-body-s);
	font-weight: 300;
	letter-spacing: var(--wp--custom--charis--ls-body-s);
	line-height: 22px;
}

.wpcf7-form label > br {
	display: none;
}

.wpcf7-form label > /* Required mark and hint lines written into the form template:
 * <span class="charis-required">*</span>, <span class="charis-note">. */
.wpcf7-form .charis-required {
	padding-inline: 2px;
	color: var(--wp--preset--color--brand-red-hover);
	font-weight: 600;
}

.wpcf7-form .charis-note {
	display: block;
	margin-top: var(--wp--preset--spacing--20);
	color: var(--wp--preset--color--brand-indigo);
	font-size: 14px;
	font-weight: 300;
	line-height: 22px;
}

.wpcf7-form-control-wrap {
	margin-top: 6px;
}

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

/* Text-like fields, select and textarea. */
.wpcf7-form :is(
	input[type="text"],
	input[type="email"],
	input[type="tel"],
	input[type="url"],
	input[type="number"],
	input[type="date"],
	input[type="password"],
	select,
	textarea
).wpcf7-form-control {
	display: block;
	box-sizing: border-box;
	width: 100%;
	max-width: none;
	height: 48px;
	margin: 0;
	padding: 0 11px;
	border: 1px solid var(--wp--preset--color--brand-lavender);
	border-radius: var(--wp--preset--border-radius--r-8, 8px);
	background-color: var(--wp--preset--color--bg-white);
	box-shadow: none;
	color: var(--wp--preset--color--brand-indigo);
	font-family: inherit;
	font-size: var(--wp--preset--font-size--fs-body-s);
	font-weight: 600;
	letter-spacing: var(--wp--custom--charis--ls-body-s);
	line-height: 24px;
	transition:
		border-color var(--charis-hover-duration, 300ms) var(--charis-hover-easing, ease-in-out),
		box-shadow var(--charis-hover-duration, 300ms) var(--charis-hover-easing, ease-in-out);
}

.wpcf7-form select.wpcf7-form-control {
	padding-right: 40px;
	background: var(--wp--preset--color--bg-white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23251a5d' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E") right 12px center / 16px no-repeat;
	cursor: pointer;
	appearance: none;
}

.wpcf7-form textarea.wpcf7-form-control {
	height: auto;
	min-height: 96px;
	padding-block: 11px;
	resize: vertical;
}

.wpcf7-form .wpcf7-form-control::placeholder {
	color: var(--wp--preset--color--brand-periwinkle);
	font-weight: 300;
	opacity: 1;
}

.wpcf7-form :is(input:not([type="checkbox"], [type="radio"], [type="submit"], [type="file"]), select, textarea).wpcf7-form-control:hover {
	border-color: var(--wp--preset--color--brand-purple);
}

/* Figma "Your name" (typing): Tangerine border; a 1px inner ring doubles it
 * so focus stays visible (WCAG 2.4.7). */
.wpcf7-form :is(input:not([type="checkbox"], [type="radio"], [type="submit"], [type="file"]), select, textarea).wpcf7-form-control:focus {
	border-color: var(--wp--preset--color--brand-tangerine);
	outline: none;
	box-shadow: inset 0 0 0 1px var(--wp--preset--color--brand-tangerine);
	caret-color: var(--wp--preset--color--brand-tangerine);
}

/* File upload (CV): dashed Lavender drop box, outline pill button. */
.wpcf7-form input[type="file"].wpcf7-form-control {
	display: block;
	box-sizing: border-box;
	width: 100%;
	padding: var(--wp--preset--spacing--60);
	border: 1px dashed var(--wp--preset--color--brand-lavender);
	border-radius: var(--wp--preset--border-radius--r-8, 8px);
	background-color: var(--wp--preset--color--bg-white);
	color: inherit;
	font-family: inherit;
	font-size: var(--wp--preset--font-size--fs-body-s);
	cursor: pointer;
}

.wpcf7-form input[type="file"].wpcf7-form-control::file-selector-button {
	margin-right: var(--wp--preset--spacing--50);
	padding: 8px 16px;
	border: 1px solid currentcolor;
	border-radius: 999px;
	background: transparent;
	color: inherit;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}

/* Checkbox, radio and acceptance lists: one option per line, 32px boxes. */
.wpcf7-form :is(.wpcf7-checkbox, .wpcf7-radio, .wpcf7-acceptance) {
	display: flex;
	flex-direction: column;
	gap: var(--wp--preset--spacing--30);
}

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

.wpcf7-form .wpcf7-list-item > label {
	display: flex;
	gap: var(--wp--preset--spacing--30);
	align-items: center;
	font-size: var(--wp--preset--font-size--fs-body-s);
	line-height: 24px;
	cursor: pointer;
}

.wpcf7-form .wpcf7-list-item-label {
	margin: 0;
}

.wpcf7-form :is(input[type="checkbox"], input[type="radio"]) {
	flex: 0 0 32px;
	width: 32px;
	height: 32px;
	margin: 0;
	border: 1px solid var(--wp--preset--color--brand-lavender);
	border-radius: var(--wp--preset--border-radius--r-4, 4px);
	background: var(--wp--preset--color--bg-white) center / 16px no-repeat;
	cursor: pointer;
	transition:
		background-color var(--charis-hover-duration, 300ms) var(--charis-hover-easing, ease-in-out),
		border-color var(--charis-hover-duration, 300ms) var(--charis-hover-easing, ease-in-out);
	appearance: none;
}

.wpcf7-form input[type="radio"] {
	border-radius: 50%;
}

.wpcf7-form :is(input[type="checkbox"], input[type="radio"]):hover {
	border-color: var(--wp--preset--color--brand-purple);
}

.wpcf7-form input[type="checkbox"]:checked {
	border-color: var(--wp--preset--color--brand-indigo);
	background-color: var(--wp--preset--color--brand-indigo);
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.5l3.2 3L13 4.5' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.wpcf7-form input[type="radio"]:checked {
	border-color: var(--wp--preset--color--brand-indigo);
	background-image: radial-gradient(circle, var(--wp--preset--color--brand-indigo) 0 7px, transparent 7.5px);
	background-size: 100%;
}

.wpcf7-form :is(input[type="checkbox"], input[type="radio"]):focus-visible {
	outline: none;
	box-shadow: var(--charis-focus-ring, 0 0 0 3px var(--wp--preset--color--ui-focus));
}

/* Consent text links: underlined, inherit the text colour (the :not() chain
 * outranks the theme's in-content Red link). */
.wpcf7-form .wpcf7-list-item-label a:not(.wp-block-button__link):not(.wp-element-button),
.wpcf7-form label a:not(.wp-block-button__link):not(.wp-element-button) {
	color: inherit;
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 3px;
}

.wpcf7-form .wpcf7-list-item-label a:not(.wp-block-button__link):not(.wp-element-button):hover,
.wpcf7-form label a:not(.wp-block-button__link):not(.wp-element-button):hover {
	color: var(--wp--preset--color--brand-red-hover);
}

/* Submit: the theme CTA button (red fill, Control/M, r8, 56px). */
.wpcf7-form .wpcf7-submit {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	min-height: 56px;
	margin: var(--wp--preset--spacing--30) 0 0;
	padding: var(--wp--preset--spacing--40) var(--wp--preset--spacing--60);
	border: 0;
	border-radius: var(--wp--preset--border-radius--r-8, 8px);
	background-color: var(--wp--preset--color--brand-red);
	color: var(--wp--preset--color--bg-white);
	font-family: inherit;
	font-size: var(--wp--preset--font-size--fs-control-m);
	font-weight: 600;
	line-height: 24px;
	cursor: pointer;
	transition: background-color var(--charis-hover-duration, 300ms) var(--charis-hover-easing, ease-in-out);
	appearance: none;
}

.wpcf7-form .wpcf7-submit:hover {
	background-color: var(--wp--preset--color--brand-red-hover);
}

.wpcf7-form .wpcf7-submit:focus-visible {
	outline: none;
	box-shadow: var(--charis-focus-ring, 0 0 0 3px var(--wp--preset--color--ui-focus));
}

.wpcf7-form .wpcf7-submit:disabled {
	background-color: var(--wp--preset--color--ui-disabled-bg);
	color: var(--wp--preset--color--ui-disabled-text);
	cursor: not-allowed;
}

.wpcf7-form .wpcf7-spinner {
	margin: 0 var(--wp--preset--spacing--40);
	vertical-align: middle;
}

/* Errors: Red border on the field, Red 14px message under it. The attribute
 * lifts the rule above the hover and focus rules. */
.wpcf7-form .wpcf7-form-control.wpcf7-not-valid[aria-invalid="true"]:is(input, select, textarea),
.wpcf7-form .wpcf7-not-valid :is(input[type="checkbox"], input[type="radio"]) {
	border-color: var(--wp--preset--color--ui-error);
}

.wpcf7-form .wpcf7-not-valid-tip {
	display: block;
	margin-top: var(--wp--preset--spacing--20);
	color: var(--wp--preset--color--ui-error);
	font-size: 14px;
	font-weight: 300;
	line-height: 22px;
}

/* Form result message: a soft panel, not the plugin's coloured outline. */
.wpcf7 form .wpcf7-response-output {
	margin: var(--wp--preset--spacing--60) 0 0;
	padding: var(--wp--preset--spacing--40) var(--wp--preset--spacing--50);
	border: 1px solid var(--wp--preset--color--brand-lavender);
	border-radius: var(--wp--preset--border-radius--r-8, 8px);
	background-color: var(--wp--preset--color--bg-white);
	color: var(--wp--preset--color--brand-indigo);
	font-size: var(--wp--preset--font-size--fs-body-s);
	font-weight: 300;
	line-height: 24px;
}

.wpcf7 form.sent .wpcf7-response-output {
	border-color: var(--wp--preset--color--ui-success);
}

.wpcf7 form:is(
	.invalid,
	.unaccepted,
	.payment-required,
	.failed,
	.aborted,
	.spam
) .wpcf7-response-output {
	border-color: var(--wp--preset--color--ui-error);
}

@media (max-width: 767px) {

	.wpcf7-form .wpcf7-submit {
		width: 100%;
		font-size: var(--wp--preset--font-size--fs-control-s);
	}
}
