/*!
 * Lead-capture popup + inline form — BEM scoped to .mw-leadcapture.
 *
 * Topic 21 LAUNCH-M-WP5.
 *
 * BEM structure:
 *   .mw-leadcapture                    root
 *   .mw-leadcapture--inline            modifier: inline embed
 *   .mw-leadcapture--popup             modifier: popup / bottom-sheet
 *   .mw-leadcapture--animate-in        modifier: JS-added when !prefersReduced
 *   .mw-leadcapture__title
 *   .mw-leadcapture__desc
 *   .mw-leadcapture__form
 *   .mw-leadcapture__label
 *   .mw-leadcapture__input
 *   .mw-leadcapture__error
 *   .mw-leadcapture__submit
 *   .mw-leadcapture__close
 *   .mw-leadcapture__teaser-img        optional: teaser.jpg shown in popup header
 *
 * Section library closure invariant (Topic 17):
 *   ZERO new bg_token values.
 *   ZERO new is_brand keys.
 *   Component is self-contained — no new inc/sections/ or inc/templates/ partials.
 *
 * @package Mystwood_Studios_AB
 * @since   Topic 21 LAUNCH-M-WP5
 */

/* ---------------------------------------------------------------------------
   Base — shared by both variants
   --------------------------------------------------------------------------- */

.mw-leadcapture {
	background: var(--mw-color-surface, #fff);
	border-radius: var(--mw-radius, 8px);
	box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
	padding: 1.5rem;
	font-family: var(--mw-font-body, inherit);
	color: var(--mw-color-text, #1a1a1a);
}

.mw-leadcapture__title {
	margin: 0 0 0.5rem;
	font-size: 1.125rem;
	font-weight: 700;
	line-height: 1.3;
	color: var(--mw-color-heading, #0d0d0d);
}

.mw-leadcapture__desc {
	margin: 0 0 1rem;
	font-size: 0.9375rem;
	line-height: 1.5;
}

.mw-leadcapture__teaser-img {
	display: block;
	width: 100%;
	height: auto;
	border-radius: calc(var(--mw-radius, 8px) - 2px);
	margin-bottom: 1rem;
	object-fit: cover;
}

/* ---------------------------------------------------------------------------
   Form elements
   --------------------------------------------------------------------------- */

.mw-leadcapture__form {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.mw-leadcapture__label {
	font-size: 0.875rem;
	font-weight: 600;
}

.mw-leadcapture__input {
	width: 100%;
	padding: 0.625rem 0.75rem;
	border: 1px solid var(--mw-color-border, #d1d5db);
	border-radius: calc(var(--mw-radius, 8px) / 2);
	font-size: 1rem;
	line-height: 1.5;
	color: inherit;
	background: var(--mw-color-input-bg, #f9fafb);
	box-sizing: border-box;
	transition: border-color 0.15s ease;
}

.mw-leadcapture__input:focus {
	outline: 2px solid var(--mw-color-focus, #4f46e5);
	outline-offset: 2px;
	border-color: var(--mw-color-focus, #4f46e5);
}

.mw-leadcapture__error {
	font-size: 0.8125rem;
	color: var(--mw-color-error, #dc2626);
}

.mw-leadcapture__submit {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0.625rem 1.25rem;
	background: var(--mw-color-accent, #4f46e5);
	color: #fff;
	border: none;
	border-radius: calc(var(--mw-radius, 8px) / 2);
	font-size: 0.9375rem;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.15s ease;
	margin-top: 0.25rem;
}

.mw-leadcapture__submit:hover,
.mw-leadcapture__submit:focus-visible {
	background: var(--mw-color-accent-dark, #4338ca);
}

.mw-leadcapture__submit:focus-visible {
	outline: 2px solid var(--mw-color-focus, #4f46e5);
	outline-offset: 3px;
}

/* ---------------------------------------------------------------------------
   Inline variant — no position override needed; flows in document
   --------------------------------------------------------------------------- */

.mw-leadcapture--inline {
	max-width: 480px;
	margin-inline: auto;
	/* Inline embeds sit inside a brand-tinted cta-band section that already
	 * owns the heading, background, and text colour — so the inline form drops
	 * the popup card chrome (white surface / shadow / padding) and lets the
	 * Gravity Forms skin render directly on the section (white fields + labels
	 * that inherit the section's light text). The popup variant keeps the card. */
	background: transparent;
	box-shadow: none;
	padding: 0;
	color: inherit;
}

/* Topic 33 FIX-WP29 Task A — left-align the FORM inside a centred band.
 *
 * Owner, 2026-08-01: "the email labels and the first name should be
 * positioned to the left".
 *
 * The cause is inheritance, not form configuration: `_cta-band.css:19` sets
 * `text-align: center` on the whole section and nothing re-sets it on the
 * label. The proof it is a scoping bug is on the same page — the IDENTICAL
 * form rendered in the footer computes `start`. Measured 2026-08-02: labels
 * `center` in-band, `start` in the footer, same form ID 8.
 *
 * Screenshot evidence is sharper than the computed values: the 480px form
 * block is ALREADY left-aligned in every other respect — inputs are
 * full-width, the Subscribe button starts at the block's left edge, the
 * "We respect your privacy" card below is left. Only the two labels sat
 * centred, which is exactly why the band read as broken.
 *
 * WHY THE ANCHOR IS `.gform_wrapper` AND NOT `.mw-leadcapture--inline`:
 * on submit, Gravity Forms' AJAX handler does
 * `jQuery('#gform_wrapper_8').replaceWith(confirmation_content)`
 * (gravityforms/form_display.php:1547) — the wrapper is REPLACED, not
 * filled. The confirmation markup it swaps in carries
 * `.gform_confirmation_wrapper` and NOT `.gform_wrapper` (verified by
 * rendering GFFormDisplay::get_confirmation_message() server-side for form
 * 8 — 241 bytes, no `gform_wrapper` class). So anchoring here left-aligns
 * the form while the one-line success message inherits the band's centring
 * on its own, which is what a centred band wants once the fields are gone.
 * Anchoring one level up on `.mw-leadcapture--inline` would have dragged
 * the confirmation left with it.
 *
 * `start` rather than `left` so RTL flips with the document, and so the
 * computed value matches the footer form's exactly — which makes the
 * verification assertion "in-band now equals footer" a literal string
 * comparison instead of a judgement call.
 *
 * Structural twin of the waitlist form on /a-balance-lost/ (`lore.css:417`
 * — centred section, left-aligned form block), which the owner has never
 * complained about. Same shape, applied to the four cta-band hosts.
 *
 * The band's own heading and subhead are NOT touched: they live outside
 * `.mw-leadcapture--inline` and stay centred, which is correct.
 *
 * This file is enqueued on exactly the four templates that host an inline
 * form (inc/critical-css.php:133-149), which is the same set the audit
 * found with centred labels — /clear-the-skies/, /coloring-book-product/,
 * /bedtime-stories/ and /griffin-roost-manager/. The `.mw-section--cta-band`
 * scope is kept anyway so the rule states its own precondition if that
 * enqueue list ever grows. */
.mw-section--cta-band .mw-leadcapture--inline .gform_wrapper {
	text-align: start;
}

/* ---------------------------------------------------------------------------
   Popup variant — fixed bottom-right card (≥721px viewport)
   --------------------------------------------------------------------------- */

.mw-leadcapture--popup {
	position: fixed;
	bottom: 1.5rem;
	right: 1.5rem;
	width: 320px;
	z-index: 9000;
}

.mw-leadcapture__close {
	position: absolute;
	top: 0.625rem;
	right: 0.625rem;
	background: transparent;
	border: none;
	font-size: 1.25rem;
	line-height: 1;
	cursor: pointer;
	color: var(--mw-color-text-muted, #6b7280);
	padding: 0.25rem;
	border-radius: 50%;
	width: 2rem;
	height: 2rem;
	display: flex;
	align-items: center;
	justify-content: center;
}

.mw-leadcapture__close:hover,
.mw-leadcapture__close:focus-visible {
	background: var(--mw-color-surface-alt, #f3f4f6);
	color: var(--mw-color-text, #1a1a1a);
}

.mw-leadcapture__close:focus-visible {
	outline: 2px solid var(--mw-color-focus, #4f46e5);
	outline-offset: 2px;
}

/* Close button adds padding to title so text doesn't overlap button */
.mw-leadcapture--popup .mw-leadcapture__title {
	padding-right: 2rem;
}

/* Animate-in — subtle slide-up (skipped by prefers-reduced-motion) */
.mw-leadcapture--animate-in {
	animation: mw-lc-slidein 0.25s ease forwards;
}

@keyframes mw-lc-slidein {
	from {
		opacity: 0;
		transform: translateY(12px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* ---------------------------------------------------------------------------
   Popup — mobile bottom-sheet (≤720px)
   Anchored to viewport bottom edge; never blocks content.
   Explicitly dismissed by user — no auto-hide.
   --------------------------------------------------------------------------- */

@media (max-width: 720px) {
	.mw-leadcapture--popup {
		position: fixed;
		bottom: 0;
		right: 0;
		left: 0;
		width: 100%;
		border-radius: var(--mw-radius, 8px) var(--mw-radius, 8px) 0 0;
	}
}

/* ---------------------------------------------------------------------------
   Reduced motion — all transitions and animations disabled
   --------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	.mw-leadcapture--popup,
	.mw-leadcapture--popup *,
	.mw-leadcapture--animate-in {
		transition: none !important;
		animation: none !important;
	}
}
