/**
 * Gravity Forms sign-up form.
 *
 * Reproduces the supplied mockup: bold near-black labels, borderless cream inputs, custom
 * square checkboxes and a solid purple submit button. Brand purple is the same var(--narthex-primary, #8a034f) used by
 * the footer, the three-step block and the supplied SVG icons.
 *
 * Scope: every rule is prefixed with :is(#top, body) and the .narthex-gform class that
 * Narthex_Gform_Style adds to the <form> tag of the forms listed in the settings.
 *
 * Why the :is(#top, body) prefix rather than a plain class:
 * Enfold styles form controls through ID-prefixed selectors (#top input[type="text"],
 * #top .main_color label, ...). A class-only selector loses to those no matter how late the
 * stylesheet loads. :is() takes the specificity of its most specific argument, so the prefix
 * buys the ID weight needed to win, while the `body` branch keeps the same rules working on a
 * theme that has no #top wrapper. This is what avoids an !important on every declaration.
 */

:is(#top, body) .narthex-gform {
	--narthex-field-height: 3rem;
	--narthex-muted: #6b6b6b;
	--narthex-error: #b32d2e;
	--narthex-box-border: #cfcfcf;

	/*
	 * Gravity Forms 2.7+ ships the "orbital" theme, which drives its own controls from these
	 * custom properties. Setting them here means the built-in theme lands on the brand palette
	 * on its own, and the explicit rules below are the belt-and-braces for older markup
	 * (legacy and the 2.5 "gravity-theme"). A property name this version does not know is
	 * simply ignored, so listing them is safe across GF versions.
	 */
	--gf-color-primary: var(--narthex-primary, var(--narthex-primary, #8a034f));
	--gf-ctrl-bg-color: var(--narthex-field-bg, #fbf3e2);
	--gf-ctrl-bg-color-focus: var(--narthex-field-bg, #fbf3e2);
	--gf-ctrl-border-color: transparent;
	--gf-ctrl-border-color-focus: var(--narthex-primary, var(--narthex-primary, #8a034f));
	--gf-ctrl-color: var(--narthex-ink, #1d1d1b);
	--gf-ctrl-radius: 0;
	--gf-ctrl-label-color-primary: var(--narthex-ink, #1d1d1b);
	--gf-ctrl-label-font-weight-primary: 700;
	--gf-ctrl-btn-bg-color-primary: var(--narthex-primary, var(--narthex-primary, #8a034f));
	--gf-ctrl-btn-border-color-primary: var(--narthex-primary, var(--narthex-primary, #8a034f));
	--gf-ctrl-btn-color-primary: #fff;
	--gf-ctrl-btn-radius: 0;
	--gf-form-gap-y: 1.5rem;
}

/* ------------------------------------------------------------------ Layout. */

/*
 * Row gap only. The 12-column grid Gravity Forms 2.5+ builds is left alone, so a form that
 * puts two fields side by side keeps doing that.
 */
:is(#top, body) .narthex-gform .gform_fields {
	row-gap: 1.5rem;
}

:is(#top, body) .narthex-gform .gfield {
	margin: 0;
	padding: 0;
}

/* Legacy markup has no grid; space the list items instead. */
:is(#top, body) .narthex-gform .gform_legacy_markup_wrapper .gfield,
:is(#top, body) .gform_legacy_markup_wrapper .narthex-gform .gfield {
	margin-bottom: 1.5rem;
}

/*
 * The mockup carries its own "* Renseignements" note under the last field, so the automatic
 * "«*» indicates required fields" legend Gravity Forms prints above the form would be a
 * duplicate. Delete this rule if the legend is wanted back.
 */
:is(#top, body) .narthex-gform .gform_required_legend {
	display: none;
}

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

:is(#top, body) .narthex-gform .gfield_label,
:is(#top, body) .narthex-gform .gfield_label_before_complex,
:is(#top, body) .narthex-gform legend.gfield_label {
	display: block;
	margin: 0 0 0.5rem;
	color: var(--narthex-ink, #1d1d1b);
	font-size: 1rem;
	font-weight: 700;
	line-height: 1.35;
	letter-spacing: 0;
	text-transform: none;
}

/* The asterisk is part of the label in the mockup, not a red marker. */
:is(#top, body) .narthex-gform .gfield_required,
:is(#top, body) .narthex-gform .gfield_required .gfield_required_asterisk {
	margin-left: 0.15rem;
	color: inherit;
	font-weight: inherit;
	text-decoration: none;
}

:is(#top, body) .narthex-gform .gfield_description,
:is(#top, body) .narthex-gform .ginput_complex label {
	padding: 0.35rem 0 0;
	color: var(--narthex-muted);
	font-size: 0.85rem;
	font-weight: 400;
	line-height: 1.45;
}

/* ------------------------------------------------------------------ Text controls. */

:is(#top, body) .narthex-gform .gfield input[type="text"],
:is(#top, body) .narthex-gform .gfield input[type="email"],
:is(#top, body) .narthex-gform .gfield input[type="tel"],
:is(#top, body) .narthex-gform .gfield input[type="url"],
:is(#top, body) .narthex-gform .gfield input[type="number"],
:is(#top, body) .narthex-gform .gfield input[type="password"],
:is(#top, body) .narthex-gform .gfield input[type="date"],
:is(#top, body) .narthex-gform .gfield input[type="search"],
:is(#top, body) .narthex-gform .gfield select,
:is(#top, body) .narthex-gform .gfield textarea {
	box-sizing: border-box;
	width: 100%;
	max-width: 100%;
	height: var(--narthex-field-height);
	margin: 0;
	padding: 0 1rem;
	border: 0;
	border-radius: 0;
	background-color: var(--narthex-field-bg, #fbf3e2);
	background-image: none;
	box-shadow: none;
	color: var(--narthex-ink, #1d1d1b);
	/* 1rem = 16px keeps iOS Safari from zooming in on focus. */
	font-size: 1rem;
	line-height: var(--narthex-field-height);
	font-family: inherit;
}

:is(#top, body) .narthex-gform .gfield textarea {
	height: auto;
	min-height: 8rem;
	padding: 0.85rem 1rem;
	line-height: 1.5;
	resize: vertical;
}

/* Native arrow needs the vertical padding back, and line-height confuses select boxes. */
:is(#top, body) .narthex-gform .gfield select {
	padding: 0 0.75rem;
	line-height: normal;
}

:is(#top, body) .narthex-gform .gfield input::placeholder,
:is(#top, body) .narthex-gform .gfield textarea::placeholder {
	color: #a3968a;
	opacity: 1;
}

/*
 * The fields have no border, so a visible focus ring is the only affordance a keyboard user
 * gets. Never remove this without replacing it with something equally visible.
 */
:is(#top, body) .narthex-gform .gfield input:focus,
:is(#top, body) .narthex-gform .gfield select:focus,
:is(#top, body) .narthex-gform .gfield textarea:focus {
	outline: 2px solid var(--narthex-primary, var(--narthex-primary, #8a034f));
	outline-offset: 2px;
	background-color: var(--narthex-field-bg, #fbf3e2);
	box-shadow: none;
}

/* Chrome's autofill repaints the field white; this keeps the cream. */
:is(#top, body) .narthex-gform .gfield input:-webkit-autofill,
:is(#top, body) .narthex-gform .gfield input:-webkit-autofill:focus {
	-webkit-text-fill-color: var(--narthex-ink, #1d1d1b);
	box-shadow: inset 0 0 0 100px var(--narthex-field-bg, #fbf3e2);
}

/* ------------------------------------------------------------------ Checkboxes and radios. */

:is(#top, body) .narthex-gform .gfield .gchoice,
:is(#top, body) .narthex-gform .gfield_checkbox li,
:is(#top, body) .narthex-gform .gfield_radio li {
	display: flex;
	align-items: flex-start;
	gap: 0.65rem;
	margin: 0 0 0.6rem;
	padding: 0;
	list-style: none;
}

:is(#top, body) .narthex-gform .gfield .gchoice:last-child,
:is(#top, body) .narthex-gform .gfield_checkbox li:last-child,
:is(#top, body) .narthex-gform .gfield_radio li:last-child {
	margin-bottom: 0;
}

:is(#top, body) .narthex-gform .gfield input[type="checkbox"],
:is(#top, body) .narthex-gform .gfield input[type="radio"] {
	appearance: none;
	-webkit-appearance: none;
	position: relative;
	flex: 0 0 auto;
	width: 1.05rem;
	height: 1.05rem;
	/* Nudged down so the box sits on the first line of a wrapping label. */
	margin: 0.15rem 0 0;
	padding: 0;
	border: 1px solid var(--narthex-box-border);
	border-radius: 2px;
	background: #f4f4f4;
	box-shadow: none;
	cursor: pointer;
}

:is(#top, body) .narthex-gform .gfield input[type="radio"] {
	border-radius: 50%;
}

:is(#top, body) .narthex-gform .gfield input[type="checkbox"]:checked,
:is(#top, body) .narthex-gform .gfield input[type="radio"]:checked {
	border-color: var(--narthex-primary, var(--narthex-primary, #8a034f));
	background: var(--narthex-primary, var(--narthex-primary, #8a034f));
}

/* Tick drawn from two borders rather than an image: no extra HTTP request, scales with the box. */
:is(#top, body) .narthex-gform .gfield input[type="checkbox"]:checked::after {
	content: "";
	position: absolute;
	top: 45%;
	left: 50%;
	width: 0.3rem;
	height: 0.55rem;
	border: solid #fff;
	border-width: 0 2px 2px 0;
	transform: translate(-50%, -55%) rotate(45deg);
}

:is(#top, body) .narthex-gform .gfield input[type="radio"]:checked::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 0.4rem;
	height: 0.4rem;
	border-radius: 50%;
	background: #fff;
	transform: translate(-50%, -50%);
}

:is(#top, body) .narthex-gform .gfield input[type="checkbox"]:focus-visible,
:is(#top, body) .narthex-gform .gfield input[type="radio"]:focus-visible {
	outline: 2px solid var(--narthex-primary, var(--narthex-primary, #8a034f));
	outline-offset: 2px;
}

/* Choice labels are body copy, not field labels: normal weight, no bottom margin. */
:is(#top, body) .narthex-gform .gfield .gchoice label,
:is(#top, body) .narthex-gform .gfield_checkbox li label,
:is(#top, body) .narthex-gform .gfield_radio li label {
	margin: 0;
	max-width: none;
	color: var(--narthex-ink, #1d1d1b);
	font-size: 0.95rem;
	font-weight: 400;
	line-height: 1.45;
	cursor: pointer;
}

/*
 * A consent field carries its text on the checkbox's own label rather than inside a .gchoice
 * row, so it needs the same two rules again.
 */
:is(#top, body) .narthex-gform .ginput_container_consent {
	display: flex;
	align-items: flex-start;
	gap: 0.65rem;
}

:is(#top, body) .narthex-gform .ginput_container_consent label {
	margin: 0;
	padding: 0;
	max-width: none;
	color: var(--narthex-ink, #1d1d1b);
	font-size: 0.95rem;
	font-weight: 400;
	line-height: 1.45;
	cursor: pointer;
}

/* ------------------------------------------------------------------ Footer note. */

/*
 * Helper for the "* Renseignements" block under the last field. Put narthex-form-note in the
 * Appearance → Custom CSS Class box of an HTML field, or on a wrapper inside it.
 */
:is(#top, body) .narthex-gform .narthex-form-note {
	margin: 1.5rem 0 0;
	color: var(--narthex-ink, #1d1d1b);
	font-size: 0.9rem;
	line-height: 1.6;
}

:is(#top, body) .narthex-gform .narthex-form-note p {
	margin: 0 0 0.25rem;
}

:is(#top, body) .narthex-gform .narthex-form-note strong,
:is(#top, body) .narthex-gform .narthex-form-note b {
	font-weight: 700;
}

:is(#top, body) .narthex-gform .narthex-form-note em,
:is(#top, body) .narthex-gform .narthex-form-note i {
	color: var(--narthex-muted);
	font-style: italic;
}

/* ------------------------------------------------------------------ Submit button. */

:is(#top, body) .narthex-gform .gform_footer,
:is(#top, body) .narthex-gform .gform_page_footer {
	margin: 1.75rem 0 0;
	padding: 0;
	text-align: left;
}

:is(#top, body) .narthex-gform .gform_footer input[type="submit"],
:is(#top, body) .narthex-gform .gform_footer button,
:is(#top, body) .narthex-gform .gform_page_footer input[type="submit"],
:is(#top, body) .narthex-gform .gform_page_footer button,
:is(#top, body) .narthex-gform .gform_button {
	display: inline-block;
	width: auto;
	margin: 0;
	padding: 1rem 1.9rem;
	border: 0;
	border-radius: 0;
	background: var(--narthex-primary, var(--narthex-primary, #8a034f));
	background-image: none;
	box-shadow: none;
	color: var(--narthex-on-primary, #fff);
	font-size: 0.95rem;
	font-weight: 700;
	letter-spacing: 0.06em;
	line-height: 1;
	text-transform: uppercase;
	text-shadow: none;
	cursor: pointer;
	transition: opacity 0.15s ease;
}

:is(#top, body) .narthex-gform .gform_footer input[type="submit"]:hover,
:is(#top, body) .narthex-gform .gform_footer input[type="submit"]:focus,
:is(#top, body) .narthex-gform .gform_page_footer input[type="submit"]:hover,
:is(#top, body) .narthex-gform .gform_page_footer input[type="submit"]:focus,
:is(#top, body) .narthex-gform .gform_button:hover,
:is(#top, body) .narthex-gform .gform_button:focus {
	background: var(--narthex-primary, var(--narthex-primary, #8a034f));
	color: var(--narthex-on-primary, #fff);
	opacity: 0.88;
}

:is(#top, body) .narthex-gform .gform_footer input[type="submit"]:focus-visible,
:is(#top, body) .narthex-gform .gform_page_footer input[type="submit"]:focus-visible,
:is(#top, body) .narthex-gform .gform_button:focus-visible {
	outline: 2px solid var(--narthex-primary, var(--narthex-primary, #8a034f));
	outline-offset: 3px;
}

/* The multi-page "Précédent" button reads as the secondary action. */
:is(#top, body) .narthex-gform .gform_page_footer .gform_previous_button {
	background: transparent;
	color: var(--narthex-primary, var(--narthex-primary, #8a034f));
	box-shadow: inset 0 0 0 2px var(--narthex-primary, var(--narthex-primary, #8a034f));
}

/* Ajax spinner sits beside the button rather than pushing the layout. */
:is(#top, body) .narthex-gform .gform_ajax_spinner {
	margin-left: 0.75rem;
	vertical-align: middle;
}

/* ------------------------------------------------------------------ Validation. */

:is(#top, body) .narthex-gform .gform_validation_errors,
:is(#top, body) .narthex-gform .validation_error {
	margin: 0 0 1.5rem;
	padding: 0.85rem 1rem;
	border: 0;
	border-left: 4px solid var(--narthex-error);
	border-radius: 0;
	background: rgba(179, 45, 46, 0.07);
	color: var(--narthex-error);
	font-size: 0.95rem;
	font-weight: 400;
	text-align: left;
}

:is(#top, body) .narthex-gform .gfield_error .gfield_label {
	color: var(--narthex-ink, #1d1d1b);
}

/*
 * Errors are marked with an inset ring rather than a border, so the field keeps the exact
 * height of a valid one and the form does not shift when validation fails.
 */
:is(#top, body) .narthex-gform .gfield_error input,
:is(#top, body) .narthex-gform .gfield_error select,
:is(#top, body) .narthex-gform .gfield_error textarea {
	box-shadow: inset 0 0 0 2px var(--narthex-error);
}

:is(#top, body) .narthex-gform .gfield_error input[type="checkbox"],
:is(#top, body) .narthex-gform .gfield_error input[type="radio"] {
	border-color: var(--narthex-error);
	box-shadow: none;
}

:is(#top, body) .narthex-gform .gfield_validation_message,
:is(#top, body) .narthex-gform .validation_message {
	margin: 0.4rem 0 0;
	padding: 0;
	border: 0;
	background: none;
	color: var(--narthex-error);
	font-size: 0.85rem;
	font-weight: 400;
}

/* Confirmation shown in place of the form after a successful submit. */
:is(#top, body) .gform_confirmation_message {
	padding: 1rem 1.25rem;
	border-left: 4px solid #1d7a3f;
	background: rgba(29, 122, 63, 0.07);
	color: #1d7a3f;
}

/* ------------------------------------------------------------------ Small screens. */

@media (max-width: 600px) {
	:is(#top, body) .narthex-gform {
		--narthex-field-height: 2.85rem;
	}

	:is(#top, body) .narthex-gform .gform_footer input[type="submit"],
	:is(#top, body) .narthex-gform .gform_page_footer input[type="submit"],
	:is(#top, body) .narthex-gform .gform_button {
		width: 100%;
		text-align: center;
	}
}
