/*
 * Submit My Application — front-end styles.
 *
 * Everything is scoped under .sma and leans on custom properties, so a theme can
 * restyle the form by redefining the variables instead of fighting selectors.
 * The Astra/Thrive pages this ships on set their own fonts and colours, so the
 * defaults here stay neutral and inherit wherever that is sensible.
 */

.sma {
	--sma-max-width: 720px;
	--sma-radius: 10px;
	--sma-gap: 18px;
	--sma-border: #d9dde3;
	--sma-border-focus: #1b4a6b;
	--sma-bg: #fff;
	--sma-fg: inherit;
	--sma-muted: #6b7280;
	--sma-error: #b3261e;
	--sma-success: #1a7f45;
	--sma-accent: #1b4a6b;
	--sma-accent-fg: #fff;
	--sma-shadow: 0 10px 40px rgba(16, 24, 40, .14);
	--sma-duration: 420ms;
	--sma-ease: cubic-bezier(.22, .61, .36, 1);

	box-sizing: border-box;
	color: var(--sma-fg);
	text-align: left;
}

/*
 * The doubled class is deliberate. Thrive ships `.thrv_wrapper div { box-sizing:
 * content-box }`, which outranks a single class and would otherwise make every
 * padded box in this form overflow its own width.
 */
.sma.sma,
.sma.sma *,
.sma.sma *::before,
.sma.sma *::after {
	box-sizing: border-box;
}

/* ---------- inline / expanded ---------- */

/*
 * The panel animates on grid-template-rows rather than max-height: the row
 * resolves to the content's real height, so there is no guessed maximum to
 * overshoot and no jump when the content is taller than expected.
 */
.sma--expanded .sma__panel {
	display: grid;
	grid-template-rows: 0fr;
	opacity: 0;
	transition:
		grid-template-rows var(--sma-duration) var(--sma-ease),
		opacity calc(var(--sma-duration) * .7) var(--sma-ease);
}

.sma--expanded .sma__panel > .sma__inner {
	min-height: 0;
	overflow: hidden;
	transform: translateY(-8px);
	transition: transform var(--sma-duration) var(--sma-ease);
}

.sma--expanded.is-open .sma__panel {
	grid-template-rows: 1fr;
	opacity: 1;
}

.sma--expanded.is-open .sma__panel > .sma__inner {
	transform: none;
}

/*
 * While open, the overflow clip has to go or the focus ring on the last field
 * and any native dropdown would be cut off. It is removed only once the
 * expansion has finished, which the script marks with .is-settled.
 */
.sma--expanded.is-settled .sma__panel > .sma__inner {
	overflow: visible;
}

/*
 * The explicit width matters: auto margins stop a grid item from stretching, so
 * without it the panel would shrink-to-fit its text and ignore --sma-max-width.
 */
.sma--expanded .sma__inner {
	width: 100%;
	max-width: var(--sma-max-width);
	margin-left: var(--sma-align, var(--sma-align-left, auto));
	margin-right: var(--sma-align, var(--sma-align-right, auto));
}

.sma--expanded.is-open .sma__inner {
	padding: clamp(20px, 4vw, 36px) 0;
}

/* ---------- modal ---------- */

/*
 * The wrapper only ever holds the overlay, which is fixed-position, so it must
 * take no room where the shortcode sits in the page.
 */
.sma--popup {
	display: contents;
}

.sma__overlay {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: flex-start;
	justify-content: center;
	padding: clamp(12px, 5vh, 56px) 16px;
	overflow-y: auto;
	background: rgba(16, 24, 40, .55);
	opacity: 0;
	transition: opacity 260ms var(--sma-ease);
	-webkit-overflow-scrolling: touch;
}

.sma__overlay[hidden] {
	display: none;
}

.sma.is-open .sma__overlay {
	opacity: 1;
}

.sma__dialog {
	position: relative;
	width: 100%;
	max-width: var(--sma-max-width);
	margin: auto;
	padding: clamp(22px, 4vw, 40px);
	border-radius: var(--sma-radius);
	background: var(--sma-bg);
	box-shadow: var(--sma-shadow);
	transform: translateY(14px) scale(.985);
	opacity: 0;
	transition:
		transform 320ms var(--sma-ease),
		opacity 260ms var(--sma-ease);
}

.sma.is-open .sma__dialog {
	transform: none;
	opacity: 1;
}

.sma__close {
	position: absolute;
	top: 10px;
	right: 10px;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--sma-muted);
	font-size: 28px;
	line-height: 1;
	cursor: pointer;
	transition: background 160ms, color 160ms;
}

.sma__close:hover,
.sma__close:focus-visible {
	background: rgba(16, 24, 40, .07);
	color: inherit;
}

/* While a modal is open the page behind it must not scroll. */
body.sma-locked {
	overflow: hidden;
}

/* ---------- shared form ---------- */

.sma__head {
	margin-bottom: var(--sma-gap);
}

.sma__title {
	margin: 0 0 .35em;
	font-size: clamp(1.25rem, 2.4vw, 1.6rem);
	line-height: 1.25;
}

.sma__intro {
	margin: 0;
	color: var(--sma-muted);
	font-size: .95rem;
	line-height: 1.5;
}

.sma__required-note {
	margin: 0 0 var(--sma-gap);
	color: var(--sma-muted);
	font-size: .8rem;
}

.sma__field {
	margin-bottom: var(--sma-gap);
}

.sma__label {
	display: block;
	margin-bottom: 6px;
	font-size: .9rem;
	font-weight: 600;
}

.sma__req {
	color: var(--sma-error);
}

.sma__input {
	display: block;
	width: 100%;
	padding: 11px 13px;
	border: 1px solid var(--sma-border);
	border-radius: 7px;
	background: var(--sma-bg);
	color: inherit;
	font: inherit;
	font-size: 1rem;
	line-height: 1.4;
	transition: border-color 160ms, box-shadow 160ms;
}

.sma__input:focus {
	border-color: var(--sma-border-focus);
	box-shadow: 0 0 0 3px rgba(27, 74, 107, .16);
	outline: none;
}

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

.sma__field.has-error .sma__input,
.sma__field.has-error .sma__file {
	border-color: var(--sma-error);
}

.sma__field.has-error .sma__input:focus {
	box-shadow: 0 0 0 3px rgba(179, 38, 30, .15);
}

/* ---------- file field ---------- */

.sma__file {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 9px 12px;
	border: 1px dashed var(--sma-border);
	border-radius: 7px;
	transition: border-color 160ms, background 160ms;
}

.sma__file:focus-within {
	border-color: var(--sma-border-focus);
	border-style: solid;
}

.sma__file.is-dragover {
	border-color: var(--sma-accent);
	background: rgba(27, 74, 107, .05);
}

.sma__file-input {
	flex: 0 1 auto;
	min-width: 0;
	max-width: 100%;
	font: inherit;
	font-size: .9rem;
}

.sma__file-name {
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	color: var(--sma-muted);
	font-size: .85rem;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.sma__hint {
	display: block;
	margin-top: 6px;
	color: var(--sma-muted);
	font-size: .8rem;
}

.sma__error {
	display: none;
	margin-top: 6px;
	color: var(--sma-error);
	font-size: .82rem;
	line-height: 1.4;
}

.sma__error.is-visible {
	display: block;
}

/* Honeypot: out of sight, out of the tab order, still submitted by bots. */
.sma__hp {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* ---------- actions ---------- */

.sma__actions {
	margin-top: calc(var(--sma-gap) + 4px);
}

.sma__submit {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 13px 28px;
	border: 0;
	border-radius: 7px;
	background: var(--sma-accent);
	color: var(--sma-accent-fg);
	font: inherit;
	font-size: 1rem;
	font-weight: 600;
	line-height: 1;
	cursor: pointer;
	transition: filter 160ms, transform 160ms, opacity 160ms;
}

.sma__submit:hover:not(:disabled) {
	filter: brightness(1.08);
}

.sma__submit:active:not(:disabled) {
	transform: translateY(1px);
}

.sma__submit:disabled {
	cursor: default;
	opacity: .65;
}

.sma__spinner {
	display: none;
	width: 15px;
	height: 15px;
	border: 2px solid currentColor;
	border-right-color: transparent;
	border-radius: 50%;
	animation: sma-spin 700ms linear infinite;
}

.sma.is-sending .sma__spinner {
	display: block;
}

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

/* ---------- status ---------- */

.sma__status {
	margin: var(--sma-gap) 0 0;
	font-size: .92rem;
	line-height: 1.5;
}

.sma__status:empty {
	margin: 0;
}

.sma__status--error {
	color: var(--sma-error);
}

.sma__status--success {
	padding: 14px 16px;
	border-radius: 7px;
	background: rgba(26, 127, 69, .09);
	color: var(--sma-success);
	font-weight: 600;
}

/* Once sent, the fields go and only the confirmation remains. */
.sma.is-sent .sma__field,
.sma.is-sent .sma__actions,
.sma.is-sent .sma__required-note,
.sma.is-sent .sma__intro {
	display: none;
}

/* ---------- motion ---------- */

@media (prefers-reduced-motion: reduce) {
	.sma *,
	.sma *::before,
	.sma *::after {
		transition-duration: 1ms !important;
		animation-duration: 1ms !important;
		animation-iteration-count: 1 !important;
	}

	.sma__spinner {
		animation: none;
		border-right-color: currentColor;
		opacity: .5;
	}
}

/* ---------- small screens ---------- */

@media (max-width: 600px) {
	.sma__dialog {
		padding: 26px 18px;
	}

	.sma__submit {
		width: 100%;
		justify-content: center;
	}
}
