/* Contact Form 7 forms, restyled to match the theme. Shared by every form page. */

.wpcf7-form {
	display: flex;
	flex-direction: column;
	gap: 18px;
	color: var(--th-text);
	font-size: var(--th-fs-sm);
}

.wpcf7-form > p,
.wpcf7-form .file-upload p {
	margin: 0;
}

/* Stray <br> from CF7's auto-paragraphs; spacing comes from the gaps above. */
.wpcf7-form br {
	display: none;
}

/* Section headings inside a form (e.g. "Contact details", "Job details"). */
.wpcf7-form h3 {
	padding-top: 10px;
	color: var(--th-navy);
	font-size: 1.125rem;
}

.wpcf7-form h3:not(:first-of-type) {
	margin-top: 10px;
	padding-top: 26px;
	border-top: 1px solid var(--th-border);
}

/* Icon fonts from the old builder aren't loaded any more. */
.wpcf7-form h3 > i {
	display: none;
}

.wpcf7-form label,
.wpcf7-form > p {
	display: flex;
	flex-direction: column;
	gap: 6px;
	font-weight: 600;
	line-height: 1.4;
}

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

/* ---------- Inputs ---------- */

.wpcf7-form input:is([type="text"], [type="email"], [type="tel"], [type="url"], [type="number"], [type="date"]),
.wpcf7-form select,
.wpcf7-form textarea {
	width: 100%;
	min-height: 48px;
	padding: 11px 14px;
	border: 1px solid var(--th-border-strong);
	border-radius: var(--th-radius-sm);
	background: var(--th-white);
	color: var(--th-text);
	font: inherit;
	font-size: var(--th-fs-body); /* 16px stops iOS zooming on focus */
	font-weight: 400;
	line-height: 1.4;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.wpcf7-form textarea {
	min-height: 120px;
	resize: vertical;
}

.wpcf7-form select {
	padding-right: 40px;
	appearance: none;
	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 1l5 5 5-5' fill='none' stroke='%23021b5b' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
	background-position: right 16px center;
	background-repeat: no-repeat;
}

.wpcf7-form :is(input, select, textarea):hover {
	border-color: var(--th-border-dashed);
}

.wpcf7-form :is(input, select, textarea):focus {
	border-color: var(--th-blue);
	outline: none;
	box-shadow: 0 0 0 3px rgb(0 151 225 / 0.25);
}

/* ---------- File upload (".file-upload" wrapper: input, then a label with #filename and a Browse button) ---------- */

.file-upload {
	position: relative;
}

.file-upload > p {
	display: flex;
	flex-direction: column-reverse;
	gap: 6px;
}

/* The real input stays focusable for keyboards; the label is the visible control. */
.file-upload input[type="file"] {
	position: absolute;
	width: 1px;
	height: 1px;
	opacity: 0;
}

.file-upload label {
	display: flex;
	flex-direction: row;
	align-items: center;
	min-height: 48px;
	overflow: hidden;
	border: 1px dashed var(--th-border-dashed);
	border-radius: var(--th-radius-sm);
	background: var(--th-surface-light);
	font-weight: 400;
	cursor: pointer;
}

.file-upload label:hover {
	border-color: var(--th-navy);
}

.file-upload:has(input:focus-visible) label {
	outline: var(--th-focus);
	outline-offset: 2px;
}

.file-upload #filename {
	flex: 1;
	min-width: 0;
	padding: 11px 14px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.file-upload #filename:empty::before {
	content: "No file chosen";
	color: var(--th-text-muted);
}

.file-upload #file-upload-btn {
	align-self: stretch;
	display: flex;
	align-items: center;
	padding-inline: 18px;
	border-left: 1px solid var(--th-border-strong);
	background: var(--th-white);
	color: var(--th-navy);
	font-weight: 600;
}

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

.wpcf7-form .wpcf7-submit {
	width: 100%;
	margin-top: 6px;
	padding: 16px 26px;
	border: 0;
	border-radius: var(--th-radius-sm);
	background: var(--th-navy);
	color: var(--th-white);
	font: inherit;
	font-size: var(--th-fs-body);
	font-weight: 600;
	cursor: pointer;
	transition: filter 0.15s ease;
}

.wpcf7-form .wpcf7-submit:hover {
	filter: brightness(1.25);
}

.wpcf7-form .wpcf7-submit:disabled {
	cursor: progress;
	opacity: 0.7;
}

/* The spinner sits under the full-width button instead of beside it. */
.wpcf7-form .wpcf7-spinner {
	display: block;
	margin: 12px auto 0;
}

.wpcf7-form:not(.submitting) .wpcf7-spinner {
	display: none;
}

/* ---------- Validation and responses ---------- */

.wpcf7-form .wpcf7-form-control.wpcf7-not-valid {
	border-color: var(--th-error);
}

.wpcf7-form .wpcf7-form-control.wpcf7-not-valid:focus {
	box-shadow: 0 0 0 3px rgb(180 35 24 / 0.2);
}

.wpcf7-not-valid-tip {
	margin-top: 6px;
	color: var(--th-error);
	font-size: var(--th-fs-xs);
	font-weight: 600;
}

.wpcf7 form .wpcf7-response-output {
	margin: 0;
	padding: 12px 16px;
	border: 1px solid var(--th-border-strong);
	border-radius: var(--th-radius-sm);
	font-size: var(--th-fs-sm);
	font-weight: 600;
}

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

.wpcf7 form.sent .wpcf7-response-output {
	border-color: var(--th-success);
	background: var(--th-success-bg);
	color: var(--th-success);
}

/* ---------- "Sent" dialog shown after a successful submission ---------- */

.th-form-dialog {
	width: min(460px, calc(100% - 32px));
	padding: 32px 28px 28px;
	border: 0;
	border-top: 4px solid var(--th-success);
	border-radius: var(--th-radius);
	color: var(--th-text);
	box-shadow: 0 20px 60px rgb(2 27 91 / 0.25);
}

.th-form-dialog::backdrop {
	background: rgb(15 26 69 / 0.55);
	backdrop-filter: blur(4px);
}

.th-form-dialog h2 {
	color: var(--th-navy);
	font-size: var(--th-fs-h3);
	letter-spacing: normal;
}

.th-form-dialog p {
	margin-top: 8px;
	color: var(--th-text-muted);
}

.th-form-dialog .th-btn {
	margin-top: 22px;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}
