/*
 * ETV Forms — Front-end form styles
 * Phase 8: accessible form layout, field states, AJAX feedback, presets
 *
 * BEM class structure:
 *   .etv-form-wrap                 outer container div
 *   .etv-form                      <form> element
 *   .etv-form__field               individual field wrapper <div> or <fieldset>
 *   .etv-form__field--{type}       type modifier (text, email, textarea, select,
 *                                  checkbox, radio, file, submit, …)
 *   .etv-form__label               <label> or <legend>
 *   .etv-form__required            required asterisk <span>
 *   .etv-form__input               text/email/phone/url/number/file <input>
 *   .etv-form__textarea            <textarea>
 *   .etv-form__select              <select>
 *   .etv-form__options             checkbox/radio group wrapper
 *   .etv-form__option              single checkbox/radio label wrapper
 *   .etv-form__checkbox            <input type="checkbox">
 *   .etv-form__radio               <input type="radio">
 *   .etv-form__field-error         per-field error message <span>
 *   .etv-form__submit              submit <button>
 *   .etv-form__response            success/error feedback <div>
 *   .etv-form__response--success   success state
 *   .etv-form__response--error     error state
 *
 * Style presets (applied via class on .etv-form):
 *   .etv-form--card                card with shadow + padding
 *   .etv-form--bordered            bordered box
 */

/* ── Wrapper ──────────────────────────────────────────────────────────────── */

.etv-form-wrap {
	max-width: 100%;
}

/* ── Form layout ──────────────────────────────────────────────────────────── */

.etv-form {
	display: flex;
	flex-wrap: wrap;
	column-gap: 18px;
	align-items: flex-start; /* prevent fields from stretching vertically */
	/* Reset: never inherit a parent's font or colour assumptions */
	font-family: inherit;
	font-size: inherit;
	line-height: inherit;
	color: inherit;
}

/* ── Field wrapper ────────────────────────────────────────────────────────── */

.etv-form__field {
	flex: 1 1 100%; /* full width by default */
	min-width: 0;   /* prevent overflow in flex container */
	display: flex;
	flex-direction: column;
	gap: 5px;
}

.etv-form__field .label{
	margin: 0 0 -10px 0;
	text-align: left;
	color: white;
}

/* Width modifiers — half and third width fields sit side-by-side */
.etv-form__field--half {
	flex: 1 1 calc(50% - 9px);   /* 50% minus half the 18px gap */
	min-width: 180px;             /* graceful collapse on narrow containers */
}

.etv-form__field--third {
	flex: 1 1 calc(33.333% - 12px); /* 33% minus 2/3 of 18px gap */
	min-width: 140px;
}

/* Submit + Turnstile always span full width */
.etv-form__field--submit,
.etv-form__field--turnstile {
	flex: 1 1 100%;
}

/* Fieldset resets — used for checkbox/radio groups */
.etv-form__field--checkbox,
.etv-form__field--radio {
	border: none;
	margin: 0;
	padding: 0;
	min-width: 0; /* fix fieldset width in some browsers */
}

/* ── Labels ───────────────────────────────────────────────────────────────── */
.etv-form__label {
	display: block;
	font-size: 14px;
	font-weight: 600;
	color: white !important;
	cursor: default;
	margin: 0 0 -10px 0;
	text-align: left;

}

.etv-form__required {
	color: #c00;
	margin-left: 3px;
	font-weight: 700;
	line-height: 1;
}

/* ── Core input styles ────────────────────────────────────────────────────── */

.etv-form__input,
.etv-form__textarea,
.etv-form__select,
.etv-form__input--error{
	width: 100%;
	box-sizing: border-box;
	padding: 9px 12px;
	border: 1.5px solid #c3c4c7;
	border-radius: 4px;
	font-family: inherit;
	font-size: 15px;
	line-height: 1.5;
	color: #333;
	background: #fff;
	-webkit-appearance: none;
	appearance: none;
	transition: border-color .15s ease, box-shadow .15s ease;
}

/* ── Placeholder ──────────────────────────────────────────────────────────── */

.etv-form__input::placeholder,
.etv-form__textarea::placeholder {
	color: #9e9e9e;
	opacity: 1; /* Firefox fix */
}

/* ── Focus ────────────────────────────────────────────────────────────────── */

.etv-form__input:focus,
.etv-form__textarea:focus,
.etv-form__select:focus {
	border-color: #2271b1;
	box-shadow: 0 0 0 3px rgba(34, 113, 177, .20);
	outline: none;
}

/* Keyboard-only focus ring (when mouse users click, no ring; keyboard = ring) */
.etv-form__input:focus:not(:focus-visible),
.etv-form__textarea:focus:not(:focus-visible),
.etv-form__select:focus:not(:focus-visible) {
	box-shadow: none;
}

.etv-form__input:focus-visible,
.etv-form__textarea:focus-visible,
.etv-form__select:focus-visible {
	border-color: #2271b1;
	box-shadow: 0 0 0 3px rgba(34, 113, 177, .20);
	outline: none;
}

/* ── Error state ──────────────────────────────────────────────────────────── */

.etv-form__input--error,
.etv-form__textarea--error,
.etv-form__select--error {
	border-color: #c00 !important;
	box-shadow: 0 0 0 3px rgba(204, 0, 0, .12) !important;
}

/* ── Textarea ─────────────────────────────────────────────────────────────── */

.etv-form__textarea {
	resize: vertical;
	min-height: 110px;
}

/* ── Select ───────────────────────────────────────────────────────────────── */

/* Chevron arrow via inline SVG data URI */
.etv-form__select {
	background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2216%22%20height%3D%2216%22%20viewBox%3D%220%200%2016%2016%22%3E%3Cpath%20d%3D%22M4%206l4%204%204-4%22%20stroke%3D%22%23666%22%20stroke-width%3D%221.5%22%20fill%3D%22none%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E");
	background-repeat: no-repeat;
	background-position: right 10px center;
	padding-right: 36px;
	cursor: pointer;
}

/* Remove default arrow in IE / old Edge */
.etv-form__select::-ms-expand {
	display: none;
}

/* ── Checkbox & Radio ─────────────────────────────────────────────────────── */

.etv-form__options {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding-top: 2px;
}

.etv-form__option {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	font-size: 14px;
	line-height: 1.4;
	cursor: pointer;
}

.etv-form__checkbox,
.etv-form__radio {
	width: 16px;
	height: 16px;
	flex-shrink: 0;
	margin-top: 2px; /* optically align with first line of text */
	cursor: pointer;
	accent-color: #2271b1;
}

/* ── File input ───────────────────────────────────────────────────────────── */

.etv-form__field--file .etv-form__input {
	padding: 6px 12px;
	font-size: 14px;
	cursor: pointer;
	background: #fafafa;
}

.etv-form__field--file .etv-form__input::file-selector-button {
	margin-right: 10px;
	padding: 4px 12px;
	background: #f0f0f0;
	border: 1px solid #c3c4c7;
	border-radius: 3px;
	font-size: 13px;
	cursor: pointer;
}

/* ── Per-field error message ──────────────────────────────────────────────── */

.etv-form__field-error {
	font-size: 13px;
	color: #c00;
	min-height: 1.1em; /* reserve space — prevents layout shift on error appear */
	line-height: 1.3;
}

/* ── Submit button ────────────────────────────────────────────────────────── */

.etv-form__field--submit {
	margin-top: 4px;
}

.etv-form__submit {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 11px 28px;
	background: #2271b1;
	color: #fff;
	font-family: inherit;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.4;
	border: 2px solid transparent;
	border-radius: 4px;
	cursor: pointer;
	text-decoration: none;
	transition: background .15s ease, border-color .15s ease, color .15s ease;
	-webkit-appearance: none;
	appearance: none;
}

.etv-form__submit:hover {
	background: #135e96;
}

.etv-form__submit:focus-visible {
	background: #135e96;
	box-shadow: 0 0 0 3px rgba(34, 113, 177, .30);
	outline: none;
}

.etv-form__submit:disabled {
	opacity: .6;
	cursor: not-allowed;
	pointer-events: none;
}

/* ── Response area (ARIA live region) ────────────────────────────────────── */

.etv-form__response {
	border-radius: 4px;
	font-size: 14px;
	line-height: 1.5;
	transition: opacity .2s ease;
}

.etv-form__response:empty {
	display: none;
}

.etv-form__response--success {
	padding: 12px 16px;
	background: #ecfdf5;
	border: 1px solid #6ee7b7;
	color: #065f46;
}

.etv-form__response--error {
	padding: 12px 16px;
	background: #fef2f2;
	border: 1px solid #fca5a5;
	color: #7f1d1d;
}

/* ── Style presets ────────────────────────────────────────────────────────── */

/* Card: white card with soft shadow */
.etv-form--card {
	background: #fff;
	border-radius: 8px;
	box-shadow: 0 2px 18px rgba(0, 0, 0, .10);
	padding: 32px;
}

/* Bordered: simple outlined box */
.etv-form--bordered {
	border: 1px solid #ddd;
	border-radius: 6px;
	padding: 24px;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */

@media ( max-width: 600px ) {
	.etv-form--card {
		padding: 20px;
	}

	.etv-form--bordered {
		padding: 16px;
	}

	.etv-form__submit {
		width: 100%;
	}

	/* Collapse half/third to full width on small screens */
	.etv-form__field--half,
	.etv-form__field--third {
		flex: 1 1 100%;
		min-width: 0;
	}
}
