/**
 * OnlineGuides Opt-in — form styles.
 * Uses shared design tokens with safe fallbacks so it inherits a site's theme
 * when those custom properties are defined, and looks polished when they are not.
 */

.og-optin {
	--_primary: var(--og-color-primary, #0e7490);
	--_primary-hover: var(--og-color-primary-hover, #0b5c72);
	--_accent: var(--og-color-accent, #f59e0b);
	--_ink: var(--og-color-ink, #0f172a);
	--_muted: var(--og-color-muted, #64748b);
	--_surface: var(--og-color-surface, #ffffff);
	--_border: var(--og-color-border, #d7dee6);
	--_success: var(--og-color-success, #16a34a);
	--_radius: var(--og-radius, 12px);
	--_shadow: var(--og-shadow, 0 10px 30px -12px rgba(15, 23, 42, 0.25));
	--_font: var(--og-font-sans, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif);

	font-family: var(--_font);
	color: var(--_ink);
	box-sizing: border-box;
	max-width: 100%;
}

.og-optin *,
.og-optin *::before,
.og-optin *::after {
	box-sizing: border-box;
}

.og-optin__head {
	margin-bottom: 0.85rem;
}

.og-optin__title {
	font-size: 1.25rem;
	font-weight: 700;
	line-height: 1.25;
	margin: 0 0 0.25rem;
}

.og-optin__subtitle {
	font-size: 0.95rem;
	color: var(--_muted);
	line-height: 1.5;
	margin: 0;
}

.og-optin__fields {
	display: flex;
	flex-wrap: wrap;
	gap: 0.6rem;
	align-items: flex-end;
}

.og-optin__field {
	display: flex;
	flex-direction: column;
	gap: 0.3rem;
	flex: 1 1 220px;
	min-width: 0;
}

.og-optin__label {
	font-size: 0.8rem;
	font-weight: 600;
	color: var(--_muted);
}

.og-optin__input {
	width: 100%;
	padding: 0.7rem 0.85rem;
	font-size: 1rem;
	font-family: inherit;
	color: var(--_ink);
	background: var(--_surface);
	border: 1.5px solid var(--_border);
	border-radius: var(--_radius);
	line-height: 1.3;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
	appearance: none;
}

.og-optin__input::placeholder {
	color: var(--_muted);
	opacity: 0.7;
}

.og-optin__input:focus {
	outline: none;
	border-color: var(--_primary);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--_primary) 22%, transparent);
}

.og-optin__button {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.4rem;
	padding: 0.72rem 1.35rem;
	font-size: 1rem;
	font-weight: 700;
	font-family: inherit;
	color: #fff;
	background: var(--_primary);
	border: none;
	border-radius: var(--_radius);
	cursor: pointer;
	line-height: 1.3;
	transition: background 0.15s ease, transform 0.05s ease;
	white-space: nowrap;
}

.og-optin__button:hover {
	background: var(--_primary-hover);
}

.og-optin__button:active {
	transform: translateY(1px);
}

.og-optin__button:focus-visible {
	outline: 3px solid color-mix(in srgb, var(--_primary) 45%, transparent);
	outline-offset: 2px;
}

.og-optin__button[disabled] {
	opacity: 0.65;
	cursor: default;
}

/* Consent */
.og-optin__field--consent {
	flex-basis: 100%;
	margin-top: 0.65rem;
}

.og-optin__consent {
	display: flex;
	align-items: flex-start;
	gap: 0.5rem;
	font-size: 0.82rem;
	color: var(--_muted);
	line-height: 1.45;
	cursor: pointer;
}

.og-optin__checkbox {
	margin-top: 0.15rem;
	width: 1rem;
	height: 1rem;
	accent-color: var(--_primary);
	flex: 0 0 auto;
}

.og-optin__consent a {
	color: var(--_primary);
	text-decoration: underline;
}

/* Message (aria-live) */
.og-optin__message {
	flex-basis: 100%;
	margin: 0.7rem 0 0;
	padding: 0.6rem 0.85rem;
	border-radius: var(--_radius);
	font-size: 0.9rem;
	line-height: 1.4;
	background: color-mix(in srgb, var(--_success) 12%, transparent);
	color: var(--_success);
	border: 1px solid color-mix(in srgb, var(--_success) 35%, transparent);
}

.og-optin__message[hidden] {
	display: none;
}

.og-optin.is-error .og-optin__message {
	background: color-mix(in srgb, #dc2626 12%, transparent);
	color: #b91c1c;
	border-color: color-mix(in srgb, #dc2626 35%, transparent);
}

/* Honeypot — hidden from users and assistive tech, still submitted. */
.og-optin__hp {
	position: absolute !important;
	left: -9999px !important;
	top: auto;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* ---------- Variants ---------- */

/* Card */
.og-optin--card {
	background: var(--_surface);
	border: 1px solid var(--_border);
	border-radius: calc(var(--_radius) + 4px);
	padding: 1.5rem;
	box-shadow: var(--_shadow);
}

/* Slim — compact, single row where possible */
.og-optin--slim .og-optin__head {
	margin-bottom: 0.5rem;
}

.og-optin--slim .og-optin__title {
	font-size: 1.05rem;
}

.og-optin--slim .og-optin__label {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

.og-optin--slim .og-optin__input {
	padding: 0.55rem 0.75rem;
}

.og-optin--slim .og-optin__button {
	padding: 0.57rem 1.1rem;
}

/* Footer — tuned for darker footer backgrounds */
.og-optin--footer {
	--_ink: var(--og-color-surface, #f8fafc);
	--_muted: color-mix(in srgb, var(--og-color-surface, #f8fafc) 70%, transparent);
	--_surface: color-mix(in srgb, #000 18%, transparent);
	--_border: color-mix(in srgb, #fff 22%, transparent);
}

.og-optin--footer .og-optin__input {
	color: #fff;
}

/* Inline default already handled by base layout */

/* ---------- Slide-in ---------- */
.og-optin-slidein {
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 99990;
	width: min(360px, calc(100vw - 40px));
	background: var(--og-color-surface, #ffffff);
	border: 1px solid var(--og-color-border, #d7dee6);
	border-radius: calc(var(--og-radius, 12px) + 4px);
	box-shadow: var(--og-shadow, 0 20px 45px -15px rgba(15, 23, 42, 0.45));
	padding: 1.35rem;
	transform: translateY(140%);
	opacity: 0;
	transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s ease;
}

.og-optin-slidein.is-visible {
	transform: translateY(0);
	opacity: 1;
}

.og-optin-slidein[hidden] {
	display: none;
}

.og-optin-slidein .og-optin {
	max-width: 100%;
}

.og-optin-slidein__close {
	position: absolute;
	top: 6px;
	right: 10px;
	width: 30px;
	height: 30px;
	border: none;
	background: transparent;
	font-size: 22px;
	line-height: 1;
	color: var(--og-color-muted, #64748b);
	cursor: pointer;
	border-radius: 999px;
}

.og-optin-slidein__close:hover {
	background: color-mix(in srgb, currentColor 14%, transparent);
}

@media (max-width: 600px) {
	.og-optin__fields {
		flex-direction: column;
		align-items: stretch;
	}
	.og-optin__button {
		width: 100%;
	}
}

@media (prefers-reduced-motion: reduce) {
	.og-optin__button,
	.og-optin-slidein {
		transition: none;
	}
	.og-optin-slidein {
		transform: none;
	}
}
