/**
 * Public form styles.
 *
 * Every visual value comes from a CSS custom property set on
 * .afft-form[data-campaign], which AssetLoader emits per campaign from the
 * admin's validated theme tokens. Nothing here hardcodes a colour or size
 * an admin is supposed to control (plan §8, FR-022).
 *
 * The fallbacks in var() matter: if a campaign has no tokens, or a token was
 * dropped as invalid, the form must still look finished.
 */

.afft-form {
	--afft-primary: #0b5fff;
	--afft-primary-hover: #0846c4;
	--afft-text: #1a1a1a;
	--afft-background: #ffffff;
	--afft-border: #d5d8dd;
	--afft-error: #c62828;
	--afft-radius: 8px;
	--afft-field-height: 44px;
	--afft-font-size: 16px;
	--afft-max-width: 520px;
	--afft-font-family: inherit;

	box-sizing: border-box;
	width: 100%;
	max-width: var(--afft-max-width);
	margin-inline: auto;
	padding: 1.5rem;
	color: var(--afft-text);
	background: var(--afft-background);
	border: 1px solid var(--afft-border);
	border-radius: var(--afft-radius);
	font-family: var(--afft-font-family);
	font-size: var(--afft-font-size);
	line-height: 1.5;
}

.afft-form *,
.afft-form *::before,
.afft-form *::after {
	box-sizing: inherit;
}

.afft-form__content {
	margin-bottom: 1.25rem;
}

.afft-form__content > *:first-child {
	margin-top: 0;
}

.afft-form__content > *:last-child {
	margin-bottom: 0;
}

/* --- Fields ------------------------------------------------------------ */

.afft-field {
	margin-bottom: 1rem;
}

.afft-field__label {
	display: block;
	margin-bottom: 0.35rem;
	font-weight: 600;
}

.afft-field__input {
	display: block;
	width: 100%;
	min-height: var(--afft-field-height);
	padding: 0.5rem 0.75rem;
	color: inherit;
	font-family: inherit;
	font-size: inherit;
	background: var(--afft-background);
	border: 1px solid var(--afft-border);
	border-radius: var(--afft-radius);
}

.afft-field__input:focus-visible,
.afft-consent__input:focus-visible,
.afft-button:focus-visible,
.afft-link:focus-visible {
	/* Never remove the focus ring — keyboard users need to see where they are. */
	outline: 2px solid var(--afft-primary);
	outline-offset: 2px;
}

.afft-field__input[aria-invalid="true"] {
	border-color: var(--afft-error);
}

/* --- Consent ----------------------------------------------------------- */

.afft-consent {
	display: flex;
	gap: 0.6rem;
	align-items: flex-start;
	cursor: pointer;
}

.afft-consent__input {
	flex: 0 0 auto;
	width: 1.1rem;
	height: 1.1rem;
	margin-top: 0.2rem;
}

.afft-consent__text {
	flex: 1 1 auto;
}

.afft-consent__link {
	color: var(--afft-primary);
}

/* --- Feedback ---------------------------------------------------------- */

.afft-error {
	margin: 0 0 1rem;
	color: var(--afft-error);
	font-size: 0.9em;
}

.afft-error[hidden],
.afft-error--empty:empty {
	display: none;
}

/* --- Buttons ----------------------------------------------------------- */

.afft-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: var(--afft-field-height);
	padding: 0.5rem 1.25rem;
	color: #fff;
	font-family: inherit;
	font-size: inherit;
	font-weight: 600;
	text-decoration: none;
	background: var(--afft-primary);
	border: 1px solid transparent;
	border-radius: var(--afft-radius);
	cursor: pointer;
}

.afft-button:hover,
.afft-button:focus {
	background: var(--afft-primary-hover);
	color: #fff;
}

.afft-button[disabled],
.afft-button[aria-disabled="true"] {
	opacity: 0.65;
	cursor: default;
}

.afft-button--submit {
	width: 100%;
}

/* --- Step two ---------------------------------------------------------- */

.afft-step-two__actions {
	margin: 1.25rem 0;
}

.afft-step-two__back {
	margin-bottom: 0;
}

.afft-link {
	color: var(--afft-primary);
}

/* --- Honeypot ---------------------------------------------------------- */

/*
 * Also concealed inline in Honeypot::render(), deliberately: if this
 * stylesheet fails to load, the trap must still be invisible, or real
 * visitors would see a mystery field and start being rejected for filling it.
 */
.afft-hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px !important;
	height: 1px !important;
	overflow: hidden !important;
}

/* --- RTL --------------------------------------------------------------- */

/*
 * Logical properties above (margin-inline, padding shorthand, flex) handle
 * most of this automatically. Only the honeypot's absolute offset needs a
 * direction-aware correction, since `left` is physical.
 */
[dir="rtl"] .afft-hp {
	left: auto !important;
	right: -9999px !important;
}

/* --- Small screens ----------------------------------------------------- */

@media (max-width: 480px) {
	.afft-form {
		padding: 1rem;
	}
}

/* --- Reduced motion / forced colours ----------------------------------- */

@media (prefers-reduced-motion: reduce) {
	.afft-form * {
		transition: none !important;
		animation: none !important;
	}
}

@media (forced-colors: active) {
	.afft-button {
		border-color: ButtonText;
	}
}

/* Returning-subscriber notice on step two. */
.afft-notice--returning {
	margin: 0 0 1rem;
	padding: 0.75rem 1rem;
	border-radius: 6px;
	border-inline-start: 4px solid #2271b1;
	background: #f0f6fc;
	color: #1d2327;
}
