/**
 * Gravity Forms: fields (3.17.0).
 *
 * Loaded only on pages that draw a form. The submit buttons are styled in
 * site-header.css (3.14.1); this file does the fields, so a form reads like
 * the checkout: 48px fields a thumb can hit, 16px text (no zoom on an iPhone),
 * small labels above each box, a green focus ring.
 *
 * Everything is scoped to forms on Gravity Forms' own "gravity-theme" markup,
 * which is what every form on the site uses. Field widths set in the form
 * editor (small / medium / large, half-width columns) are left alone.
 *
 * Two layout helpers at the end:
 *   #csa-form       the CSA contract's form section: narrower, centred, in a
 *                   card, with room under it.
 *   .pm-form-narrow the same on any other page: add it under Advanced →
 *                   Additional CSS class(es) on the Group around a form.
 */

body .gform_wrapper.gravity-theme {
	--pmf-green: var(--wp--preset--color--primary, #004b2a);
	--pmf-ink: #1f2a22;
	--pmf-muted: #5b6b5f;
	--pmf-line: #dfe5df;
	--pmf-field: #c5cfc7;
	--pmf-tint: #f5f9f5;
	--pmf-error: #b3261e;
	color: var(--pmf-ink);
}

body .gform_wrapper.gravity-theme .gform_fields {
	grid-row-gap: 20px;
	grid-column-gap: 16px;
}

body .gform_wrapper.gravity-theme .gform_required_legend {
	margin: 0 0 16px;
	font-size: 13px;
	color: var(--pmf-muted);
}

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

body .gform_wrapper.gravity-theme .gfield_label {
	margin-bottom: 6px;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.35;
	color: var(--pmf-ink);
}

body .gform_wrapper.gravity-theme .gfield_required {
	color: var(--pmf-error);
}

/* The small label of each part of a Name or Address field ("First", "City")
   sits above its box, where the eye looks before typing, not under it. */
body .gform_wrapper.gravity-theme .ginput_complex > span {
	display: flex;
	flex-direction: column-reverse;
	justify-content: flex-end;
}

body .gform_wrapper.gravity-theme .ginput_complex label,
body .gform_wrapper.gravity-theme .ginput_complex .gform-field-label--type-sub {
	margin: 0 0 4px;
	padding: 0;
	font-size: 13px;
	font-weight: 500;
	line-height: 1.3;
	color: var(--pmf-muted);
}

body .gform_wrapper.gravity-theme .gfield_description {
	padding-top: 6px;
	font-size: 14px;
	line-height: 1.5;
	color: var(--pmf-muted);
}

/* ---- Text fields, lists, text areas ---------------------------------- */

body .gform_wrapper.gravity-theme input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="image"]):not([type="file"]):not([type="hidden"]):not([type="range"]):not([type="color"]),
body .gform_wrapper.gravity-theme select,
body .gform_wrapper.gravity-theme textarea {
	box-sizing: border-box;
	min-height: 48px;
	margin: 0;
	padding: 11px 14px;
	border: 1px solid var(--pmf-field);
	border-radius: 10px;
	background-color: #fff;
	color: var(--pmf-ink);
	font-family: inherit;
	font-size: 16px;
	line-height: 1.3;
	box-shadow: none;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

body .gform_wrapper.gravity-theme select[multiple] {
	min-height: 0;
}

body .gform_wrapper.gravity-theme textarea {
	min-height: 112px;
	line-height: 1.5;
}

body .gform_wrapper.gravity-theme input::placeholder,
body .gform_wrapper.gravity-theme textarea::placeholder {
	color: #8a968d;
	opacity: 1;
}

body .gform_wrapper.gravity-theme input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="image"]):not([type="file"]):focus,
body .gform_wrapper.gravity-theme select:focus,
body .gform_wrapper.gravity-theme textarea:focus {
	border-color: var(--pmf-green);
	box-shadow: 0 0 0 3px rgba(0, 75, 42, 0.16);
	outline: 2px solid transparent;
}

/* ---- Tick boxes and radio buttons ------------------------------------ */

body .gform_wrapper.gravity-theme input[type="checkbox"],
body .gform_wrapper.gravity-theme input[type="radio"] {
	width: 20px;
	height: 20px;
	margin-top: 1px;
	accent-color: var(--pmf-green);
	cursor: pointer;
}

body .gform_wrapper.gravity-theme .gchoice label,
body .gform_wrapper.gravity-theme .ginput_container_consent label {
	font-size: 16px;
	line-height: 1.4;
	cursor: pointer;
}

body .gform_wrapper.gravity-theme .gfield_checkbox .gchoice,
body .gform_wrapper.gravity-theme .gfield_radio .gchoice {
	margin-bottom: 8px;
}

body .gform_wrapper.gravity-theme .ginput_container_consent label {
	font-weight: 600;
}

/* The policy text under a consent box. Current Gravity Forms puts the text in
   an inner box of its own; older markup has only the outer one. */
body .gform_wrapper.gravity-theme .gfield_consent_description,
body .gform_wrapper.gravity-theme .gfield_consent_description_text {
	max-height: 220px;
	margin-top: 10px;
	padding: 12px 14px;
	border: 1px solid var(--pmf-line);
	border-radius: 10px;
	background: var(--pmf-tint);
	font-size: 14px;
	line-height: 1.55;
	color: var(--pmf-ink);
	overflow-y: auto;
}

body .gform_wrapper.gravity-theme .gfield_consent_description:has(> .gfield_consent_description_text) {
	max-height: none;
	padding: 0;
	border: 0;
	background: none;
	overflow: visible;
}

body .gform_wrapper.gravity-theme .gfield_consent_description > .gfield_consent_description_text {
	margin-top: 0;
}

/* ---- Section breaks --------------------------------------------------- */

body .gform_wrapper.gravity-theme .gsection {
	margin: 4px 0 0;
	padding: 8px 0 0;
	border: 0;
	border-top: 1px solid var(--pmf-line);
}

body .gform_wrapper.gravity-theme .gsection .gsection_title {
	margin: 0;
	font-size: 20px;
	font-weight: 700;
	line-height: 1.25;
	color: var(--pmf-green);
}

/* A section with no title is only a dividing line. */
body .gform_wrapper.gravity-theme .gsection .gsection_title:empty {
	display: none;
}

/* ---- Prices and the total --------------------------------------------- */

body .gform_wrapper.gravity-theme .ginput_product_price,
body .gform_wrapper.gravity-theme .ginput_shipping_price {
	color: var(--pmf-ink);
	font-weight: 600;
}

body .gform_wrapper.gravity-theme .gfield--type-total .ginput_total,
body .gform_wrapper.gravity-theme input.ginput_total {
	min-height: 0;
	padding: 0;
	border: 0;
	background: none;
	box-shadow: none;
	color: var(--pmf-green);
	font-size: 26px;
	font-weight: 700;
}

/* ---- Errors ------------------------------------------------------------ */

body .gform_wrapper.gravity-theme .gfield_error input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]),
body .gform_wrapper.gravity-theme .gfield_error select,
body .gform_wrapper.gravity-theme .gfield_error textarea {
	border-color: var(--pmf-error);
}

body .gform_wrapper.gravity-theme .gfield_validation_message,
body .gform_wrapper.gravity-theme .validation_message {
	margin-top: 6px;
	padding: 8px 12px;
	border-radius: 8px;
	font-size: 14px;
}

body .gform_wrapper.gravity-theme .gform_validation_errors {
	border-radius: 12px;
	box-shadow: none;
}

body .gform_wrapper.gravity-theme .gform_footer,
body .gform_wrapper.gravity-theme .gform_page_footer {
	margin-top: 8px;
	padding: 20px 0 0;
}

/* ---- Phones ------------------------------------------------------------ */

@media (max-width: 640px) {
	body .gform_wrapper.gravity-theme .gform_fields {
		grid-row-gap: 18px;
	}

	/* Half-width boxes set with "medium" would be 150px wide on a phone. */
	body .gform_wrapper.gravity-theme .gfield input.small,
	body .gform_wrapper.gravity-theme .gfield input.medium,
	body .gform_wrapper.gravity-theme .gfield select.small,
	body .gform_wrapper.gravity-theme .gfield select.medium {
		width: 100%;
	}

	/* State and ZIP share a row on a phone: one row fewer to scroll past. */
	body .gform_wrapper.gravity-theme .ginput_container_address .address_state,
	body .gform_wrapper.gravity-theme .ginput_container_address .address_zip {
		flex: 0 0 50%;
		max-width: 50%;
	}
}

/* ---- Layout helpers ----------------------------------------------------- */

#csa-form {
	padding-bottom: clamp(48px, 7vw, 96px);
}

#csa-form .gravity-form-responsive-width,
.pm-form-narrow {
	max-width: 760px;
	margin-left: auto;
	margin-right: auto;
}

@media (min-width: 700px) {
	#csa-form .gform_wrapper.gravity-theme,
	.pm-form-narrow .gform_wrapper.gravity-theme {
		padding: 32px 36px 36px;
		border: 1px solid #dfe5df;
		border-radius: 16px;
		background: #fff;
		box-shadow: 0 1px 2px rgba(16, 32, 20, 0.04), 0 8px 24px rgba(16, 32, 20, 0.05);
	}
}
