/*
 * Forms.
 *
 * Two jobs: style Lagoon's own forms (freight quote, shipment question,
 * 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
   --------------------------------------------------------------------------- */

.lagoon-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;
}

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

.lagoon-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. */
.lagoon-field__control {
	min-height: 2.75rem;
}

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

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

.lagoon-field__label,
.wpcf7 label,
.wpforms-field-label,
.gfield_label,
.fluentform .ff-el-input--label label {
	display: block;
	margin-bottom: 0.3rem;
	font-size: var(--wp--preset--font-size--x-small);
	font-weight: 400;
	letter-spacing: 0.02em;
	line-height: 1.6;
	text-transform: uppercase;
	color: var(--wp--preset--color--contrast);
}

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

/* ---------------------------------------------------------------------------
   Lagoon's forms
   --------------------------------------------------------------------------- */

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

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

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

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

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

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

/* 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. */
.lagoon-form select.lagoon-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;
}

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

/* Grid: the quote card. Three fields to a row with their labels above, the
   description across the full width and the button centred beneath, as the
   template's estimate form. */
.lagoon-form--grid .lagoon-form__grid {
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 1rem 1.875rem;
}

.lagoon-form--grid .lagoon-field--cargo,
.lagoon-form--grid .lagoon-field--question {
	grid-column: 1 / -1;
}

.lagoon-form--grid .lagoon-form__actions {
	margin-top: 2.5rem;
	text-align: center;
}

@media (max-width: 781px) {
	.lagoon-form--grid .lagoon-form__grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 559px) {
	.lagoon-form--grid .lagoon-form__grid {
		grid-template-columns: minmax(0, 1fr);
	}
}

/* Split: the contact page. The message across the top, name and email side
   by side, the subject across, as the template's "Get in Touch" form. */
.lagoon-form--split .lagoon-form__grid {
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 1.25rem 1.875rem;
}

.lagoon-form--split .lagoon-field--message,
.lagoon-form--split .lagoon-field--subject {
	grid-column: 1 / -1;
}

.lagoon-form--split .lagoon-field--message .lagoon-field__control {
	min-height: 11.875rem;
}

.lagoon-form--split .lagoon-form__actions {
	margin-top: 1.875rem;
}

@media (max-width: 559px) {
	.lagoon-form--split .lagoon-form__grid {
		grid-template-columns: minmax(0, 1fr);
	}
}

/* Stacked: the sidebar's newsletter box. The field and a full-width button. */
.lagoon-form--stacked .lagoon-form__actions .wp-element-button {
	width: 100%;
}

/* Inline: the footer newsletter. A field ruled in a pale hairline on the navy
   and a square accent button with an arrow, flush against it, as the
   template's. */
.lagoon-form--inline .lagoon-form__grid {
	grid-template-columns: minmax(0, 1fr) auto;
	align-items: stretch;
	gap: 0;
	max-width: 25.5rem;
}

.lagoon-form--inline .lagoon-field__control {
	min-height: 3.125rem;
	padding: 0.5rem 1.1rem;
	font-size: var(--wp--preset--font-size--small);
	border-color: color-mix(in srgb, var(--wp--preset--color--overlay) 25%, transparent);
	border-right: 0;
	background-color: transparent;
	color: var(--wp--preset--color--overlay);
}

.lagoon-form--inline .lagoon-field__control::placeholder {
	color: var(--wp--preset--color--on-dark);
}

.lagoon-form__round {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 3.25rem;
	height: 100%;
	min-height: 3.125rem;
	padding: 0;
	/* A deep accent is under 3:1 against the navy; the pale hairline is the
	   button's edge there (WCAG 1.4.11). */
	border: 1px solid color-mix(in srgb, var(--wp--preset--color--overlay) 60%, var(--wp--preset--color--accent));
	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;
}

.lagoon-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;
}

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

.lagoon-form--inline .lagoon-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. */
.lagoon-form__trap {
	position: absolute;
	left: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.lagoon-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);
}

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

.lagoon-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: 0.8125rem;
	font-weight: 700;
	line-height: 1.5;
	letter-spacing: 0.03em;
	text-transform: uppercase;
	padding: 1.3rem 2.5rem;
	color: var(--wp--preset--color--on-accent);
	background: var(--wp--preset--color--accent);
	border: 0;
	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);
}

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