/**
 * Contact Form 7 form-field styling for nordnatur.tech.
 *
 * CSS BUDGET EXCEPTION (CLAUDE.md rule 14).
 * Rule 14 caps custom CSS at <20 lines per plugin. This file ships ~95
 * lines because CF7 emits HTML outside Gutenberg's block tree — theme.json
 * and block-style variations cannot reach the markup. Plain CSS is the
 * only place this can live. Conditionally enqueued via `has_shortcode()`
 * in ntech-core.php so it only loads on pages with a CF7 form. Logged in
 * ntech-core CHANGELOG 0.5.0 with semver intent.
 *
 * All values resolve through theme.json custom properties (palette,
 * spacing scale, font-size scale, radius, transition). Source of truth
 * for the design lives at styling/elements/form-field.html.
 *
 * Atom: form-field — B3 of the 2026-04-30 atom-first polish pass.
 */

/* Field-group rhythm — CF7 wraps each field in <p>. */
.wpcf7 p {
	margin-bottom: var(--wp--preset--spacing--50);
}
.wpcf7 p:last-child {
	margin-bottom: 0;
}

/* Label — block, sm, weight 500, contrast-2. */
.wpcf7 label {
	display: block;
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--sm);
	font-weight: 500;
	color: var(--wp--preset--color--contrast-2);
	line-height: 1.4;
}

/* Required marker — leading red asterisk on any <p> wrapping a CF7
   input flagged wpcf7-validates-as-required. E-form-2 resolved. */
.wpcf7 p:has(.wpcf7-validates-as-required) > label::before {
	content: "*";
	color: var(--wp--preset--color--accent-red);
	margin-right: 0.25em;
	font-weight: 600;
}

/* CF7 form-template artefact — the block-level wrapper below already
   breaks the input to its own line; hide the literal <br> if authors
   keep it in their template. */
.wpcf7 label > br {
	display: none;
}

/* Input wrapper inside the label — block, gap to label text. */
.wpcf7 label > .wpcf7-form-control-wrap {
	display: block;
	margin-top: var(--wp--preset--spacing--20);
}

/* Input / textarea / select base. */
.wpcf7 input[type="text"],
.wpcf7 input[type="email"],
.wpcf7 input[type="tel"],
.wpcf7 input[type="url"],
.wpcf7 input[type="number"],
.wpcf7 textarea,
.wpcf7 select {
	display: block;
	width: 100%;
	box-sizing: border-box;
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--md);
	line-height: 1.5;
	color: var(--wp--preset--color--contrast-2);
	background: var(--wp--preset--color--base-3);
	border: 1px solid var(--wp--preset--color--contrast-3);
	border-radius: var(--wp--custom--radius--default);
	padding: var(--wp--preset--spacing--30) var(--wp--preset--spacing--40);
	transition: border-color var(--wp--custom--transition--base, 200ms ease-out);
}

/* Focus state — border shifts to accent-2 + visible 2px ring on text-like
   inputs only. The prior bare `input:focus` selector silently suppressed the
   UA outline on every input including checkbox / radio / submit / file (a11y
   regression). The 2px outline meets WCAG 2.4.11 (Focus Appearance, WCAG 2.2
   AA) thickness + contrast requirements (~7:1 accent vs base-3). */
.wpcf7 :where(input[type="text"],
              input[type="email"],
              input[type="tel"],
              input[type="url"],
              input[type="number"]):focus,
.wpcf7 textarea:focus,
.wpcf7 select:focus {
	border-color: var(--wp--preset--color--accent-2);
	outline: 2px solid var(--wp--custom--focus--ring);
	outline-offset: 2px;
}

/* Invalid state — CF7 adds .wpcf7-not-valid to the input. */
.wpcf7 .wpcf7-not-valid {
	border-color: var(--wp--preset--color--accent-red);
}

/* Error message — CF7-emitted span below invalid inputs. */
.wpcf7 .wpcf7-not-valid-tip {
	display: block;
	font-size: var(--wp--preset--font-size--xs);
	color: var(--wp--preset--color--accent-red);
	margin-top: var(--wp--preset--spacing--20);
}

/* Helper text — author opt-in convention.
   Type <span class="form-helper">…</span> after the input shortcode
   in the CF7 form template. Always-on (E-form-1 resolved). */
.wpcf7 .form-helper {
	display: block;
	font-size: var(--wp--preset--font-size--xs);
	color: var(--wp--preset--color--contrast-3);
	margin-top: var(--wp--preset--spacing--20);
}

/* Submit button — mirrors the theme.json `elements.button` primary style
   (accent fill, base-3 text, 4px radius, heading font 500) so the CF7
   submit matches a core/button. CF7 emits a plain <input type="submit">
   that the block-style variation can't reach, hence the duplication here. */
.wpcf7 input[type="submit"] {
	display: inline-block;
	cursor: pointer;
	background: var(--wp--preset--color--accent);
	color: var(--wp--preset--color--base-3);
	border: 1px solid transparent;
	border-radius: var(--wp--custom--radius--default);
	padding: 0.85rem 1.6rem;
	font-family: var(--wp--preset--font-family--heading);
	font-size: 1rem;
	font-weight: 500;
	letter-spacing: 0;
	line-height: 1.2;
	transition: background-color var(--wp--custom--transition--base, 200ms ease-out), border-color var(--wp--custom--transition--base, 200ms ease-out);
}
.wpcf7 input[type="submit"]:hover {
	background: var(--wp--preset--color--accent-2);
}
.wpcf7 input[type="submit"]:focus-visible {
	outline: 2px solid var(--wp--custom--focus--ring);
	outline-offset: 2px;
}
