/* MemberMath v1.3.0 — dark design system (approved mockup v4).
 * Every color and font flows through CSS custom properties set inline by the
 * shortcode from WP Admin settings. Inputs carry hard resets so The7 /
 * Elementor form styling cannot bleed in. */

.membermath {
	--mm-bg1: #0b3866;
	--mm-bg2: #062748;
	--mm-ink: #ffffff;
	--mm-ink-soft: #b8d4ea;
	--mm-accent: #00ace7;
	--mm-light: #9fdbef;
	--mm-cta: #00ace7;
	--mm-cta-ink: #ffffff;
	--mm-green: #7ee2a8;
	--mm-red: #ffb3b3;
	--mm-font-head: "Roboto Slab", Georgia, serif;
	--mm-font-body: "Noto Sans", -apple-system, sans-serif;

	font-family: var(--mm-font-body);
	background: linear-gradient(165deg, var(--mm-bg1), var(--mm-bg2));
	border-radius: 16px;
	/* The card contributes zero space above itself — external spacing
	 * belongs to Elementor. Interior padding is the original 28px
	 * (v1.4.4 revert of the 10px top experiment). */
	margin-top: 0;
	padding: 28px;
	color: var(--mm-ink);
	max-width: 720px;
	margin: 0 auto;
	box-shadow: 0 8px 30px rgba(4, 32, 61, 0.25);
}

.membermath *,
.membermath *::before,
.membermath *::after { box-sizing: border-box; }

.membermath .mm-loading,
.membermath .mm-error { padding: 10px 4px; color: var(--mm-ink-soft); font-size: 0.95em; }
.membermath .mm-error { color: var(--mm-red); }

.membermath .mm-title {
	font-family: var(--mm-font-head);
	font-weight: 800;
	font-size: 26px;
	line-height: 1.2;
	margin: 0 0 6px;
	color: var(--mm-ink);
}

.membermath .mm-sub { margin: 0 0 22px; color: var(--mm-ink-soft); font-size: 15px; }

/* ------------------------------------------------------------------ */
/* Tabs                                                                */
/* ------------------------------------------------------------------ */

.membermath .mm-tabs {
	display: flex;
	gap: 8px;
	margin: 0 0 14px;
	background: rgba(255, 255, 255, 0.08);
	padding: 5px;
	border-radius: 12px;
}

.membermath .mm-tab {
	appearance: none;
	-webkit-appearance: none;
	background: none;
	border: 0;
	box-shadow: none;
	flex: 1;
	text-align: center;
	padding: 11px 8px;
	border-radius: 8px;
	font-family: var(--mm-font-body);
	font-weight: 700;
	font-size: 14px;
	line-height: 1.3;
	color: var(--mm-ink-soft);
	cursor: pointer;
	margin: 0;
}

.membermath .mm-tabs[hidden] { display: none; }
.membermath .mm-tab.is-active { background: #fff; color: #0b2b4a; }
.membermath .mm-tab:focus-visible { outline: 3px solid var(--mm-accent); outline-offset: 1px; }

.membermath .mm-tab-sub { margin: 0 0 18px; color: var(--mm-ink-soft); font-size: 14px; }
.membermath .mm-tab-sub[hidden] { display: none; }

/* ------------------------------------------------------------------ */
/* Form grid & fields                                                  */
/* ------------------------------------------------------------------ */

/* minmax(0, …) + min-width: 0 let cells SHRINK below their content's
 * intrinsic width (v1.5.6): plain 1fr columns refuse to go narrower than
 * the nowrap EST/AUTO pills + the %-segment, so once ZIP estimates
 * prefilled, the grid pushed wider than the card on desktop. */
.membermath .mm-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px 16px; }
.membermath .mm-grid > * { min-width: 0; }
.membermath .mm-span2 { grid-column: 1 / -1; }

/* Positioning context for the field-width tooltip bubble (v1.6.2). */
.membermath .mm-field { position: relative; }

.membermath .mm-field label {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 8px;
	font-weight: 700;
	font-size: 13.5px;
	margin: 0 0 7px;
	color: var(--mm-ink);
	line-height: 1.35;
}

.membermath .mm-label { display: inline-flex; align-items: center; gap: 6px; }
.membermath .mm-req { color: var(--mm-light); font-weight: 400; font-size: 12px; }
.membermath .mm-opt { color: var(--mm-ink-soft); font-weight: 400; font-size: 12px; }

.membermath .mm-input {
	display: flex;
	align-items: center;
	background: #fff;
	border-radius: 10px;
	border: 0;
	overflow: hidden;
	height: 52px;
}

.membermath .mm-input:focus-within { outline: 3px solid var(--mm-accent); outline-offset: 1px; }
.membermath .mm-input .mm-fix { padding: 0 2px 0 14px; color: #47586a; font-weight: 600; font-size: 16px; flex: none; }
.membermath .mm-input .mm-fix.right { padding: 0 14px 0 2px; }

/* Hard resets: keep theme form styles out. Inputs and selects styled
 * separately so select text stays vertically centered. */
.membermath .mm-input input {
	all: unset;
	flex: 1;
	min-width: 0;
	height: 100% !important;
	min-height: 0 !important;
	max-height: none !important;
	padding: 0 14px 0 6px !important;
	margin: 0 !important;
	font-family: var(--mm-font-body) !important;
	font-weight: 600;
	font-size: 17px !important;
	line-height: normal !important;
	color: #0b2b4a !important;
	border: 0 !important;
	border-radius: 0 !important;
	background: transparent !important;
	box-shadow: none !important;
	vertical-align: middle;
}

.membermath .mm-input select {
	flex: 1;
	min-width: 0;
	height: 100% !important;
	min-height: 0 !important;
	max-height: none !important;
	border: 0 !important;
	outline: 0;
	/* Custom chevron so the control is obviously a dropdown — theme resets
	 * suppress the native arrow. Color matches the $/% affix (#47586a). */
	appearance: none !important;
	-webkit-appearance: none !important;
	-moz-appearance: none !important;
	background-color: #fff !important;
	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='%2347586a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E") !important;
	background-repeat: no-repeat !important;
	background-position: right 14px center !important;
	background-size: 12px 8px !important;
	box-shadow: none !important;
	padding: 0 40px 0 14px !important;
	margin: 0 !important;
	cursor: pointer;
	font-family: var(--mm-font-body) !important;
	font-weight: 600;
	font-size: 17px !important;
	line-height: normal !important;
	color: #0b2b4a !important;
	border-radius: 0;
}

.membermath .mm-input select::-ms-expand { display: none; }

.membermath .mm-input input::placeholder { color: #9db0c2; font-weight: 400; opacity: 1; }

/* Inputs with no $/% prefix span (ZIP Code, Remaining Term, Current
 * Interest Rate) get the full left padding; the default 6px assumes a
 * prefix sits before the input (v1.5.10). */
.membermath .mm-input > input:first-child { padding-left: 14px !important; }

/* ------------------------------------------------------------------ */
/* Tooltips                                                            */
/* ------------------------------------------------------------------ */

.membermath .mm-tip {
	appearance: none;
	-webkit-appearance: none;
	border: 0;
	background: rgba(255, 255, 255, 0.22);
	color: #fff;
	font-family: var(--mm-font-body);
	font-size: 11px;
	font-weight: 800;
	width: 17px;
	height: 17px;
	line-height: 17px;
	padding: 0;
	text-align: center;
	border-radius: 50%;
	cursor: help;
	position: static;
	flex: none;
	box-shadow: none;
}

/* v1.6.2: the bubble is anchored to the FIELD (spanning its width, just
 * above the label row), not centered on the ? button. Bubbles centered
 * on the button extended past the viewport's left edge on phones —
 * fields always live inside the card, so this can never clip at any
 * viewport or column width. */
.membermath .mm-tip::after {
	content: attr(data-tip);
	position: absolute;
	bottom: calc(100% + 6px);
	left: 0;
	right: 0;
	background: #04203d;
	color: #fff;
	font-weight: 400;
	font-size: 12px;
	line-height: 1.45;
	padding: 8px 10px;
	border-radius: 6px;
	text-align: left;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.15s ease;
	z-index: 20;
}

.membermath .mm-tip:hover::after,
.membermath .mm-tip:focus-visible::after { opacity: 1; }
.membermath .mm-tip:focus-visible { outline: 2px solid var(--mm-accent); outline-offset: 1px; }

/* ------------------------------------------------------------------ */
/* Sliders                                                             */
/* ------------------------------------------------------------------ */

.membermath .mm-slider-value {
	color: var(--mm-light);
	font-weight: 800;
	font-size: 15px;
	white-space: nowrap;
}

.membermath input[type="range"] {
	/* v1.6.1 thumb-width compensation: the 26px thumb's CENTER travels
	 * from 13px to (100% − 13px), not edge to edge. JS supplies --fill
	 * as a unitless 0–1 fraction; the fill edge lands exactly under the
	 * thumb center at every stop (the ticks below use the same formula).
	 * Keep 13px = half the ::-webkit-slider-thumb width. */
	--mm-fill-edge: calc(13px + var(--fill, 0.5) * (100% - 26px));
	-webkit-appearance: none !important;
	appearance: none !important;
	width: 100%;
	height: 8px !important;
	min-height: 0 !important;
	max-height: none !important;
	border-radius: 4px !important;
	background: linear-gradient(to right, var(--mm-accent) var(--mm-fill-edge), rgba(255, 255, 255, 0.22) 0) !important;
	outline: none;
	margin: 14px 0 6px !important;
	border: 0 !important;
	box-shadow: none !important;
	padding: 0 !important;
	display: block;
}

.membermath input[type="range"]::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 26px;
	height: 26px;
	border-radius: 50%;
	background: #fff;
	border: 4px solid var(--mm-accent);
	cursor: pointer;
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.membermath input[type="range"]::-moz-range-thumb {
	width: 26px;
	height: 26px;
	border-radius: 50%;
	background: #fff;
	border: 4px solid var(--mm-accent);
	cursor: pointer;
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.membermath input[type="range"]:focus-visible {
	box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35);
}

/* Locked single-stop slider (e.g. 15-year home equity, FHA/VA/USDA
 * 30-year, single-term model years): thumb at the right, track fully
 * filled, control disabled — never an ambiguous grey slider. */
.membermath input[type="range"].is-locked { cursor: not-allowed; opacity: 0.92; }
.membermath input[type="range"].is-locked::-webkit-slider-thumb { cursor: not-allowed; }
.membermath input[type="range"].is-locked::-moz-range-thumb { cursor: not-allowed; }
.membermath .mm-ticks.is-locked .mm-tick,
.membermath .mm-ticks.is-locked .mm-tick:first-child { left: auto; right: 0; transform: none; text-align: right; }
.membermath .mm-locked-note { margin: 4px 0 0; font-size: 12.5px; color: var(--mm-ink-soft); }

/* v1.6.1: tick labels sit on the SAME thumb-center formula as the fill
 * edge (JS sets --pos = stop ÷ (stops − 1)), so the label, the fill
 * boundary, and the thumb agree at every stop. First and last labels
 * stay flush with the edges, matching how the thumb parks at the ends. */
.membermath .mm-ticks { position: relative; display: block; height: 16px; font-size: 12px; color: var(--mm-ink-soft); }
.membermath .mm-ticks.has-subs { height: 30px; }
.membermath .mm-tick {
	position: absolute;
	top: 0;
	left: calc(13px + var(--pos, 0) * (100% - 26px));
	transform: translateX(-50%);
	text-align: center;
	white-space: nowrap;
}
.membermath .mm-tick:first-child { left: 0; transform: none; text-align: left; }
.membermath .mm-tick:last-child { left: auto; right: 0; transform: none; text-align: right; }
.membermath .mm-tick .mm-tick-label { display: block; }
.membermath .mm-tick.is-active .mm-tick-label { color: var(--mm-ink); font-weight: 800; }

.membermath .mm-tick-sub {
	display: block;
	font-size: 10px;
	color: var(--mm-light);
	font-weight: 700;
	letter-spacing: 0.03em;
}

/* ------------------------------------------------------------------ */
/* Eligibility message                                                 */
/* ------------------------------------------------------------------ */

.membermath .mm-msg {
	margin-top: 18px;
	padding: 12px 16px;
	border-left: 4px solid var(--mm-light);
	background: rgba(159, 219, 239, 0.12);
	border-radius: 0 10px 10px 0;
	font-size: 14px;
	color: var(--mm-ink);
}

.membermath .mm-msg[hidden] { display: none; }

/* ------------------------------------------------------------------ */
/* Results panel                                                       */
/* ------------------------------------------------------------------ */

.membermath .mm-results {
	margin-top: 22px;
	background: rgba(255, 255, 255, 0.07);
	border: 1px solid rgba(255, 255, 255, 0.12);
	border-radius: 14px;
	padding: 24px 22px 22px;
	text-align: center;
	transition: border-color 0.25s ease;
}

.membermath.mm-mode-standard .mm-results { border-color: var(--mm-light); }

.membermath .mm-kicker {
	font-size: 13px;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--mm-ink-soft);
	margin: 0 0 4px;
}

.membermath .mm-hero {
	font-family: var(--mm-font-head);
	font-weight: 900;
	font-size: 52px;
	line-height: 1.05;
	color: var(--mm-ink);
}

.membermath .mm-hero .mm-per { font-size: 20px; font-weight: 700; color: var(--mm-ink-soft); }
.membermath .mm-hero-sub { margin-top: 4px; font-size: 14px; color: var(--mm-ink-soft); }

.membermath .mm-lines { margin: 18px 0 0; padding: 0; list-style: none; text-align: left; }

.membermath .mm-lines li {
	display: flex;
	justify-content: space-between;
	gap: 12px;
	padding: 10px 2px;
	margin: 0;
	border-top: 1px solid rgba(255, 255, 255, 0.12);
	font-size: 15px;
	color: var(--mm-ink-soft);
}

.membermath .mm-lines li strong { color: var(--mm-ink); font-weight: 700; text-align: right; }

/* Sub-treatment under a line value (e.g. "Includes $X Cash Out"). */
.membermath .mm-lines li strong .mm-li-sub {
	display: block;
	font-size: 12px;
	font-weight: 400;
	color: var(--mm-ink-soft);
	margin-top: 2px;
}
.membermath .mm-lines li strong.mm-save { color: var(--mm-green); }
.membermath .mm-lines li strong.mm-cost { color: var(--mm-red); }

.membermath .mm-gate { padding: 26px 10px; color: var(--mm-ink-soft); font-size: 15px; }
.membermath .mm-hint { padding: 20px 10px; color: var(--mm-ink-soft); font-size: 15px; margin: 0; }

/* ------------------------------------------------------------------ */
/* CTA                                                                 */
/* ------------------------------------------------------------------ */

/* --mm-cta-bg / --mm-cta-bg-hover (v1.5.10) accept any CSS background —
 * admin "CTA Background" fields, e.g. an Elementor-style radial
 * gradient. Unset = the solid --mm-cta color and the classic brightness
 * hover, exactly as before. When a hover background is set the
 * shortcode also emits --mm-cta-hover-filter: none. */
.membermath a.mm-cta {
	display: block;
	width: 100%;
	margin-top: 18px;
	background: var(--mm-cta-bg, var(--mm-cta));
	color: var(--mm-cta-ink);
	text-decoration: none;
	text-align: center;
	font-family: var(--mm-font-body);
	font-weight: 800;
	font-size: 17px;
	padding: 16px;
	border-radius: 10px;
	transition: filter 0.15s ease;
}

.membermath a.mm-cta:hover,
.membermath a.mm-cta:focus-visible {
	background: var(--mm-cta-bg-hover, var(--mm-cta-bg, var(--mm-cta)));
	filter: var(--mm-cta-hover-filter, brightness(1.08));
	color: var(--mm-cta-hover-ink, var(--mm-cta-ink));
}

.membermath .mm-cta-note { margin: 10px 0 0; font-size: 12.5px; color: var(--mm-ink-soft); text-align: center; }
.membermath .mm-pi-note { margin: 12px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--mm-ink-soft); text-align: center; }

/* Server-rendered crawlable description; doubles as the loading state and
 * is replaced by the calculator when JS boots. */
.membermath .mm-seo { margin: 0; color: var(--mm-ink-soft); font-size: 14.5px; line-height: 1.65; }

/* Link-styled tab (navigates instead of switching panes). */
.membermath a.mm-tab-link { text-decoration: none !important; display: flex; align-items: center; justify-content: center; }
.membermath a.mm-tab-link:hover { color: var(--mm-ink); }

/* ------------------------------------------------------------------ */
/* PITI mode (v1.5.2) — rendered only while the admin toggle is on     */
/* ------------------------------------------------------------------ */

.membermath {
	--mm-chart-principal: #00ace7;
	--mm-chart-interest: #9fdbef;
	--mm-chart-tax: #f6c344;
	--mm-chart-insurance: #7ee2a8;
	--mm-chart-pmi: #ff9d76;
	--mm-chart-hoa: #b8a6e8;
}

/* Section label above the taxes/insurance/HOA fields. */
.membermath .mm-piti-sec {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-top: 4px;
	font-size: 12px;
	font-weight: 800;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--mm-ink-soft);
	white-space: nowrap;
}

.membermath .mm-piti-sec span { letter-spacing: 0.05em; }

.membermath .mm-piti-sec::after {
	content: "";
	flex: 1;
	height: 1px;
	background: rgba(255, 255, 255, 0.18);
}

/* "EST · ZIP 73116" / "AUTO · 25% DOWN" pills inside white inputs. */
.membermath .mm-input .mm-est {
	flex: none;
	margin-right: 10px;
	padding: 4px 8px;
	border-radius: 5px;
	background: #eef2f6;
	color: #47586a;
	font-size: 10.5px;
	font-weight: 700;
	letter-spacing: 0.04em;
	white-space: nowrap;
}

.membermath .mm-input .mm-est[hidden] { display: none; }

/* Down payment % segment (synced with the $ amount). */
.membermath .mm-input input.mm-pct {
	flex: none;
	width: 58px;
	text-align: right;
	border-left: 1px solid #dde5ec !important;
	padding-left: 10px !important;
	padding-right: 2px !important;
}

.membermath .mm-area-note {
	margin: -8px 0 0;
	font-size: 12px;
	color: var(--mm-ink-soft);
}

.membermath .mm-area-note[hidden] { display: none; }

/* Payment-breakdown donut (inline SVG). */
.membermath .mm-donut-wrap { margin: 16px auto 2px; }
.membermath .mm-donut { width: 148px; height: 148px; display: block; margin: 0 auto; }

.membermath .mm-donut-val {
	fill: var(--mm-ink);
	font-family: var(--mm-font-head);
	font-size: 22px;
	font-weight: 800;
}

.membermath .mm-donut-sub {
	fill: var(--mm-ink-soft);
	font-family: var(--mm-font-body);
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 0.08em;
}

/* Breakdown line items: color dot + label, dimmed when $0. */
.membermath .mm-dotline .mm-li-label { display: inline-flex; align-items: center; gap: 9px; }

.membermath .mm-dot {
	flex: none;
	width: 9px;
	height: 9px;
	border-radius: 50%;
	display: inline-block;
}

.membermath .mm-dotline.is-dim .mm-dot { opacity: 0.35; }
.membermath .mm-dotline.is-dim strong { color: var(--mm-ink-soft); font-weight: 600; }

.membermath .mm-donut-cap {
	margin: 14px 0 0;
	font-size: 12px;
	line-height: 1.5;
	color: var(--mm-ink-soft);
	text-align: center;
}

/* ------------------------------------------------------------------ */
/* Wide side-by-side layout (v1.5.7)                                   */
/* ------------------------------------------------------------------ */

/* v1.5.8: the split is driven by a VIEWPORT media query — deliberately
 * NOT a container query. container-type: inline-size on the wrapper
 * poisoned intrinsic sizing inside Elementor's column-flex containers:
 * the shortcode widget (a flex item) measured the calculator as if it
 * were a few pixels wide, inflating the widget to ~2.4× its real height
 * and leaving a huge phantom gap below the disclaimer (Chrome, Edge,
 * and Safari alike; no fit-content/contain-intrinsic-size workaround
 * held up — verified on the Mortgage Spot staging site 2026-08-12).
 * .membermath-scope stays in the markup as an inert styling hook.
 * Trade-off: a calculator placed in a narrow column on a wide desktop
 * attempts the split and runs snug (the minmax(0,…) tracks shrink
 * gracefully); both properties use full-width calculator columns. */
@media (min-width: 1200px) {
	/* Approved mockup (2026-08-11): inputs left (55), results right (45),
	 * card up to 1300px. The results panel stretches to the input
	 * column's height with the CTA pinned to the bottom. */
	.membermath {
		max-width: 1300px;
		display: grid;
		grid-template-columns: minmax(0, 55fr) minmax(0, 45fr);
		grid-template-rows: auto auto auto auto 1fr auto;
		grid-template-areas:
			"title   results"
			"sub     results"
			"tabs    results"
			"tabsub  results"
			"inputs  results"
			"msg     results";
		column-gap: 32px;
		align-content: start;
	}

	.membermath > .mm-title   { grid-area: title; }
	.membermath > .mm-sub     { grid-area: sub; }
	.membermath > .mm-tabs    { grid-area: tabs; }
	.membermath > .mm-tab-sub { grid-area: tabsub; }
	.membermath > .mm-grid    { grid-area: inputs; align-content: start; }
	.membermath > .mm-msg     { grid-area: msg; }

	.membermath > .mm-results {
		grid-area: results;
		margin-top: 0;
		display: flex;
		flex-direction: column;
	}

	/* Results content centers in the stretched panel; the CTA (a later
	 * flex sibling) stays anchored at the bottom. */
	.membermath > .mm-results .mm-out {
		flex: 1 1 auto;
		display: flex;
		flex-direction: column;
		justify-content: center;
	}

	/* Server-rendered SEO/loading text and the noscript notice span the
	 * full card while the calculator hasn't booted. */
	.membermath > .mm-seo,
	.membermath > .mm-loading,
	.membermath > .mm-error,
	.membermath > noscript { grid-column: 1 / -1; }

	.membermath-disclaimer { max-width: 1300px; }
}

/* ------------------------------------------------------------------ */
/* Disclaimer (outside the card, on the page background)               */
/* ------------------------------------------------------------------ */

.membermath-disclaimer {
	max-width: 720px;
	margin: 12px auto 0;
	font-size: 12.5px;
	line-height: 1.55;
	color: #6b7c8d;
}

.membermath-disclaimer:empty { display: none; }

/* ------------------------------------------------------------------ */
/* Responsive                                                          */
/* ------------------------------------------------------------------ */

@media (max-width: 560px) {
	.membermath { padding: 20px 16px; border-radius: 14px; }
	.membermath .mm-title { font-size: 22px; }
	.membermath .mm-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
	.membermath .mm-hero { font-size: 42px; }
	.membermath .mm-tabs { flex-direction: column; }
	/* Thin out crowded tick labels; endpoints and the active stop stay. */
	.membermath .mm-ticks .mm-tick:nth-child(even):not(.is-active) .mm-tick-label { visibility: hidden; }
	.membermath .mm-ticks .mm-tick:not(.is-active) .mm-tick-sub { visibility: hidden; }
	.membermath .mm-results { padding: 20px 14px 18px; }
}

@media (prefers-reduced-motion: reduce) {
	.membermath * { transition: none !important; }
}
