/* UB Kit forms (Contact Form 7), from the theme's tokens: palette, spacing and sizes from theme.json,
   form radius and state colours from settings.custom.form. Loaded only where a form is shown. Works
   on light and dark sections: text follows the section colour, messages carry their own background. */

.wpcf7 {
	--ub-form-radius: var(--wp--custom--form--radius, 10px);
	--ub-form-error: var(--wp--custom--form--error, #b42318);
	--ub-form-success: var(--wp--custom--form--success, #157347);
	--ub-form-gap: var(--wp--preset--spacing--30, 1rem);
}

.ub-form__grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--ub-form-gap); }
@media (min-width: 640px) {
	.ub-form__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.ub-form__field--wide { grid-column: 1 / -1; }
}
.ub-form__field { display: flex; flex-direction: column; gap: 0.375rem; margin: 0; }
.ub-form__label { font-weight: 600; }
.ub-form__optional { font-weight: 400; opacity: 0.8; }

.wpcf7 :is(input[type="text"], input[type="email"], input[type="tel"], input[type="url"], input[type="number"], input[type="date"], select, textarea) {
	box-sizing: border-box;
	inline-size: 100%;
	min-block-size: 48px;
	padding: 0.75rem 1rem;
	font: inherit;
	font-size: max(1rem, 16px); /* no zoom on phones */
	color: var(--wp--preset--color--ink, #111827);
	background: var(--wp--preset--color--base, #fff);
	border: 1px solid var(--wp--preset--color--muted, #4b5563); /* 3:1 or more against the field */
	border-radius: var(--ub-form-radius);
}
.wpcf7 textarea { min-block-size: 8rem; resize: vertical; }
.wpcf7 [aria-invalid="true"] { border-color: var(--ub-form-error); border-width: 2px; }

.ub-form__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin-block-start: var(--ub-form-gap); }
.wpcf7 .wpcf7-submit { cursor: pointer; } /* look: theme.json's button element (.wp-element-button) */
.wpcf7 .wpcf7-submit:disabled { opacity: 0.6; cursor: progress; }
.wpcf7 form:not(.submitting) .wpcf7-spinner::before { animation: none; } /* CF7 keeps it spinning while hidden */

.ub-form__privacy { margin-block: var(--ub-form-gap) 0; font-size: var(--wp--preset--font-size--small, 0.875rem); opacity: 0.85; }
.ub-form__privacy a { color: inherit; text-decoration: underline; } /* readable on light and dark sections */

/* Messages: white on their state colour, readable on any section */
.wpcf7-not-valid-tip {
	display: inline-block; align-self: flex-start; margin-block-start: 0.25rem; padding: 0.125rem 0.5rem;
	font-size: var(--wp--preset--font-size--small, 0.875rem); color: #fff; background: var(--ub-form-error); border-radius: 6px;
}
.wpcf7 form .wpcf7-response-output {
	margin: var(--ub-form-gap) 0 0; padding: 0.75rem 1rem; border: 0; border-radius: var(--ub-form-radius); color: #fff; background: var(--ub-form-error);
}
.wpcf7 form.sent .wpcf7-response-output { background: var(--ub-form-success); }

/* [ub_trap]: never shown, never focused */
.ub-trap { display: none !important; }

/* Checkbox, radio and acceptance lists: one item per line, the box beside its label as one target of
   at least 24 px; CF7's default indent and spaces go (grun-ro H75) */
.wpcf7 :is(.wpcf7-checkbox, .wpcf7-radio, .wpcf7-acceptance) { display: flex; flex-direction: column; gap: 0.5rem; }
.wpcf7 .wpcf7-list-item { display: block; margin: 0; }
.wpcf7 .wpcf7-list-item > label,
.wpcf7 .wpcf7-list-item:not(:has(> label)) { display: inline-flex; align-items: flex-start; gap: 0.625rem; min-block-size: 1.5rem; line-height: 1.5; cursor: pointer; }
.wpcf7 .wpcf7-list-item-label::before,
.wpcf7 .wpcf7-list-item-label::after { content: none; }
.wpcf7 :is(input[type="checkbox"], input[type="radio"]) { flex: none; inline-size: 1.375rem; block-size: 1.375rem; margin: 0.0625rem 0 0; accent-color: var(--wp--preset--color--primary, currentColor); }

/* The phone field with a country list (intl-tel-input, `[tel* telefon intl]`): as wide as the other fields, in the
   field's colours wherever the form sits (on a dark section it inherited light text on its white list and field), the
   country button with a visible focus ring. On a phone the list opens full screen, attached to the body
   (.iti--fullscreen-popup), so those rules aren't under .wpcf7. The library's own CSS loads with it (forms.php). */
.wpcf7 .iti { display: block; inline-size: 100%; }
.iti {
	color: var(--wp--preset--color--ink, #111827);
	--iti-border-color: var(--wp--preset--color--muted, #4b5563);
	--iti-country-selector-bg: var(--wp--preset--color--base, #fff);
	--iti-hover-color: color-mix(in srgb, var(--wp--preset--color--ink, #111827) 8%, transparent);
	--iti-icon-color: currentColor;
}
.wpcf7 .iti__selected-country { border-radius: var(--ub-form-radius) 0 0 var(--ub-form-radius); }
.iti__selected-country:focus-visible { outline: 2px solid currentColor; outline-offset: -4px; }
.iti__country-selector { border-radius: var(--ub-form-radius); }
.iti__search-input { min-block-size: 44px; font: inherit; font-size: max(1rem, 16px); color: inherit; background: transparent; }
