/*
 * Forms.
 *
 * Two jobs: style Industry's own forms (quote, contact and newsletter, all
 * drawn by inc/enquiry.php), and pull the common form plugins onto the theme's
 * tokens so a form block does not look like a different website dropped into
 * the page.
 *
 * Everything here is expressed in palette variables, so a form follows
 * whichever of the eight colour variations a site has active.
 */

/* ---------------------------------------------------------------------------
   Shared controls
   --------------------------------------------------------------------------- */

.industry-field__control,
.wpcf7 input[type="text"],
.wpcf7 input[type="email"],
.wpcf7 input[type="tel"],
.wpcf7 input[type="date"],
.wpcf7 input[type="number"],
.wpcf7 textarea,
.wpcf7 select,
.wpforms-field input[type="text"],
.wpforms-field input[type="email"],
.wpforms-field input[type="tel"],
.wpforms-field textarea,
.wpforms-field select,
.gform_wrapper input[type="text"],
.gform_wrapper input[type="email"],
.gform_wrapper input[type="tel"],
.gform_wrapper textarea,
.gform_wrapper select,
.fluentform input[type="text"],
.fluentform input[type="email"],
.fluentform textarea,
.fluentform select,
.forminator-input,
.forminator-textarea,
.nf-form-content input[type="text"],
.nf-form-content input[type="email"],
.nf-form-content textarea {
	width: 100%;
	/* Form controls do not inherit a border-box reset from WordPress or from
	   the theme; without it `width: 100%` plus padding and a border is wider
	   than the cell the control sits in. */
	box-sizing: border-box;
	margin: 0;
	padding: 0.85rem 1rem;
	font-family: inherit;
	font-size: var(--wp--preset--font-size--small);
	font-weight: 400;
	line-height: 1.5;
	color: var(--wp--preset--color--contrast);
	background-color: var(--wp--preset--color--base);
	border: 1px solid var(--wp--preset--color--divider);
	border-radius: 0;
	box-shadow: none;
	transition: border-color 0.2s ease;
	-webkit-appearance: none;
	appearance: none;
}

.industry-field__control::placeholder {
	/* The placeholder carries the field's name in the compact layouts, so it
	   has to be readable, not the browser's pale grey. */
	color: var(--wp--preset--color--muted);
	opacity: 1;
}

.industry-field__control:focus,
.wpcf7 input:focus,
.wpcf7 textarea:focus,
.wpforms-field input:focus,
.wpforms-field textarea:focus,
.gform_wrapper input:focus,
.gform_wrapper textarea:focus,
.fluentform input:focus,
.fluentform textarea:focus,
.forminator-input:focus,
.forminator-textarea:focus {
	border-color: var(--wp--preset--color--primary);
	outline: 2px solid color-mix(in srgb, var(--wp--preset--color--primary) 35%, transparent);
	outline-offset: 0;
}

/* One height for every single-line control: a date input renders its own
   picker and otherwise comes out taller than the text input beside it. */
.industry-field__control {
	min-height: 2.75rem;
}

textarea.industry-field__control {
	min-height: 6rem;
	resize: vertical;
}

/* ---------------------------------------------------------------------------
   Labels
   --------------------------------------------------------------------------- */

.industry-field__label,
.wpcf7 label,
.wpforms-field-label,
.gfield_label,
.fluentform .ff-el-input--label label {
	display: block;
	margin-bottom: 0.4rem;
	font-size: var(--wp--preset--font-size--small);
	font-weight: 500;
	color: var(--wp--preset--color--contrast);
}

.industry-field__required {
	color: var(--wp--preset--color--primary);
}

/* ---------------------------------------------------------------------------
   Industry's forms
   --------------------------------------------------------------------------- */

.industry-form {
	position: relative;
	margin: 0;
}

/* The anchor the POST redirect comes back to, clear of the sticky header. */
.industry-form__anchor {
	position: absolute;
	top: -140px;
	width: 0;
	height: 0;
}

.industry-form .industry-field {
	margin: 0;
}

.industry-form__grid {
	display: grid;
	gap: 1.25rem;
}

.industry-form__actions {
	margin: 1.25rem 0 0;
}

.industry-form__actions .wp-element-button {
	cursor: pointer;
}

/* Compact: the quote panel on its darkened photograph. Transparent controls
   with a pale hairline and white words, stacked tight, and a full-width
   button, as the template's "Request a Quote" box. */
.industry-form--compact .industry-form__grid {
	gap: 0.3125rem;
}

.industry-form--compact .industry-field__control {
	min-height: 2.5rem;
	padding: 0.5rem 0.75rem;
	font-size: 0.8125rem;
	background-color: transparent;
	border-color: color-mix(in srgb, var(--wp--preset--color--overlay) 85%, transparent);
	color: var(--wp--preset--color--overlay);
}

.industry-form--compact .industry-field__control::placeholder {
	color: var(--wp--preset--color--overlay);
}

.industry-form--compact textarea.industry-field__control {
	min-height: 6.5rem;
}

/* The select draws its own arrow, in the words' colour. Its options open in
   the browser's own list, which is light, so they take the page's colours. */
.industry-form select.industry-field__control {
	padding-right: 2.25rem;
	background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
		linear-gradient(135deg, currentColor 50%, transparent 50%);
	background-position: calc(100% - 1.1rem) 50%, calc(100% - 0.8rem) 50%;
	background-size: 0.3rem 0.3rem;
	background-repeat: no-repeat;
	cursor: pointer;
}

.industry-form select.industry-field__control option {
	background-color: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
}

.industry-form--compact .industry-form__actions {
	margin-top: 0.3125rem;
}

.industry-form--compact .industry-form__actions .wp-element-button {
	width: 100%;
}

/* On a photograph, a visible label is light. */
.wp-block-cover .industry-field__label {
	color: var(--wp--preset--color--overlay);
}

/* Split: the contact page. Name, email and subject in the left column, the
   message filling the right, the button under it on the right. */
.industry-form--split .industry-form__grid {
	grid-template-columns: repeat(2, minmax(0, 1fr));
	grid-template-rows: repeat(3, auto);
	grid-auto-flow: column;
	gap: 1.25rem 1.875rem;
}

.industry-form--split .industry-field--message {
	grid-column: 2;
	grid-row: 1 / span 3;
	display: flex;
}

.industry-form--split .industry-field--message .industry-field__control {
	height: 100%;
	min-height: 11.875rem;
}

.industry-form--split .industry-form__actions {
	text-align: right;
}

.industry-form--split .industry-form__actions .wp-element-button {
	text-transform: uppercase;
}

@media (max-width: 781px) {
	.industry-form--split .industry-form__grid {
		grid-template-columns: 1fr;
		grid-template-rows: none;
		grid-auto-flow: row;
	}

	.industry-form--split .industry-field--message {
		grid-column: auto;
		grid-row: auto;
	}
}

/* Inline: the footer newsletter. A white field and a square accent button
   with an arrow, flush against each other, as the template's. */
.industry-form--inline .industry-form__grid {
	grid-template-columns: minmax(0, 1fr) auto;
	align-items: stretch;
	gap: 0;
	max-width: 17.5rem;
}

.industry-form--inline .industry-field__control {
	min-height: 2.5rem;
	padding: 0.5rem 0.9rem;
	font-size: 0.8125rem;
	border-color: var(--wp--preset--color--base);
	background-color: var(--wp--preset--color--base);
}

.industry-form__round {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.5rem;
	height: 100%;
	min-height: 2.5rem;
	padding: 0;
	border: 1px solid var(--wp--preset--color--accent-deep);
	border-radius: 0;
	background: var(--wp--preset--color--accent);
	color: var(--wp--preset--color--on-accent);
	cursor: pointer;
	transition: background-color 0.25s ease, color 0.25s ease;
}

.industry-form__round::before {
	content: "";
	width: 1.1rem;
	height: 1.1rem;
	background-color: currentColor;
	-webkit-mask: url("../icons/arrow-right.svg") center / contain no-repeat;
	mask: url("../icons/arrow-right.svg") center / contain no-repeat;
}

.industry-form__round:hover,
.industry-form__round:focus-visible {
	background: var(--wp--preset--color--on-accent);
	color: var(--wp--preset--color--accent);
}

.industry-form--inline .industry-form__notice {
	margin-bottom: 0.75rem;
}

/* The honeypot. Off-screen rather than display:none, because some bots skip
   anything that is display:none and fill everything else. */
.industry-form__trap {
	position: absolute;
	left: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.industry-form__notice {
	margin: 0 0 1.25rem;
	padding: 0.85rem 1.1rem;
	border-left: 3px solid currentColor;
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.6;
	background-color: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
}

.industry-form__notice.is-ok {
	/* The words carry the message; the colour only marks it. */
	border-left-color: var(--wp--preset--color--brand);
}

.industry-form__notice.is-error {
	border-left-color: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--primary);
}

/* ---------------------------------------------------------------------------
   Plugin submit buttons
   --------------------------------------------------------------------------- */

.wpcf7 input[type="submit"],
.wpforms-submit,
.gform_button,
.fluentform .ff-btn-submit,
.forminator-button-submit,
.nf-form-content .submit-wrap input {
	font-family: inherit;
	font-size: var(--wp--preset--font-size--small);
	font-weight: 600;
	line-height: 1.5;
	padding: 0.6rem 1.875rem;
	color: var(--wp--preset--color--on-accent);
	background: var(--wp--preset--color--accent);
	border: 1px solid var(--wp--preset--color--accent-deep);
	border-radius: 0;
	cursor: pointer;
	width: auto;
}

.wpcf7 input[type="submit"]:hover,
.wpforms-submit:hover,
.gform_button:hover,
.fluentform .ff-btn-submit:hover,
.forminator-button-submit:hover {
	background: var(--wp--preset--color--on-accent);
	color: var(--wp--preset--color--accent);
}

.wpcf7-not-valid-tip,
.wpforms-error,
.gfield_validation_message,
.fluentform .error {
	color: var(--wp--preset--color--primary);
	font-size: var(--wp--preset--font-size--small);
}

.wpcf7 .wpcf7-response-output {
	margin: 1.25rem 0 0;
	padding: 0.85rem 1.1rem;
	border: 0;
	border-left: 3px solid currentColor;
	font-size: var(--wp--preset--font-size--small);
}

/* ---------------------------------------------------------------------------
   Core search and comments
   --------------------------------------------------------------------------- */

.wp-block-search__input {
	box-sizing: border-box;
	padding: 0.6rem 0.9rem;
	border: 1px solid var(--wp--preset--color--divider);
	border-radius: 0;
	background-color: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
	font-family: inherit;
	font-size: var(--wp--preset--font-size--small);
}

.wp-block-post-comments-form input[type="text"],
.wp-block-post-comments-form input[type="email"],
.wp-block-post-comments-form input[type="url"],
.wp-block-post-comments-form textarea {
	width: 100%;
	box-sizing: border-box;
	padding: 0.75rem 1rem;
	font-family: inherit;
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--contrast);
	background-color: var(--wp--preset--color--surface);
	border: 1px solid var(--wp--preset--color--surface);
	border-radius: 0;
}

.wp-block-post-comments-form label {
	font-size: var(--wp--preset--font-size--small);
	font-weight: 500;
	color: var(--wp--preset--color--contrast);
}

.wp-block-post-comments-form .form-submit .wp-element-button,
.wp-block-post-comments-form input[type="submit"] {
	/* Core's comment form gives its submit the page's text colour, which in dark
	   mode is light text on the lifted, light fill. */
	color: var(--wp--preset--color--on-accent);
	text-transform: uppercase;
	padding-left: 3.125rem;
	padding-right: 3.125rem;
}

/* Reduced motion: controls change state at once. */
@media (prefers-reduced-motion: reduce) {
	.industry-field__control,
	.industry-form__round {
		transition: none;
	}
}
