/* Mammoth Forms — frontend. Deliberately light-touch so themes keep control. */

.mammoth-form-wrap {
	--mammoth-gap: 16px;
	--mammoth-radius: 6px;
	--mammoth-border: #d6dbe1;
	--mammoth-accent: #2563eb;
	--mammoth-error: #c0392b;
	--mammoth-muted: #6b7280;
	max-width: 100%;
}

.mammoth-form .mammoth-fields {
	display: flex;
	flex-wrap: wrap;
	margin: 0 calc(var(--mammoth-gap) / -2);
}

.mammoth-form .mammoth-field {
	box-sizing: border-box;
	padding: 0 calc(var(--mammoth-gap) / 2);
	margin-bottom: var(--mammoth-gap);
	flex: 0 0 100%;
	max-width: 100%;
	min-width: 0;
}

.mammoth-form .mammoth-w-75 { flex-basis: 75%; max-width: 75%; }
.mammoth-form .mammoth-w-66 { flex-basis: 66.6666%; max-width: 66.6666%; }
.mammoth-form .mammoth-w-50 { flex-basis: 50%; max-width: 50%; }
.mammoth-form .mammoth-w-33 { flex-basis: 33.3333%; max-width: 33.3333%; }
.mammoth-form .mammoth-w-25 { flex-basis: 25%; max-width: 25%; }

@media (max-width: 640px) {
	.mammoth-form .mammoth-field {
		flex-basis: 100%;
		max-width: 100%;
	}
}

.mammoth-form .mammoth-label {
	display: block;
	font-weight: 600;
	margin-bottom: 4px;
}

.mammoth-form .mammoth-req {
	color: var(--mammoth-error);
}

.mammoth-form .mammoth-desc {
	color: var(--mammoth-muted);
	font-size: 0.875em;
	margin-top: 4px;
}

.mammoth-form .mammoth-input {
	width: 100%;
	box-sizing: border-box;
	padding: 9px 11px;
	border: 1px solid var(--mammoth-border);
	border-radius: var(--mammoth-radius);
	background: #fff;
	color: inherit;
	font: inherit;
	line-height: 1.4;
}

.mammoth-form .mammoth-input:focus {
	outline: 2px solid var(--mammoth-accent);
	outline-offset: 1px;
	border-color: var(--mammoth-accent);
}

.mammoth-form .mammoth-input-wrap {
	display: flex;
	align-items: center;
	gap: 6px;
}

.mammoth-form .mammoth-affix {
	color: var(--mammoth-muted);
	white-space: nowrap;
}

/*
 * Theme-proofing. Themes size inputs with element selectors (OceanWP gives
 * number inputs a fixed narrow width on phones, Astra a fixed select
 * height); these rules are one class more specific so the form keeps its
 * own layout. The input shrinks next to a prefix/suffix instead of pushing
 * it out of the box.
 */
.mammoth-form .mammoth-input-wrap .mammoth-input {
	flex: 1 1 0%;
	width: 100%;
	min-width: 0;
	max-width: none;
	height: auto;
	margin: 0;
}

.mammoth-form .mammoth-input-wrap .mammoth-range {
	padding: 0;
	border: 0;
	background: transparent;
}

.mammoth-form select.mammoth-input[multiple] {
	height: auto;
	min-height: 6.5em;
	padding: 4px;
	background-image: none;
	overflow-y: auto;
}

.mammoth-form select.mammoth-input:not([multiple]) {
	-webkit-appearance: none;
	-moz-appearance: none;
	appearance: none;
	padding-right: 34px;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%236b7280' stroke-width='1.6' d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 12px center;
	background-size: 12px 8px;
}

.mammoth-form .mammoth-anchor,
.mammoth-anchor {
	display: block;
	height: 0;
	scroll-margin-top: 80px;
}

.mammoth-form .mammoth-choices {
	display: flex;
	flex-direction: column;
	gap: 6px;
	width: 100%;
}

.mammoth-form .mammoth-choice {
	display: flex;
	align-items: center;
	gap: 8px;
	cursor: pointer;
}

.mammoth-form .mammoth-choice-input {
	margin: 0;
	flex: 0 0 auto;
}

.mammoth-form .mammoth-slider-row {
	display: flex;
	align-items: center;
	gap: 12px;
	width: 100%;
}

.mammoth-form .mammoth-range {
	flex: 1 1 auto;
	width: 100%;
}

.mammoth-form .mammoth-range-out {
	min-width: 4em;
	text-align: right;
	font-variant-numeric: tabular-nums;
	font-weight: 600;
}

.mammoth-form .mammoth-calc-display {
	display: flex;
	align-items: baseline;
	gap: 2px;
	padding: 10px 12px;
	border: 1px solid var(--mammoth-border);
	border-radius: var(--mammoth-radius);
	background: #f6f8fa;
	font-size: 1.15em;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	width: 100%;
	box-sizing: border-box;
}

.mammoth-form .mammoth-calc-prefix,
.mammoth-form .mammoth-calc-suffix {
	font-weight: 600;
	opacity: 0.75;
}

.mammoth-form .mammoth-heading {
	margin: 8px 0 0;
}

.mammoth-form .mammoth-divider {
	border: 0;
	border-top: 1px solid var(--mammoth-border);
	margin: 4px 0;
}

.mammoth-form .mammoth-error {
	color: var(--mammoth-error);
	font-size: 0.875em;
	margin-top: 4px;
}

.mammoth-form .mammoth-error:empty {
	display: none;
}

.mammoth-form .mammoth-has-error .mammoth-input,
.mammoth-form .mammoth-has-error .mammoth-calc-display {
	border-color: var(--mammoth-error);
}

.mammoth-form .mammoth-hidden-field,
.mammoth-form .mammoth-hidden-by-logic,
.mammoth-form .mammoth-hp {
	display: none !important;
}

.mammoth-form .mammoth-actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px;
	margin-top: 4px;
}

.mammoth-form .mammoth-submit {
	background: var(--mammoth-accent);
	color: #fff;
	border: 0;
	border-radius: var(--mammoth-radius);
	padding: 11px 22px;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}

.mammoth-form .mammoth-submit:disabled {
	opacity: 0.6;
	cursor: default;
}

/* "Save and continue later": a quieter second button. */
.mammoth-form .mammoth-save-later {
	background: transparent;
	color: var(--mammoth-accent);
	border: 1px solid currentColor;
	border-radius: var(--mammoth-radius);
	padding: 10px 18px;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}

.mammoth-form .mammoth-save-later:disabled {
	opacity: 0.6;
	cursor: default;
}

.mammoth-form .mammoth-resume-row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
}

.mammoth-form .mammoth-resume-link {
	overflow-wrap: anywhere;
	min-width: 0;
}

.mammoth-form .mammoth-resume-copy {
	font: inherit;
	font-size: 0.9em;
	padding: 4px 10px;
	border: 1px solid var(--mammoth-border);
	border-radius: var(--mammoth-radius);
	background: #fff;
	color: inherit;
	cursor: pointer;
}

/* Number range: two boxes side by side. */
.mammoth-form .mammoth-range-pair {
	display: flex;
	align-items: center;
	gap: 8px;
	width: 100%;
	min-width: 0;
}

.mammoth-form .mammoth-range-end {
	display: flex;
	align-items: center;
	gap: 6px;
	flex: 1 1 0%;
	min-width: 0;
}

.mammoth-form .mammoth-range-sep {
	color: var(--mammoth-muted);
}

/* Address: street lines across, city and postal code side by side. */
.mammoth-form .mammoth-address {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
	gap: 10px 12px;
	width: 100%;
}

.mammoth-form .mammoth-address-street,
.mammoth-form .mammoth-address-street2 {
	grid-column: 1 / -1;
}

.mammoth-form .mammoth-address-part {
	min-width: 0;
}

.mammoth-form .mammoth-address .mammoth-input {
	display: block;
	flex: none;
	width: 100%;
	box-sizing: border-box;
}

.mammoth-form .mammoth-sublabel {
	display: block;
	margin-top: 3px;
	font-size: 0.8em;
	color: var(--mammoth-muted);
}

@media (max-width: 480px) {
	.mammoth-form .mammoth-address {
		grid-template-columns: minmax(0, 1fr);
	}
}

.mammoth-form.mammoth-busy .mammoth-spinner {
	display: inline-block;
	width: 16px;
	height: 16px;
	border: 2px solid var(--mammoth-border);
	border-top-color: var(--mammoth-accent);
	border-radius: 50%;
	animation: mammoth-spin 0.7s linear infinite;
}

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

.mammoth-message {
	margin-top: 12px;
}

.mammoth-message:empty {
	display: none;
}

.mammoth-message-success {
	padding: 12px 14px;
	border-radius: var(--mammoth-radius);
	background: #e8f6ee;
	border: 1px solid #a8dcc0;
}

.mammoth-message-error {
	padding: 12px 14px;
	border-radius: var(--mammoth-radius);
	background: #fdecea;
	border: 1px solid #f5b7b1;
	color: var(--mammoth-error);
}

.mammoth-notice {
	padding: 10px 12px;
	border-left: 4px solid var(--mammoth-accent);
	background: #f6f8fa;
}

.mammoth-notice-error {
	border-left-color: var(--mammoth-error);
}

/* Labels beside the field. */
.mammoth-form.mammoth-labels-left .mammoth-field {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
}

.mammoth-form.mammoth-labels-left .mammoth-label {
	flex: 0 0 34%;
	margin: 0;
	padding-right: 12px;
	box-sizing: border-box;
}

.mammoth-form.mammoth-labels-left .mammoth-input-wrap {
	flex: 1 1 60%;
}

.mammoth-form.mammoth-labels-left .mammoth-desc,
.mammoth-form.mammoth-labels-left .mammoth-error {
	flex: 0 0 100%;
	margin-left: 34%;
}

/* Formula problems, shown above a form only to people who can edit it. */
.mammoth-admin-only ul {
	margin: 0.4em 0 0.4em 1.2em;
	padding: 0;
}
.mammoth-admin-only p {
	margin: 0.3em 0;
}

/* Image */
.mammoth-form .mammoth-image {
	margin: 0;
	text-align: center;
}
.mammoth-form .mammoth-image img {
	display: inline-block;
	max-width: 100%;
	height: auto;
	border-radius: var(--mammoth-radius);
	vertical-align: middle;
}
.mammoth-form .mammoth-align-left { text-align: left; }
.mammoth-form .mammoth-align-right { text-align: right; }
.mammoth-form .mammoth-align-wide img { width: 100%; }
.mammoth-form .mammoth-image-caption {
	margin-top: 6px;
	font-size: .875em;
	color: var(--mammoth-muted);
}

/* Table */
.mammoth-form .mammoth-table-title {
	display: block;
	margin-bottom: 6px;
}
.mammoth-form .mammoth-table-scroll {
	overflow-x: auto;
}
.mammoth-form .mammoth-table {
	width: 100%;
	border-collapse: collapse;
	font-variant-numeric: tabular-nums;
	margin: 0;
}
.mammoth-form .mammoth-table th,
.mammoth-form .mammoth-table td {
	padding: 8px 12px;
	border-bottom: 1px solid var(--mammoth-border);
	text-align: left;
	vertical-align: top;
}
.mammoth-form .mammoth-table th:not(:first-child),
.mammoth-form .mammoth-table td:not(:first-child) {
	text-align: right;
}
.mammoth-form .mammoth-table thead th {
	font-weight: 600;
	border-bottom-width: 2px;
}
.mammoth-form .mammoth-table tfoot td {
	font-weight: 700;
	border-top: 2px solid var(--mammoth-border);
	border-bottom: 0;
}

/* After a submission with "hide the form" */
.mammoth-form.mammoth-done .mammoth-fields,
.mammoth-form.mammoth-done .mammoth-actions,
.mammoth-form.mammoth-done .mammoth-form-description {
	display: none;
}
.mammoth-form .mammoth-message table {
	border-collapse: collapse;
	width: 100%;
}
.mammoth-form .mammoth-message th,
.mammoth-form .mammoth-message td {
	padding: 6px 8px;
	border-bottom: 1px solid var(--mammoth-border);
	text-align: left;
}

/* ------------------------------------------------------------ choices: buttons */
.mammoth-form .mammoth-choices-buttons {
	flex-direction: row;
	flex-wrap: wrap;
	gap: 8px;
}
.mammoth-form .mammoth-choices-buttons .mammoth-choice {
	position: relative;
	padding: 8px 14px;
	border: 1.5px solid var(--mammoth-border);
	border-radius: var(--mammoth-radius);
	background: var(--mammoth-surface, #fff);
	transition: border-color .15s, box-shadow .15s, background-color .15s;
}
.mammoth-form .mammoth-choices-buttons .mammoth-choice-input {
	position: absolute;
	opacity: 0;
	width: 1px;
	height: 1px;
}
.mammoth-form .mammoth-choices-buttons .mammoth-choice:hover {
	border-color: var(--mammoth-accent);
}
.mammoth-form .mammoth-choices-buttons .mammoth-choice:has(input:checked) {
	border-color: var(--mammoth-accent);
	background: var(--mammoth-accent);
	color: var(--mammoth-on-accent, #fff);
}
.mammoth-form .mammoth-choices-buttons .mammoth-choice:has(input:focus-visible) {
	outline: 2px solid var(--mammoth-accent);
	outline-offset: 2px;
}

/* ------------------------------------------------------------ consent and bot check */
.mammoth-form .mammoth-consent { align-items: flex-start; }
.mammoth-form .mammoth-consent .mammoth-choice-input { margin-top: .25em; }
.mammoth-form .mammoth-captcha { margin: 0 0 var(--mammoth-gap); }
.mammoth-form .mammoth-captcha-note { font-size: .75em; color: var(--mammoth-muted); margin: 0 0 var(--mammoth-gap); }

/* ------------------------------------------------------------ width and size */
.mammoth-form-wrap.mammoth-width-720 { max-width: 720px; margin-left: auto; margin-right: auto; }
.mammoth-form-wrap.mammoth-width-560 { max-width: 560px; margin-left: auto; margin-right: auto; }
.mammoth-size-large .mammoth-form { font-size: 1.125em; }
.mammoth-size-large .mammoth-form .mammoth-input { padding: 12px 14px; }
.mammoth-size-large .mammoth-form .mammoth-submit { padding: 14px 28px; }

/* ------------------------------------------------------------ styles */
.mammoth-theme-clean {
	--mammoth-accent: #111827;
	--mammoth-border: #e5e7eb;
	--mammoth-radius: 8px;
}
.mammoth-theme-clean .mammoth-form .mammoth-input,
.mammoth-theme-clean .mammoth-form select,
.mammoth-theme-clean .mammoth-form textarea {
	background: #f9fafb;
}
.mammoth-theme-rounded {
	--mammoth-accent: #7c3aed;
	--mammoth-border: #e4e4e7;
	--mammoth-radius: 16px;
}
.mammoth-theme-rounded .mammoth-form .mammoth-submit { border-radius: 999px; }
@media (prefers-reduced-motion: reduce) {
	.mammoth-form .mammoth-choice { transition: none; }
}
