/*
 * Components: forms. Loaded when a Contact Form 7, Formidable or WPForms form
 * or the comment form renders (inc/assets.php entry "forms", widened in
 * inc/skin.php; inc/forms.php fallback for shortcode output). CF7's own
 * stylesheet is never loaded, so this is the complete CF7 skin, built from
 * tokens; for Formidable and WPForms it is the field skin under their own
 * markup (components/forms-addons.css adds their wrappers and the CF7
 * multistep / conditional / confirm-email add-ons). The field rules are
 * repeated in components/wc-bookings.css, which loads alone on booking
 * product pages.
 *
 * The field selectors are scoped with
 *   :is(.wpcf7-form, .frm_forms, .wpforms-form, .comment-form)
 * so one rule serves every form plugin.
 */

/* ---------- structure (CF7) ----------
   CF7 wraps each field in a <p> and puts a <br> between a label's text and
   its control; the control wrapper becomes the block under the label. */

.wpcf7-form p {
	margin: 0 0 var(--wp--preset--spacing--30);
}

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

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

:is(.wpcf7-form, .frm_forms, .wpforms-form, .comment-form) label {
	display: block;
	margin-bottom: 0.35rem;
	font-weight: var(--wp--custom--typography--font-weight--bold, 600);
}

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

.wpcf7-form label > .wpcf7-form-control-wrap {
	margin-top: 0.35rem;
}

.wpcf7-form label:has(> .wpcf7-form-control-wrap) {
	margin-bottom: 0;
}

/* ---------- fields ---------- */

:is(.wpcf7-form, .frm_forms, .wpforms-form, .comment-form) :is(input[type="text"], input[type="email"], input[type="tel"], input[type="url"], input[type="number"], input[type="date"], input[type="time"], input[type="search"], input[type="password"], select, textarea) {
	box-sizing: border-box;
	display: block;
	width: 100%;
	max-width: 100%;
	margin: 0;
	padding: 13px 15px;
	border: var(--wp--custom--border--strong, 2px) solid var(--wp--preset--color--border-strong);
	border-radius: var(--wp--custom--radius--medium, 0.75rem);
	background-color: var(--wp--preset--color--base-2);
	color: var(--wp--preset--color--contrast);
	font-family: inherit;
	font-size: inherit;
	font-weight: inherit;
	line-height: 1.4;
	-webkit-appearance: none;
	appearance: none;
	transition: border-color var(--wp--custom--transition--fast, 0.15s ease);
}

:is(.wpcf7-form, .frm_forms, .wpforms-form, .comment-form) :is(input, select, textarea)::placeholder {
	color: var(--wp--preset--color--contrast-2);
	opacity: 1;
}

:is(.wpcf7-form, .frm_forms, .wpforms-form, .comment-form) :is(input[type="text"], input[type="email"], input[type="tel"], input[type="url"], input[type="number"], input[type="date"], input[type="time"], input[type="search"], input[type="password"], select, textarea):hover {
	border-color: var(--wp--preset--color--contrast-2);
}

:is(.wpcf7-form, .frm_forms, .wpforms-form, .comment-form) :is(input[type="text"], input[type="email"], input[type="tel"], input[type="url"], input[type="number"], input[type="date"], input[type="time"], input[type="search"], input[type="password"], select, textarea):focus {
	border-color: var(--wp--preset--color--secondary);
	outline: none;
}

:is(.wpcf7-form, .frm_forms, .wpforms-form, .comment-form) textarea {
	min-height: 140px;
	resize: vertical;
}

/* iOS draws date inputs as a centred, shrink-wrapped pill. */
:is(.wpcf7-form, .frm_forms, .wpforms-form) input[type="date"],
:is(.wpcf7-form, .frm_forms, .wpforms-form) input[type="time"] {
	display: block;
	min-height: 3.375rem;
	text-align: left;
}

:is(.wpcf7-form, .frm_forms, .wpforms-form) input[type="date"]::-webkit-date-and-time-value,
:is(.wpcf7-form, .frm_forms, .wpforms-form) input[type="time"]::-webkit-date-and-time-value {
	text-align: left;
}

/* Select: native arrow replaced by a token-coloured chevron, masked onto the
   wrapper because a <select> cannot carry a pseudo-element. */
:is(.wpcf7-form, .frm_forms, .wpforms-form) select {
	padding-right: 2.75rem;
	cursor: pointer;
}

.wpcf7-form .wpcf7-form-control-wrap:has(> select)::after {
	content: "";
	position: absolute;
	right: 1rem;
	top: 50%;
	width: 0.75rem;
	height: 0.75rem;
	transform: translateY(-50%);
	pointer-events: none;
	background-color: currentColor;
	-webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path d='M1.5 4L6 8l4.5-4' fill='none' stroke='currentColor' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>") center / contain no-repeat;
	mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path d='M1.5 4L6 8l4.5-4' fill='none' stroke='currentColor' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>") center / contain no-repeat;
}

@supports not selector(:has(a)) {
	:is(.wpcf7-form, .frm_forms, .wpforms-form) select {
		-webkit-appearance: menulist;
		appearance: auto;
	}
}

/* Formidable and WPForms draw no wrapper pseudo-element: keep the native arrow. */
:is(.frm_forms, .wpforms-form) select {
	-webkit-appearance: menulist;
	appearance: auto;
}

/* ---------- checkboxes, radios, acceptance ---------- */

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

.wpcf7-form .wpcf7-list-item label {
	display: inline-flex;
	align-items: flex-start;
	gap: 0.6rem;
	margin: 0;
	font-weight: var(--wp--custom--typography--font-weight--body, 400);
	cursor: pointer;
}

:is(.wpcf7-form, .frm_forms, .wpforms-form, .comment-form) :is(input[type="checkbox"], input[type="radio"]) {
	flex: none;
	width: 1.25rem;
	height: 1.25rem;
	margin: 0.2rem 0 0;
	accent-color: var(--wp--preset--color--primary);
}

/* Consent row: flush with the fields, 44px tall, hanging text. */
.wpcf7-form .wpcf7-acceptance .wpcf7-list-item {
	display: block;
	margin: 0;
}

.wpcf7-form .wpcf7-acceptance label {
	display: flex;
	box-sizing: border-box;
	min-height: 44px;
	padding-block: 0.25rem;
}

/* ---------- submit ----------
   CF7 adds no .wp-element-button, so the theme button is rebuilt from the
   same tokens; a submit that does carry the class is left to theme.json. */

.wpcf7-form .wpcf7-submit {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5em;
	box-sizing: border-box;
	min-height: 48px;
	margin: 0;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}

.wpcf7-form .wpcf7-submit:not(.wp-element-button) {
	padding: 0.9rem 1.5rem;
	border: 0;
	border-radius: var(--wp--custom--radius--medium, 0.75rem);
	background-color: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--primary-contrast);
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--medium);
	font-weight: var(--wp--custom--typography--font-weight--label, 600);
	line-height: 1.2;
	text-decoration: none;
	transition:
		transform var(--wp--custom--transition--fast, 0.15s ease),
		background-color var(--wp--custom--transition--fast, 0.15s ease);
}

.wpcf7-form .wpcf7-submit:not(.wp-element-button):hover,
.wpcf7-form .wpcf7-submit:not(.wp-element-button):focus-visible {
	background-color: var(--wp--preset--color--primary-2);
	transform: translateY(-2px);
}

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

/* Sending indicator (CF7 toggles .submitting on the form). */
.wpcf7-form .wpcf7-spinner {
	display: inline-block;
	width: 1em;
	height: 1em;
	margin-left: 0.5em;
	border: 2px solid currentColor;
	border-right-color: transparent;
	border-radius: 50%;
	vertical-align: middle;
	visibility: hidden;
	animation: revsults-spin 0.75s linear infinite;
}

.wpcf7-form.submitting .wpcf7-spinner {
	visibility: visible;
}

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

/* ---------- validation and response ---------- */

.wpcf7-form .wpcf7-form-control.wpcf7-not-valid,
.wpcf7-form .wpcf7-form-control.wpcf7-not-valid:hover {
	border-color: var(--wp--preset--color--error);
}

.wpcf7-form .wpcf7-not-valid-tip {
	display: block;
	margin-top: 0.35rem;
	font-size: var(--wp--preset--font-size--x-small);
	color: var(--wp--preset--color--error);
}

.wpcf7-form .wpcf7-response-output {
	margin: var(--wp--preset--spacing--30) 0 0;
	padding: 0.75rem 1rem;
	border: 0;
	border-left: 4px solid var(--wp--preset--color--secondary);
	border-radius: var(--wp--custom--radius--medium, 0.75rem);
	background-color: var(--wp--preset--color--tint);
	color: var(--wp--preset--color--contrast);
	font-size: var(--wp--preset--font-size--small);
}

/* No message box while CF7 starts, refills or sends (CF7's own rule). */
.wpcf7-form:is(.init, .resetting, .submitting) .wpcf7-response-output {
	display: none;
}

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

.wpcf7-form.invalid .wpcf7-response-output,
.wpcf7-form.unaccepted .wpcf7-response-output {
	border-left-color: var(--wp--preset--color--warning);
}

.wpcf7-form.failed .wpcf7-response-output,
.wpcf7-form.aborted .wpcf7-response-output,
.wpcf7-form.spam .wpcf7-response-output {
	border-left-color: var(--wp--preset--color--error);
}

/* CF7 6 puts its hidden inputs in a fieldset; its own stylesheet (never
   loaded here) hides it, else an empty bordered box shows above the form. */
.wpcf7 .hidden-fields-container {
	display: none;
}

/* CF7's live region for screen readers stays out of sight. */
.wpcf7 .screen-reader-response {
	position: absolute;
	overflow: hidden;
	clip: rect(1px, 1px, 1px, 1px);
	clip-path: inset(50%);
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	border: 0;
}

/* ---------- honeypots ----------
   The engine's trap field (class revsults-hp on the CF7 tag) and the Contact
   Form 7 Honeypot add-on (.cf7apps-honeypot-wrap, [data-cf7apps-honeypot]).
   visibility:hidden takes them out of the tab order and the accessibility
   tree; the <p> around them collapses so no empty row remains. */

.revsults-hp,
.cf7apps-honeypot-wrap,
[data-cf7apps-honeypot],
.wpcf7-form .wpcf7-form-control-wrap:has(> .revsults-hp) {
	position: absolute !important;
	left: -9999px;
	width: 1px;
	height: 1px;
	margin: 0;
	padding: 0;
	overflow: hidden;
	visibility: hidden;
}

:is(.wpcf7-form, .frm_forms, .wpforms-form) p:has(.revsults-hp, .cf7apps-honeypot-wrap, [data-cf7apps-honeypot]) {
	margin: 0;
}

/* ---------- motion ---------- */

@media (prefers-reduced-motion: reduce) {
	.wpcf7-form .wpcf7-submit:not(.wp-element-button):hover,
	.wpcf7-form .wpcf7-submit:not(.wp-element-button):focus-visible {
		transform: none;
	}

	.wpcf7-form .wpcf7-spinner {
		animation: none;
		border-right-color: currentColor;
		opacity: 0.6;
	}
}
