/*
 * Forms.
 *
 * Two jobs: style Horseclub's own forms (booking, contact and newsletter, all
 * drawn by inc/booking.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
   --------------------------------------------------------------------------- */

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

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

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

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

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

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

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

/* ---------------------------------------------------------------------------
   Horseclub's forms
   --------------------------------------------------------------------------- */

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

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

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

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

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

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

/* Compact: the booking band's box. Stacked controls on the pale surface
   colour, and a full-width gradient button, as the template's form. */
.horseclub-form--compact .horseclub-field__control {
	background-color: var(--wp--preset--color--surface);
	border-color: var(--wp--preset--color--surface);
	border-radius: 4px;
	padding: 0.55rem 0.75rem;
	min-height: 2.5rem;
}

.horseclub-form--compact textarea.horseclub-field__control {
	min-height: 4.5rem;
}

.horseclub-form--compact .horseclub-form__grid {
	gap: 1.25rem;
}

.horseclub-form--compact .horseclub-form__actions .wp-element-button {
	width: 100%;
	border-radius: 4px;
}

/* On a photograph, the one visible label (the date's) is light. */
.wp-block-cover .horseclub-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. */
.horseclub-form--split .horseclub-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;
}

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

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

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

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

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

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

/* Inline: the footer newsletter. A pill of pale surface with a round button
   carrying an arrow at its end. */
.horseclub-form--inline .horseclub-form__grid {
	grid-template-columns: minmax(0, 1fr) auto;
	align-items: center;
	gap: 0;
	padding: 0.2rem 0.3rem 0.2rem 0;
	background-color: var(--wp--preset--color--surface);
	border-radius: 999px;
}

.horseclub-form--inline .horseclub-field__control {
	min-height: 2.5rem;
	padding: 0.5rem 1.25rem;
	font-size: 0.8125rem;
	background: transparent;
	border: 0;
	border-radius: 999px;
}

.horseclub-form__round {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.25rem;
	height: 2.25rem;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--on-primary);
	cursor: pointer;
	transition: background-color 0.25s ease, transform 0.25s ease;
}

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

.horseclub-form__round:hover,
.horseclub-form__round:focus-visible {
	background: var(--wp--preset--color--primary-deep);
	transform: translateX(2px);
}

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

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

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

.horseclub-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-primary);
	background: var(--wp--preset--gradient--brand-deep);
	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--primary-deep);
}

.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 gradient: 2.2:1. */
	color: var(--wp--preset--color--on-primary);
	text-transform: uppercase;
	padding-left: 3.125rem;
	padding-right: 3.125rem;
}
