/* Contact Form 7 styles, followed by Store Kit and guest account form overrides. */
.wpcf7 {
	--f-error: var(--humpf-error);
	--f-ok: var(--humpf-ok);
	margin: 0;
}
.wpcf7 form {
	background: var(--wp--preset--color--accent-3);
	border: 1px solid var(--wp--custom--card-border, #262626);
	border-radius: var(--wp--preset--border-radius--md, 12px);
	padding: clamp(var(--wp--preset--spacing--50), 4vw, calc(var(--wp--preset--spacing--50) + var(--wp--preset--spacing--30)));
	display: grid;
	gap: var(--wp--preset--spacing--50);
	margin: 0;
}
.wpcf7 form > p:empty,
.wpcf7 form br { display: none; }
.wpcf7 form p { margin: 0; }
.wpcf7 .wpcf7-note {
	color: var(--wp--preset--color--accent-4);
	font-size: var(--wp--preset--font-size--small);
}
.wpcf7 .req { color: var(--wp--preset--color--accent-1); font-weight: 800; }
.wpcf7 .opt { color: var(--wp--preset--color--accent-4); font-weight: 500; font-size: var(--wp--preset--font-size--small); }

.wpcf7 fieldset.wpcf7-group {
	border: 0;
	border-top: 1px solid var(--wp--preset--color--accent-6);
	margin: 0;
	padding: var(--wp--preset--spacing--50) 0 0;
	min-width: 0;
	display: grid;
	gap: var(--wp--preset--spacing--50);
}
.wpcf7 fieldset.wpcf7-group legend {
	float: left;
	width: 100%;
	padding: 0;
	margin: 0 0 0.25rem;
	font-size: var(--wp--preset--font-size--x-small);
	font-weight: 700;
	letter-spacing: var(--humpf-eyebrow-tracking);
	text-transform: uppercase;
	color: var(--wp--preset--color--accent-2);
}
.wpcf7 fieldset.wpcf7-group legend + * { clear: both; }

.wpcf7 .wpcf7-row { display: grid; gap: var(--wp--preset--spacing--50); grid-template-columns: 1fr; }
@media (min-width: 640px) {
	.wpcf7 .wpcf7-row { grid-template-columns: 1fr 1fr; }
}
.wpcf7 .wpcf7-field { display: flex; flex-direction: column; gap: 0.375rem; min-width: 0; }
.wpcf7 .wpcf7-field > br { display: none; }
.wpcf7 label,
.wpcf7 .wpcf7-label {
	display: block;
	color: var(--wp--preset--color--contrast);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 700;
	line-height: 1.3;
}
.wpcf7 .wpcf7-hint {
	display: block;
	color: var(--wp--preset--color--accent-4);
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.45;
}
.wpcf7 .wpcf7-form-control-wrap { display: block; }

.wpcf7 input[type="text"],
.wpcf7 input[type="email"],
.wpcf7 input[type="tel"],
.wpcf7 input[type="number"],
.wpcf7 input[type="url"],
.wpcf7 textarea,
.wpcf7 select {
	display: block;
	width: 100%;
	box-sizing: border-box;
	min-height: var(--humpf-control-h);
	background: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
	border: 1px solid var(--humpf-field-border);
	border-radius: var(--wp--preset--border-radius--sm, 6px);
	padding: 0.75rem 0.875rem;
	font: inherit;
	font-size: 1rem; /* 16px stops iOS zoom on focus */
	line-height: 1.4;
}
.wpcf7 textarea { min-height: 8rem; resize: vertical; }
.wpcf7 input:hover,
.wpcf7 textarea:hover { border-color: var(--wp--preset--color--accent-4); }
.wpcf7 input:focus-visible,
.wpcf7 textarea:focus-visible,
.wpcf7 select:focus-visible,
.wpcf7 input[type="submit"]:focus-visible {
	outline: 2px solid var(--wp--custom--focus-ring, #e6ddcf);
	outline-offset: 2px;
	border-color: var(--wp--custom--focus-ring, #e6ddcf);
}

/* File upload */
.wpcf7 input[type="file"] {
	display: block;
	width: 100%;
	box-sizing: border-box;
	min-height: 44px;
	padding: 0.5rem;
	background: var(--wp--preset--color--base);
	color: var(--wp--preset--color--accent-2);
	border: 1px dashed var(--wp--preset--color--accent-4);
	border-radius: var(--wp--preset--border-radius--sm, 6px);
	font: inherit;
	font-size: var(--wp--preset--font-size--medium);
	cursor: pointer;
}
.wpcf7 input[type="file"]::file-selector-button {
	min-height: 44px;
	margin-right: 0.75rem;
	padding: 0 1rem;
	background: var(--wp--preset--color--accent-5);
	color: var(--wp--preset--color--contrast);
	border: 1px solid var(--wp--preset--color--accent-6);
	border-radius: var(--wp--preset--border-radius--sm, 6px);
	font: inherit;
	font-weight: 700;
	cursor: pointer;
}
.wpcf7 input[type="file"]:focus-visible {
	outline: 2px solid var(--wp--custom--focus-ring, #e6ddcf);
	outline-offset: 2px;
}

/* Radios and the consent checkbox */
.wpcf7 .wpcf7-list-item { display: block; margin: 0; }
.wpcf7 .wpcf7-radio { display: flex; flex-wrap: wrap; gap: 0.5rem 0.75rem; }
.wpcf7 .wpcf7-list-item label,
.wpcf7 .wpcf7-acceptance label {
	display: flex;
	align-items: center;
	gap: 0.625rem;
	min-height: 44px;
	padding: 0 1rem 0 0.75rem;
	font-weight: 500;
	font-size: 1rem;
	cursor: pointer;
}
.wpcf7 .wpcf7-radio .wpcf7-list-item label {
	background: var(--wp--preset--color--base);
	border: 1px solid var(--wp--preset--color--accent-6);
	border-radius: var(--wp--preset--border-radius--sm, 6px);
	min-width: 5.5rem;
}
.wpcf7 .wpcf7-radio .wpcf7-list-item label:has(input:checked) { border-color: var(--wp--preset--color--accent-2); }
.wpcf7 input[type="radio"],
.wpcf7 input[type="checkbox"] {
	width: 1.25rem;
	height: 1.25rem;
	margin: 0;
	flex: none;
	accent-color: var(--wp--preset--color--accent-1);
}
.wpcf7 input[type="radio"]:focus-visible,
.wpcf7 input[type="checkbox"]:focus-visible {
	outline: 2px solid var(--wp--custom--focus-ring, #e6ddcf);
	outline-offset: 3px;
}
.wpcf7 .wpcf7-consent .wpcf7-list-item label { padding: 0.5rem 0; align-items: flex-start; line-height: 1.45; color: var(--wp--preset--color--accent-2); }
.wpcf7 .wpcf7-consent input[type="checkbox"] { margin-top: 0.125rem; }

/* Submit: same as the theme button */
.wpcf7 .wpcf7-actions { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.wpcf7 input[type="submit"] {
	min-height: var(--humpf-control-h);
	padding: 0.875rem 1.5rem;
	background: var(--wp--preset--color--accent-1);
	color: var(--wp--preset--color--white);
	border: 0;
	border-radius: var(--wp--preset--border-radius--sm, 6px);
	font-family: inherit;
	font-size: var(--wp--preset--font-size--small);
	font-weight: 700;
	letter-spacing: var(--humpf-button-tracking);
	line-height: 1.25;
	text-transform: uppercase;
	cursor: pointer;
}
.wpcf7 input[type="submit"]:hover { background: var(--wp--preset--color--accent-7); }
.wpcf7 input[type="submit"]:disabled,
.wpcf7 form.submitting input[type="submit"] { opacity: 0.6; cursor: progress; }
@media (max-width: 599px) {
	.wpcf7 input[type="submit"] { width: 100%; }
}
.wpcf7 .wpcf7-spinner { margin: 0; background-color: var(--wp--preset--color--accent-4); }

/* Validation */
.wpcf7 .wpcf7-not-valid { border-color: var(--f-error) !important; }
.wpcf7 .wpcf7-not-valid-tip {
	display: block;
	margin-top: 0.375rem;
	color: var(--f-error);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 600;
	line-height: 1.4;
}
.wpcf7 .wpcf7-not-valid-tip::before { content: "\26A0\FE0E\00a0"; }

/* Response banner */
.wpcf7 form .wpcf7-response-output {
	margin: 0;
	padding: 0.875rem 1rem;
	border: 1px solid var(--wp--preset--color--accent-6);
	border-left-width: 4px;
	border-radius: var(--wp--preset--border-radius--sm, 6px);
	background: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
	font-weight: 600;
	line-height: 1.45;
}
.wpcf7 form.init .wpcf7-response-output,
.wpcf7 form.resetting .wpcf7-response-output,
.wpcf7 form.submitting .wpcf7-response-output { display: none; }
.wpcf7 form.sent .wpcf7-response-output { border-color: var(--f-ok); }
.wpcf7 form.invalid .wpcf7-response-output,
.wpcf7 form.unaccepted .wpcf7-response-output,
.wpcf7 form.failed .wpcf7-response-output,
.wpcf7 form.aborted .wpcf7-response-output,
.wpcf7 form.spam .wpcf7-response-output { border-color: var(--f-error); }
.wpcf7 form.sent .wpcf7-response-output::before { content: "\2713\00a0"; color: var(--f-ok); }
@media (prefers-reduced-motion: reduce) {
	.wpcf7 * { transition: none !important; animation: none !important; }
}

.threedh-form-card { margin-bottom: var(--wp--preset--spacing--60, 2rem); }
@media (min-width: 640px) {
	.wpcf7 .wpcf7-row-3 { grid-template-columns: 2fr 1fr 1fr; }
}
.wpcf7 .wpcf7-field select { appearance: auto; }
.wpcf7 select { cursor: pointer; }

/* Store Kit forms: one rhythm for contact, custom requests and registration. */
:is(.threedh-contact__form, .threedh-quote__form, .threedh-reg__form) {
	gap: 1.25rem;
	padding: clamp(1.25rem, 3vw, 2rem);
	border-color: var(--wp--custom--card-border);
	border-radius: var(--wp--preset--border-radius--md);
}

:is(.threedh-contact__row, .threedh-quote__row, .threedh-reg__row) {
	gap: 1.25rem;
	align-items: stretch;
}

:is(.threedh-contact__field, .threedh-quote__field, .threedh-reg__field) {
	min-width: 0;
	gap: 0.375rem;
}

/* Keep controls aligned when neighboring labels or hints wrap. */
:is(.threedh-contact__row, .threedh-quote__row, .threedh-reg__row) > div > :is(input, select) {
	margin-top: auto;
}

:is(.threedh-quote__form .threedh-quote__group, .threedh-reg__form .threedh-reg__group) {
	gap: 1.25rem;
	padding-top: var(--wp--preset--spacing--50);
	border-top-color: var(--wp--preset--color--accent-6);
}

:is(.threedh-quote__form .threedh-quote__group, .threedh-reg__form .threedh-reg__group) legend {
	margin-bottom: var(--wp--preset--spacing--10);
	font-size: var(--wp--preset--font-size--large);
	font-weight: 700;
	letter-spacing: -0.01em;
	line-height: 1.35;
	text-transform: none;
	color: var(--wp--preset--color--contrast);
}

:is(.threedh-contact__field, .threedh-quote__field, .threedh-reg__field):has([class$="__opt"]) > label {
	color: var(--wp--preset--color--accent-2);
	font-weight: 500;
}

:is(.threedh-contact__opt, .threedh-quote__opt, .threedh-reg__opt) {
	color: var(--wp--preset--color--accent-4);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 400;
}

:is(.threedh-contact__form, .threedh-quote__form, .threedh-reg__form) :is([class$="__hint"], [class$="__note"]) {
	color: var(--wp--preset--color--accent-4);
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.5;
}

:is(.threedh-contact__req, .threedh-quote__req, .threedh-reg__req) {
	color: var(--humpf-error);
}

/* All text controls keep a 48px row and 16px text to avoid iOS focus zoom. */
:is(.threedh-contact__form, .threedh-quote__form, .threedh-reg__form) :is(input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]), textarea, select) {
	box-sizing: border-box;
	min-height: var(--humpf-control-h);
	font-size: var(--wp--preset--font-size--medium);
}

:is(.threedh-quote__form, .threedh-reg__form) select {
	height: var(--humpf-control-h);
}

.threedh-quote__form textarea {
	height: 8rem;
	min-height: 8rem;
}

:is(.threedh-contact__form, .threedh-quote__form, .threedh-reg__form) :is(input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]), textarea, select):not([aria-invalid="true"]):not(:user-invalid) {
	border-color: var(--humpf-field-border);
}

:is(.threedh-contact__form, .threedh-quote__form, .threedh-reg__form) :is(input, textarea, select, button):focus-visible {
	outline: 2px solid var(--wp--custom--focus-ring);
	outline-offset: 3px;
}

/* Respect existing validation and the browser's touched-invalid state. */
:is(.threedh-contact__form, .threedh-quote__form, .threedh-reg__form) :is(input, textarea, select):is([aria-invalid="true"], :user-invalid) {
	border-color: var(--humpf-error) !important;
}

:is(.threedh-contact__error, .threedh-quote__error, .threedh-reg__error) {
	color: var(--humpf-error);
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.5;
}

/* Native checkboxes remain native; align the box with the first line of copy. */
:is(.threedh-contact__consent, .threedh-quote__consent, .threedh-reg__consent) label {
	align-items: flex-start;
	gap: var(--wp--preset--spacing--30);
	min-height: 44px;
	padding-block: var(--wp--preset--spacing--10);
	color: var(--wp--preset--color--accent-2);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 400;
	line-height: 1.6;
}

:is(.threedh-contact__form, .threedh-quote__form, .threedh-reg__form) :is(input[type="checkbox"], input[type="radio"]) {
	flex: none;
	width: 1.25rem;
	height: 1.25rem;
	accent-color: var(--wp--preset--color--accent-2);
}

:is(.threedh-contact__consent, .threedh-quote__consent, .threedh-reg__consent) input[type="checkbox"] {
	margin-top: 0.125rem;
}

.threedh-reg__choices label {
	min-height: var(--humpf-control-h);
	box-sizing: border-box;
	border-color: var(--humpf-field-border);
}

.threedh-reg__choices label:has(input:checked) {
	border-color: var(--wp--preset--color--accent-2);
	background: var(--wp--preset--color--accent-5);
}

.threedh-reg__choices label:has(input:focus-visible) {
	outline: 2px solid var(--wp--custom--focus-ring);
	outline-offset: 3px;
}

/* A quieter upload tray, with the same button height as the rest of the form. */
:is(.threedh-quote__form, .threedh-reg__form) input[type="file"] {
	max-width: 100%;
	min-width: 0;
	padding: var(--wp--preset--spacing--20);
	border-color: var(--humpf-field-border);
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--accent-2);
}

:is(.threedh-quote__form, .threedh-reg__form) input[type="file"]::file-selector-button {
	min-height: 44px;
	margin-right: var(--wp--preset--spacing--30);
	padding-inline: var(--wp--preset--spacing--30);
	font-size: var(--wp--preset--font-size--small);
	border-color: var(--humpf-field-border);
}

:is(.threedh-contact__actions, .threedh-quote__actions, .threedh-reg__actions) {
	padding-top: var(--wp--preset--spacing--50);
	border-top: 1px solid var(--wp--preset--color--accent-6);
}

:is(.threedh-contact__submit, .threedh-quote__submit, .threedh-reg__submit) {
	min-height: var(--humpf-control-h);
	letter-spacing: var(--humpf-button-tracking);
}

/* The existing after-form blocks form a compact desktop side column.
 * Their DOM order stays intact; smaller screens keep the original stack. */
@media (max-width: 1023px) {
	.wp-site-blocks main > .wp-block-post-content > .threedh-form-card ~ h2.wp-block-heading {
		font-size: var(--wp--preset--font-size--large);
		line-height: 1.35;
	}
}

@media (min-width: 1024px) {
	.wp-site-blocks main:has(.threedh-form-card) > :is(.wp-block-post-title, .wp-block-post-content) {
		max-width: 72rem;
	}

	.wp-site-blocks main > .wp-block-post-content:has(> .threedh-form-card) {
		display: grid;
		grid-template-columns: minmax(0, 2.25fr) minmax(16rem, 1fr);
		grid-template-rows: repeat(7, min-content) 1fr;
		gap: var(--wp--preset--spacing--50) var(--wp--preset--spacing--60);
		align-items: start;
	}

	.wp-site-blocks main > .wp-block-post-content:has(> .threedh-form-card) > * {
		min-width: 0;
		width: auto;
		margin: 0;
		margin-inline: 0 !important; /* Override constrained-block auto centering. */
	}

	.wp-site-blocks main > .wp-block-post-content:has(> .threedh-form-card) > :nth-child(-n+3) {
		grid-column: 1 / -1;
		max-width: var(--wp--style--global--content-size);
	}

	.wp-site-blocks main > .wp-block-post-content:has(> .threedh-form-card) > h2.wp-block-heading {
		margin-top: 0 !important; /* Override the general page section spacing. */
	}

	.wp-site-blocks main > .wp-block-post-content:has(> .threedh-form-card) > .threedh-form-card {
		grid-column: 1;
		grid-row: 4 / span 5;
	}

	.wp-site-blocks main > .wp-block-post-content > .threedh-form-card ~ * {
		grid-column: 2;
		font-size: var(--wp--preset--font-size--small);
		line-height: 1.65;
	}

	.wp-site-blocks main > .wp-block-post-content > .threedh-form-card ~ h2.wp-block-heading {
		font-size: var(--wp--preset--font-size--large);
		line-height: 1.35;
		padding-top: var(--wp--preset--spacing--50);
		border-top: 1px solid var(--wp--preset--color--accent-6);
	}

	.wp-site-blocks main > .wp-block-post-content > .threedh-form-card + h2.wp-block-heading {
		padding-top: 0;
		border-top: 0;
	}

	.wp-site-blocks main > .wp-block-post-content > .threedh-form-card ~ ol {
		padding-left: 1.25rem;
	}
}

/* Guest account panels use the same padding, field rhythm and action divider. */
.woocommerce-account #customer_login :is(form.login, form.register) {
	padding: clamp(1.25rem, 3vw, 2rem);
	border-color: var(--wp--custom--card-border);
}

.woocommerce-account #customer_login .form-row {
	margin-bottom: 1.25rem;
}

.woocommerce-account #customer_login form :is(.input-text, input[type="checkbox"], button):focus-visible {
	outline: 2px solid var(--wp--custom--focus-ring);
	outline-offset: 3px;
}

.woocommerce-account #customer_login form .input-text:focus-visible {
	box-shadow: none;
}

.woocommerce-account #customer_login form .input-text:user-invalid {
	border-color: var(--humpf-error) !important;
}

.woocommerce-account #customer_login form input[type="checkbox"] {
	accent-color: var(--wp--preset--color--accent-2);
	flex: none;
	width: 1.25rem;
	height: 1.25rem;
}

.woocommerce-account #customer_login form .form-row:has(> button[type="submit"]) {
	margin-top: var(--wp--preset--spacing--50);
	padding-top: var(--wp--preset--spacing--50);
	border-top: 1px solid var(--wp--preset--color--accent-6);
}

.woocommerce-account #customer_login .woocommerce-LostPassword {
	margin-bottom: 0;
	font-size: var(--wp--preset--font-size--small);
}
