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

.sunshine-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);
	/* The template's #ddd edge is 1.4:1 on white: nobody could find the
	   field. Half the text colour into the ground clears 3:1 in every palette. */
	border: 1px solid var(--sunshine-edge, var(--wp--preset--color--muted));
	border-radius: 0;
	box-shadow: none;
	transition: border-color 0.2s ease;
	-webkit-appearance: none;
	appearance: none;
}

/* A select drawn by the theme, with its own chevron in the text colour. */
select.sunshine-field__control {
	padding-right: 2.5rem;
	background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
	background-position: calc(100% - 1.25rem) 50%, calc(100% - 0.9rem) 50%;
	background-size: 0.35rem 0.35rem;
	background-repeat: no-repeat;
}

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

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

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

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

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

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

/* ---------------------------------------------------------------------------
   Sunshine's forms
   --------------------------------------------------------------------------- */

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

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

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

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

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

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

/* Split: two fields to a row where they belong together, as the template's
   contact form sets them, with its message first and widest. */
.sunshine-form--split .sunshine-form__grid {
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 1.25rem 1.25rem;
}

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

.sunshine-form--contact textarea.sunshine-field__control {
	min-height: 11rem;
}

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

/* Compact: the RSVP card. One column of 50px fields named by their
   placeholders, as the template draws it, and the button the full width. */
.sunshine-form--compact .sunshine-form__grid {
	gap: 1.25rem;
}

.sunshine-form--compact .sunshine-field__control {
	min-height: 3.125rem;
}

.sunshine-form--compact textarea.sunshine-field__control {
	min-height: 7.5rem;
}

.sunshine-form--compact .sunshine-form__actions .wp-element-button {
	width: 100%;
	font-size: var(--wp--preset--font-size--x-large);
}

/* Yes or no: two answers side by side, each a box the whole of which can be
   tapped, with the native radio kept (and visible) for the keyboard. */
.sunshine-field--choice {
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
}

.sunshine-choices {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
	gap: 0.75rem;
}

.sunshine-choice {
	display: flex;
	align-items: center;
	gap: 0.6rem;
	min-height: 3.125rem;
	padding: 0.6rem 1rem;
	border: 1px solid var(--sunshine-edge, var(--wp--preset--color--muted));
	color: var(--wp--preset--color--contrast);
	font-size: var(--wp--preset--font-size--small);
	cursor: pointer;
}

.sunshine-choice input {
	flex: none;
	width: 1.1rem;
	height: 1.1rem;
	margin: 0;
	accent-color: var(--wp--preset--color--primary);
}

.sunshine-choice:has(input:checked) {
	border-color: var(--wp--preset--color--primary);
	background-color: var(--wp--preset--color--blush);
}

.sunshine-choice:has(input:focus-visible) {
	outline: 2px solid var(--wp--preset--color--primary);
	outline-offset: 2px;
}

/* Someone who cannot come is not asked how many are coming (the server
   ignores the answer too). */
.sunshine-form--rsvp:has(input[name="attending"][value="no"]:checked) .sunshine-field--guests {
	display: none;
}

/* Inline: the sidebar's sign-up. The address, then a full-width button. */
.sunshine-form--inline .sunshine-form__grid {
	gap: 0.9rem;
}

.sunshine-form--inline .sunshine-form__submit {
	width: 100%;
	cursor: pointer;
	text-transform: uppercase;
	font-size: var(--wp--preset--font-size--small);
}

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

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

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

.sunshine-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--primary);
	background: var(--wp--preset--color--base);
	border: 2px solid var(--wp--preset--color--primary);
	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);
	color: var(--wp--preset--color--on-primary);
}

.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(--sunshine-edge, var(--wp--preset--color--muted));
	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--base);
	border: 1px solid var(--sunshine-edge, var(--wp--preset--color--muted));
	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"] {
	text-transform: uppercase;
	padding-left: 3.125rem;
	padding-right: 3.125rem;
}
