/**
 * COD Cambridge - Serve "Join a Team" page (/serve/join/) and the Serve Interest Form
 *
 * Styles the Fluent Form "Serve Interest Form" (2 steps) so it feels native to the COD site.
 * Presentation only: no markup, logic, fields or Fluent Forms settings are changed here.
 * Loaded only on pages whose Elementor content contains the cod-serve-join marker (see inc/service-page.php).
 *
 * COD design system:
 *   green #154734 · lime #c7ea46 · cream #e5e1da · page #f4f2ed · dark #101512
 *   radius 12px (rows, fields) / pill (buttons) · Gotham (gotham-black)
 *
 * Scoped to .cod-serve-join and written against Fluent Forms' stable class names (not form IDs or
 * generated element IDs). The Elementor kit styles every <button>, so button rules are prefixed
 * with "html" and mark background / colour / radius as !important.
 *
 * Selected state is never colour-only: a selected row gets a filled box with a tick (checkbox) or
 * a filled dot (radio), a heavier border and a lime edge bar.
 */

.cod-serve-join form.frm-fluent-form {
	--cod-sf-green: #154734;
	--cod-sf-lime: #c7ea46;
	--cod-sf-lime-hover: #b6da38;
	--cod-sf-cream: #e5e1da;
	--cod-sf-dark: #101512;
	--cod-sf-muted: rgba(16, 21, 18, 0.72);
	--cod-sf-line: rgba(21, 71, 52, 0.32);
	--cod-sf-error: #b3261e;
	font-family: gotham-black, sans-serif;
	color: var(--cod-sf-dark);
}

/* ---------- Links on the page (back link, privacy link): always show keyboard focus ---------- */

html .cod-serve-join a:focus-visible {
	outline: 2px solid #154734;
	outline-offset: 4px;
	border-radius: 2px;
}

/* ---------- Progress ---------- */

.cod-serve-join .ff-step-header {
	margin: 0 0 32px;
}

.cod-serve-join .ff-el-progress-status {
	margin: 0 0 12px;
	color: var(--cod-sf-green);
	font-size: 14px;
	font-weight: 700;
	letter-spacing: 0.04em;
	line-height: 1.4;
}

.cod-serve-join .ff-el-progress {
	height: 4px;
	background: var(--cod-sf-cream);
	border-radius: 999px;
	overflow: hidden;
	box-shadow: none;
}

.cod-serve-join .ff-el-progress-bar {
	height: 4px;
	background: var(--cod-sf-green);
	border-radius: 999px;
	box-shadow: none;
}

/* the % text inside the bar is redundant next to "Step 1 of 2" */
.cod-serve-join .ff-el-progress-bar span {
	display: none;
}

/* ---------- Step headings (custom HTML fields) ---------- */

.cod-serve-join .cod-serve-form__heading {
	margin: 0 0 12px;
	color: var(--cod-sf-green);
	font-family: gotham-black, sans-serif;
	font-size: 32px;
	font-weight: 700;
	line-height: 1.1;
	letter-spacing: -0.8px;
}

.cod-serve-join .cod-serve-form__helper {
	margin: 0 0 28px;
	color: var(--cod-sf-muted);
	font-size: 16px;
	line-height: 1.6;
}

/* ---------- Groups, labels, help ---------- */

.cod-serve-join .ff-el-group {
	margin-bottom: 26px;
}

.cod-serve-join .ff-el-input--label {
	margin-bottom: 8px;
}

.cod-serve-join .ff-el-input--label label {
	color: var(--cod-sf-dark);
	font-size: 15px;
	font-weight: 700;
	line-height: 1.4;
}

.cod-serve-join .ff-el-input--label.ff-el-is-required.asterisk-right label::after {
	color: var(--cod-sf-green);
}

/* The team group is introduced by the step heading; keep its label for screen readers. */
.cod-serve-join .ff-el-group:has(input[name="teams[]"]) > .ff-el-input--label {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

.cod-serve-join .ff-el-help-message {
	margin-top: 6px;
	color: var(--cod-sf-muted);
	font-style: normal;
	font-size: 14px;
	line-height: 1.5;
}

/* ---------- Text inputs, textarea ---------- */

.cod-serve-join .ff-el-form-control {
	box-sizing: border-box;
	width: 100%;
	min-height: 52px;
	padding: 12px 16px;
	background: #ffffff;
	color: var(--cod-sf-dark);
	border: 1px solid var(--cod-sf-line);
	border-radius: 12px;
	box-shadow: none;
	outline: 2px solid transparent; /* keeps a visible focus ring in forced-colours mode */
	font-family: gotham-black, sans-serif;
	font-size: 16px; /* 16px stops iOS zooming into the field */
	line-height: 1.4;
	transition: border-color 0.15s ease;
}

.cod-serve-join textarea.ff-el-form-control {
	min-height: 140px;
	resize: vertical;
}

.cod-serve-join .ff-el-form-control:hover {
	border-color: var(--cod-sf-green);
}

/* focus: one 2px deep-green edge (1px border + 1px inner line), nothing stacked outside it */
.cod-serve-join .ff-el-form-control:focus,
.cod-serve-join .ff-el-form-control:focus-visible {
	border-color: var(--cod-sf-green);
	box-shadow: inset 0 0 0 1px var(--cod-sf-green);
	outline: 2px solid transparent;
}

/* Phone field (intl-tel-input) */
.cod-serve-join .iti {
	display: block;
	width: 100%;
}

/* ---------- Selectable rows: team checkboxes + relationship radios ---------- */

.cod-serve-join .ff-el-input--content > .ff-el-form-check {
	margin: 0 0 10px;
}

.cod-serve-join .ff-el-form-check:not(.ff-el-tc) .ff-el-form-check-label {
	position: relative;
	display: flex;
	align-items: center;
	gap: 14px;
	box-sizing: border-box;
	width: 100%;
	min-height: 56px;
	margin: 0;
	padding: 14px 18px 14px 20px;
	background: #ffffff;
	color: var(--cod-sf-dark);
	border: 1px solid var(--cod-sf-line);
	border-radius: 12px;
	font-size: 17px;
	font-weight: 500;
	line-height: 1.35;
	cursor: pointer;
	transition: border-color 0.15s ease, background-color 0.15s ease;
}

.cod-serve-join .ff-el-form-check:not(.ff-el-tc) .ff-el-form-check-label:hover {
	border-color: var(--cod-sf-green);
}

/* the real input stays in the layout, so keyboard and screen-reader behaviour is native */
.cod-serve-join .ff-el-form-check:not(.ff-el-tc) .ff-el-form-check-input {
	position: relative;
	flex: 0 0 24px;
	width: 24px;
	height: 24px;
	margin: 0;
	padding: 0 !important; /* the Elementor kit pads every input; that would inflate the box */
	background: #ffffff;
	border: 1.5px solid var(--cod-sf-green);
	border-radius: 6px;
	box-shadow: none;
	-webkit-appearance: none;
	appearance: none;
	box-sizing: border-box;
	cursor: pointer;
}

.cod-serve-join .ff-el-form-check:not(.ff-el-tc) .ff-el-form-check-radio {
	border-radius: 50%;
}

.cod-serve-join .ff-el-form-check:not(.ff-el-tc) .ff-el-form-check-input:checked {
	background: var(--cod-sf-green);
}

/* tick (checkbox) */
.cod-serve-join .ff-el-form-check:not(.ff-el-tc) .ff-el-form-check-checkbox:checked::after {
	content: "";
	position: absolute;
	left: 50%;
	top: 46%;
	width: 6px;
	height: 12px;
	border: solid #ffffff;
	border-width: 0 2.5px 2.5px 0;
	transform: translate(-50%, -50%) rotate(45deg);
}

/* dot (radio) */
.cod-serve-join .ff-el-form-check:not(.ff-el-tc) .ff-el-form-check-radio:checked::after {
	content: "";
	position: absolute;
	inset: 4px;
	background: #ffffff;
	border-radius: 50%;
}

/* selected row: heavier border, light lime tint and a lime edge bar */
.cod-serve-join .ff-el-form-check:not(.ff-el-tc) .ff-el-form-check-label:has(input:checked) {
	background-color: #f8fbea; /* very pale lime */
	background-image: linear-gradient(var(--cod-sf-lime), var(--cod-sf-lime));
	background-size: 5px 100%;
	background-position: left center;
	background-repeat: no-repeat;
	border-color: var(--cod-sf-green);
	box-shadow: inset 0 0 0 1px var(--cod-sf-green); /* 1px border + 1px inner line = one 2px edge */
	font-weight: 700;
}

/* keyboard focus */
.cod-serve-join .ff-el-form-check:not(.ff-el-tc) .ff-el-form-check-label:has(input:focus-visible) {
	outline: 2px solid var(--cod-sf-green);
	outline-offset: 3px;
}

.cod-serve-join .ff-el-form-check:not(.ff-el-tc) .ff-el-form-check-input:focus-visible {
	outline: 2px solid var(--cod-sf-green);
	outline-offset: 2px;
}

/* where :has() works the row carries the focus ring, so the box does not draw a second one */
@supports selector(:has(*)) {
	.cod-serve-join .ff-el-form-check:not(.ff-el-tc) .ff-el-form-check-input:focus-visible {
		outline: none;
	}
}

/* ---------- Consent ---------- */

/* Fluent Forms lays the consent label out as a table row; switch it to flex so the box and text align */
html .cod-serve-join .ff-el-tc .ff-el-form-check-label,
html .cod-serve-join .ff-el-tc .ff_tc_label {
	display: flex !important;
	align-items: flex-start;
	gap: 14px;
	margin: 0;
	cursor: pointer;
}

html .cod-serve-join .ff-el-tc .ff_tc_checkbox {
	display: block !important;
	flex: 0 0 24px;
	width: 24px;
}

html .cod-serve-join .ff-el-tc .ff_t_c {
	display: block !important;
	flex: 1 1 auto;
}

.cod-serve-join .ff-el-tc .ff-el-form-check-input {
	position: relative;
	width: 24px;
	height: 24px;
	margin: 2px 0 0;
	padding: 0 !important;
	background: #ffffff;
	border: 1.5px solid var(--cod-sf-green);
	border-radius: 6px;
	-webkit-appearance: none;
	appearance: none;
	box-sizing: border-box;
	cursor: pointer;
}

.cod-serve-join .ff-el-tc .ff-el-form-check-input:checked {
	background: var(--cod-sf-green);
}

.cod-serve-join .ff-el-tc .ff-el-form-check-input:checked::after {
	content: "";
	position: absolute;
	left: 50%;
	top: 46%;
	width: 6px;
	height: 12px;
	border: solid #ffffff;
	border-width: 0 2.5px 2.5px 0;
	transform: translate(-50%, -50%) rotate(45deg);
}

.cod-serve-join .ff-el-tc .ff-el-form-check-input:focus-visible {
	outline: 2px solid var(--cod-sf-green);
	outline-offset: 2px;
}

.cod-serve-join .ff_t_c {
	color: var(--cod-sf-dark);
	font-size: 15px;
	line-height: 1.55;
}

html .cod-serve-join .ff_t_c a {
	color: #154734 !important;
	letter-spacing: normal;
	font-weight: 700;
	text-decoration: underline;
	text-underline-offset: 3px;
}

/* ---------- Errors (text + border, never colour alone) ---------- */

.cod-serve-join .ff-el-is-error .ff-el-form-control,
.cod-serve-join .ff-el-is-error .ff-el-form-control:focus {
	border-color: var(--cod-sf-error);
	box-shadow: inset 0 0 0 1px var(--cod-sf-error);
}

.cod-serve-join .ff-el-is-error .ff-el-form-check:not(.ff-el-tc) .ff-el-form-check-label {
	border-color: var(--cod-sf-error);
}

.cod-serve-join .ff-el-is-error .ff-el-form-check:not(.ff-el-tc) .ff-el-form-check-label:has(input:checked) {
	border-color: var(--cod-sf-green);
}

.cod-serve-join .error.text-danger,
.cod-serve-join .ff-el-is-error .text-danger {
	margin-top: 8px;
	color: var(--cod-sf-error);
	font-size: 14px;
	font-weight: 700;
	line-height: 1.4;
}

.cod-serve-join .ff-errors-in-stack,
.cod-serve-join .ff-message-error {
	color: var(--cod-sf-error);
}

/* ---------- Buttons ---------- */

html .cod-serve-join .step-nav {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin: 32px 0 0;
	padding: 0;
}

html .cod-serve-join .ff-btn {
	float: none !important;
	box-sizing: border-box;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 52px;
	margin: 0;
	padding: 0 32px;
	border-radius: 999px !important;
	font-family: gotham-black, sans-serif;
	font-size: 16px;
	font-weight: 700;
	letter-spacing: 0.01em;
	line-height: 1;
	cursor: pointer;
	transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

/* Continue / Take the Next Step: lime fill, green text */
html .cod-serve-join .ff-btn-next,
html .cod-serve-join .ff-btn-submit {
	background: var(--cod-sf-lime, #c7ea46) !important;
	color: #154734 !important;
	border: 1.5px solid #c7ea46 !important;
}

html .cod-serve-join .ff-btn-next:hover,
html .cod-serve-join .ff-btn-submit:hover {
	background: #b6da38 !important;
	border-color: #b6da38 !important;
	color: #154734 !important;
}

/* Back: outline */
html .cod-serve-join .ff-btn-prev {
	background: transparent !important;
	color: #154734 !important;
	border: 1.5px solid #154734 !important;
}

html .cod-serve-join .ff-btn-prev:hover {
	background: rgba(21, 71, 52, 0.08) !important;
	color: #154734 !important;
}

html .cod-serve-join .ff-btn:focus-visible {
	outline: 2px solid #154734;
	outline-offset: 3px;
}

html .cod-serve-join .ff-btn:disabled,
html .cod-serve-join .ff-btn.disabled {
	opacity: 0.6;
	cursor: wait;
}

/* Step 2: Fluent Forms puts Back and the submit button in a table; lay them out as one flex row */
html .cod-serve-join .ff-step-t-container {
	display: flex !important;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin: 32px 0 0;
}

html .cod-serve-join .ff-step-t-container .ff-t-cell {
	display: block !important;
	width: auto !important;
	padding: 0;
}

html .cod-serve-join .ff-step-t-container .step-nav,
html .cod-serve-join .ff-step-t-container .ff-el-group {
	margin: 0;
}

.cod-serve-join .ff_submit_btn_wrapper {
	margin: 0;
	text-align: right;
}

/* ---------- Success message ---------- */

.cod-serve-join .ff-message-success {
	margin: 0;
	padding: 8px 0;
	background: transparent;
	border: 0;
	box-shadow: none;
	color: var(--cod-sf-dark);
	font-size: 17px;
	line-height: 1.6;
}

.cod-serve-join .ff-message-success h2 {
	margin: 0 0 12px;
	color: var(--cod-sf-green);
	font-size: 32px;
	font-weight: 700;
	letter-spacing: -0.8px;
	line-height: 1.1;
}

/* ---------- Tablet ---------- */

@media (max-width: 1024px) {
	.cod-serve-join .cod-serve-form__heading {
		font-size: 28px;
	}
}

/* ---------- Mobile ---------- */

@media (max-width: 767px) {
	.cod-serve-join .cod-serve-form__heading {
		font-size: 26px;
		letter-spacing: -0.6px;
	}

	.cod-serve-join .ff-step-header {
		margin-bottom: 24px;
	}

	.cod-serve-join .ff-el-form-check:not(.ff-el-tc) .ff-el-form-check-label {
		min-height: 56px;
		padding: 14px 14px 14px 16px;
		font-size: 16px;
	}

	html .cod-serve-join .step-nav {
		flex-direction: column-reverse;
		align-items: stretch;
	}

	html .cod-serve-join .ff-btn {
		width: 100%;
	}

	html .cod-serve-join .ff-step-t-container {
		flex-direction: column-reverse;
		align-items: stretch;
	}

	html .cod-serve-join .ff-step-t-container .ff-t-cell {
		width: 100% !important;
	}

	.cod-serve-join .ff_submit_btn_wrapper {
		text-align: center;
	}
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
	.cod-serve-join *,
	.cod-serve-join *::before,
	.cod-serve-join *::after {
		transition: none !important;
		animation: none !important;
		scroll-behavior: auto !important;
	}
}
