/**
 * Pigeon Form front-end styles.
 *
 * Deliberately low-specificity and variable-driven so themes can restyle
 * without fighting !important. Disable entirely in Settings → Pigeon Form.
 */

.pigeon-form {
	--pigeon-form-gap: 1.25rem;
	--pigeon-form-radius: 6px;
	--pigeon-form-border: #d0d5dd;
	--pigeon-form-border-hover: #98a2b3;
	/* The plugin's own accent, on the button, the focus ring and the checked
	   state of a box. A theme that wants its own brand sets these three and
	   nothing else. */
	--pigeon-form-border-focus: #eb6a00;
	--pigeon-form-input-bg: #fff;
	--pigeon-form-input-min-height: 2.75rem;
	--pigeon-form-disabled-bg: #f9fafb;

	/* A dropdown's arrow cannot inherit currentColor from a background image,
	   so the whole url() is exposed rather than a colour: a theme that needs a
	   lighter arrow on a dark form swaps this one value. */
	--pigeon-form-select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%23667085' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6.5 8 10.5 12 6.5'/%3E%3C/svg%3E");
	--pigeon-form-error: #b42318;
	--pigeon-form-error-bg: #fef3f2;
	--pigeon-form-success: #067647;
	--pigeon-form-success-bg: #ecfdf3;
	--pigeon-form-info-bg: #eff8ff;
	--pigeon-form-text: inherit;
	--pigeon-form-muted: #667085;
	--pigeon-form-button-bg: #eb6a00;
	--pigeon-form-button-text: #fff;
	--pigeon-form-focus-ring: rgba(235, 106, 0, 0.16);

	color: var(--pigeon-form-text);
}

.pigeon-form-fields {
	display: flex;
	flex-wrap: wrap;
	gap: var(--pigeon-form-gap);
}

.pigeon-form-field {
	flex: 1 1 100%;
	min-width: 0;
}

.pigeon-form-field--width-half {
	flex-basis: calc(50% - (var(--pigeon-form-gap) / 2));
}

.pigeon-form-field--width-third {
	flex-basis: calc(33.333% - (var(--pigeon-form-gap) * 2 / 3));
}

.pigeon-form-field--width-two-thirds {
	flex-basis: calc(66.666% - (var(--pigeon-form-gap) / 3));
}

@media (max-width: 600px) {
	.pigeon-form-field {
		flex-basis: 100%;
	}
}

.pigeon-form-label {
	display: block;
	margin-bottom: 0.375rem;
	font-weight: 600;
	line-height: 1.4;
}

.pigeon-form-required {
	color: var(--pigeon-form-error);
}

/* Date, time and number controls size themselves from their own text in Safari
   and end up shorter than the text boxes beside them. The shared min-height is
   what keeps a row of mixed field types on one baseline. */
.pigeon-form-input {
	box-sizing: border-box;
	width: 100%;
	min-height: var(--pigeon-form-input-min-height);
	padding: 0.625rem 0.75rem;
	border: 1px solid var(--pigeon-form-border);
	border-radius: var(--pigeon-form-radius);
	background: var(--pigeon-form-input-bg);
	color: inherit;
	font: inherit;
	line-height: 1.4;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.pigeon-form-input:hover:not(:disabled):not([readonly]) {
	border-color: var(--pigeon-form-border-hover);
}

.pigeon-form-input:focus {
	outline: none;
	border-color: var(--pigeon-form-border-focus);
	box-shadow: 0 0 0 3px var(--pigeon-form-focus-ring);
}

.pigeon-form-input::placeholder {
	color: var(--pigeon-form-muted);
	/* Firefox dims placeholders on top of the colour it is given. */
	opacity: 1;
}

.pigeon-form-input:disabled {
	background: var(--pigeon-form-disabled-bg);
	color: var(--pigeon-form-muted);
	cursor: not-allowed;
}

.pigeon-form-input[readonly] {
	background: var(--pigeon-form-disabled-bg);
}

/* Chrome paints its own yellow over the field; this keeps an autofilled value
   looking like the rest of the form. */
.pigeon-form-input:-webkit-autofill,
.pigeon-form-input:-webkit-autofill:hover,
.pigeon-form-input:-webkit-autofill:focus {
	-webkit-box-shadow: 0 0 0 100px var(--pigeon-form-input-bg) inset;
	-webkit-text-fill-color: currentColor;
}

.pigeon-form-input--textarea,
textarea.pigeon-form-input {
	resize: vertical;
	min-height: 8rem;
}

/* The native dropdown chrome is the one control that never matches the rest of
   a form, so the arrow is drawn here instead. */
select.pigeon-form-input {
	appearance: none;
	-webkit-appearance: none;
	padding-inline-end: 2.25rem;
	background-image: var(--pigeon-form-select-arrow);
	background-repeat: no-repeat;
	background-position: right 0.75rem center;
	background-size: 16px 16px;
	cursor: pointer;
}

/* The custom dropdown (pigeon-forms.js). The native select stays in the form,
   hidden; this draws the control and its list from the same variables as every
   other input, so a theme that restyles inputs restyles it too. */
.pigeon-form-dropdown {
	position: relative;
}

.pigeon-form-dropdown__native {
	position: absolute !important;
	inset: 0;
	width: 100%;
	height: 100%;
	opacity: 0;
	pointer-events: none;
}

.pigeon-form-dropdown__btn {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	padding-inline-end: 2.25rem;
	background-image: var(--pigeon-form-select-arrow);
	background-repeat: no-repeat;
	background-position: right 0.75rem center;
	background-size: 16px 16px;
	text-align: start;
	cursor: pointer;
}

.pigeon-form-dropdown.is-open .pigeon-form-dropdown__btn {
	border-color: var(--pigeon-form-border-focus);
	box-shadow: 0 0 0 3px var(--pigeon-form-focus-ring);
}

.pigeon-form-dropdown__btn.is-placeholder .pigeon-form-dropdown__text {
	color: var(--pigeon-form-muted);
}

.pigeon-form-dropdown__list {
	position: absolute;
	inset-inline: 0;
	top: calc(100% + 6px);
	z-index: 30;
	box-sizing: border-box;
	max-height: min(18rem, 50vh);
	margin: 0;
	padding: 6px;
	overflow-y: auto;
	list-style: none;
	background: var(--pigeon-form-input-bg);
	border: 1px solid var(--pigeon-form-border-hover);
	border-radius: var(--pigeon-form-radius);
	box-shadow: 0 14px 32px rgba(16, 24, 40, 0.18);
	color: var(--pigeon-form-text);
	overscroll-behavior: contain;
}

.pigeon-form-dropdown.is-up .pigeon-form-dropdown__list {
	top: auto;
	bottom: calc(100% + 6px);
}

.pigeon-form-dropdown__list[hidden] {
	display: none;
}

.pigeon-form-dropdown__option {
	padding: 0.6rem 0.75rem;
	border-radius: calc(var(--pigeon-form-radius) - 2px);
	cursor: pointer;
}

.pigeon-form-dropdown__option.is-active {
	background: color-mix(in srgb, currentColor 9%, transparent);
}

.pigeon-form-dropdown__option[aria-selected="true"] {
	color: var(--pigeon-form-border-focus);
	font-weight: 600;
}

.pigeon-form-dropdown__option[aria-disabled="true"] {
	opacity: 0.45;
	cursor: not-allowed;
}

@media (prefers-reduced-motion: no-preference) {
	.pigeon-form-dropdown__list:not([hidden]) {
		animation: pigeon-form-dropdown-in 0.14s ease-out;
	}
}

@keyframes pigeon-form-dropdown-in {
	from {
		opacity: 0;
		transform: translateY(-4px);
	}
}

[dir="rtl"] .pigeon-form-dropdown__btn {
	background-position: left 0.75rem center;
}

[dir="rtl"] select.pigeon-form-input {
	background-position: left 0.75rem center;
}

/* A list box is not a dropdown: it has no arrow to draw, and forcing the
   single-row height on it would cut the list off. */
select.pigeon-form-input[multiple],
select.pigeon-form-input[size]:not([size="1"]) {
	height: auto;
	padding-inline-end: 0.75rem;
	background-image: none;
	cursor: default;
}

/* Date and time fields keep the browser's picker — replacing it costs the
   keyboard and locale handling that comes free — but the trigger is dimmed to
   sit with the form rather than shout over it. */
.pigeon-form-input::-webkit-calendar-picker-indicator {
	opacity: 0.55;
	cursor: pointer;
	transition: opacity 0.15s ease;
}

.pigeon-form-input:hover::-webkit-calendar-picker-indicator,
.pigeon-form-input:focus::-webkit-calendar-picker-indicator {
	opacity: 1;
}

.pigeon-form-input--file {
	padding: 0.5rem 0.75rem;
	cursor: pointer;
}

.pigeon-form-input--file::file-selector-button {
	margin-inline-end: 0.75rem;
	padding: 0.375rem 0.875rem;
	border: 1px solid var(--pigeon-form-border);
	border-radius: calc(var(--pigeon-form-radius) - 2px);
	background: var(--pigeon-form-disabled-bg);
	color: inherit;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.15s ease, border-color 0.15s ease;
}

.pigeon-form-input--file::file-selector-button:hover {
	border-color: var(--pigeon-form-border-hover);
	background: var(--pigeon-form-input-bg);
}

.pigeon-form-input--checkbox,
.pigeon-form-input--radio,
.pigeon-form-input--consent {
	flex: none;
	width: 1.05em;
	height: 1.05em;
	min-height: 0;
	margin: 0.15em 0.5rem 0 0;
	padding: 0;
	/* One line instead of a rebuilt control: the native box keeps its
	   indeterminate state, its high-contrast rendering and its hit target. */
	accent-color: var(--pigeon-form-border-focus);
}

[dir="rtl"] .pigeon-form-input--checkbox,
[dir="rtl"] .pigeon-form-input--radio,
[dir="rtl"] .pigeon-form-input--consent {
	margin-right: 0;
	margin-left: 0.5rem;
}

.pigeon-form-input--range {
	appearance: none;
	-webkit-appearance: none;
	min-height: 0;
	padding: 0;
	border: 0;
	background: transparent;
	cursor: pointer;
}

.pigeon-form-input--range:focus {
	box-shadow: none;
}

.pigeon-form-input--range::-webkit-slider-runnable-track {
	height: 6px;
	border-radius: 999px;
	background: var(--pigeon-form-border);
}

.pigeon-form-input--range::-moz-range-track {
	height: 6px;
	border-radius: 999px;
	background: var(--pigeon-form-border);
}

.pigeon-form-input--range::-webkit-slider-thumb {
	-webkit-appearance: none;
	width: 16px;
	height: 16px;
	/* Half the thumb minus half the track, so it rides centred. */
	margin-top: -5px;
	border: 2px solid var(--pigeon-form-input-bg);
	border-radius: 50%;
	background: var(--pigeon-form-button-bg);
	box-shadow: 0 0 0 1px var(--pigeon-form-border);
}

.pigeon-form-input--range::-moz-range-thumb {
	width: 16px;
	height: 16px;
	border: 2px solid var(--pigeon-form-input-bg);
	border-radius: 50%;
	background: var(--pigeon-form-button-bg);
	box-shadow: 0 0 0 1px var(--pigeon-form-border);
}

.pigeon-form-input--range:focus-visible::-webkit-slider-thumb {
	box-shadow: 0 0 0 1px var(--pigeon-form-border), 0 0 0 4px var(--pigeon-form-focus-ring);
}

.pigeon-form-input--range:focus-visible::-moz-range-thumb {
	box-shadow: 0 0 0 1px var(--pigeon-form-border), 0 0 0 4px var(--pigeon-form-focus-ring);
}

.pigeon-form-choices {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.pigeon-form-choices.is-inline {
	flex-direction: row;
	flex-wrap: wrap;
	gap: 1rem;
}

.pigeon-form-choice {
	display: flex;
	align-items: flex-start;
	gap: 0.25rem;
	font-weight: 400;
	cursor: pointer;
}

.pigeon-form-description {
	margin: 0.375rem 0 0;
	color: var(--pigeon-form-muted);
	font-size: 0.875em;
}

.pigeon-form-error {
	margin: 0.375rem 0 0;
	color: var(--pigeon-form-error);
	font-size: 0.875em;
}

.pigeon-form-field.has-error .pigeon-form-input {
	border-color: var(--pigeon-form-error);
}

.pigeon-form-field.has-error .pigeon-form-input:focus {
	box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.15);
}

.pigeon-form-actions {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	margin-top: var(--pigeon-form-gap);
}

/* An empty spinner is still a flex item, and the row's gap would hold 12px
   open beside it — enough to keep a right-aligned button visibly short of the
   edge it is meant to sit on. */
.pigeon-form-spinner:empty {
	display: none;
}

/* Alignment moves the row rather than the button, so anything that later joins
   the button in here travels with it. Left is the default and is stated
   anyway: a theme that sets justify-content on descendants of its content area
   would otherwise decide this for us. */
.pigeon-form-actions--left {
	justify-content: flex-start;
}

.pigeon-form-actions--center {
	justify-content: center;
}

.pigeon-form-actions--right {
	justify-content: flex-end;
}

/* Full width is a different thing from an alignment: the button stops being
   an object on a line and becomes the line. */
.pigeon-form-actions--full .pigeon-form-submit {
	width: 100%;
}

.pigeon-form-submit {
	padding: 0.6875rem 1.5rem;
	border: 0;
	border-radius: var(--pigeon-form-radius);
	background: var(--pigeon-form-button-bg);
	color: var(--pigeon-form-button-text);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	transition: opacity 0.15s ease;
}

.pigeon-form-submit:hover {
	opacity: 0.9;
}

.pigeon-form-submit[disabled] {
	opacity: 0.6;
	cursor: progress;
}

.pigeon-form-alert {
	margin: 0 0 var(--pigeon-form-gap);
	padding: 0.875rem 1rem;
	border-radius: var(--pigeon-form-radius);
	border-left: 3px solid transparent;
}

.pigeon-form-alert > :first-child {
	margin-top: 0;
}

.pigeon-form-alert > :last-child {
	margin-bottom: 0;
}

.pigeon-form-alert--error {
	background: var(--pigeon-form-error-bg);
	border-left-color: var(--pigeon-form-error);
	color: var(--pigeon-form-error);
}

.pigeon-form-alert--success {
	background: var(--pigeon-form-success-bg);
	border-left-color: var(--pigeon-form-success);
	color: var(--pigeon-form-success);
}

.pigeon-form-alert--info {
	background: var(--pigeon-form-info-bg);
	border-left-color: var(--pigeon-form-border-focus);
}

/* Left-aligned label layout. */
@media (min-width: 782px) {
	.pigeon-form-form--labels-left .pigeon-form-field {
		display: grid;
		grid-template-columns: minmax(6rem, 25%) 1fr;
		column-gap: 1rem;
		align-items: start;
	}

	.pigeon-form-form--labels-left .pigeon-form-label {
		margin: 0.625rem 0 0;
	}

	.pigeon-form-form--labels-left .pigeon-form-description,
	.pigeon-form-form--labels-left .pigeon-form-error {
		grid-column: 2;
	}
}

.pigeon-form-form--labels-hidden .pigeon-form-label {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Most themes define .screen-reader-text, but the plugin emits it and cannot
   assume that — and inside the builder's shadow-root previews no theme CSS
   exists at all. Scoped to .pigeon-form so it never fights a theme's own rule. */
.pigeon-form .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Honeypot: hidden from humans, still reachable to a naive bot. */
.pigeon-form-hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.pigeon-form-form.is-submitting {
	opacity: 0.75;
	pointer-events: none;
}
