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

.docmed-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.8rem 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 hairline, as a mix so it follows the palette; an
	   edge a control needs (WCAG 1.4.11) is drawn by --docmed-edge below. */
	border: 1px solid var(--docmed-edge);
	border-radius: 0;
	box-shadow: none;
	transition: border-color 0.2s ease;
	-webkit-appearance: none;
	appearance: none;
}

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

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

/* A select loses its arrow to `appearance: none`; this puts one back, in the
   text colour. */
select.docmed-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) 55%, calc(100% - 0.9rem) 55%;
	background-size: 0.35rem 0.35rem;
	background-repeat: no-repeat;
	cursor: pointer;
}

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

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

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

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

/* ---------------------------------------------------------------------------
   Docmed's forms
   --------------------------------------------------------------------------- */

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

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

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

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

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

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

/* Grid: the appointment form, two columns as the template's popup has it:
   department and doctor, date and time, name and phone, then email and the
   note across the width. */
.docmed-form--grid .docmed-form__grid {
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 1.25rem 1.5rem;
}

.docmed-form--grid .docmed-field--email,
.docmed-form--grid .docmed-field--message {
	grid-column: 1 / -1;
}

.docmed-form--grid .docmed-form__actions .wp-element-button {
	width: 100%;
}

.docmed-form__hint {
	margin: 0.75rem 0 0;
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--muted);
}

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

/* Split: the contact page, as the template's: the message across the top,
   then name and email, subject and phone in pairs, an outlined button. */
.docmed-form--split .docmed-form__grid {
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 1.25rem 1.5rem;
}

.docmed-form--split .docmed-field--message {
	grid-column: 1 / -1;
}

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

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

.docmed-form--split .docmed-form__actions .wp-element-button {
	background: transparent;
	border-color: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--primary);
	padding-left: 2.75rem;
	padding-right: 2.75rem;
	text-transform: uppercase;
	letter-spacing: 0.1em;
}

.docmed-form--split .docmed-form__actions .wp-element-button:hover,
.docmed-form--split .docmed-form__actions .wp-element-button:focus-visible {
	background: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--on-primary);
}

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

/* Stacked: the sidebar's newsletter, one control over an outlined button the
   width of the box, as the template's widget. */
.docmed-form--stacked .docmed-form__actions .wp-element-button {
	width: 100%;
	background: transparent;
	border-color: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--primary);
	text-transform: uppercase;
	letter-spacing: 0.1em;
	font-size: var(--wp--preset--font-size--x-small);
}

.docmed-form--stacked .docmed-form__actions .wp-element-button:hover,
.docmed-form--stacked .docmed-form__actions .wp-element-button:focus-visible {
	background: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--on-primary);
}

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

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

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

.docmed-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: 500;
	line-height: 1.5;
	padding: 0.9rem 2.25rem;
	color: var(--wp--preset--color--on-primary);
	background: var(--wp--preset--gradient--brand);
	border: 0;
	border-radius: 4px;
	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;
}
