/**
 * Quote form styles.
 *
 * Falls back to sensible values when the theme does not define the tokens,
 * so the form still looks right if it is dropped into another theme.
 */

.tbha-form-wrap {
	--tbha-form-bg: var(--wp--preset--color--base, #fff);
	--tbha-form-ink: var(--wp--preset--color--contrast, #141a24);
	--tbha-form-muted: var(--wp--preset--color--muted-text, #5a6172);
	--tbha-form-line: var(--wp--preset--color--hairline, #e4e6ec);
	--tbha-form-brand: var(--wp--preset--color--primary, #d93908);
	--tbha-form-accent: var(--wp--preset--color--accent, #4b66db);
	--tbha-form-error: #b3261e;
	--tbha-form-success: #146c43;
	--tbha-form-radius: var(--wp--custom--tbha--radius--md, 12px);

	/* Controls sit on a tinted fill with a border dark enough to read as an
	   edge. A white field on a white card is invisible until it is focused. */
	--tbha-form-field-bg: var(--wp--preset--color--surface, #f4f6fa);
	--tbha-form-field-line: #767e8c;

	container-type: inline-size;
	max-width: 46rem;
	padding: clamp(1.25rem, 0.8rem + 1.6vw, 2.5rem);
	background: var(--tbha-form-bg);
	color: var(--tbha-form-ink);
	border: 1px solid var(--tbha-form-line);
	border-radius: var(--wp--custom--tbha--radius--lg, 18px);
	box-shadow: var(--wp--custom--tbha--shadow--md, 0 10px 24px rgba(13, 20, 32, 0.08));
}

.tbha-form-wrap--compact {
	padding: 1.25rem;
	box-shadow: none;
}

.tbha-form__title {
	margin: 0 0 1.25rem;
	font-size: 1.5rem;
	line-height: 1.2;
}

/* --- Layout ------------------------------------------------------- */

/* One rhythm for the whole form. The blocks are a mix of grids, fieldsets
   and paragraphs, and each was carrying its own margin, so the gaps between
   them did not match — the line chooser ran straight into the Gender row. */
.tbha-form-wrap .tbha-form > * + * {
	margin-block-start: 1.75rem;
}

.tbha-form-wrap .tbha-form > .tbha-fieldset + * {
	margin-block-start: 2rem;
}

.tbha-field-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 1rem 1.25rem;
}

.tbha-field {
	display: flex;
	flex-direction: column;
	gap: 0.4rem;
	margin: 0;
}

/* display:flex above would otherwise beat the UA rule for [hidden], leaving
   the conditional fields on screen. */
.tbha-field[hidden] {
	display: none;
}

.tbha-field--full {
	grid-column: 1 / -1;
}

/* One column on narrow containers, not just narrow viewports: the form is
   also used inside a sidebar-width column. */
@container (max-width: 34rem) {
	.tbha-field-grid {
		grid-template-columns: minmax(0, 1fr);
	}
}

@supports not (container-type: inline-size) {
	@media (max-width: 34rem) {
		.tbha-field-grid {
			grid-template-columns: minmax(0, 1fr);
		}
	}
}

/* --- Controls ----------------------------------------------------- */

.tbha-field label {
	font-size: 0.9375rem;
	font-weight: 600;
	line-height: 1.3;
}

.tbha-required {
	color: var(--tbha-form-brand);
	margin-inline-start: 0.15rem;
}

.tbha-optional {
	margin-inline-start: 0.35rem;
	font-weight: 400;
	font-size: 0.8125rem;
	color: var(--tbha-form-muted);
}

/* Nothing here can rely on a theme reset: without border-box the padding is
   added to the 100% width and every control overflows its grid column. */
.tbha-form-wrap,
.tbha-form-wrap *,
.tbha-form-wrap *::before,
.tbha-form-wrap *::after {
	box-sizing: border-box;
}

.tbha-form input[type="text"],
.tbha-form input[type="email"],
.tbha-form input[type="tel"],
.tbha-form input[type="url"],
.tbha-form input[type="number"],
.tbha-form input[type="date"],
.tbha-form select,
.tbha-form textarea {
	display: block;
	width: 100%;
	min-height: 3rem;
	padding: 0.7rem 0.85rem;
	font: inherit;
	font-size: 1rem; /* 16px minimum stops iOS zooming on focus. */
	color: inherit;
	background: var(--tbha-form-field-bg);
	border: 1px solid var(--tbha-form-field-line);
	border-radius: var(--tbha-form-radius);
	transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

/* Selects keep their native arrow but need the appearance reset so the fill
   and radius apply on WebKit. */
.tbha-form select {
	appearance: none;
	-webkit-appearance: none;
	padding-inline-end: 2.5rem;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23586074' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 0.9rem center;
	cursor: pointer;
}

.tbha-form textarea {
	resize: vertical;
	min-height: 6.5rem;
}

.tbha-form ::placeholder {
	color: var(--tbha-form-muted);
	opacity: 1;
}

/* The field lifts to white on focus, so the active control is the brightest
   thing in the form rather than indistinguishable from the ones around it. */
.tbha-form :is(input, select, textarea):focus-visible {
	outline: 3px solid var(--tbha-form-accent);
	outline-offset: 2px;
	background: var(--tbha-form-bg);
	border-color: var(--tbha-form-accent);
}

.tbha-form :is(input, select, textarea):hover:not(:focus) {
	border-color: color-mix(in srgb, var(--tbha-form-ink) 38%, transparent);
}

/* --- Date of birth ------------------------------------------------ */

/* Chrome renders an unstyled date input at its own intrinsic size, which is
   what made this field sit at a different height from the one beside it. */
.tbha-form input[type="date"] {
	appearance: none;
	-webkit-appearance: none;
	cursor: pointer;
}

/* The editable date part carries its own padding, which made the field two
   pixels taller than the text input beside it. */
.tbha-form input[type="date"]::-webkit-datetime-edit {
	padding: 0;
	line-height: inherit;
	color: var(--tbha-form-muted);
}

.tbha-form input[type="date"]::-webkit-datetime-edit-fields-wrapper {
	padding: 0;
}

.tbha-form input[type="date"]:not(:placeholder-shown)::-webkit-datetime-edit,
.tbha-form input[type="date"][data-filled="true"]::-webkit-datetime-edit {
	color: var(--tbha-form-ink);
}

/* Native icon is a low-contrast grey glyph; make it read as a button. */
.tbha-form input[type="date"]::-webkit-calendar-picker-indicator {
	width: 1.15rem;
	height: 1.15rem;
	padding: 0;
	margin-inline-start: 0.5rem;
	opacity: 0.75;
	cursor: pointer;
	transition: opacity 150ms ease;
}

.tbha-form input[type="date"]::-webkit-calendar-picker-indicator:hover {
	opacity: 1;
}

.tbha-form :is(input, select, textarea)[aria-invalid="true"] {
	border-color: var(--tbha-form-error);
}

.tbha-form :is(input, select, textarea)[aria-invalid="true"]:focus-visible {
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--tbha-form-error) 22%, transparent);
}

/* --- Checkbox ----------------------------------------------------- */

.tbha-field--checkbox label {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr);
	gap: 0.65rem;
	align-items: start;
	font-weight: 400;
	font-size: 0.9375rem;
	line-height: 1.5;
	color: var(--tbha-form-muted);
}

.tbha-field--checkbox input {
	width: 1.15rem;
	height: 1.15rem;
	margin-top: 0.15rem;
	accent-color: var(--tbha-form-brand);
}

/* --- Messages ----------------------------------------------------- */

.tbha-field__error {
	font-size: 0.875rem;
	font-weight: 500;
	color: var(--tbha-form-error);
}

.tbha-field__hint {
	font-size: 0.8125rem;
	color: var(--tbha-form-muted);
}

.tbha-field__hint--warn {
	color: var(--tbha-form-error);
}

.tbha-alert {
	margin: 0 0 1.25rem;
	padding: 0.9rem 1.1rem;
	border-radius: var(--tbha-form-radius);
	border: 1px solid transparent;
	font-size: 0.9375rem;
}

.tbha-alert p {
	margin: 0;
}

.tbha-alert--error {
	color: var(--tbha-form-error);
	background: color-mix(in srgb, var(--tbha-form-error) 8%, transparent);
	border-color: color-mix(in srgb, var(--tbha-form-error) 30%, transparent);
}

.tbha-alert--success {
	color: var(--tbha-form-success);
	background: color-mix(in srgb, var(--tbha-form-success) 8%, transparent);
	border-color: color-mix(in srgb, var(--tbha-form-success) 30%, transparent);
}

/* Empty status node must not take up space before it has a message. */
.tbha-form__status:empty {
	display: none;
}

/* --- Actions ------------------------------------------------------ */

.tbha-form__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem 1rem;
	align-items: center;
	margin: 0;
}

.tbha-button {
	appearance: none;
	display: inline-flex;
	align-items: center;
	gap: 0.6rem;
	padding: 0.9rem 1.9rem;
	font: inherit;
	font-weight: 600;
	color: #fff;
	background: var(--tbha-form-brand);
	border: none;
	border-radius: var(--wp--custom--tbha--radius--pill, 999px);
	cursor: pointer;
	transition: transform 150ms ease, filter 150ms ease;
}

.tbha-button:hover:not(:disabled) {
	filter: brightness(0.93);
	transform: translateY(-1px);
}

.tbha-button:disabled {
	opacity: 0.65;
	cursor: progress;
	transform: none;
}

/* Spinner shown while the request is in flight. */
.tbha-button[data-busy="true"]::before {
	content: "";
	width: 1rem;
	height: 1rem;
	border: 2px solid rgba(255, 255, 255, 0.45);
	border-top-color: #fff;
	border-radius: 50%;
	animation: tbha-spin 700ms linear infinite;
}

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

.tbha-form__note {
	font-size: 0.8125rem;
	color: var(--tbha-form-muted);
}

/* --- Honeypot ----------------------------------------------------- */

.tbha-hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* --- Motion ------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	.tbha-button,
	.tbha-form :is(input, select, textarea) {
		transition: none;
	}

	.tbha-button[data-busy="true"]::before {
		animation-duration: 2s;
	}
}

/* ---------------------------------------------------------------
 * Insurance line chooser (maps to the Salesforce multi-select)
 * --------------------------------------------------------------- */

.tbha-fieldset {
	margin: 0;
	padding: 0;
	border: 0;
}

.tbha-fieldset legend {
	padding: 0;
	margin-bottom: 0.65rem;
	font-size: 0.9375rem;
	font-weight: 600;
}

.tbha-choice-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
	gap: 0.65rem;
}

/* Whole tile is the target, not just the 16px box. */
.tbha-choice {
	display: flex;
	align-items: center;
	gap: 0.6rem;
	padding: 0.85rem 1rem;
	font-size: 0.9375rem;
	font-weight: 500;
	border: 1px solid var(--tbha-form-line);
	border-radius: var(--tbha-form-radius);
	cursor: pointer;
	transition: border-color 150ms ease, background-color 150ms ease;
}

.tbha-choice:hover {
	border-color: color-mix(in srgb, var(--tbha-form-brand) 45%, transparent);
}

.tbha-choice input {
	width: 1.1rem;
	height: 1.1rem;
	accent-color: var(--tbha-form-brand);
}

.tbha-choice:has(input:checked) {
	border-color: var(--tbha-form-brand);
	background: color-mix(in srgb, var(--tbha-form-brand) 7%, transparent);
}

.tbha-choice:has(input:focus-visible) {
	outline: 3px solid var(--tbha-form-accent);
	outline-offset: 2px;
}

/* --- reCAPTCHA ---------------------------------------------------- */

/* The widget is a fixed 304px iframe; let it shrink rather than overflow. */
.tbha-field--captcha .g-recaptcha {
	transform-origin: 0 0;
	max-width: 100%;
	overflow: hidden;
}

/* The widget is a fixed 304px iframe. What matters is the width of the form
   column, not the viewport: inside the contact page's two-column layout the
   column is 297px at a 375px viewport, so a viewport-based query never fired
   and the right edge of the widget was clipped. */
@container (max-width: 22rem) {
	.tbha-field--captcha .g-recaptcha {
		transform: scale(0.85);
	}
}

@supports not (container-type: inline-size) {
	@media (max-width: 26rem) {
		.tbha-field--captcha .g-recaptcha {
			transform: scale(0.85);
		}
	}
}

/* --- Error summary ------------------------------------------------ */

.tbha-alert__list {
	margin: 0.5rem 0 0;
	padding-left: 1.2rem;
}

.tbha-alert__list li + li {
	margin-top: 0.3rem;
}

.tbha-alert__list a {
	color: inherit;
	font-weight: 500;
}

.tbha-alert[tabindex]:focus-visible {
	outline: 3px solid var(--tbha-form-error);
	outline-offset: 2px;
}

/* --- reCAPTCHA v3 -------------------------------------------------- */

/*
 * v3 floats a badge in the bottom-right corner of every page that loads it,
 * which covers page content and follows the visitor around. Google allows it
 * to be hidden as long as the branding text is shown instead, which the form
 * does in .tbha-captcha-notice.
 */
.grecaptcha-badge {
	visibility: hidden;
}

.tbha-captcha-notice {
	margin: 0;
	font-size: 0.8125rem;
	line-height: 1.5;
	color: var(--tbha-form-muted);
}

.tbha-captcha-notice a {
	color: inherit;
	text-underline-offset: 0.18em;
}

.tbha-captcha-notice a:hover {
	color: var(--tbha-form-ink);
}
