/* ==========================================================================
   Zen Dev Tools Contact Form – front end
   Every rule sits inside :where(), which has zero specificity: whatever the
   theme already says about inputs, labels and buttons wins, and these rules
   only fill the gaps. Colours come from the text colour around the form
   (currentColor), so the form fits light and dark themes alike.
   ========================================================================== */

:where(.zdtcf) {
	--zdtcf-gap: 1.25em;
	--zdtcf-radius: 0.375em;
	--zdtcf-border: rgba(128, 128, 128, 0.55);
	--zdtcf-error: #c62828;
	--zdtcf-ok: #1b7f45;
	max-width: 100%;
	margin-block: 1.5em;
}

/* The hidden attribute must always win. Any display rule (the grid below, or a
   theme's) beats the browser's own [hidden] rule, which would show fields that
   should stay hidden until their URL parameter is present. */
.zdtcf [hidden] {
	display: none !important;
}

@supports (color: color-mix(in srgb, red 50%, blue)) {
	:where(.zdtcf) {
		--zdtcf-border: color-mix(in srgb, currentColor 35%, transparent);
	}
}

:where(.zdtcf-form) {
	display: grid;
	gap: var(--zdtcf-gap);
	margin: 0;
}

:where(.zdtcf-field) {
	display: grid;
	gap: 0.4em;
	min-width: 0;
	margin: 0;
}

:where(.zdtcf-label) {
	padding: 0;
	font-weight: 600;
}

:where(.zdtcf-required) {
	color: var(--zdtcf-error);
}

:where(.zdtcf-help) {
	margin: 0;
	font-size: 0.875em;
	opacity: 0.8;
}

/* Text fields, dropdowns and paragraphs */
:where(.zdtcf) :where(input:not([type="checkbox"], [type="radio"], [type="hidden"]), select, textarea) {
	box-sizing: border-box;
	width: 100%;
	max-width: 100%;
	padding: 0.65em 0.8em;
	border: 1px solid var(--zdtcf-border);
	border-radius: var(--zdtcf-radius);
	background-color: transparent;
	color: inherit;
	font: inherit;
	line-height: 1.4;
}

:where(.zdtcf) :where(textarea) {
	min-height: 8em;
	resize: vertical;
}

/* The open list of a dropdown is drawn by the system; give it system colours so it stays readable on dark themes. */
:where(.zdtcf) :where(select option) {
	background-color: Field;
	color: FieldText;
}

:where(.zdtcf) :where([readonly], .is-locked select) {
	cursor: default;
	opacity: 0.8;
}

/* Radio buttons, checkboxes and the consent box */
:where(.zdtcf-group) {
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
}

:where(.zdtcf-group) > :where(legend) {
	margin-bottom: 0.4em;
}

:where(.zdtcf-choices) {
	display: grid;
	gap: 0.35em;
}

:where(.zdtcf-choice) {
	display: inline-flex;
	align-items: flex-start;
	gap: 0.5em;
	font-weight: inherit;
	cursor: pointer;
}

:where(.zdtcf-choice) :where(input) {
	flex: 0 0 auto;
	width: 1.1em;
	height: 1.1em;
	margin: 0.2em 0 0;
	accent-color: currentColor;
}

:where(.is-locked .zdtcf-choice) {
	cursor: default;
}

/* Errors and messages */
:where(.zdtcf-error) {
	margin: 0;
	color: var(--zdtcf-error);
	font-size: 0.875em;
	font-weight: 600;
}

:where(.has-error) :where(input:not([type="checkbox"], [type="radio"]), select, textarea) {
	border-color: var(--zdtcf-error);
}

:where(.zdtcf-status:empty) {
	display: none;
}

:where(.zdtcf-status.is-error) {
	color: var(--zdtcf-error);
	font-weight: 600;
}

:where(.zdtcf-success) {
	padding: 1em 1.25em;
	border: 1px solid var(--zdtcf-ok);
	border-inline-start-width: 4px;
	border-radius: var(--zdtcf-radius);
}

:where(.zdtcf-success:focus) {
	outline: none;
}

:where(.zdtcf-success:focus-visible) {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* Send button: block themes style .wp-element-button, classic themes style button. */
:where(.zdtcf-actions) {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.75em;
}

:where(.zdtcf-submit) {
	cursor: pointer;
}

:where(.zdtcf-submit:disabled) {
	cursor: progress;
	opacity: 0.7;
}

:where(.zdtcf) :where(:focus-visible) {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* The honeypot: out of sight for people, still in the page for bots. */
.zdtcf-hp {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
}

/* Captcha widgets keep their own size. */
:where(.zdtcf-captcha) {
	min-height: 0;
	max-width: 100%;
	overflow-x: auto;
}

:where(.zdtcf-missing) {
	padding: 0.75em 1em;
	border: 1px dashed var(--zdtcf-error);
}

@media (prefers-reduced-motion: reduce) {
	:where(.zdtcf) * {
		transition: none !important;
		animation: none !important;
	}
}
