/*
 * AIZN inquiry forms. The form takes the theme's font and text color, its
 * button style (wp-element-button) and its palette colors; a form set to its
 * own look ("custom") overrides them through the --aizn-* variables.
 * Every control is styled here, so no browser default look shows through.
 */

.aizn-form,
.aizn-modal,
.aizn-launcher {
	--aizn-accent: var(--wp--preset--color--primary, var(--wp--preset--color--accent, var(--wp--preset--color--contrast, #1e1e1e)));
	--aizn-button-text: var(--wp--preset--color--base, #ffffff);
	--aizn-radius: 6px;
	--aizn-border: rgba(127, 127, 127, 0.45);
	--aizn-border: color-mix(in srgb, currentColor 28%, transparent);
	--aizn-muted: rgba(127, 127, 127, 0.9);
	--aizn-muted: color-mix(in srgb, currentColor 62%, transparent);
	--aizn-fill: rgba(127, 127, 127, 0.08);
	--aizn-fill: color-mix(in srgb, currentColor 6%, transparent);
	--aizn-error: #c62828;
	--aizn-success: #1b7f3b;
}

.aizn-form {
	box-sizing: border-box;
	max-width: 100%;
	font: inherit;
	color: inherit;
}

.aizn-form *,
.aizn-form *::before,
.aizn-form *::after {
	box-sizing: border-box;
}

.aizn-form__title {
	margin: 0 0 0.4em;
}

.aizn-form__description {
	margin: 0 0 1.2em;
	color: var(--aizn-muted);
}

.aizn-form__grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: 1em 1.1em;
}

@media (min-width: 600px) {
	.aizn-form__grid {
		grid-template-columns: 1fr 1fr;
	}

	.aizn-field--full {
		grid-column: 1 / -1;
	}
}

.aizn-field {
	display: flex;
	flex-direction: column;
	gap: 0.35em;
	min-width: 0;
}

.aizn-field__label {
	padding: 0;
	font-size: 0.92em;
	font-weight: 600;
	line-height: 1.4;
}

.aizn-field__required {
	margin-left: 0.2em;
	color: var(--aizn-error);
}

.aizn-form--labels-hidden .aizn-field:not(.aizn-field--radio):not(.aizn-field--checkbox) > .aizn-field__label {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

.aizn-field__help {
	margin: 0;
	font-size: 0.85em;
	color: var(--aizn-muted);
}

.aizn-field__error {
	margin: 0;
	font-size: 0.85em;
	color: var(--aizn-error);
}

.aizn-field__error[hidden] {
	display: none;
}

/* Text fields, paragraphs and dropdowns */

.aizn-form .aizn-input {
	display: block;
	width: 100%;
	min-height: 2.75em;
	margin: 0;
	padding: 0.6em 0.8em;
	font: inherit;
	font-size: 1em;
	line-height: 1.4;
	color: inherit;
	background: transparent;
	border: 1px solid var(--aizn-border);
	border-radius: var(--aizn-radius);
	box-shadow: none;
	outline: none;
	-webkit-appearance: none;
	appearance: none;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.aizn-form textarea.aizn-input {
	min-height: 7em;
	resize: vertical;
}

.aizn-form .aizn-input::placeholder {
	color: var(--aizn-muted);
	opacity: 1;
}

.aizn-form .aizn-input:hover {
	border-color: var(--aizn-muted);
}

.aizn-form .aizn-input:focus-visible,
.aizn-form .aizn-input:focus {
	border-color: var(--aizn-accent);
	box-shadow: 0 0 0 2px color-mix(in srgb, var(--aizn-accent) 30%, transparent);
	outline: none;
}

.aizn-form--inputs-filled .aizn-input {
	background: var(--aizn-fill);
	border-color: transparent;
}

.aizn-form--inputs-underline .aizn-input {
	padding-left: 0;
	padding-right: 0;
	border-width: 0 0 1px;
	border-radius: 0;
}

.aizn-form--inputs-underline .aizn-input:focus {
	box-shadow: 0 1px 0 0 var(--aizn-accent);
}

.aizn-form .aizn-input::-webkit-outer-spin-button,
.aizn-form .aizn-input::-webkit-inner-spin-button {
	margin: 0;
	-webkit-appearance: none;
}

.aizn-form input[type="number"].aizn-input {
	-moz-appearance: textfield;
}

.aizn-select {
	position: relative;
	display: block;
}

.aizn-form .aizn-select .aizn-input {
	padding-right: 2.4em;
	cursor: pointer;
}

.aizn-form--inputs-underline .aizn-select .aizn-input {
	padding-right: 1.6em;
}

/* A chevron drawn with two borders, in the text color. */
.aizn-select::after {
	position: absolute;
	top: 50%;
	right: 0.95em;
	width: 0.45em;
	height: 0.45em;
	content: "";
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	opacity: 0.6;
	transform: translateY(-70%) rotate(45deg);
	pointer-events: none;
}

.aizn-form .aizn-select option {
	color: #1e1e1e;
	background: #ffffff;
}

.aizn-field--invalid .aizn-input,
.aizn-form--inputs-filled .aizn-field--invalid .aizn-input {
	border-color: var(--aizn-error);
}

/* Single choice, multiple choice and consent */

.aizn-field__group {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5em 1.2em;
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
}

.aizn-field__group > .aizn-field__label {
	flex-basis: 100%;
	margin-bottom: 0.1em;
	float: none;
}

.aizn-choice {
	position: relative;
	display: inline-flex;
	align-items: flex-start;
	gap: 0.55em;
	font-size: 0.95em;
	line-height: 1.45;
	cursor: pointer;
}

.aizn-choice input {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	opacity: 0;
}

.aizn-choice__mark {
	position: relative;
	flex: 0 0 auto;
	width: 1.15em;
	height: 1.15em;
	margin-top: 0.15em;
	background: transparent;
	border: 1.5px solid var(--aizn-border);
	border-radius: calc(var(--aizn-radius) * 0.5);
	transition: background-color 0.15s ease, border-color 0.15s ease;
}

.aizn-choice--radio .aizn-choice__mark {
	border-radius: 50%;
}

.aizn-choice:hover .aizn-choice__mark {
	border-color: var(--aizn-muted);
}

.aizn-choice input:checked + .aizn-choice__mark {
	background: var(--aizn-accent);
	border-color: var(--aizn-accent);
}

/* The tick of a checkbox, the dot of a radio button. */
.aizn-choice input:checked + .aizn-choice__mark::after {
	position: absolute;
	top: 45%;
	left: 50%;
	width: 0.3em;
	height: 0.55em;
	content: "";
	border-right: 2px solid var(--aizn-button-text);
	border-bottom: 2px solid var(--aizn-button-text);
	transform: translate(-50%, -50%) rotate(45deg);
}

.aizn-choice--radio input:checked + .aizn-choice__mark::after {
	top: 50%;
	width: 0.42em;
	height: 0.42em;
	background: var(--aizn-button-text);
	border: 0;
	border-radius: 50%;
	transform: translate(-50%, -50%);
}

.aizn-choice input:focus-visible + .aizn-choice__mark {
	outline: 2px solid var(--aizn-accent);
	outline-offset: 2px;
}

.aizn-field--invalid .aizn-choice__mark {
	border-color: var(--aizn-error);
}

/* Robots fill every field; people never see this one. */
.aizn-form__trap {
	position: absolute !important;
	left: -10000px !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* Status and button */

.aizn-form__status {
	margin: 1em 0 0;
	font-size: 0.92em;
}

.aizn-form__status:empty {
	display: none;
}

.aizn-form__status--error {
	color: var(--aizn-error);
}

.aizn-form__actions {
	margin-top: 1.2em;
}

/* Low specificity: a theme's own button style (wp-element-button) wins. */
:where(.aizn-form__submit, .aizn-open-button) {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5em;
	min-height: 2.75em;
	padding: 0.7em 1.6em;
	font: inherit;
	font-weight: 600;
	line-height: 1.2;
	color: var(--aizn-button-text);
	background: var(--aizn-accent);
	border: 0;
	border-radius: var(--aizn-radius);
	cursor: pointer;
	transition: filter 0.15s ease, opacity 0.15s ease;
}

:where(.aizn-form__submit, .aizn-open-button):hover {
	filter: brightness(1.08);
}

.aizn-form__submit:focus-visible,
.aizn-open-button:focus-visible {
	outline: 2px solid var(--aizn-accent);
	outline-offset: 2px;
}

.aizn-form__submit[disabled] {
	opacity: 0.6;
	cursor: progress;
}

/* A form with its own look overrides the theme's button. */
.aizn-form--custom .aizn-form__submit {
	color: var(--aizn-button-text);
	background: var(--aizn-accent);
	border-radius: var(--aizn-radius);
}

.aizn-form__success {
	padding: 1.2em 1.3em;
	border: 1px solid color-mix(in srgb, var(--aizn-success) 40%, transparent);
	border-radius: var(--aizn-radius);
	background: color-mix(in srgb, var(--aizn-success) 8%, transparent);
}

.aizn-form__success p {
	margin: 0 0 0.8em;
}

.aizn-form__again {
	padding: 0;
	font: inherit;
	color: var(--aizn-accent);
	text-decoration: underline;
	background: none;
	border: 0;
	cursor: pointer;
}

.aizn-form__again:focus-visible {
	outline: 2px solid var(--aizn-accent);
	outline-offset: 2px;
}

/* Popup */

.aizn-modal {
	position: fixed;
	inset: 0;
	z-index: 2147482500;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	background: rgba(0, 0, 0, 0.5);
	opacity: 0;
	transition: opacity 0.18s ease;
}

.aizn-modal[hidden] {
	display: none;
}

.aizn-modal--open {
	opacity: 1;
}

.aizn-modal__dialog {
	position: relative;
	width: min(600px, 100%);
	max-height: min(90vh, 900px);
	overflow-y: auto;
	padding: 28px 28px 24px;
	color: var(--wp--preset--color--contrast, #1e1e1e);
	background: var(--wp--preset--color--base, #ffffff);
	border-radius: 12px;
	box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
	transform: translateY(12px) scale(0.98);
	transition: transform 0.18s ease;
	overscroll-behavior: contain;
	scrollbar-width: thin;
	scrollbar-color: rgba(127, 127, 127, 0.5) transparent;
}

.aizn-modal__dialog::-webkit-scrollbar {
	width: 8px;
}

.aizn-modal__dialog::-webkit-scrollbar-thumb {
	background: rgba(127, 127, 127, 0.5);
	border-radius: 4px;
}

.aizn-modal--open .aizn-modal__dialog {
	transform: none;
}

.aizn-modal__title {
	margin: 0 40px 1em 0;
	font-size: 1.3em;
	line-height: 1.3;
}

.aizn-modal__close {
	position: absolute;
	top: 14px;
	right: 14px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	padding: 0;
	color: inherit;
	background: transparent;
	border: 0;
	border-radius: 50%;
	cursor: pointer;
}

.aizn-modal__close:hover {
	background: rgba(127, 127, 127, 0.15);
}

.aizn-modal__close:focus-visible {
	outline: 2px solid var(--aizn-accent);
	outline-offset: 1px;
}

/* An X drawn with two bars. */
.aizn-modal__close::before,
.aizn-modal__close::after {
	position: absolute;
	width: 16px;
	height: 2px;
	content: "";
	background: currentColor;
	border-radius: 1px;
}

.aizn-modal__close::before {
	transform: rotate(45deg);
}

.aizn-modal__close::after {
	transform: rotate(-45deg);
}

.aizn-modal__loading {
	margin: 0;
	color: var(--aizn-muted);
}

body.aizn-modal-is-open {
	overflow: hidden;
}

@media (max-width: 480px) {
	.aizn-modal {
		align-items: flex-end;
		padding: 0;
	}

	.aizn-modal__dialog {
		width: 100%;
		max-height: 92vh;
		padding: 24px 18px calc(18px + env(safe-area-inset-bottom));
		border-radius: 14px 14px 0 0;
	}
}

/* Floating button: a tab on the side, clear of the live chat button in the corner. */

.aizn-launcher {
	position: fixed;
	top: 50%;
	z-index: 2147482000;
	padding: 16px 10px;
	font: inherit;
	font-size: 15px;
	font-weight: 600;
	line-height: 1;
	letter-spacing: 0.02em;
	color: var(--aizn-button-text);
	background: var(--aizn-accent);
	border: 0;
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
	cursor: pointer;
	writing-mode: vertical-rl;
	transform: translateY(-50%);
	transition: padding 0.15s ease;
}

.aizn-launcher--right {
	right: 0;
	border-radius: 8px 0 0 8px;
}

/* Turned over so the text reads bottom to top; the turn also moves the rounded corners to the inner side. */
.aizn-launcher--left {
	left: 0;
	border-radius: 8px 0 0 8px;
	transform: translateY(-50%) rotate(180deg);
}

.aizn-launcher:hover {
	padding-top: 18px;
	padding-bottom: 18px;
}

.aizn-launcher:focus-visible {
	outline: 2px solid var(--aizn-accent);
	outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
	.aizn-modal,
	.aizn-modal__dialog,
	.aizn-launcher,
	.aizn-form .aizn-input,
	.aizn-choice__mark {
		transition: none;
	}

	.aizn-modal__dialog {
		transform: none;
	}
}
