/**
 * Mini Mortgage Calculator — front-end styles.
 * Scoped under .mmc-wrap / .mmc-modal so themes stay untouched.
 */

.mmc-wrap {
	--mmc-accent: #2563eb;
	--mmc-bg: #ffffff;
	--mmc-fg: #0f172a;
	--mmc-muted: #64748b;
	--mmc-border: #e2e8f0;
	--mmc-subtle: #f8fafc;
	--mmc-radius: 14px;
	--mmc-shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);

	box-sizing: border-box;
	color: var(--mmc-fg);
	font-size: 15px;
	line-height: 1.5;
	max-width: 100%;
}

.mmc-wrap *,
.mmc-wrap *::before,
.mmc-wrap *::after,
.mmc-modal *,
.mmc-modal *::before,
.mmc-modal *::after {
	box-sizing: border-box;
}

/* ------------------------------------------------------------------ layout */

.mmc-layout-card .mmc-form {
	background: var(--mmc-bg);
	border: 1px solid var(--mmc-border);
	border-radius: var(--mmc-radius);
	box-shadow: var(--mmc-shadow);
	padding: 22px;
}

.mmc-layout-compact .mmc-form {
	background: var(--mmc-bg);
	border: 1px solid var(--mmc-border);
	border-radius: var(--mmc-radius);
	padding: 16px;
	font-size: 14px;
}

.mmc-layout-inline .mmc-form {
	padding: 0;
}

.mmc-title {
	font-size: 1.15em;
	font-weight: 700;
	letter-spacing: -0.01em;
	margin: 0 0 16px;
}

.mmc-fields {
	display: grid;
	gap: 16px;
}

.mmc-layout-card .mmc-fields {
	grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.mmc-layout-card .mmc-advanced,
.mmc-layout-card .mmc-field--full {
	grid-column: 1 / -1;
}

/* ------------------------------------------------------------------ fields */

.mmc-field {
	min-width: 0;
}

.mmc-label-row {
	align-items: center;
	display: flex;
	gap: 8px;
	justify-content: space-between;
	margin-bottom: 6px;
	min-height: 24px;
}

.mmc-wrap label {
	color: var(--mmc-fg);
	display: block;
	font-size: .875em;
	font-weight: 600;
	margin: 0;
}

.mmc-value-badge {
	background: var(--mmc-subtle);
	border-radius: 999px;
	color: var(--mmc-muted);
	font-size: .8em;
	font-variant-numeric: tabular-nums;
	font-weight: 600;
	padding: 2px 9px;
	white-space: nowrap;
}

.mmc-input-group {
	align-items: center;
	background: var(--mmc-bg);
	border: 1px solid var(--mmc-border);
	border-radius: 10px;
	display: flex;
	overflow: hidden;
	transition: border-color .15s ease, box-shadow .15s ease;
}

.mmc-input-group:focus-within {
	border-color: var(--mmc-accent);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--mmc-accent) 18%, transparent);
}

.mmc-wrap .mmc-input {
	background: transparent;
	border: 0;
	color: inherit;
	flex: 1 1 auto;
	font: inherit;
	font-variant-numeric: tabular-nums;
	margin: 0;
	min-width: 0;
	outline: 0;
	padding: 10px 12px;
	width: 100%;
}

.mmc-wrap .mmc-input:focus {
	box-shadow: none;
	outline: 0;
}

/* Hide the spin buttons; the sliders and chips cover stepping. */
.mmc-wrap .mmc-input::-webkit-outer-spin-button,
.mmc-wrap .mmc-input::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

.mmc-wrap .mmc-input[type="number"] {
	-moz-appearance: textfield;
	appearance: textfield;
}

.mmc-affix {
	color: var(--mmc-muted);
	flex: 0 0 auto;
	font-size: .875em;
	font-weight: 600;
	padding: 0 12px 0 0;
	user-select: none;
}

.mmc-affix--lead {
	padding: 0 0 0 12px;
}

.mmc-hint {
	color: var(--mmc-muted);
	font-size: .78em;
	margin: 6px 0 0;
	min-height: 1em;
}

/* ----------------------------------------------------------------- sliders */

.mmc-range {
	-webkit-appearance: none;
	appearance: none;
	background: transparent;
	display: block;
	height: 22px;
	margin: 0 0 6px;
	padding: 0;
	width: 100%;
}

.mmc-range::-webkit-slider-runnable-track {
	background: var(--mmc-border);
	border-radius: 999px;
	height: 5px;
}

.mmc-range::-moz-range-track {
	background: var(--mmc-border);
	border-radius: 999px;
	height: 5px;
}

.mmc-range::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	background: var(--mmc-accent);
	border: 3px solid #fff;
	border-radius: 50%;
	box-shadow: 0 1px 4px rgba(15, 23, 42, .3);
	cursor: grab;
	height: 18px;
	margin-top: -6.5px;
	width: 18px;
}

.mmc-range::-moz-range-thumb {
	background: var(--mmc-accent);
	border: 3px solid #fff;
	border-radius: 50%;
	box-shadow: 0 1px 4px rgba(15, 23, 42, .3);
	cursor: grab;
	height: 18px;
	width: 18px;
}

.mmc-range:focus-visible::-webkit-slider-thumb {
	box-shadow: 0 0 0 4px color-mix(in srgb, var(--mmc-accent) 25%, transparent);
}

/* -------------------------------------------------------- toggles & chips */

.mmc-toggle {
	background: var(--mmc-subtle);
	border-radius: 8px;
	display: inline-flex;
	padding: 2px;
}

.mmc-wrap .mmc-toggle-btn {
	background: transparent;
	border: 0;
	border-radius: 6px;
	color: var(--mmc-muted);
	cursor: pointer;
	font: inherit;
	font-size: .78em;
	font-weight: 700;
	line-height: 1;
	min-width: 30px;
	padding: 5px 8px;
	transition: background .15s ease, color .15s ease;
}

.mmc-wrap .mmc-toggle-btn.is-active {
	background: var(--mmc-bg);
	box-shadow: 0 1px 2px rgba(15, 23, 42, .12);
	color: var(--mmc-fg);
}

.mmc-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-bottom: 8px;
}

.mmc-wrap .mmc-chip {
	background: var(--mmc-subtle);
	border: 1px solid transparent;
	border-radius: 999px;
	color: var(--mmc-muted);
	cursor: pointer;
	font: inherit;
	font-size: .8em;
	font-weight: 600;
	line-height: 1;
	padding: 7px 13px;
	transition: all .15s ease;
}

.mmc-wrap .mmc-chip:hover {
	color: var(--mmc-fg);
}

.mmc-wrap .mmc-chip.is-active {
	background: color-mix(in srgb, var(--mmc-accent) 12%, transparent);
	border-color: var(--mmc-accent);
	color: var(--mmc-accent);
}

/* --------------------------------------------------------------- advanced */

.mmc-wrap .mmc-advanced-toggle {
	align-items: center;
	background: none;
	border: 0;
	color: var(--mmc-accent);
	cursor: pointer;
	display: inline-flex;
	font: inherit;
	font-size: .85em;
	font-weight: 600;
	gap: 7px;
	padding: 4px 0;
}

.mmc-caret {
	border-color: currentColor transparent transparent;
	border-style: solid;
	border-width: 5px 4px 0;
	display: inline-block;
	height: 0;
	transform: rotate(-90deg);
	transition: transform .18s ease;
	width: 0;
}

.mmc-advanced-toggle.is-open .mmc-caret {
	transform: rotate(0deg);
}

.mmc-advanced-panel {
	border-top: 1px dashed var(--mmc-border);
	display: grid;
	gap: 14px;
	grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
	margin-top: 12px;
	padding-top: 14px;
}

/* An explicit `display` beats the user-agent [hidden] rule, so restore it. */
.mmc-advanced-panel[hidden] {
	display: none;
}

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

.mmc-actions {
	margin-top: 18px;
}

.mmc-wrap .mmc-submit,
.mmc-modal .mmc-lead-submit {
	align-items: center;
	background: var(--mmc-accent);
	border: 0;
	border-radius: 10px;
	color: #fff;
	cursor: pointer;
	display: inline-flex;
	font: inherit;
	font-size: .95em;
	font-weight: 700;
	gap: 10px;
	justify-content: center;
	line-height: 1.2;
	padding: 13px 22px;
	position: relative;
	transition: filter .15s ease, transform .1s ease;
	width: 100%;
}

.mmc-wrap .mmc-submit:hover,
.mmc-modal .mmc-lead-submit:hover {
	filter: brightness(1.08);
}

.mmc-wrap .mmc-submit:active {
	transform: translateY(1px);
}

.mmc-wrap .mmc-submit[disabled],
.mmc-modal .mmc-lead-submit[disabled] {
	cursor: progress;
	opacity: .75;
}

.mmc-spinner {
	animation: mmc-spin .7s linear infinite;
	border: 2px solid rgba(255, 255, 255, .4);
	border-radius: 50%;
	border-top-color: #fff;
	display: none;
	height: 15px;
	width: 15px;
}

.is-busy .mmc-spinner {
	display: inline-block;
}

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

.mmc-error,
.mmc-lead-error {
	background: #fef2f2;
	border-radius: 8px;
	color: #b91c1c;
	font-size: .85em;
	margin: 10px 0 0;
	padding: 9px 12px;
}

.mmc-preview {
	align-items: baseline;
	border-top: 1px solid var(--mmc-border);
	display: flex;
	gap: 10px;
	justify-content: space-between;
	margin-top: 16px;
	padding-top: 14px;
}

.mmc-preview[hidden] {
	display: none;
}

.mmc-preview-label {
	color: var(--mmc-muted);
	font-size: .82em;
}

.mmc-preview-value {
	font-size: 1.3em;
	font-variant-numeric: tabular-nums;
	font-weight: 800;
	letter-spacing: -0.02em;
}

/* Honeypot: off-screen but not display:none, so bots still see it. */
.mmc-hp {
	height: 0;
	left: -9999px;
	overflow: hidden;
	position: absolute;
	width: 0;
}

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

body.mmc-modal-open {
	overflow: hidden;
}

.mmc-modal {
	--mmc-fg: #0f172a;
	--mmc-muted: #64748b;
	--mmc-border: #e2e8f0;
	--mmc-subtle: #f8fafc;

	align-items: center;
	bottom: 0;
	color: var(--mmc-fg);
	display: flex;
	font-size: 15px;
	justify-content: center;
	left: 0;
	line-height: 1.5;
	padding: 20px;
	position: fixed;
	right: 0;
	top: 0;
	z-index: 100000;
}

.mmc-modal[hidden] {
	display: none;
}

.mmc-modal-backdrop {
	background: rgba(15, 23, 42, .55);
	inset: 0;
	opacity: 0;
	position: absolute;
	transition: opacity .2s ease;
}

.mmc-modal.is-open .mmc-modal-backdrop {
	opacity: 1;
}

.mmc-modal-dialog {
	background: #fff;
	border-radius: 18px;
	box-shadow: 0 24px 64px rgba(15, 23, 42, .28);
	max-height: calc(100vh - 40px);
	max-width: 560px;
	opacity: 0;
	overflow-y: auto;
	position: relative;
	transform: translateY(14px) scale(.98);
	transition: opacity .22s ease, transform .22s ease;
	width: 100%;
	-webkit-overflow-scrolling: touch;
}

.mmc-modal.is-open .mmc-modal-dialog {
	opacity: 1;
	transform: none;
}

.mmc-modal-close {
	align-items: center;
	background: rgba(255, 255, 255, .9);
	border: 0;
	border-radius: 50%;
	color: var(--mmc-muted);
	cursor: pointer;
	display: flex;
	height: 34px;
	justify-content: center;
	padding: 0;
	position: absolute;
	right: 14px;
	top: 14px;
	transition: background .15s ease, color .15s ease;
	width: 34px;
	z-index: 2;
}

.mmc-modal-close:hover {
	background: #f1f5f9;
	color: var(--mmc-fg);
}

.mmc-modal-head {
	background: linear-gradient(160deg, color-mix(in srgb, var(--mmc-accent, #2563eb) 10%, #fff), #fff);
	border-bottom: 1px solid var(--mmc-border);
	padding: 30px 26px 22px;
	text-align: center;
}

.mmc-modal-eyebrow {
	color: var(--mmc-muted);
	font-size: .8em;
	font-weight: 600;
	letter-spacing: .06em;
	margin: 0 0 6px;
	text-transform: uppercase;
}

.mmc-modal .mmc-modal-total {
	color: var(--mmc-fg);
	font-size: 2.6em;
	font-variant-numeric: tabular-nums;
	font-weight: 800;
	letter-spacing: -0.03em;
	line-height: 1.05;
	margin: 0;
	padding: 0;
}

.mmc-modal-sub {
	color: var(--mmc-muted);
	font-size: .85em;
	margin: 8px 0 0;
}

.mmc-modal-body {
	padding: 22px 26px 26px;
}

/* --------------------------------------------------------------- donut */

.mmc-breakdown {
	align-items: center;
	display: grid;
	gap: 20px;
	grid-template-columns: 132px 1fr;
}

.mmc-donut-wrap {
	position: relative;
}

.mmc-donut {
	display: block;
	transform: rotate(-90deg);
	width: 100%;
}

.mmc-donut-track {
	stroke: #eef2f7;
}

.mmc-donut-seg {
	transition: stroke-dasharray .5s ease;
}

.mmc-donut-center {
	align-items: center;
	display: flex;
	flex-direction: column;
	inset: 0;
	justify-content: center;
	pointer-events: none;
	position: absolute;
}

.mmc-donut-value {
	font-size: 1.05em;
	font-variant-numeric: tabular-nums;
	font-weight: 800;
	letter-spacing: -0.02em;
}

.mmc-donut-label {
	color: var(--mmc-muted);
	font-size: .68em;
}

.mmc-modal .mmc-legend {
	list-style: none;
	margin: 0;
	padding: 0;
}

.mmc-legend-item {
	align-items: center;
	display: flex;
	font-size: .87em;
	gap: 8px;
	padding: 5px 0;
}

.mmc-swatch {
	border-radius: 3px;
	display: inline-block;
	flex: 0 0 auto;
	height: 10px;
	width: 10px;
}

.mmc-swatch--balance {
	background: var(--mmc-accent, #2563eb);
}

.mmc-legend-label {
	color: var(--mmc-muted);
	flex: 1 1 auto;
	min-width: 0;
}

.mmc-legend-value {
	font-variant-numeric: tabular-nums;
	font-weight: 700;
}

/* ---------------------------------------------------------------- stats */

.mmc-modal .mmc-stats {
	display: grid;
	gap: 1px;
	grid-template-columns: repeat(2, 1fr);
	background: var(--mmc-border);
	border: 1px solid var(--mmc-border);
	border-radius: 12px;
	margin: 22px 0 0;
	overflow: hidden;
}

.mmc-stat {
	background: #fff;
	margin: 0;
	padding: 12px 14px;
}

.mmc-stat--good {
	background: #f0fdf4;
}

.mmc-modal .mmc-stat-label {
	color: var(--mmc-muted);
	font-size: .76em;
	font-weight: 600;
	margin: 0 0 3px;
}

.mmc-modal .mmc-stat-value {
	font-size: 1em;
	font-variant-numeric: tabular-nums;
	font-weight: 700;
	margin: 0;
}

.mmc-stat--good .mmc-stat-value {
	color: #15803d;
}

/* ---------------------------------------------------------------- chart */

.mmc-chart-block {
	margin-top: 24px;
}

.mmc-chart-head {
	align-items: center;
	display: flex;
	justify-content: space-between;
	margin-bottom: 8px;
}

.mmc-modal .mmc-chart-head h4 {
	font-size: .9em;
	font-weight: 700;
	margin: 0;
	padding: 0;
}

.mmc-chart-legend {
	align-items: center;
	color: var(--mmc-muted);
	display: inline-flex;
	font-size: .76em;
	gap: 6px;
}

.mmc-linechart {
	background: var(--mmc-subtle);
	border: 1px solid var(--mmc-border);
	border-radius: 12px;
	padding: 10px 12px 8px;
}

.mmc-line-svg {
	display: block;
	height: 110px;
	width: 100%;
}

.mmc-line-path {
	stroke: var(--mmc-accent, #2563eb);
	stroke-linecap: round;
	stroke-linejoin: round;
	stroke-width: 2;
	vector-effect: non-scaling-stroke;
}

.mmc-line-area {
	fill: color-mix(in srgb, var(--mmc-accent, #2563eb) 14%, transparent);
	stroke: none;
}

.mmc-line-axis {
	color: var(--mmc-muted);
	display: flex;
	font-size: .72em;
	justify-content: space-between;
	padding-top: 4px;
}

/* ------------------------------------------------------------- schedule */

.mmc-schedule {
	border: 1px solid var(--mmc-border);
	border-radius: 12px;
	margin-top: 16px;
	overflow: hidden;
}

.mmc-schedule > summary {
	cursor: pointer;
	font-size: .87em;
	font-weight: 600;
	list-style: none;
	padding: 12px 14px;
	user-select: none;
}

.mmc-schedule > summary::-webkit-details-marker {
	display: none;
}

.mmc-schedule > summary::after {
	content: "+";
	float: right;
	font-weight: 700;
}

.mmc-schedule[open] > summary::after {
	content: "–";
}

.mmc-table-scroll {
	max-height: 260px;
	overflow: auto;
	-webkit-overflow-scrolling: touch;
}

.mmc-modal .mmc-table {
	border-collapse: collapse;
	font-size: .8em;
	margin: 0;
	width: 100%;
}

.mmc-modal .mmc-table th,
.mmc-modal .mmc-table td {
	border-bottom: 1px solid var(--mmc-border);
	font-variant-numeric: tabular-nums;
	padding: 8px 12px;
	text-align: right;
}

.mmc-modal .mmc-table thead th {
	background: var(--mmc-subtle);
	color: var(--mmc-muted);
	font-weight: 600;
	position: sticky;
	top: 0;
	z-index: 1;
}

.mmc-modal .mmc-table th:first-child,
.mmc-modal .mmc-table td:first-child {
	text-align: left;
}

.mmc-modal .mmc-table tbody th {
	font-weight: 600;
}

/* ------------------------------------------------------------ lead form */

.mmc-lead {
	background: var(--mmc-subtle);
	border: 1px solid var(--mmc-border);
	border-radius: 14px;
	margin-top: 22px;
	padding: 18px;
}

.mmc-modal .mmc-lead-title {
	font-size: 1em;
	font-weight: 700;
	margin: 0 0 4px;
	padding: 0;
}

.mmc-lead-intro {
	color: var(--mmc-muted);
	font-size: .85em;
	margin: 0 0 14px;
}

.mmc-lead-field {
	margin-bottom: 12px;
}

.mmc-modal .mmc-lead-field label {
	display: block;
	font-size: .8em;
	font-weight: 600;
	margin-bottom: 5px;
}

.mmc-optional {
	color: var(--mmc-muted);
	font-weight: 400;
}

.mmc-modal .mmc-lead-field input {
	background: #fff;
	border: 1px solid var(--mmc-border);
	border-radius: 9px;
	color: var(--mmc-fg);
	display: block;
	font: inherit;
	font-size: .92em;
	margin: 0;
	padding: 10px 12px;
	transition: border-color .15s ease, box-shadow .15s ease;
	width: 100%;
}

.mmc-modal .mmc-lead-field input:focus {
	border-color: var(--mmc-accent, #2563eb);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--mmc-accent, #2563eb) 18%, transparent);
	outline: 0;
}

.mmc-modal .mmc-lead-field input.is-invalid {
	border-color: #dc2626;
}

.mmc-field-error {
	color: #dc2626;
	display: block;
	font-size: .75em;
	margin-top: 4px;
	min-height: 1em;
}

.mmc-lead-consent {
	margin: 4px 0 14px;
}

.mmc-modal .mmc-lead-consent label {
	align-items: flex-start;
	color: var(--mmc-muted);
	display: flex;
	font-size: .78em;
	font-weight: 400;
	gap: 8px;
	line-height: 1.45;
	margin: 0;
}

.mmc-modal .mmc-lead-consent input {
	flex: 0 0 auto;
	margin: 2px 0 0;
}

.mmc-lead-success {
	padding: 12px 0;
	text-align: center;
}

.mmc-lead-success svg {
	color: #16a34a;
}

.mmc-lead-success-text {
	font-size: .95em;
	font-weight: 600;
	margin: 8px 0 0;
}

.mmc-disclaimer {
	color: var(--mmc-muted);
	font-size: .72em;
	line-height: 1.5;
	margin: 18px 0 0;
}

/* Gated mode: blur everything above the lead form until an email arrives. */
.mmc-modal.is-gated .mmc-breakdown,
.mmc-modal.is-gated .mmc-stats,
.mmc-modal.is-gated .mmc-chart-block,
.mmc-modal.is-gated .mmc-schedule,
.mmc-modal.is-gated .mmc-modal-total {
	filter: blur(9px);
	pointer-events: none;
	user-select: none;
}

.mmc-modal.is-gated .mmc-lead {
	border-color: var(--mmc-accent, #2563eb);
}

/* --------------------------------------------------------------- mobile */

@media (max-width: 600px) {
	.mmc-modal {
		align-items: flex-end;
		padding: 0;
	}

	.mmc-modal-dialog {
		border-radius: 18px 18px 0 0;
		max-height: 92vh;
		transform: translateY(24px);
	}

	.mmc-modal-body {
		padding: 18px 18px 24px;
	}

	.mmc-modal-head {
		padding: 26px 18px 20px;
	}

	.mmc-modal .mmc-modal-total {
		font-size: 2.1em;
	}

	.mmc-breakdown {
		grid-template-columns: 1fr;
		justify-items: center;
	}

	.mmc-donut-wrap {
		max-width: 150px;
		width: 100%;
	}

	.mmc-modal .mmc-legend {
		width: 100%;
	}
}

@media (prefers-reduced-motion: reduce) {
	.mmc-modal-dialog,
	.mmc-modal-backdrop,
	.mmc-donut-seg,
	.mmc-spinner {
		animation: none !important;
		transition: none !important;
	}
}

/* Dark theme support when the host theme opts in. */
@media (prefers-color-scheme: dark) {
	.mmc-wrap[data-mmc-dark="auto"] {
		--mmc-bg: #0f172a;
		--mmc-fg: #e2e8f0;
		--mmc-muted: #94a3b8;
		--mmc-border: #1e293b;
		--mmc-subtle: #111c30;
	}
}
