/* PJ Mortgage Tools — front-end calculator
   Custom properties:
     --pjmc-bg  summary panel + slider accent (preset, custom color or color="")
     --pjmc-fg  summary panel text color (setting, auto contrast or text_color="")
*/

.pjmc {
	--pjmc-bg: #22183a;
	--pjmc-fg: #ffffff;
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
	font-variant-numeric: tabular-nums;
	background: #f6f6f7;
	padding: 36px 28px;
	box-sizing: border-box;
	container-type: inline-size;
}

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

.pjmc--theme-purple { --pjmc-bg: #22183a; }
.pjmc--theme-navy   { --pjmc-bg: #1a2b44; }
.pjmc--theme-gray   { --pjmc-bg: #2b2b2b; }

/* Header ------------------------------------------------------------------ */

.pjmc__header {
	display: flex;
	flex-direction: column;
	gap: 10px;
	margin-bottom: 24px;
}

.pjmc__title {
	font-size: clamp(28px, 3.4vw, 54px);
	font-weight: 300;
	letter-spacing: 0.2px;
	line-height: 1.1;
	margin: 0;
	color: #222;
}

.pjmc__type {
	font-size: 18px;
	font-weight: 700;
	color: #222;
}

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

.pjmc__layout {
	display: grid;
	grid-template-columns: 1.2fr 0.9fr;
	gap: 0;
	align-items: stretch;
	background: #fff;
	border-radius: 8px;
	overflow: hidden;
}

.pjmc__controls {
	display: flex;
	flex-direction: column;
	padding: 38px 34px;
	background: #fff;
}

.pjmc__grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 34px 40px;
	align-items: start;
}

.pjmc-field {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

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

.pjmc-field__label {
	display: block;
	font-size: 16px;
	color: #444;
	margin-bottom: 10px;
}

.pjmc-field__value {
	font-size: 22px;
	font-weight: 700;
	color: #222;
	margin-bottom: 8px;
	transition: opacity 160ms ease;
}

.pjmc-field__moneyline,
.pjmc-field__selectline {
	display: flex;
	align-items: baseline;
	gap: 8px;
	margin-top: 5px;
}

.pjmc-field__prefix {
	font-size: 22px;
	color: #777;
}

.pjmc-field__underline {
	height: 2px;
	background: #e4e4e6;
	margin-top: 10px;
}

.pjmc-field__sub {
	margin-top: 8px;
	font-size: 18px;
	color: #333;
	transition: opacity 160ms ease;
}

/* Inputs ------------------------------------------------------------------ */

.pjmc .pjmc-input {
	width: 100%;
	min-width: 0;
	border: 0;
	outline: 0;
	border-radius: 0;
	box-shadow: none;
	font-size: 16px;
	font-weight: 500;
	line-height: 1.4;
	color: #222;
	background: transparent;
	padding: 0;
	margin: 0;
}

.pjmc .pjmc-input:focus-visible {
	outline: 2px solid var(--pjmc-bg, #22183a);
	outline-offset: 3px;
}

.pjmc .pjmc-input--select {
	font-size: 18px;
	max-width: 180px;
	padding: 2px 0;
	appearance: auto;
	-webkit-appearance: auto;
}

.pjmc .pjmc-range {
	width: 100%;
	margin: 0;
	accent-color: var(--pjmc-bg, #22183a);
}

.pjmc .pjmc-range--years {
	margin-top: 10px;
}

/* Summary panel ----------------------------------------------------------- */

.pjmc__summary {
	background: var(--pjmc-bg, #22183a);
	color: var(--pjmc-fg, #ffffff);
	padding: 44px 38px;
	display: flex;
	flex-direction: column;
	justify-content: flex-start;
	height: 100%;
}

.pjmc__summary,
.pjmc__summary * {
	color: var(--pjmc-fg, #ffffff);
}

.pjmc-sum__big {
	font-size: clamp(44px, 5vw, 52px);
	font-weight: 600;
	letter-spacing: 0.5px;
	line-height: 1.1;
	transition: opacity 160ms ease;
}

.pjmc-sum__sub {
	margin-top: 6px;
	letter-spacing: 6px;
	font-size: 14px;
	text-transform: uppercase;
	opacity: 0.6;
}

.pjmc-sum__list {
	margin-top: 44px;
	display: grid;
	gap: 22px;
}

.pjmc-sum__row {
	display: flex;
	justify-content: space-between;
	gap: 12px;
	font-size: 18px;
}

.pjmc-sum__row > div:last-child {
	font-weight: 700;
	font-size: 22px;
	min-width: 140px;
	text-align: right;
	transition: opacity 160ms ease;
}

.pjmc-sum__row.is-disabled {
	opacity: 0.45;
}

.pjmc-savings {
	margin-top: 26px;
	padding-top: 18px;
	border-top: 1px solid rgba(255, 255, 255, 0.18);
	border-top-color: color-mix(in srgb, var(--pjmc-fg, #ffffff) 22%, transparent);
	display: grid;
	gap: 12px;
}

.pjmc-savings__title {
	font-size: 13px;
	letter-spacing: 1.5px;
	text-transform: uppercase;
	opacity: 0.75;
}

.pjmc-savings__row {
	display: flex;
	justify-content: space-between;
	gap: 14px;
	font-size: 16px;
}

.pjmc-savings__row > div:last-child {
	font-weight: 700;
	min-width: 140px;
	text-align: right;
	transition: opacity 160ms ease;
}

/* Amortization ------------------------------------------------------------ */

.pjmc-amort {
	background: #fff;
	border-radius: 8px;
	margin-top: 22px;
	padding: 18px 18px 10px;
	border: 1px solid #eee;
}

.pjmc-amort[hidden] {
	display: none;
}

.pjmc-amort__header {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 16px;
	margin-bottom: 12px;
}

.pjmc-amort__title {
	font-size: 14px;
	letter-spacing: 1.5px;
	text-transform: uppercase;
	color: #333;
	font-weight: 700;
}

.pjmc-amort__note {
	font-size: 12px;
	color: #666;
}

.pjmc-amort__table {
	max-height: 520px;
	overflow: auto;
}

.pjmc-amort table {
	width: 100%;
	border-collapse: collapse;
	font-size: 14px;
	margin: 0;
}

.pjmc-amort th,
.pjmc-amort td {
	padding: 10px 8px;
	border: 0;
	border-bottom: 1px solid #eee;
	text-align: right;
	white-space: nowrap;
	background: transparent;
	color: #222;
}

.pjmc-amort th {
	font-weight: 700;
}

.pjmc-amort th:first-child,
.pjmc-amort td:first-child {
	text-align: left;
}

/* Credit (opt-in) --------------------------------------------------------- */

.pjmc__powered {
	margin-top: auto;
	padding-top: 18px;
	font-size: 12px;
	color: #777;
	opacity: 0.85;
}

.pjmc__powered a {
	color: inherit;
	text-decoration: none;
	font-weight: 600;
}

.pjmc__powered a:hover,
.pjmc__powered a:focus {
	text-decoration: underline;
}

/* Fade on value change ---------------------------------------------------- */

.pjmc .is-dim {
	opacity: 0.35;
}

/* Responsive -------------------------------------------------------------- */
/* Breakpoints are based on the calculator's own width (container queries),
   with viewport fallbacks for older browsers. */

@container (max-width: 820px) {
	.pjmc__layout {
		grid-template-columns: 1fr;
	}
	.pjmc__summary {
		height: auto;
	}
}

@container (max-width: 520px) {
	.pjmc__grid {
		grid-template-columns: 1fr;
	}
}

@media (max-width: 980px) {
	.pjmc__layout {
		grid-template-columns: 1fr;
	}
	.pjmc__summary {
		height: auto;
	}
}

@media (max-width: 600px) {
	.pjmc__grid {
		grid-template-columns: 1fr;
	}
}

@media (max-width: 900px) {
	.pjmc-amort__table {
		overflow-x: auto;
	}
	.pjmc-amort table {
		min-width: 640px;
	}
}

@media (max-width: 600px) {
	.pjmc {
		padding: 20px 14px;
	}
	.pjmc__controls {
		padding: 24px 18px;
	}
	.pjmc__summary {
		padding: 30px 22px;
	}
	.pjmc-sum__row > div:last-child,
	.pjmc-savings__row > div:last-child {
		min-width: 0;
	}
}

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

/* Print ------------------------------------------------------------------- */

@media print {
	.pjmc {
		background: #fff;
		padding: 0;
	}
	.pjmc__layout {
		display: block;
		border: 1px solid #ddd;
		break-inside: avoid;
	}
	.pjmc__controls {
		padding: 16px;
	}
	.pjmc__grid {
		grid-template-columns: 1fr 1fr 1fr;
		gap: 12px 24px;
	}
	.pjmc-field__label {
		font-size: 12px;
		margin-bottom: 2px;
	}
	.pjmc-field__value,
	.pjmc-field__sub,
	.pjmc .pjmc-input {
		font-size: 14px;
	}
	.pjmc .pjmc-range,
	.pjmc-field__underline,
	.pjmc__powered {
		display: none !important;
	}
	.pjmc__summary {
		padding: 16px;
		-webkit-print-color-adjust: exact;
		print-color-adjust: exact;
		border-top: 1px solid #ddd;
	}
	.pjmc-sum__list {
		margin-top: 12px;
		gap: 6px;
	}
	.pjmc-sum__big {
		font-size: 32px;
	}
	.pjmc-amort {
		border: 0;
		padding: 0;
		break-before: page;
	}
	.pjmc-amort__table {
		max-height: none;
		overflow: visible;
	}
	.pjmc-amort table {
		min-width: 0;
		font-size: 11px;
	}
	.pjmc-amort th,
	.pjmc-amort td {
		padding: 4px 6px;
	}
	.pjmc-amort thead {
		display: table-header-group;
	}
	.pjmc-amort tr {
		break-inside: avoid;
	}
}
