/*
 * Shared form styling for MailPoet (subscribe + subscriber pages) and
 * Fluent Forms (contact). Single source of truth in the theme — no styling
 * configured in either plugin's UI, so styles are versioned, env-portable,
 * and Rebecca never has to touch them.
 *
 * Cascade strategy:
 *   - MailPoet inline styles + <input type="submit"> on the subscribe form
 *     are neutralized by the mailpoet_form_widget_post_process filter
 *     (functions.php), which strips inline styles and rewrites submit to
 *     <button>. After that, shared button rules apply cleanly.
 *   - Fluent Forms' wpf_has_custom_css class ships an inline color that
 *     beats plain class rules — bg/color use !important on the shared
 *     button rule.
 *   - MailPoet's public.css forces `font-size:16px !important` and
 *     `line-height:1.4 !important` on all .mailpoet_form .mailpoet_submit
 *     buttons — font-size/line-height use !important on our button rule.
 *   - MailPoet's ID-scoped <style> block (#mailpoet_form_N) is still
 *     present on the subscribe form; we match its specificity with
 *     #rebeccasham-subscribe selectors for anything MailPoet writes there.
 */

/* ---------- Inputs & textareas (shared) ---------- */

input.ff-el-form-control,
textarea.ff-el-form-control,
.mailpoet_text {
	width: 100%;
	box-sizing: border-box;
	min-height: 44px;
	padding: 0.6rem 0.75rem;
	border: 1px solid rgba(38, 33, 28, 0.25);
	border-radius: 6px;
	background: var(--wp--preset--color--white);
	color: var(--wp--preset--color--foreground);
	font-family: var(--wp--preset--font-family--spectral);
	font-size: var(--wp--preset--font-size--base);
	box-shadow: none;
	transition: border-color 120ms ease, box-shadow 120ms ease;
}

textarea.ff-el-form-control {
	min-height: 6rem;
	line-height: 1.5;
}

input.ff-el-form-control::placeholder,
textarea.ff-el-form-control::placeholder,
.mailpoet_text::placeholder {
	font-size: var(--wp--preset--font-size--xs);
	color: var(--wp--preset--color--muted);
	opacity: 0.7;
}

input.ff-el-form-control:focus,
textarea.ff-el-form-control:focus,
.mailpoet_text:focus {
	border-color: var(--wp--preset--color--foreground);
	outline: 2px solid var(--wp--preset--color--foreground);
	outline-offset: 1px;
}

/* ---------- Fluent Forms labels ---------- */

.ff-el-input--label,
.ff-el-input--label.asterisk-right {
	font-family: var(--wp--preset--font-family--spectral);
	color: var(--wp--preset--color--foreground);
}

/* ---------- Submit buttons (shared across all form contexts) ---------- */

.ff-btn.ff-btn-submit,
#rebeccasham-subscribe .mailpoet_submit,
.mailpoet-manage-subscription-actions input.mailpoet_submit,
.mailpoet-manage-subscription-actions .mailpoet_submit,
.mailpoet_page input.mailpoet_submit {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 48px;
	min-width: 44px;
	padding: 0.85rem 2rem;
	background: var(--wp--preset--color--footer-bg) !important;
	color: var(--wp--preset--color--footer-text) !important;
	border: none;
	border-radius: 6px;
	font-family: var(--wp--preset--font-family--playfair-display);
	font-style: italic;
	font-size: var(--wp--preset--font-size--base) !important;
	font-weight: 600;
	line-height: 1 !important;
	cursor: pointer;
	white-space: nowrap;
	box-shadow: none;
	transition: opacity 120ms ease;
}

.ff-btn.ff-btn-submit:hover,
.ff-btn.ff-btn-submit:focus-visible,
#rebeccasham-subscribe .mailpoet_submit:hover,
#rebeccasham-subscribe .mailpoet_submit:focus-visible,
.mailpoet-manage-subscription-actions input.mailpoet_submit:hover,
.mailpoet-manage-subscription-actions input.mailpoet_submit:focus-visible,
.mailpoet-manage-subscription-actions .mailpoet_submit:hover,
.mailpoet-manage-subscription-actions .mailpoet_submit:focus-visible,
.mailpoet_page input.mailpoet_submit:hover,
.mailpoet_page input.mailpoet_submit:focus-visible {
	opacity: 0.85;
}

/* ---------- Email subscribe pattern (section wrapper) ---------- */

/* Slightly darker cream — reads as a distinct section without needing
   border rules that clash with post/page dividers. Bottom margin ensures
   breathing room before whatever follows (Recent Posts on single pages,
   the dark footer on home/About). */
.rebeccasham-email-subscribe {
	padding-block: var(--wp--preset--spacing--70);
	margin-block-end: var(--wp--preset--spacing--60);
	background: #F5DDC5;
}

.rebeccasham-email-subscribe > .wp-block-group {
	max-width: 640px;
	margin-inline: auto;
	padding-inline: var(--wp--preset--spacing--40);
}

.rebeccasham-email-subscribe > .wp-block-group > * + * {
	margin-block-start: var(--wp--preset--spacing--40);
}

/* ---------- MailPoet subscribe pattern — specificity-boosted overrides
   MailPoet's <style> block sets `#mailpoet_form_N .mailpoet_text {
   width: 200px }` and `padding: 20px` on the form at specificity (1,1,0).
   We need (1,2,0) to beat, which chaining a second class provides. */

#rebeccasham-subscribe .mailpoet_form.mailpoet_form_form {
	padding: 0;
}

#rebeccasham-subscribe .mailpoet_form .mailpoet_text {
	width: 100%;
	box-sizing: border-box;
}

#rebeccasham-subscribe .mailpoet_text::placeholder {
	font-size: var(--wp--preset--font-size--xs);
	color: var(--wp--preset--color--muted);
	opacity: 0.7;
}

#rebeccasham-subscribe .mailpoet_validate_success,
#rebeccasham-subscribe .mailpoet_validate_error {
	font-family: var(--wp--preset--font-family--spectral);
	font-size: var(--wp--preset--font-size--sm);
	margin-block-start: var(--wp--preset--spacing--40);
}
