/**
 * fm-give.css: guided giving flow styling.
 *
 * Design intent: one cohesive card. Our own controls and Stripe's hosted
 * Payment Element are tuned to the SAME radius, border color, input height and
 * type scale (Stripe side via the appearance API in fm-give.js), so the iframe
 * reads as part of the form rather than a foreign box.
 *
 * COLOR CONTRACT
 * --------------
 * Brand (inherited per church from faithmade-styles):
 *   --fm-accent-color, --fm-primary-button-* and --fmborder-radius.
 * Text (NOT inherited, deliberately):
 *   A fixed neutral ink ramp. --fm-muted-color is a SURFACE token on real
 *   installs (Cross Church ships #eee8da, a pale cream), so deriving body or
 *   helper text from it produced 1.22:1 text, including the legal recurring
 *   consent line. Every text token below is fixed and AA-safe on the white
 *   card; only accent, button and radius follow the church palette.
 *
 * Theme defaults live under :where(.fm-give) where BB per-instance CSS must be
 * able to win without !important. Anything the surrounding theme also styles
 * (buttons, inputs, selects) is scoped as `.fm-give .fm-give__x` so a generic
 * theme `button {}` rule cannot strip it.
 *
 * Mobile-first, 16px minimum input text (no iOS zoom), 44px+ tap targets.
 */

.fm-give {
	/* --- Brand, inherited from the church palette when present --- */
	--fm-give-accent: var(--fm-accent-color, #2f6f5e);
	--fm-give-accent-strong: var(--fm-accent-color-hover, #245647);
	--fm-give-btn-bg: var(--fm-primary-button-color, var(--fm-give-accent));
	--fm-give-btn-bg-hover: var(--fm-primary-button-color-hover, var(--fm-give-accent-strong));
	--fm-give-btn-text: var(--fm-primary-button-text-color, #ffffff);

	/* --- Neutral ink ramp (fixed: guaranteed AA on the white card) --- */
	--fm-give-ink: #1f2933;         /* 14.7:1 on #fff: headings, values, legal copy */
	--fm-give-body: #33404e;        /*  10.3:1 on #fff: body copy */
	--fm-give-muted: #52606d;       /*   6.5:1 on #fff: helper + secondary text */
	--fm-give-placeholder: #6b7684; /*   4.6:1 on #fff: placeholders only */

	/* --- Surfaces --- */
	--fm-give-card: #ffffff;
	--fm-give-surface: #f5f7f9;
	--fm-give-border: #d7dde5;
	--fm-give-border-strong: #aab4c0;
	--fm-give-danger: #a4231d;
	--fm-give-danger-surface: #fdeceb;
	--fm-give-danger-border: #f0c3c0;

	/* Accent-derived surfaces. Plain fallbacks first so a browser without
	   color-mix() still gets a valid neutral, never an unset background. */
	--fm-give-accent-soft: #eef2f6;
	--fm-give-accent-ring: rgba(31, 41, 51, 0.16);

	/* --- Shape --- */
	--fm-give-radius: var(--fmborder-radius, 12px);
	--fm-give-radius-lg: 20px;
	--fm-give-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 18px 40px -20px rgba(16, 24, 40, 0.28);
}

@supports (color: color-mix(in srgb, red, blue)) {
	.fm-give {
		--fm-give-accent-soft: color-mix(in srgb, var(--fm-give-accent) 12%, #ffffff);
		--fm-give-accent-ring: color-mix(in srgb, var(--fm-give-accent) 34%, transparent);
	}
}

/* ---------------------------------------------------------------- Card --- */

:where(.fm-give) {
	box-sizing: border-box;
	max-width: 32rem;
	margin: 0 auto;
	padding: 1.5rem 1.25rem;
	background: var(--fm-give-card);
	border: 1px solid var(--fm-give-border);
	border-radius: var(--fm-give-radius-lg);
	box-shadow: var(--fm-give-shadow);
	color: var(--fm-give-body);
	font-size: 16px;
	line-height: 1.5;
	text-align: left;
}

.fm-give *,
.fm-give *::before,
.fm-give *::after {
	box-sizing: border-box;
}

/* Standalone /give route wrapper (replaces the old inline style attribute). */
.fm-give-page {
	box-sizing: border-box;
	min-height: 100vh;
	margin: 0 auto;
	padding: clamp(6.5rem, 16vh, 11rem) 1.25rem 4.5rem;
	background: var(--fm-give-page-bg, #f6f7f9);
}

/* ---------------------------------------------------------------- Intro -- */

.fm-give__intro {
	margin: 0 0 1.5rem;
	text-align: center;
}

.fm-give__heading {
	margin: 0;
	color: var(--fm-give-ink);
	font-size: 1.5rem;
	line-height: 1.25;
	font-weight: 700;
}

.fm-give__subheading {
	margin: 0.375rem 0 0;
	color: var(--fm-give-muted);
	font-size: 0.9375rem;
}

/* ------------------------------------------------------- Step indicator -- */

.fm-give__steps {
	display: flex;
	margin: 0 0 1.75rem;
	padding: 0;
	list-style: none;
}

.fm-give__step {
	position: relative;
	flex: 1 1 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.4375rem;
	min-width: 0;
}

/* Connector rail from the previous dot's centre to this one's. */
.fm-give__step + .fm-give__step::before {
	content: "";
	position: absolute;
	top: 13px;
	right: 50%;
	left: -50%;
	height: 2px;
	background: var(--fm-give-border);
}

.fm-give__step.is-active::before,
.fm-give__step.is-done::before {
	background: var(--fm-give-accent);
}

.fm-give__step-dot {
	position: relative;
	z-index: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	border: 2px solid var(--fm-give-border);
	border-radius: 50%;
	background: var(--fm-give-card);
	color: var(--fm-give-muted);
	font-size: 0.75rem;
	font-weight: 700;
	line-height: 1;
}

.fm-give__step.is-active .fm-give__step-dot,
.fm-give__step.is-done .fm-give__step-dot {
	border-color: var(--fm-give-accent);
	background: var(--fm-give-accent-soft);
	color: var(--fm-give-ink);
}

.fm-give__step.is-active .fm-give__step-dot {
	box-shadow: 0 0 0 4px var(--fm-give-accent-ring);
}

.fm-give__step-label {
	color: var(--fm-give-muted);
	font-size: 0.6875rem;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	text-align: center;
}

.fm-give__step.is-done .fm-give__step-label {
	color: var(--fm-give-body);
}

.fm-give__step.is-active .fm-give__step-label {
	color: var(--fm-give-ink);
	font-weight: 700;
}

/* --------------------------------------------------------------- Panels -- */

.fm-give__panel {
	display: flex;
	flex-direction: column;
	gap: 1.25rem;
}

.fm-give__section {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}

.fm-give__section-title {
	margin: 0;
	color: var(--fm-give-ink);
	font-size: 0.8125rem;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.fm-give__error {
	background: var(--fm-give-danger-surface);
	border: 1px solid var(--fm-give-danger-border);
	border-radius: var(--fm-give-radius);
	padding: 0.8125rem 1rem;
	margin-bottom: 1rem;
	color: var(--fm-give-danger);
	font-size: 0.9375rem;
	font-weight: 500;
}

/* --------------------------------------------------------- Amount chips -- */

.fm-give__chips {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(6rem, 1fr));
	gap: 0.625rem;
}

.fm-give .fm-give__chip {
	appearance: none;
	-webkit-appearance: none;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	margin: 0;
	border: 1px solid var(--fm-give-border);
	background: var(--fm-give-card);
	color: var(--fm-give-ink);
	border-radius: var(--fm-give-radius);
	padding: 0.875rem 0.75rem;
	font-family: inherit;
	font-size: 1.0625rem;
	font-weight: 700;
	line-height: 1.2;
	letter-spacing: 0;
	text-transform: none;
	cursor: pointer;
	min-height: 56px;
	box-shadow: none;
	transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.fm-give .fm-give__chip:hover {
	border-color: var(--fm-give-border-strong);
	background: var(--fm-give-surface);
}

.fm-give .fm-give__chip.is-selected {
	border-color: var(--fm-give-accent);
	background: var(--fm-give-accent-soft);
	box-shadow: inset 0 0 0 1px var(--fm-give-accent);
}

.fm-give .fm-give__chip--custom {
	grid-column: 1 / -1;
	font-size: 1rem;
	font-weight: 600;
	color: var(--fm-give-body);
	min-height: 50px;
}

/* --------------------------------------------------------------- Fields -- */

.fm-give__field {
	display: flex;
	flex-direction: column;
	gap: 0.4375rem;
}

.fm-give__label {
	color: var(--fm-give-ink);
	font-size: 0.875rem;
	font-weight: 600;
}

/* Required / optional is stated in words, never by color alone. */
.fm-give__label-hint {
	margin-left: 0.25rem;
	color: var(--fm-give-muted);
	font-size: 0.8125rem;
	font-weight: 500;
}

.fm-give__custom {
	display: flex;
	flex-direction: row;
	align-items: center;
	gap: 0;
	border: 1px solid var(--fm-give-border);
	border-radius: var(--fm-give-radius);
	background: var(--fm-give-card);
	padding: 0 1rem;
}

.fm-give__custom:focus-within {
	border-color: var(--fm-give-accent);
	box-shadow: 0 0 0 4px var(--fm-give-accent-ring);
}

.fm-give__prefix {
	color: var(--fm-give-ink);
	font-size: 1.375rem;
	font-weight: 700;
	line-height: 1;
}

/* Below-minimum "Other amount" inline notice — matches .fm-give__error tone but
   sits inline with the field instead of the top-of-form banner. */
.fm-give__custom-hint {
	margin-top: 0.4375rem;
	color: var(--fm-give-danger);
	font-size: 0.8125rem;
	font-weight: 500;
}

.fm-give .fm-give__custom-input {
	flex: 1 1 auto;
	width: 100%;
	min-height: 56px;
	margin: 0;
	border: 0;
	outline: 0;
	background: transparent;
	box-shadow: none;
	color: var(--fm-give-ink);
	font-family: inherit;
	font-size: 1.375rem;
	font-weight: 700;
	padding: 0.75rem 0.5rem;
}

.fm-give .fm-give__input,
.fm-give .fm-give__select {
	width: 100%;
	margin: 0;
	border: 1px solid var(--fm-give-border);
	border-radius: var(--fm-give-radius);
	background: var(--fm-give-card);
	box-shadow: none;
	color: var(--fm-give-ink);
	font-family: inherit;
	font-size: 1rem;
	line-height: 1.4;
	padding: 0.8125rem 1rem;
	min-height: 52px;
}

.fm-give .fm-give__input:hover,
.fm-give .fm-give__select:hover {
	border-color: var(--fm-give-border-strong);
}

.fm-give .fm-give__input:focus,
.fm-give .fm-give__select:focus {
	border-color: var(--fm-give-accent);
	box-shadow: 0 0 0 4px var(--fm-give-accent-ring);
}

.fm-give .fm-give__input::placeholder {
	color: var(--fm-give-placeholder);
	opacity: 1;
}

.fm-give .fm-give__select {
	appearance: none;
	-webkit-appearance: none;
	padding-right: 2.75rem;
	background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath fill='none' stroke='%2352606d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M1 1l6 6 6-6'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 1rem center;
	background-size: 14px 9px;
}

.fm-give .fm-give__note {
	min-height: 88px;
	resize: vertical;
	line-height: 1.5;
}

.fm-give__row {
	display: grid;
	grid-template-columns: 1fr;
	gap: 0.75rem;
}

/* ------------------------------------------------------- Cover the fees -- */

.fm-give__cover {
	display: flex;
	align-items: flex-start;
	gap: 0.75rem;
	background: var(--fm-give-surface);
	border: 1px solid var(--fm-give-border);
	border-radius: var(--fm-give-radius);
	padding: 0.875rem 1rem;
	cursor: pointer;
}

.fm-give__cover:hover {
	border-color: var(--fm-give-border-strong);
}

.fm-give .fm-give__cover input[type="checkbox"],
.fm-give .fm-give__consent-cb {
	width: 20px;
	height: 20px;
	margin: 1px 0 0;
	flex: 0 0 auto;
	accent-color: var(--fm-give-accent);
	cursor: pointer;
}

.fm-give__cover-line {
	color: var(--fm-give-body);
	font-size: 0.9375rem;
}

/* ---------------------------------------------------------- Frequencies -- */

.fm-give__freqs {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.fm-give .fm-give__freq {
	position: relative;
	appearance: none;
	-webkit-appearance: none;
	margin: 0;
	border: 1px solid var(--fm-give-border);
	background: var(--fm-give-card);
	color: var(--fm-give-body);
	border-radius: 999px;
	padding: 0.625rem 1.25rem;
	font-family: inherit;
	font-size: 0.9375rem;
	font-weight: 600;
	letter-spacing: 0;
	text-transform: none;
	line-height: 1.2;
	cursor: pointer;
	min-height: 46px;
	box-shadow: none;
	transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.fm-give .fm-give__freq:hover {
	border-color: var(--fm-give-border-strong);
	background: var(--fm-give-surface);
}

.fm-give .fm-give__freq.is-selected {
	border-color: var(--fm-give-accent);
	background: var(--fm-give-accent-soft);
	color: var(--fm-give-ink);
	box-shadow: inset 0 0 0 1px var(--fm-give-accent);
}

.fm-give .fm-give__freq.is-coming-soon {
	color: var(--fm-give-muted);
	background: var(--fm-give-surface);
	cursor: not-allowed;
}

.fm-give__soon {
	display: inline-block;
	margin-left: 0.4rem;
	padding: 0.15rem 0.4rem;
	border-radius: 4px;
	background: var(--fm-give-ink);
	color: #ffffff;
	font-size: 0.625rem;
	font-weight: 700;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	vertical-align: middle;
}

/* -------------------------------------------------------- Gift summary --- */

.fm-give__summary {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	border: 1px solid var(--fm-give-accent);
	border-radius: var(--fm-give-radius);
	background: var(--fm-give-accent-soft);
	padding: 0.875rem 1.125rem;
}

.fm-give__summary-label {
	color: var(--fm-give-body);
	font-size: 0.8125rem;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.fm-give__summary-value {
	display: flex;
	align-items: baseline;
	gap: 0.5rem;
}

.fm-give__summary-amount {
	color: var(--fm-give-ink);
	font-size: 1.5rem;
	font-weight: 700;
	line-height: 1.1;
}

.fm-give__summary-freq {
	color: var(--fm-give-body);
	font-size: 0.875rem;
	font-weight: 600;
}

/* ------------------------------------------------ Stripe Payment Element -- */

.fm-give__payment-element {
	min-height: 40px;
}

.fm-give__dev-note,
.fm-give__notice {
	border-radius: var(--fm-give-radius);
	padding: 0.8125rem 1rem;
	font-size: 0.875rem;
}

.fm-give__dev-note {
	background: #fff8e1;
	border: 1px solid #e2c86a;
	color: #5c4d00;
}

.fm-give__notice {
	background: var(--fm-give-surface);
	border: 1px solid var(--fm-give-border);
	color: var(--fm-give-body);
}

/* Honeypot: visually hidden but present in DOM for bots. */
.fm-give__honeypot {
	position: absolute !important;
	left: -9999px !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* ----------------------------------------------------- Recurring consent -- */

/*
 * LEGAL COPY. This states amount, period, start date and cancel-any-time, so it
 * is rendered at body weight in the darkest ink on a bordered surface, never
 * as de-emphasised helper text.
 */
.fm-give__consent {
	display: flex;
	align-items: flex-start;
	gap: 0.75rem;
	margin: 0;
	border: 1px solid var(--fm-give-border);
	border-radius: var(--fm-give-radius);
	background: var(--fm-give-surface);
	padding: 0.875rem 1rem;
	cursor: pointer;
	color: var(--fm-give-ink);
	font-size: 0.9375rem;
	line-height: 1.5;
}

.fm-give__consent:hover {
	border-color: var(--fm-give-border-strong);
}

.fm-give__consent-line {
	flex: 1 1 auto;
	color: var(--fm-give-ink);
}

/* ------------------------------------------------------------ Turnstile -- */

.fm-give__turnstile {
	min-height: 65px;
}

/* ------------------------------------------------------- Nav and submit -- */

.fm-give__nav {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	margin-top: 0.25rem;
}

.fm-give .fm-give__back {
	appearance: none;
	flex: 0 0 auto;
	margin: 0;
	background: transparent;
	border: 1px solid transparent;
	border-radius: var(--fm-give-radius);
	color: var(--fm-give-muted);
	font-family: inherit;
	font-size: 1rem;
	font-weight: 600;
	letter-spacing: 0;
	text-transform: none;
	cursor: pointer;
	min-height: 52px;
	padding: 0.75rem 1rem;
	box-shadow: none;
	transition: color 0.15s ease, border-color 0.15s ease;
}

.fm-give .fm-give__back:hover {
	color: var(--fm-give-ink);
	border-color: var(--fm-give-border);
}

.fm-give .fm-give__submit {
	flex: 1 1 auto;
	appearance: none;
	margin: 0;
	border: 0;
	background: var(--fm-give-btn-bg);
	color: var(--fm-give-btn-text);
	border-radius: var(--fm-give-radius);
	padding: 1rem 1.5rem;
	font-family: inherit;
	font-size: 1.0625rem;
	font-weight: 700;
	line-height: 1.2;
	letter-spacing: 0;
	text-transform: none;
	cursor: pointer;
	min-height: 56px;
	box-shadow: none;
	transition: background-color 0.15s ease, opacity 0.15s ease;
}

.fm-give .fm-give__submit:hover {
	background: var(--fm-give-btn-bg-hover);
	color: var(--fm-give-btn-text);
}

.fm-give .fm-give__submit.is-disabled,
.fm-give .fm-give__submit:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

.fm-give .fm-give__submit.is-busy {
	opacity: 0.7;
	cursor: wait;
}

/* --------------------------------------------------------- Focus states -- */

/*
 * Ink-colored ring rather than the accent: a church accent can be very pale
 * (Cross Church ships #efc47c at 1.63:1 on white), which would leave the focus
 * indicator invisible. Ink is 14.7:1 on every surface used here.
 */
.fm-give button:focus-visible,
.fm-give input:focus-visible,
.fm-give select:focus-visible,
.fm-give textarea:focus-visible,
.fm-give label:focus-within {
	outline: 2px solid var(--fm-give-ink);
	outline-offset: 2px;
}

.fm-give .fm-give__custom-input:focus-visible {
	outline: none;
}

/* ----------------------------------------------------------- Completion -- */

.fm-give__complete {
	align-items: center;
	text-align: center;
	padding: 1.5rem 0 0.5rem;
	gap: 1rem;
}

.fm-give__check {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 64px;
	height: 64px;
	border: 2px solid var(--fm-give-accent);
	border-radius: 50%;
	background: var(--fm-give-accent-soft);
	color: var(--fm-give-ink);
	font-size: 1.875rem;
	line-height: 1;
}

.fm-give__thanks {
	margin: 0;
	color: var(--fm-give-ink);
	font-size: 1.5rem;
	font-weight: 700;
}

.fm-give__status {
	margin: 0;
	color: var(--fm-give-body);
	font-size: 0.9375rem;
}

/* ------------------------------------------------------------ Responsive -- */

@media (min-width: 26em) {
	.fm-give__row {
		grid-template-columns: 1fr 1fr;
	}
}

@media (min-width: 30em) {
	:where(.fm-give) {
		padding: 2rem;
	}

	.fm-give__heading {
		font-size: 1.75rem;
	}
}
