/**
 * AWB Newsletter — frontend styles.
 *
 * Common / Theme / Astra rules are deliberately UNLAYERED: most theme CSS
 * (Tailwind v3 builds, classic themes, WP preflight resets) is unlayered too,
 * and unlayered CSS always beats anything declared inside a cascade layer —
 * so a layered ruleset would lose to the theme's `input { ... }` reset.
 *
 * Only the Tailwind-mode section lives in `@layer awb`, because there the
 * markup carries utilities and plugin CSS must never outrank them (utilities
 * in Tailwind v4 are layered; in v3 they are unlayered and win anyway).
 * Keyframes are declared outside any layer.
 */


/* ---------------------------------------------------------------------
 * Base form structure (all style modes)
 * ------------------------------------------------------------------- */

.awb-nl {
	--awb-nl-accent: var(--wp--preset--color--primary, #111111);
	--awb-nl-accent-contrast: #ffffff;
	--awb-nl-radius: 6px;
	--awb-nl-border: rgba(0, 0, 0, 0.15);
	--awb-nl-bg: transparent;

	box-sizing: border-box;
	max-width: 100%;
}

.awb-nl *,
.awb-nl *::before,
.awb-nl *::after {
	box-sizing: inherit;
}

.awb-nl__header {
	margin-block-end: 0.75em;
}

.awb-nl__title {
	margin: 0 0 0.25em;
	font-size: 1.25em;
}

.awb-nl__desc {
	margin: 0;
	opacity: 0.85;
}

.awb-nl__fields {
	display: flex;
	flex-direction: column;
	gap: 0.6em;
}

.awb-nl--inline .awb-nl__fields {
	flex-direction: column;
}

@media (min-width: 480px) {
	.awb-nl--inline .awb-nl__fields {
		flex-direction: row;
		align-items: stretch;
	}

	.awb-nl--inline .awb-nl__input--email {
		flex: 1 1 auto;
	}
}

.awb-nl--card {
	padding: 1.5em;
	border-radius: var(--awb-nl-radius);
}

.awb-nl__consent,
.awb-nl__privacy {
	margin-block-start: 0.6em;
	font-size: 0.85em;
	text-align: start;
}

.awb-nl__consent label {
	display: flex;
	align-items: flex-start;
	gap: 0.5em;
}

/* Honeypot: visually hidden but not display:none (bots skip display:none checks less reliably). */
.awb-nl__hp {
	position: absolute;
	inset-inline-start: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
	opacity: 0;
}

.screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(1px, 1px, 1px, 1px);
	white-space: nowrap;
}

/* ---------------------------------------------------------------------
 * Button + spinner (shared)
 * ------------------------------------------------------------------- */

.awb-nl__button {
	position: relative;
	cursor: pointer;
}

.awb-nl__button[disabled] {
	cursor: default;
	opacity: 0.7;
}

.awb-nl__spinner {
	display: none;
	width: 1em;
	height: 1em;
	margin-inline-start: 0.5em;
	border: 2px solid currentColor;
	border-inline-end-color: transparent;
	border-radius: 50%;
	vertical-align: -0.15em;
}

.awb-nl__button.is-loading .awb-nl__spinner {
	display: inline-block;
	animation: awb-nl-spin 0.7s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
	.awb-nl__button.is-loading .awb-nl__spinner {
		animation-duration: 1.8s;
	}
}

/* ---------------------------------------------------------------------
 * Message area
 * ------------------------------------------------------------------- */

.awb-nl__message {
	margin-block-start: 0.6em;
	font-size: 0.9em;
	text-align: start;
}

.awb-nl__message:empty {
	display: none;
}

.awb-nl__message.is-success {
	color: #1a7f37;
}

.awb-nl__message.is-error {
	color: #c62828;
}

.awb-nl-notice {
	max-width: 720px;
	margin: 1em auto;
	padding: 0.75em 1em;
	border-radius: 4px;
	font-size: 0.95em;
}

.awb-nl-notice--success {
	background: #eaf7ee;
	color: #1a7f37;
	border: 1px solid #b7e4c7;
}

.awb-nl-notice--error {
	background: #fdecea;
	color: #c62828;
	border: 1px solid #f5c2c0;
}

/* ---------------------------------------------------------------------
 * THEME mode — neutral, inherits typography, driven by CSS variables
 * ------------------------------------------------------------------- */

.awb-nl--theme .awb-nl__input {
	font: inherit;
	color: inherit;
	background: var(--awb-nl-bg);
	border: 1px solid var(--awb-nl-border);
	border-radius: var(--awb-nl-radius);
	padding: 0.6em 0.8em;
	width: 100%;
}

.awb-nl--theme .awb-nl__button {
	font: inherit;
	background: var(--awb-nl-accent);
	color: var(--awb-nl-accent-contrast);
	border: none;
	border-radius: var(--awb-nl-radius);
	padding: 0.65em 1.2em;
	white-space: nowrap;
}

.awb-nl--theme.awb-nl--card {
	border: 1px solid var(--awb-nl-border);
	background: var(--awb-nl-bg);
}

/* ---------------------------------------------------------------------
 * ASTRA mode — uses Astra's own CSS custom properties, layout rules only
 * ------------------------------------------------------------------- */

.awb-nl--astra .awb-nl__input {
	font: inherit;
	color: var(--ast-global-color-3, inherit);
	background: var(--ast-global-color-5, #fff);
	border: 1px solid var(--ast-border-color, rgba(0, 0, 0, 0.15));
	border-radius: var(--ast-border-radius, 4px);
	padding: 0.6em 0.8em;
	width: 100%;
}

.awb-nl--astra .awb-nl__button.ast-button {
	border-radius: var(--ast-border-radius, 4px);
	white-space: nowrap;
}

.awb-nl--astra.awb-nl--card {
	border: 1px solid var(--ast-border-color, rgba(0, 0, 0, 0.15));
	background: var(--ast-global-color-4, #f7f7f7);
	border-radius: var(--ast-border-radius, 4px);
}

.awb-nl--astra .awb-nl__desc {
	color: var(--ast-global-color-3, inherit);
}

/* ---------------------------------------------------------------------
 * Dark variant (shortcode dark="1") — for dark sections / dark themes
 * ------------------------------------------------------------------- */

.awb-nl--dark {
	--awb-nl-accent: var(--wp--preset--color--primary, #ffffff);
	--awb-nl-accent-contrast: #111111;
	--awb-nl-border: rgba(255, 255, 255, 0.22);
	--awb-nl-bg: rgba(255, 255, 255, 0.06);
	color: #ffffff;
}

.awb-nl--dark .awb-nl__input::placeholder {
	color: rgba(255, 255, 255, 0.55);
}

.awb-nl--dark .awb-nl__message.is-success {
	color: #7ee2a8;
}

.awb-nl--dark .awb-nl__message.is-error {
	color: #ff8a80;
}

@layer awb {
	/* ---------------------------------------------------------------------
	 * TAILWIND mode — markup already carries utility classes; this only
	 * fills small gaps utilities don't cover (spacing between stacked
	 * elements not already expressed via gap, and the spinner colour).
	 * ------------------------------------------------------------------- */

	.awb-nl--tailwind .awb-nl__fields {
		gap: 0.75rem;
	}

	.awb-nl--tailwind.awb-nl--inline .awb-nl__fields {
		flex-direction: column;
	}

	@media (min-width: 640px) {
		.awb-nl--tailwind.awb-nl--inline .awb-nl__fields {
			flex-direction: row;
		}
	}
}


@keyframes awb-nl-spin {
	to {
		transform: rotate(360deg);
	}
}
