/*
 * Ax Forms — the plugin's own rules: pages and inserted forms.
 *
 * Not the forms' look. The look is the site's DEFAULT STYLES, kept in Forms →
 * Settings → General and edited there, and each form may add its own on top.
 * These are what make a form in pages show one page at a time and an inserted
 * form's questions sit in the outer form's rows — machinery a stylesheet edit
 * must not be able to break — so they are always loaded, after the default
 * styles, and are never copied into a form's stylesheet.
 */

/*
 * ANOTHER FORM, INSERTED. No box of its own: the section and its body step out
 * of the layout, so its questions are rows of this form's grid — a half-width
 * question beside one of the outer form's, the same gaps, nothing to show where
 * one form ends and the other begins. Put away by its conditions, it is gone.
 */
.section--embedded,
.section--embedded > .section__body {
	display: contents;
}

.section--embedded[hidden],
.section--embedded.hidden {
	display: none;
}

/* -- Pages ------------------------------------------------------------------
   A form shown a page at a time. Only with a script: without one every page is
   on screen, one under the other, and the steps and Back / Next are not drawn. */

.form__steps,
.form__page-nav {
	display: none;
}

.forms-js form[data-paged] .form__page:not(.is-current) {
	display: none;
}

/* The form's own button, and what comes with it (the total, the consent), under the last page only. */
.forms-js form[data-paged][data-page-last='0'] :is(.form__actions, .form__finish) {
	display: none;
}

form[data-paged] .form__steps {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4em 1.2em;
	margin: 0 0 1.4em;
	padding: 0;
	list-style: none;
	counter-reset: none;
}

.form__step[hidden] {
	display: none;
}

.form__step-button {
	display: inline-flex;
	align-items: center;
	gap: 0.5em;
	padding: 0.2em 0;
	font: inherit;
	font-size: 0.9em;
	color: var(--muted);
	background: none;
	border: 0;
	border-bottom: 2px solid transparent;
	cursor: pointer;
}

.form__step-button:disabled {
	cursor: default;
	opacity: 0.55;
}

.form__step-button[aria-current='step'] {
	color: var(--ink);
	font-weight: 620;
	border-bottom-color: var(--accent);
}

.form__step-number {
	display: inline-grid;
	place-items: center;
	width: 1.6em;
	height: 1.6em;
	font-size: 0.85em;
	font-variant-numeric: tabular-nums;
	border-radius: 999px;
	border: 1px solid var(--line-strong, var(--line));
}

.form__step.is-passed .form__step-number,
.form__step-button[aria-current='step'] .form__step-number {
	color: var(--accent-ink);
	background: var(--accent);
	border-color: var(--accent);
}

.form__body > .form__page {
	padding-bottom: 0;
	border-bottom: 0;
}

.form__page-title {
	font-size: 1.1em;
}

form[data-paged] .form__page-nav {
	display: flex;
	gap: 0.8em;
	justify-content: space-between;
	align-items: center;
	margin-top: 1.4em;
}

.form__page-nav [hidden] {
	display: none;
}

.form__next {
	margin-left: auto;
	font: inherit;
	font-weight: 620;
	padding: 0.75em 1.9em;
	min-height: 2.9em;
	border: 0;
	border-radius: 999px;
	background: var(--button, var(--accent));
	color: var(--accent-ink);
	cursor: pointer;
}

.form__next:hover:not(:disabled) {
	background: var(--button-hover, var(--accent));
}

.form__next:disabled,
.form__page[aria-busy='true'] .form__next {
	opacity: 0.6;
	cursor: progress;
}

.form__back {
	font: inherit;
	font-weight: 600;
	padding: 0.75em 1.2em;
	min-height: 2.9em;
	border: 0;
	border-radius: 999px;
	background: none;
	color: var(--muted);
	cursor: pointer;
}

.form__back:hover {
	color: var(--ink);
}

/* The way pages change: in from the side they come from, or a fade. */
.form__page.is-leaving--slide.is-leaving--next {
	animation: axf-page-out-left 0.18s ease-in both;
}

.form__page.is-leaving--slide.is-leaving--back {
	animation: axf-page-out-right 0.18s ease-in both;
}

.form__page.is-entering--slide.is-entering--next {
	animation: axf-page-in-right 0.26s ease-out both;
}

.form__page.is-entering--slide.is-entering--back {
	animation: axf-page-in-left 0.26s ease-out both;
}

.form__page.is-leaving--fade {
	animation: axf-page-fade-out 0.16s ease-in both;
}

.form__page.is-entering--fade {
	animation: axf-page-fade-in 0.24s ease-out both;
}

@keyframes axf-page-out-left {
	to { opacity: 0; transform: translateX(-2.5rem); }
}

@keyframes axf-page-out-right {
	to { opacity: 0; transform: translateX(2.5rem); }
}

@keyframes axf-page-in-right {
	from { opacity: 0; transform: translateX(2.5rem); }
}

@keyframes axf-page-in-left {
	from { opacity: 0; transform: translateX(-2.5rem); }
}

@keyframes axf-page-fade-out {
	to { opacity: 0; }
}

@keyframes axf-page-fade-in {
	from { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
	.form__page[class*='is-entering'],
	.form__page[class*='is-leaving'] {
		animation: none;
	}
}
