/**
 * Forms Guard — frontend widget (vertical layout everywhere)
 */

.forms-guard-widget {
	--fg-border: #cbd5e1;
	--fg-bg: #f8fafc;
	--fg-text: #0f172a;
	--fg-accent: #0f766e;
	--fg-error: #b91c1c;
	--fg-radius: 8px;
	display: block;
	margin: 1em 0;
	max-width: 14rem;
	width: 100%;
	color: var(--fg-text);
	font-size: 14px;
	line-height: 1.4;
}

.forms-guard-label {
	display: block;
	margin-bottom: 0.4em;
	font-weight: 600;
}

.forms-guard-required {
	color: var(--fg-error);
	margin-inline-start: 0.15em;
}

.forms-guard-row {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: 0.55rem;
}

.forms-guard-captcha {
	display: flex;
	flex-direction: row;
	align-items: center;
	gap: 0.4rem;
	width: 100%;
}

.forms-guard-image-wrap {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 1 1 auto;
	min-width: 0;
	background: var(--fg-bg);
	border: 1px solid var(--fg-border);
	border-radius: var(--fg-radius);
	overflow: hidden;
	min-height: 64px;
}

.forms-guard-image {
	display: block;
	width: 100%;
	max-width: 200px;
	height: 64px;
	object-fit: contain;
	user-select: none;
	pointer-events: none;
	margin-inline: auto;
}

/* Refresh sits beside the image — never over the digits. */
.forms-guard-refresh {
	flex: 0 0 auto;
	width: 26px;
	height: 26px;
	padding: 0;
	border: 1px solid var(--fg-border);
	border-radius: 6px;
	background: #fff;
	box-shadow: none;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s ease, border-color 0.15s ease;
	color: #475569;
}

.forms-guard-refresh:hover,
.forms-guard-refresh:focus-visible {
	background: var(--fg-bg);
	border-color: var(--fg-accent);
	outline: 2px solid rgba(15, 118, 110, 0.25);
	outline-offset: 1px;
}

.forms-guard-refresh-icon {
	width: 13px;
	height: 13px;
	display: block;
	background-color: currentColor;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='23 4 23 10 17 10'/%3E%3Cpolyline points='1 20 1 14 7 14'/%3E%3Cpath d='M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15'/%3E%3C/svg%3E") center / contain no-repeat;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='23 4 23 10 17 10'/%3E%3Cpolyline points='1 20 1 14 7 14'/%3E%3Cpath d='M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15'/%3E%3C/svg%3E") center / contain no-repeat;
}

.forms-guard-refresh.is-spinning .forms-guard-refresh-icon {
	animation: forms-guard-spin 0.7s linear infinite;
}

@keyframes forms-guard-spin {
	to {
		transform: rotate(360deg);
	}
}

.forms-guard-input {
	display: block;
	width: 100%;
	box-sizing: border-box;
	padding: 0.55rem 0.75rem;
	border: 1px solid var(--fg-border);
	border-radius: var(--fg-radius);
	background: #fff;
	color: inherit;
	font: inherit;
	letter-spacing: 0.04em;
}

.forms-guard-input:focus {
	border-color: var(--fg-accent);
	outline: 2px solid rgba(15, 118, 110, 0.25);
	outline-offset: 0;
}

.forms-guard-widget.is-error .forms-guard-input,
.forms-guard-widget.is-error .forms-guard-image-wrap {
	border-color: var(--fg-error);
}

.forms-guard-widget.is-error .forms-guard-label {
	color: var(--fg-error);
}

.forms-guard-widget[dir="rtl"] .forms-guard-input {
	text-align: right;
}

/* Login / Woo / narrow contexts */
.login .forms-guard-widget,
.woocommerce .forms-guard-widget,
.woocommerce-page .forms-guard-widget {
	max-width: 100%;
}

.forms-guard-blocks-checkout {
	max-width: 14rem;
	margin: 1rem 0;
}
