/**
 * Contact Form 7 styling for the Residem child theme.
 *
 * Residem ships styles for MetForm and the Elementor form widget, but nothing
 * for Contact Form 7, so CF7 renders with raw browser defaults. This file gives
 * CF7 the same visual language the theme uses for its own forms (see the comment
 * form rules in residem/assets/scss/theme.css): 1px hairline borders, 6px radius
 * on inputs, pill-shaped submit buttons, primary-colour focus.
 *
 * Colours come from the Elementor kit's global palette, so changing a brand
 * colour in Elementor > Site Settings > Global Colors updates this form too.
 * The hex values are fallbacks for when the kit CSS is absent.
 *
 * Everything is scoped under .wpcf7 so nothing leaks into other forms.
 * Verified against Contact Form 7 6.1.6 markup.
 */

/* -------------------------------------------------------------------------
 * 1. Tokens
 *
 * Override any of these on .wpcf7 (or a parent) to reskin the form without
 * touching the rules below.
 * ---------------------------------------------------------------------- */
.wpcf7 {
	--rcf7-primary: var(--e-global-color-primary, #b07e50);
	--rcf7-secondary: var(--e-global-color-secondary, #103c3b);
	--rcf7-text: var(--e-global-color-text, rgba(0, 0, 0, 0.6));
	--rcf7-dark: var(--e-global-color-144a295, #1e1e1e);

	--rcf7-field-bg: #ffffff;
	--rcf7-field-color: var(--rcf7-text);
	--rcf7-border: rgba(0, 0, 0, 0.1);
	--rcf7-border-hover: rgba(0, 0, 0, 0.25);
	--rcf7-placeholder: rgba(0, 0, 0, 0.4);

	--rcf7-radius: 6px;
	--rcf7-radius-pill: 30px;
	--rcf7-field-padding: 15px 20px;
	--rcf7-field-height: 54px;
	--rcf7-gap: 22px;

	--rcf7-font: var(--e-global-typography-text-font-family, "DM Sans"), sans-serif;
	--rcf7-font-size: 15px;
	--rcf7-label-font: var(--e-global-typography-accent-font-family, "Jost"), sans-serif;

	--rcf7-error: #d13c3c;
	--rcf7-success: #1e7a55;
	--rcf7-notice: #b8860b;

	--rcf7-transition: 0.25s ease;
}

/* -------------------------------------------------------------------------
 * 2. Wrapper and field rhythm
 * ---------------------------------------------------------------------- */
.wpcf7 {
	font-family: var(--rcf7-font);
	font-size: var(--rcf7-font-size);
	color: var(--rcf7-text);
}

.wpcf7 .wpcf7-form > p {
	margin: 0 0 var(--rcf7-gap);
}

.wpcf7 .wpcf7-form > p:last-of-type {
	margin-bottom: 0;
}

/* Forms built with divs or Elementor rows instead of <p> get the same rhythm. */
.wpcf7 .wpcf7-form > div:not(.wpcf7-response-output):not(.hidden-fields-container) {
	margin-bottom: var(--rcf7-gap);
}

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

/* Labels wrapping a control must not collapse it. */
.wpcf7 .wpcf7-form label {
	display: block;
	font-family: var(--rcf7-label-font);
	font-weight: 500;
	font-size: 15px;
	line-height: 1.5;
	color: var(--rcf7-secondary);
	margin-bottom: 8px;
}

/* Inside choice lists the label is the clickable row, not a field caption. */
.wpcf7 .wpcf7-form .wpcf7-list-item label {
	margin-bottom: 0;
	font-weight: 400;
	color: var(--rcf7-text);
}

/* -------------------------------------------------------------------------
 * 3. Text-like controls
 * ---------------------------------------------------------------------- */
.wpcf7 .wpcf7-form-control.wpcf7-text,
.wpcf7 .wpcf7-form-control.wpcf7-email,
.wpcf7 .wpcf7-form-control.wpcf7-tel,
.wpcf7 .wpcf7-form-control.wpcf7-url,
.wpcf7 .wpcf7-form-control.wpcf7-number,
.wpcf7 .wpcf7-form-control.wpcf7-date,
.wpcf7 .wpcf7-form-control.wpcf7-quiz,
.wpcf7 .wpcf7-form-control.wpcf7-textarea,
.wpcf7 .wpcf7-form-control.wpcf7-select {
	width: 100%;
	max-width: 100%;
	box-sizing: border-box;
	padding: var(--rcf7-field-padding);
	font-family: var(--rcf7-font);
	font-size: var(--rcf7-font-size);
	line-height: 1.5;
	color: var(--rcf7-field-color);
	background-color: var(--rcf7-field-bg);
	border: 1px solid var(--rcf7-border);
	border-radius: var(--rcf7-radius);
	box-shadow: none;
	transition: border-color var(--rcf7-transition), box-shadow var(--rcf7-transition);
	-webkit-appearance: none;
	appearance: none;
}

/* CF7 sets size="40" on inputs, which browsers turn into an intrinsic width. */
.wpcf7 .wpcf7-form-control.wpcf7-text,
.wpcf7 .wpcf7-form-control.wpcf7-email,
.wpcf7 .wpcf7-form-control.wpcf7-tel,
.wpcf7 .wpcf7-form-control.wpcf7-url,
.wpcf7 .wpcf7-form-control.wpcf7-number,
.wpcf7 .wpcf7-form-control.wpcf7-date,
.wpcf7 .wpcf7-form-control.wpcf7-quiz {
	height: var(--rcf7-field-height);
}

.wpcf7 .wpcf7-form-control.wpcf7-textarea {
	height: 145px;
	min-height: 120px;
	resize: vertical;
	display: block;
}

.wpcf7 .wpcf7-form-control::placeholder {
	color: var(--rcf7-placeholder);
	opacity: 1;
}

.wpcf7 .wpcf7-form-control:hover:not(:focus):not([type="submit"]) {
	border-color: var(--rcf7-border-hover);
}

.wpcf7 .wpcf7-form-control:focus {
	border-color: var(--rcf7-primary);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--rcf7-primary) 18%, transparent);
	outline: none;
	background-color: var(--rcf7-field-bg);
}

/* Browsers without color-mix() still get a visible ring. */
@supports not (color: color-mix(in srgb, red 50%, blue)) {
	.wpcf7 .wpcf7-form-control:focus {
		box-shadow: 0 0 0 3px rgba(176, 126, 80, 0.18);
	}
}

.wpcf7 .wpcf7-form-control:disabled,
.wpcf7 .wpcf7-form-control[readonly] {
	opacity: 0.6;
	cursor: not-allowed;
	background-color: rgba(0, 0, 0, 0.02);
}

/* Autofill in Chrome otherwise paints a hard blue background. */
.wpcf7 .wpcf7-form-control:-webkit-autofill,
.wpcf7 .wpcf7-form-control:-webkit-autofill:hover,
.wpcf7 .wpcf7-form-control:-webkit-autofill:focus {
	-webkit-text-fill-color: var(--rcf7-field-color);
	-webkit-box-shadow: 0 0 0 1000px #fff inset;
	transition: background-color 9999s ease-out;
}

/* Hide the number spinner, matching the theme's own reset. */
.wpcf7 .wpcf7-form-control.wpcf7-number::-webkit-outer-spin-button,
.wpcf7 .wpcf7-form-control.wpcf7-number::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

.wpcf7 .wpcf7-form-control.wpcf7-number {
	-moz-appearance: textfield;
}

/* Date fields: keep the native picker reachable but tinted. */
.wpcf7 .wpcf7-form-control.wpcf7-date::-webkit-calendar-picker-indicator {
	cursor: pointer;
	opacity: 0.55;
	transition: opacity var(--rcf7-transition);
}

.wpcf7 .wpcf7-form-control.wpcf7-date:hover::-webkit-calendar-picker-indicator {
	opacity: 1;
}

/* -------------------------------------------------------------------------
 * 4. Select
 *
 * The arrow is an inlined SVG: a strict CSP on some hosts blocks external
 * assets, and a data URI has no extra request either way.
 * ---------------------------------------------------------------------- */
.wpcf7 .wpcf7-form-control.wpcf7-select {
	padding-right: 46px;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%23103c3b' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 20px center;
	background-size: 12px 8px;
	cursor: pointer;
}

/* A multiple select is a list box, so the arrow and fixed height are wrong. */
.wpcf7 .wpcf7-form-control.wpcf7-select[multiple] {
	height: auto;
	min-height: 120px;
	padding: 10px;
	background-image: none;
}

.wpcf7 .wpcf7-form-control.wpcf7-select[multiple] option {
	padding: 7px 10px;
	border-radius: 4px;
}

.wpcf7 .wpcf7-form-control.wpcf7-select[multiple] option:checked {
	background: var(--rcf7-primary) linear-gradient(0deg, var(--rcf7-primary), var(--rcf7-primary));
	color: #fff;
}

/* -------------------------------------------------------------------------
 * 5. Checkbox, radio and acceptance
 *
 * Markup is span.wpcf7-checkbox > span.wpcf7-list-item > label > input
 *                                                             + span.label
 * ---------------------------------------------------------------------- */
.wpcf7 .wpcf7-form-control.wpcf7-checkbox,
.wpcf7 .wpcf7-form-control.wpcf7-radio,
.wpcf7 .wpcf7-form-control.wpcf7-acceptance {
	display: flex;
	flex-wrap: wrap;
	gap: 10px 24px;
}

.wpcf7 .wpcf7-form-control.wpcf7-acceptance {
	display: block;
}

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

.wpcf7 .wpcf7-list-item > label {
	display: inline-flex;
	align-items: flex-start;
	gap: 10px;
	cursor: pointer;
	line-height: 1.5;
}

.wpcf7 .wpcf7-list-item input[type="checkbox"],
.wpcf7 .wpcf7-list-item input[type="radio"] {
	flex: 0 0 auto;
	width: 18px;
	height: 18px;
	margin: 2px 0 0;
	accent-color: var(--rcf7-primary);
	cursor: pointer;
}

.wpcf7 .wpcf7-list-item-label {
	color: var(--rcf7-text);
}

/* CF7 appends a separator after each label; the flex gap replaces it. */
.wpcf7 .wpcf7-list-item-label::after,
.wpcf7 .wpcf7-list-item-label::before {
	content: "";
	margin: 0;
}

/* Acceptance is usually a single consent line with a link in it. */
.wpcf7 .wpcf7-acceptance .wpcf7-list-item-label {
	font-size: 14px;
}

.wpcf7 .wpcf7-acceptance a {
	color: var(--rcf7-primary);
	text-decoration: underline;
	text-underline-offset: 2px;
}

/* -------------------------------------------------------------------------
 * 6. File upload
 * ---------------------------------------------------------------------- */
.wpcf7 .wpcf7-form-control.wpcf7-file {
	display: block;
	width: 100%;
	box-sizing: border-box;
	padding: 12px 14px;
	font-family: var(--rcf7-font);
	font-size: 14px;
	color: var(--rcf7-text);
	background: var(--rcf7-field-bg);
	border: 1px dashed var(--rcf7-border-hover);
	border-radius: var(--rcf7-radius);
	cursor: pointer;
	transition: border-color var(--rcf7-transition), background-color var(--rcf7-transition);
}

.wpcf7 .wpcf7-form-control.wpcf7-file:hover {
	border-color: var(--rcf7-primary);
	background-color: rgba(0, 0, 0, 0.015);
}

.wpcf7 .wpcf7-form-control.wpcf7-file::file-selector-button {
	margin-right: 14px;
	padding: 9px 18px;
	font-family: var(--rcf7-label-font);
	font-size: 14px;
	font-weight: 500;
	color: #fff;
	background: var(--rcf7-secondary);
	border: 0;
	border-radius: var(--rcf7-radius-pill);
	cursor: pointer;
	transition: background-color var(--rcf7-transition);
}

.wpcf7 .wpcf7-form-control.wpcf7-file:hover::file-selector-button {
	background: var(--rcf7-primary);
}

/* -------------------------------------------------------------------------
 * 7. Range
 * ---------------------------------------------------------------------- */
.wpcf7 .wpcf7-form-control.wpcf7-range {
	width: 100%;
	height: 22px;
	padding: 0;
	background: transparent;
	border: 0;
	accent-color: var(--rcf7-primary);
	cursor: pointer;
}

/* -------------------------------------------------------------------------
 * 8. Quiz
 *
 * CF7 wraps the question and the answer field in one label.
 * ---------------------------------------------------------------------- */
.wpcf7 .wpcf7-quiz-label {
	display: block;
	font-family: var(--rcf7-label-font);
	font-weight: 500;
	color: var(--rcf7-secondary);
	margin-bottom: 8px;
}

/* -------------------------------------------------------------------------
 * 9. Submit button and spinner
 * ---------------------------------------------------------------------- */
.wpcf7 .wpcf7-form-control.wpcf7-submit {
	display: inline-block;
	width: auto;
	padding: 15px 34px;
	/* padding: 5px 24px; */
	font-family: var(--rcf7-label-font);
	font-size: 16px;
	font-weight: 500;
	line-height: 1.2;
	color: #fff;
	background: var(--rcf7-primary);
	border: 0;
	border-radius: var(--rcf7-radius);
	cursor: pointer;
	transition: background-color var(--rcf7-transition), transform var(--rcf7-transition),
		box-shadow var(--rcf7-transition);
	-webkit-appearance: none;
	appearance: none;
}

.wpcf7 .wpcf7-form-control.wpcf7-submit:hover,
.wpcf7 .wpcf7-form-control.wpcf7-submit:focus-visible {
	background: var(--rcf7-secondary);
	color: #fff;
	box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
	transform: translateY(-1px);
}

.wpcf7 .wpcf7-form-control.wpcf7-submit:active {
	transform: translateY(0);
	box-shadow: none;
}

.wpcf7 .wpcf7-form-control.wpcf7-submit:focus-visible {
	outline: 2px solid var(--rcf7-secondary);
	outline-offset: 3px;
}

.wpcf7 .wpcf7-form-control.wpcf7-submit:disabled {
	opacity: 0.55;
	cursor: not-allowed;
	transform: none;
	box-shadow: none;
}

/* CF7 injects the spinner next to the button while the request is in flight. */
.wpcf7 .wpcf7-spinner {
	margin: 0 0 0 14px;
	background-color: var(--rcf7-primary);
	vertical-align: middle;
}

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

/* -------------------------------------------------------------------------
 * 10. Validation
 * ---------------------------------------------------------------------- */
.wpcf7 .wpcf7-form-control.wpcf7-not-valid {
	border-color: var(--rcf7-error);
}

.wpcf7 .wpcf7-form-control.wpcf7-not-valid:focus {
	border-color: var(--rcf7-error);
	box-shadow: 0 0 0 3px rgba(209, 60, 60, 0.16);
}

.wpcf7 .wpcf7-not-valid-tip {
	display: block;
	margin-top: 7px;
	font-family: var(--rcf7-font);
	font-size: 13px;
	font-weight: 400;
	line-height: 1.4;
	color: var(--rcf7-error);
}

/* CF7's floating-tip mode positions the tip over the field. */
.wpcf7 .use-floating-validation-tip .wpcf7-not-valid-tip {
	padding: 6px 10px;
	font-size: 12px;
	color: #fff;
	background: var(--rcf7-error);
	border: 0;
	border-radius: 4px;
}

/* -------------------------------------------------------------------------
 * 11. Response messages
 *
 * CF7's own rules are `.wpcf7 form .wpcf7-response-output`, so these need the
 * same shape to win without !important.
 * ---------------------------------------------------------------------- */
.wpcf7 form .wpcf7-response-output {
	margin: var(--rcf7-gap) 0 0;
	padding: 14px 18px;
	font-family: var(--rcf7-font);
	font-size: 14px;
	line-height: 1.5;
	border-width: 1px;
	border-style: solid;
	border-radius: var(--rcf7-radius);
}

.wpcf7 form.sent .wpcf7-response-output {
	color: var(--rcf7-success);
	background: rgba(30, 122, 85, 0.07);
	border-color: rgba(30, 122, 85, 0.35);
}

.wpcf7 form.invalid .wpcf7-response-output,
.wpcf7 form.unaccepted .wpcf7-response-output,
.wpcf7 form.payment-required .wpcf7-response-output {
	color: var(--rcf7-notice);
	background: rgba(184, 134, 11, 0.07);
	border-color: rgba(184, 134, 11, 0.35);
}

.wpcf7 form.failed .wpcf7-response-output,
.wpcf7 form.aborted .wpcf7-response-output,
.wpcf7 form.spam .wpcf7-response-output {
	color: var(--rcf7-error);
	background: rgba(209, 60, 60, 0.07);
	border-color: rgba(209, 60, 60, 0.35);
}

/* -------------------------------------------------------------------------
 * 12. Things that must stay invisible
 * ---------------------------------------------------------------------- */
.wpcf7 .hidden-fields-container,
.wpcf7 .wpcf7-form .wpcf7-display-none,
.wpcf7 .wpcf7-form-control-wrap[data-name^="honeypot"],
.wpcf7 .wpcf7-honeypot-container {
	display: none !important;
}

/* Keep the screen-reader response available to assistive tech, not on screen. */
.wpcf7 .screen-reader-response {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	overflow: hidden;
	clip: rect(1px, 1px, 1px, 1px);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* reCAPTCHA v3 badge: give it room instead of letting it overlap the button. */
.wpcf7 .wpcf7-recaptcha ~ p,
.wpcf7 .grecaptcha-badge {
	margin-top: 10px;
}

/* -------------------------------------------------------------------------
 * 13. Opt-in modifiers
 *
 * Nothing here applies unless you ask for it. There are two places to put the
 * class, and each modifier below accepts both:
 *
 *   a) On the form itself, via the shortcode:
 *        [contact-form-7 id="123" html_class="cf7-two-col"]
 *      CF7 appends html_class to the <form> element, not to the .wpcf7
 *      wrapper — see WPCF7_ContactForm::form_html_attributes().
 *
 *   b) On any ancestor: the CSS Classes field of the Elementor widget holding
 *      the shortcode, or a wrapper div in a template.
 *
 * The token-overriding modifiers (cf7-compact, cf7-on-dark) have to land on
 * .wpcf7 or deeper, because section 1 defines the tokens on .wpcf7 and a
 * custom property set on a nearer ancestor loses to that.
 * ---------------------------------------------------------------------- */

/* Two fields per row on tablet and up. */
:is(.cf7-two-col .wpcf7-form, .wpcf7-form.cf7-two-col) {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 0 var(--rcf7-gap);
}

:is(.cf7-two-col .wpcf7-form, .wpcf7-form.cf7-two-col) > p {
	grid-column: span 2;
}

:is(.cf7-two-col .wpcf7-form, .wpcf7-form.cf7-two-col)
	> p:has(
		.wpcf7-text,
		.wpcf7-email,
		.wpcf7-tel,
		.wpcf7-date,
		.wpcf7-number,
		.wpcf7-select:not([multiple])
	) {
	grid-column: span 1;
}

/* Search-bar style: field and button on one line. */
:is(.cf7-inline .wpcf7-form, .wpcf7-form.cf7-inline) {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--rcf7-gap);
}

:is(.cf7-inline .wpcf7-form, .wpcf7-form.cf7-inline) > p {
	flex: 1 1 220px;
	margin-bottom: 0;
}

:is(.cf7-inline .wpcf7-form, .wpcf7-form.cf7-inline) > p:has(.wpcf7-submit) {
	flex: 0 0 auto;
}

/* Tighter vertical rhythm for sidebars and popups. */
:is(.cf7-compact .wpcf7, .wpcf7.cf7-compact, .wpcf7 .wpcf7-form.cf7-compact) {
	--rcf7-gap: 14px;
	--rcf7-field-padding: 11px 16px;
	--rcf7-field-height: 46px;
}

/* For forms sitting on a dark section. */
:is(.cf7-on-dark .wpcf7, .wpcf7.cf7-on-dark, .wpcf7 .wpcf7-form.cf7-on-dark) {
	--rcf7-field-color: rgba(255, 255, 255, 0.85);
	--rcf7-border: rgba(255, 255, 255, 0.2);
	--rcf7-border-hover: rgba(255, 255, 255, 0.45);
	--rcf7-placeholder: rgba(255, 255, 255, 0.5);
	--rcf7-text: rgba(255, 255, 255, 0.8);
	--rcf7-secondary: #ffffff;
}

:is(.cf7-on-dark, .wpcf7-form.cf7-on-dark) :is(.wpcf7-form label, .wpcf7-quiz-label),
.wpcf7-form.cf7-on-dark label,
.wpcf7-form.cf7-on-dark .wpcf7-quiz-label {
	color: #fff;
}

:is(.cf7-on-dark, .wpcf7-form.cf7-on-dark) .wpcf7-form-control.wpcf7-select {
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%23ffffff' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

:is(.cf7-on-dark, .wpcf7-form.cf7-on-dark) .wpcf7-form-control.wpcf7-select option {
	color: var(--rcf7-dark);
}

:is(.cf7-on-dark, .wpcf7-form.cf7-on-dark) .wpcf7-form-control:-webkit-autofill,
:is(.cf7-on-dark, .wpcf7-form.cf7-on-dark) .wpcf7-form-control:-webkit-autofill:hover,
:is(.cf7-on-dark, .wpcf7-form.cf7-on-dark) .wpcf7-form-control:-webkit-autofill:focus {
	-webkit-text-fill-color: rgba(255, 255, 255, 0.85);
	-webkit-box-shadow: 0 0 0 1000px var(--rcf7-dark) inset;
}

:is(.cf7-on-dark, .wpcf7-form.cf7-on-dark) .wpcf7-form-control.wpcf7-submit:hover,
:is(.cf7-on-dark, .wpcf7-form.cf7-on-dark) .wpcf7-form-control.wpcf7-submit:focus-visible {
	background: #fff;
	color: var(--rcf7-dark);
}

/* Full-width submit, useful in narrow columns. */
:is(.cf7-block-submit, .wpcf7-form.cf7-block-submit) .wpcf7-form-control.wpcf7-submit {
	display: block;
	width: 100%;
}

/* -------------------------------------------------------------------------
 * 14. Responsive
 * ---------------------------------------------------------------------- */
@media (max-width: 767px) {
	.wpcf7 {
		--rcf7-gap: 16px;
		--rcf7-field-padding: 12px 16px;
		--rcf7-field-height: 48px;
	}

	:is(.cf7-two-col .wpcf7-form, .wpcf7-form.cf7-two-col) {
		display: block;
	}

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

	.wpcf7 .wpcf7-form-control.wpcf7-checkbox,
	.wpcf7 .wpcf7-form-control.wpcf7-radio {
		flex-direction: column;
		gap: 10px;
	}

	/* iOS zooms the page when a focused field is under 16px. */
	.wpcf7 .wpcf7-form-control:not([type="submit"]):not([type="range"]) {
		font-size: 16px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.wpcf7 .wpcf7-form-control,
	.wpcf7 .wpcf7-form-control.wpcf7-submit {
		transition: none;
	}

	.wpcf7 .wpcf7-form-control.wpcf7-submit:hover {
		transform: none;
	}
}
