/* Form shell, plain step form, inputs, notices and the step-flow pieces. */

.form-shell {
	min-width: 0;
	padding: 32px;
	background: var(--fg-color-surface);
}

.form-step__title {
	margin: 0 0 24px;
	font-family: var(--fg-font-display);
	font-size: 2.2rem;
	font-weight: 400;
	line-height: 1.12;
	letter-spacing: -0.025em;
	text-wrap: balance;
}

.form-step {
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
}

.form-step + .form-step {
	margin-top: 40px;
	padding-top: 40px;
	border-top: 1px solid var(--fg-color-line);
}

.form-step__title {
	float: left;
	width: 100%;
	padding: 0;
}

.form-step__title + * {
	clear: both;
}

.form-step__text {
	margin-bottom: 24px;
}

/* Choices: radio inputs styled as the mockup's choice buttons */

.flow-choices {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.flow-choice {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	min-height: 62px;
	padding: 18px 20px;
	background: transparent;
	color: var(--fg-color-text);
	border: 1px solid var(--fg-color-line);
	text-align: left;
}

.flow-choice > span:last-child {
	color: var(--fg-color-accent);
}

label.flow-choice {
	cursor: pointer;
	justify-content: flex-start;
}

label.flow-choice > span:last-child {
	margin-left: auto;
}

label.flow-choice input {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	opacity: 0;
	cursor: pointer;
}

label.flow-choice::before {
	content: "";
	flex: 0 0 18px;
	width: 18px;
	height: 18px;
	border: 1px solid var(--fg-color-line);
	border-radius: 50%;
	background: var(--fg-color-bg);
}

label.flow-choice:has(input:checked) {
	background: var(--fg-color-surface-alt);
	border-color: var(--fg-color-accent);
	box-shadow: inset 0 0 0 1px var(--fg-color-accent);
}

label.flow-choice:has(input:checked)::before {
	border-color: var(--fg-color-accent);
	background: radial-gradient(circle, var(--fg-color-accent) 0 4px, var(--fg-color-bg) 5px);
}

label.flow-choice:has(input:focus-visible) {
	outline: 3px solid var(--fg-color-accent);
	outline-offset: 5px;
}

/* History rows and success panel (step flow) */

.flow-history {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 12px;
	padding-bottom: 16px;
	margin-bottom: 24px;
	border-bottom: 1px solid var(--fg-color-line);
}

.flow-history > * {
	min-width: 0;
}

.flow-history p {
	margin: 0;
	font-size: 0.9rem;
	overflow-wrap: anywhere;
}

.change {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	padding: 8px 0;
	background: transparent;
	border: 0;
	color: var(--fg-color-accent);
	text-decoration: underline;
}

.form-review p {
	margin-bottom: 16px;
}

/* Enhanced flow: one fieldset visible at a time, folded answers above it */

.form-shell {
	scroll-margin-top: 120px;
}

.form-flow .form-step + .form-step {
	margin: 0;
	padding: 0;
	border: 0;
}

.form-flow .form-step__title:focus {
	outline: none;
}

.flow-rows:empty {
	display: none;
}

.flow-choice[aria-pressed="true"] {
	background: var(--fg-color-surface-alt);
	border-color: var(--fg-color-accent);
	box-shadow: inset 0 0 0 1px var(--fg-color-accent);
}

/* Fields */

.form-fields {
	display: grid;
	gap: 20px;
}

.form-fields .button {
	justify-self: start;
	margin-top: 4px;
}

.field {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.field label {
	font-size: 0.95rem;
}

.field input,
.field textarea,
.field select {
	width: 100%;
	min-height: 50px;
	padding: 13px 14px;
	background: var(--fg-color-bg);
	color: var(--fg-color-text);
	border: 1px solid var(--fg-color-line);
	border-radius: var(--fg-radius-s);
}

.field textarea {
	min-height: 130px;
	resize: vertical;
}

.field input::placeholder,
.field textarea::placeholder {
	color: var(--fg-color-muted);
	opacity: 1;
}

.field input:invalid:not(:placeholder-shown) {
	border-color: var(--fg-color-accent);
}

.fg-consent {
	display: flex;
	flex-wrap: wrap;
	gap: 0 12px;
	align-items: flex-start;
	font-size: 0.94rem;
}

.fg-consent input {
	flex: 0 0 22px;
	width: 22px;
	height: 22px;
	margin: 4px 0 0;
	accent-color: var(--fg-color-accent);
}

.fg-consent label {
	flex: 1 1 0;
	min-width: 0;
}

.fg-consent__hint {
	flex-basis: 100%;
	margin: 6px 0 0 34px;
	font-size: 0.875rem;
	color: var(--fg-color-muted);
}

.form-error {
	display: block;
	margin-top: 5px;
	font-size: 0.9rem;
	color: var(--fg-color-danger);
}

.fg-consent .form-error {
	flex-basis: 100%;
}

.fg-consent input[aria-invalid="true"] {
	outline: 2px solid var(--fg-color-danger);
	outline-offset: 2px;
}

[aria-invalid="true"] {
	border-color: var(--fg-color-danger) !important;
}

/* Server notices */

.fg-form-notice {
	margin-bottom: 28px;
	padding-top: 24px;
	border-top: 1px solid var(--fg-color-accent);
}

.fg-form-notice p {
	max-width: 460px;
}

.fg-form-notice__title {
	margin-bottom: 8px;
	font-family: var(--fg-font-display);
	font-size: 1.9rem;
	line-height: 1.15;
}

.fg-form-notice--success {
	margin-bottom: 0;
}

.fg-form-notice--error {
	border-top-color: var(--fg-color-danger);
}

.fg-form-notice--error .fg-form-notice__title {
	color: var(--fg-color-danger);
}

@media (hover: hover) and (pointer: fine) {
	.flow-choice:hover {
		background: var(--fg-color-surface-alt);
	}
}

@media (max-width: 700px) {
	.form-shell {
		padding: 26px 20px;
	}

	.form-step__title {
		font-size: 1.9rem;
	}
}
