/**
 * Brothers Mortgage Calculators.
 *
 * Scoped under .bmc-app so the plugin never leaks styles into the theme, and
 * built on custom properties so a site can rebrand it without editing this file.
 */

.bmc-app {
	/* Brand palette — Brothers Financial is black + gold, so this scheme is
	   entirely warm (charcoal / gold / bronze / tan). No blue or navy anywhere.
	   Override any of these in your theme to rebrand; nothing here uses
	   !important, so a single custom rule wins cleanly. */
	--bmc-brand: #2c2822;         /* warm charcoal — titles, focus, text accents */
	--bmc-brand-dark: #1a1712;
	--bmc-accent: #e0a340;        /* brand gold — hero, active tabs, CTA */
	--bmc-accent-dark: #c07f1f;   /* deeper gold — gradients, borders */
	--bmc-ink: #14120e;           /* near-black, matches the site header */
	--bmc-text: #241f19;
	--bmc-muted: #6b6357;
	--bmc-line: #e7e2d7;
	--bmc-bg: #ffffff;
	--bmc-bg-alt: #f7f4ee;        /* warm cream, never cool grey */
	--bmc-radius: 10px;
	--bmc-gap: 18px;
	--bmc-danger: #c0392b;
	--bmc-success: #2e7d5b;

	/* Chart series colours (read by the JS). All warm tones so the graphs read
	   as part of the black/gold brand — deliberately zero blue. */
	--bmc-chart-1: #24262c;       /* charcoal — largest slice (P&I) */
	--bmc-chart-2: #e0a340;       /* gold */
	--bmc-chart-3: #b9762a;       /* bronze */
	--bmc-chart-4: #ecc98d;       /* tan */
	--bmc-chart-5: #8a7c66;       /* warm taupe */
	--bmc-chart-6: #cf9a4a;       /* amber */
	--bmc-chart-7: #6f6459;       /* stone */
	--bmc-chart-8: #ddd2bf;       /* sand */

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

.bmc-app *,
.bmc-app *::before,
.bmc-app *::after {
	box-sizing: inherit;
}

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

.bmc-tabs {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-bottom: var(--bmc-gap);
	border-bottom: 2px solid var(--bmc-line);
	padding-bottom: 6px;
}

.bmc-tab {
	appearance: none;
	background: transparent;
	border: 1px solid transparent;
	border-radius: var(--bmc-radius) var(--bmc-radius) 0 0;
	color: var(--bmc-muted);
	cursor: pointer;
	font: inherit;
	font-weight: 600;
	padding: 9px 14px;
	transition: background 0.15s ease, color 0.15s ease;
}

.bmc-tab:hover {
	background: var(--bmc-bg-alt);
	color: var(--bmc-accent-dark);
}

.bmc-tab.is-active {
	background: linear-gradient(135deg, var(--bmc-accent), var(--bmc-accent-dark));
	color: var(--bmc-ink);
}

.bmc-tab:focus-visible {
	outline: 2px solid var(--bmc-accent);
	outline-offset: 2px;
}

/* -------------------------------------------------------------- Layout */

.bmc-layout {
	display: grid;
	gap: var(--bmc-gap);
	grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
	align-items: start;
}

@media (max-width: 900px) {
	.bmc-layout {
		grid-template-columns: minmax(0, 1fr);
	}
}

/* ---------------------------------------------------------------- Form */

.bmc-group {
	background: var(--bmc-bg-alt);
	border: 1px solid var(--bmc-line);
	border-radius: var(--bmc-radius);
	margin: 0 0 14px;
	padding: 14px 16px 16px;
}

.bmc-group-title {
	color: var(--bmc-brand);
	font-size: 14px;
	font-weight: 700;
	letter-spacing: 0.03em;
	padding: 0 4px;
	text-transform: uppercase;
}

.bmc-grid {
	display: grid;
	gap: 12px;
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 600px) {
	.bmc-grid {
		grid-template-columns: minmax(0, 1fr);
	}
}

.bmc-field-wide {
	grid-column: 1 / -1;
}

.bmc-label {
	align-items: center;
	color: var(--bmc-muted);
	display: flex;
	font-size: 13px;
	font-weight: 600;
	gap: 6px;
	margin-bottom: 5px;
}

.bmc-inputwrap,
.bmc-dual,
.bmc-term {
	align-items: stretch;
	display: flex;
	gap: 6px;
}

.bmc-input {
	background: var(--bmc-bg);
	border: 1px solid var(--bmc-line);
	border-radius: 7px;
	color: var(--bmc-text);
	font: inherit;
	min-width: 0;
	padding: 9px 11px;
	width: 100%;
}

/* Dual ($ / %) fields: the text input takes the free space while the affix and
   the $/% switch keep their natural width instead of being crushed. */
.bmc-dual .bmc-input {
	flex: 1 1 auto;
	min-width: 0;
}

.bmc-dual .bmc-affix,
.bmc-dual .bmc-toggle {
	flex: 0 0 auto;
}

.bmc-input:focus {
	border-color: var(--bmc-accent);
	box-shadow: 0 0 0 3px rgba(224, 163, 64, 0.22);
	outline: none;
}

.bmc-affix,
.bmc-suffix {
	align-items: center;
	background: var(--bmc-bg);
	border: 1px solid var(--bmc-line);
	border-radius: 7px;
	color: var(--bmc-muted);
	display: flex;
	flex: 0 0 auto;
	font-weight: 600;
	padding: 0 10px;
}

.bmc-readonly {
	background: var(--bmc-bg-alt);
	border: 1px solid var(--bmc-line);
	border-left: 3px solid var(--bmc-accent);
	border-radius: 7px;
	color: var(--bmc-brand);
	font-weight: 700;
	padding: 9px 11px;
}

.bmc-term .bmc-input {
	flex: 1 1 0;
}

/* Info tooltip */

.bmc-tip {
	background: var(--bmc-muted);
	border: 0;
	border-radius: 50%;
	color: #fff;
	cursor: help;
	flex: 0 0 auto;
	font-size: 10px;
	font-style: italic;
	font-weight: 700;
	height: 15px;
	line-height: 15px;
	padding: 0;
	width: 15px;
}

/* Toggles */

.bmc-toggle {
	display: inline-flex;
	background: var(--bmc-bg);
	border: 1px solid var(--bmc-line);
	border-radius: 7px;
	overflow: hidden;
}

.bmc-toggle-btn {
	appearance: none;
	background: transparent;
	border: 0;
	color: var(--bmc-muted);
	cursor: pointer;
	flex: 0 0 auto;
	font: inherit;
	font-size: 13px;
	font-weight: 600;
	padding: 8px 12px;
	transition: background 0.15s ease, color 0.15s ease;
	white-space: nowrap;
}

.bmc-toggle-btn.is-active {
	background: var(--bmc-accent);
	color: var(--bmc-ink);
}

/* The compact $/% switch: give each glyph a firm, equal footprint so both stay
   legible and the control never collapses to a single crushed button. */
.bmc-toggle-sm .bmc-toggle-btn {
	min-width: 30px;
	padding: 8px 0;
	text-align: center;
}

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

.bmc-results {
	display: flex;
	flex-direction: column;
	gap: 14px;
}

.bmc-hero {
	background: linear-gradient(135deg, var(--bmc-accent), var(--bmc-accent-dark));
	border-radius: var(--bmc-radius);
	color: var(--bmc-ink);
	padding: 22px 20px;
	text-align: center;
}

.bmc-hero-value {
	font-size: 2.4rem;
	font-weight: 800;
	letter-spacing: -0.02em;
	line-height: 1.1;
}

.bmc-hero-label {
	font-size: 14px;
	opacity: 0.85;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	margin-top: 4px;
}

.bmc-hero-sub {
	font-size: 13px;
	margin-top: 8px;
	opacity: 0.8;
}

.bmc-panel {
	background: var(--bmc-bg);
	border: 1px solid var(--bmc-line);
	border-radius: var(--bmc-radius);
	padding: 14px 16px;
}

.bmc-panel-title {
	color: var(--bmc-brand);
	font-size: 13px;
	font-weight: 700;
	letter-spacing: 0.04em;
	margin: 0 0 10px;
	text-transform: uppercase;
}

.bmc-rows {
	display: grid;
	grid-template-columns: 1fr auto;
	gap: 7px 12px;
	margin: 0;
}

.bmc-rows dt {
	align-items: center;
	color: var(--bmc-muted);
	display: flex;
	font-size: 14px;
	gap: 6px;
	margin: 0;
}

.bmc-rows dd {
	font-variant-numeric: tabular-nums;
	font-weight: 600;
	margin: 0;
	text-align: right;
}

.bmc-rows dt.is-em,
.bmc-rows dd.is-em {
	border-top: 1px solid var(--bmc-line);
	color: var(--bmc-text);
	font-weight: 800;
	margin-top: 4px;
	padding-top: 8px;
}

/* Charts */

.bmc-chart {
	align-items: center;
	background: var(--bmc-bg);
	border: 1px solid var(--bmc-line);
	border-radius: var(--bmc-radius);
	display: flex;
	flex-wrap: wrap;
	gap: 16px;
	justify-content: center;
	padding: 16px;
}

.bmc-donut {
	flex: 0 0 auto;
	height: 190px;
	width: 190px;
}

.bmc-donut-value {
	fill: var(--bmc-text);
	font-size: 20px;
	font-weight: 800;
}

.bmc-donut-label {
	fill: var(--bmc-muted);
	font-size: 11px;
	text-transform: uppercase;
}

.bmc-legend {
	flex: 1 1 200px;
	list-style: none;
	margin: 0;
	min-width: 190px;
	padding: 0;
}

.bmc-legend li {
	align-items: center;
	display: flex;
	font-size: 14px;
	gap: 8px;
	padding: 4px 0;
}

.bmc-swatch {
	border-radius: 3px;
	flex: 0 0 auto;
	height: 12px;
	width: 12px;
}

.bmc-legend-label {
	color: var(--bmc-muted);
	flex: 1 1 auto;
}

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

.bmc-bars {
	background: var(--bmc-bg);
	border: 1px solid var(--bmc-line);
	border-radius: var(--bmc-radius);
	display: flex;
	flex-direction: column;
	gap: 9px;
	padding: 16px;
}

.bmc-bar-row {
	align-items: center;
	display: grid;
	gap: 10px;
	grid-template-columns: minmax(90px, 30%) 1fr minmax(70px, auto);
}

.bmc-bar-label {
	color: var(--bmc-muted);
	font-size: 13px;
}

.bmc-bar-track {
	background: var(--bmc-bg-alt);
	border-radius: 999px;
	height: 12px;
	overflow: hidden;
}

.bmc-bar-fill {
	border-radius: 999px;
	display: block;
	height: 100%;
	transition: width 0.25s ease;
}

.bmc-bar-value {
	font-size: 13px;
	font-variant-numeric: tabular-nums;
	font-weight: 700;
	text-align: right;
}

/* DTI meters */

.bmc-meter + .bmc-meter {
	margin-top: 12px;
}

.bmc-meter-head {
	display: flex;
	font-size: 13px;
	justify-content: space-between;
	margin-bottom: 5px;
}

.bmc-meter-value {
	font-weight: 700;
}

.bmc-meter-value.is-over {
	color: var(--bmc-danger);
}

.bmc-meter-track {
	background: var(--bmc-bg-alt);
	border-radius: 999px;
	height: 10px;
	overflow: hidden;
}

.bmc-meter-fill {
	background: var(--bmc-success);
	height: 100%;
	transition: width 0.25s ease;
}

.bmc-meter-fill.is-over {
	background: var(--bmc-danger);
}

/* Tables */

.bmc-compare,
.bmc-table {
	border-collapse: collapse;
	font-size: 14px;
	width: 100%;
}

.bmc-compare th,
.bmc-compare td,
.bmc-table th,
.bmc-table td {
	border-bottom: 1px solid var(--bmc-line);
	padding: 8px 6px;
	text-align: right;
}

.bmc-compare thead th,
.bmc-table thead th {
	color: var(--bmc-muted);
	font-size: 12px;
	letter-spacing: 0.03em;
	text-transform: uppercase;
}

.bmc-compare tbody th,
.bmc-table tbody th {
	color: var(--bmc-muted);
	font-weight: 600;
	text-align: left;
}

.bmc-compare tr.is-em th,
.bmc-compare tr.is-em td {
	font-weight: 800;
}

.bmc-compare td,
.bmc-table td {
	font-variant-numeric: tabular-nums;
}

/* Amortization: collapsed to a scrollable preview until expanded. */

.bmc-amort {
	overflow-x: auto;
}

.bmc-amort.is-collapsed {
	max-height: 260px;
	overflow-y: hidden;
	position: relative;
	-webkit-mask-image: linear-gradient(to bottom, #000 70%, transparent 100%);
	mask-image: linear-gradient(to bottom, #000 70%, transparent 100%);
}

.bmc-link-btn {
	background: none;
	border: 0;
	color: var(--bmc-brand);
	cursor: pointer;
	font: inherit;
	font-weight: 700;
	margin-top: 8px;
	padding: 4px 0;
	text-decoration: underline;
}

/* Narrative + CTA */

.bmc-summary {
	background: var(--bmc-bg-alt);
	border-left: 4px solid var(--bmc-brand);
	border-radius: 0 var(--bmc-radius) var(--bmc-radius) 0;
	font-size: 14px;
	margin: 0;
	padding: 12px 14px;
}

.bmc-note {
	background: #fff6e8;
	border-left: 4px solid var(--bmc-accent);
	border-radius: 0 var(--bmc-radius) var(--bmc-radius) 0;
	font-size: 14px;
	margin: 0;
	padding: 12px 14px;
}

.bmc-cta {
	background: var(--bmc-accent);
	border-radius: 999px;
	color: var(--bmc-ink);
	display: block;
	font-weight: 800;
	padding: 13px 20px;
	text-align: center;
	text-decoration: none;
	transition: filter 0.15s ease;
}

.bmc-cta:hover,
.bmc-cta:focus {
	color: #1f2733;
	filter: brightness(0.94);
	text-decoration: none;
}

.bmc-disclaimer {
	color: var(--bmc-muted);
	font-size: 11px;
	line-height: 1.5;
	margin: 0;
}

.bmc-loading {
	color: var(--bmc-muted);
	padding: 30px;
	text-align: center;
}

@media print {
	.bmc-tabs,
	.bmc-cta,
	.bmc-link-btn {
		display: none;
	}

	.bmc-layout {
		grid-template-columns: minmax(0, 1fr);
	}
}
