/*
 * CPH Mortgage Calculator. Theme it by setting the --cphmc-* properties on
 * .cphmc (or :root) from the site's own tokens; the rules below should not need
 * overriding. Layout switches on the calculator's own width (container query),
 * so it works full width or in a sidebar.
 */
.cphmc {
	--cphmc-ink: #1d1d1f;
	--cphmc-muted: #6b6b70;
	--cphmc-accent: #1a5d57;
	--cphmc-on-accent: #fff;
	--cphmc-surface: transparent;
	--cphmc-field: #fff;
	--cphmc-rule: rgba(0, 0, 0, 0.18);
	--cphmc-alert: #b3261e;
	--cphmc-radius: 8px;
	--cphmc-font-body: inherit;
	--cphmc-font-display: inherit;
	--cphmc-total-size: clamp(40px, 6cqi, 72px);
	--cphmc-gap: clamp(24px, 4cqi, 56px);
	--cphmc-part-1: #1a5d57;
	--cphmc-part-2: #2fb4a1;
	--cphmc-part-3: #d8c94a;
	--cphmc-part-4: #f08a4b;
	--cphmc-part-5: #e0567a;

	container-type: inline-size;
	color: var(--cphmc-ink);
	background: var(--cphmc-surface);
	font-family: var(--cphmc-font-body);
	font-size: 16px;
	line-height: 1.4;
}

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

.cphmc [hidden] { display: none !important; }

/* Tabs */
.cphmc .cphmc__tabs { display: flex; gap: 4px; margin: 0 0 var(--cphmc-gap); border-bottom: 1px solid var(--cphmc-rule); }
.cphmc button.cphmc__tab {
	margin: 0 0 -1px; padding: 12px 4px; margin-right: 24px;
	background: none; border: 0; border-bottom: 3px solid transparent; border-radius: 0 !important;
	color: var(--cphmc-muted); font: inherit; font-family: var(--cphmc-font-display); font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
	cursor: pointer; box-shadow: none;
}
.cphmc button.cphmc__tab[aria-selected="true"] { color: var(--cphmc-ink); border-bottom-color: var(--cphmc-accent); }
.cphmc button.cphmc__tab:focus-visible { outline: 2px solid var(--cphmc-accent); outline-offset: 2px; }

/* Layout */
.cphmc .cphmc__body { display: grid; gap: var(--cphmc-gap); margin: 0; }
@container (min-width: 760px) {
	.cphmc .cphmc__body { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; }
}
.cphmc .cphmc__inputs { display: grid; gap: 20px; }
.cphmc .cphmc__group { display: grid; gap: 20px; }
.cphmc .cphmc__group--shared { padding-top: 20px; border-top: 1px solid var(--cphmc-rule); }
.cphmc .cphmc__pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.cphmc .cphmc__pair--three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@container (max-width: 459px) {
	.cphmc .cphmc__pair--three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Fields */
.cphmc .cphmc__field { display: grid; gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; }
.cphmc .cphmc__label { padding: 0; margin: 0; color: var(--cphmc-muted); font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.cphmc .cphmc__control {
	display: flex; align-items: center; min-height: 48px; padding: 0 14px;
	background: var(--cphmc-field); border: 1px solid var(--cphmc-rule); border-radius: var(--cphmc-radius);
}
.cphmc .cphmc__control:focus-within { border-color: var(--cphmc-accent); box-shadow: 0 0 0 1px var(--cphmc-accent); }
.cphmc .cphmc__affix { color: var(--cphmc-muted); font-weight: 600; }
.cphmc .cphmc__control--usd .cphmc__affix { margin-right: 4px; }
.cphmc .cphmc__control--pct .cphmc__affix { margin-left: 4px; }
.cphmc input.cphmc__input,
.cphmc select.cphmc__input {
	width: 100%; min-width: 0; height: 46px; margin: 0; padding: 0;
	background: transparent !important; border: 0 !important; border-radius: 0; box-shadow: none !important; outline: none;
	color: var(--cphmc-ink); font: inherit; font-size: 18px !important; font-weight: 600; line-height: 46px; /* Salient sets inputs to 14px */
	-moz-appearance: textfield;
}
.cphmc input.cphmc__input::-webkit-outer-spin-button,
.cphmc input.cphmc__input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.cphmc .cphmc__hint { margin: 0; padding: 0; color: var(--cphmc-alert); font-size: 13px; line-height: 1.35; }
.cphmc .cphmc__hint:empty { display: none; }

/* Sliders: a range input that mirrors the number field above it. The filled part
   of the track is --cphmc-fill, set by the script. */
.cphmc .cphmc__slider { display: grid; gap: 2px; margin-top: -8px; }
.cphmc input.cphmc__range {
	--cphmc-fill: 0%;
	width: 100%; height: 32px; margin: 0; padding: 0;
	background: transparent; border: 0; box-shadow: none;
	-webkit-appearance: none; appearance: none; cursor: pointer;
}
.cphmc input.cphmc__range::-webkit-slider-runnable-track {
	height: 4px; border-radius: 999px;
	background: linear-gradient(to right, var(--cphmc-accent) var(--cphmc-fill), var(--cphmc-rule) var(--cphmc-fill));
}
.cphmc input.cphmc__range::-moz-range-track { height: 4px; border-radius: 999px; background: var(--cphmc-rule); }
.cphmc input.cphmc__range::-moz-range-progress { height: 4px; border-radius: 999px; background: var(--cphmc-accent); }
.cphmc input.cphmc__range::-webkit-slider-thumb {
	-webkit-appearance: none; appearance: none;
	width: 22px; height: 22px; margin-top: -9px; border-radius: 50%;
	background: var(--cphmc-accent); border: 3px solid var(--cphmc-field); box-shadow: 0 0 0 1px var(--cphmc-accent);
}
.cphmc input.cphmc__range::-moz-range-thumb {
	width: 16px; height: 16px; border-radius: 50%;
	background: var(--cphmc-accent); border: 3px solid var(--cphmc-field); box-shadow: 0 0 0 1px var(--cphmc-accent);
}
.cphmc input.cphmc__range:focus-visible { outline: 2px solid var(--cphmc-accent); outline-offset: 4px; }
.cphmc .cphmc__scale { display: flex; justify-content: space-between; color: var(--cphmc-muted); font-size: 12px; font-variant-numeric: tabular-nums; }

/* Loan type segments */
.cphmc .cphmc__segments { display: flex; flex-wrap: wrap; gap: 8px; }
.cphmc .cphmc__segment { position: relative; margin: 0; cursor: pointer; }
.cphmc .cphmc__segment input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.cphmc .cphmc__segment span {
	display: inline-block; padding: 10px 20px; border: 1px solid var(--cphmc-rule); border-radius: 999px;
	color: var(--cphmc-ink); font-weight: 600; transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease;
}
.cphmc .cphmc__segment input:checked + span { background: var(--cphmc-accent); border-color: var(--cphmc-accent); color: var(--cphmc-on-accent); }
.cphmc .cphmc__segment input:focus-visible + span { outline: 2px solid var(--cphmc-accent); outline-offset: 2px; }

/* Results */
.cphmc .cphmc__results { min-width: 0; }
/* Single column: the answer first, the inputs under it. */
@container (max-width: 759px) {
	.cphmc .cphmc__results { order: -1; padding-bottom: 8px; border-bottom: 1px solid var(--cphmc-rule); }
}
@container (min-width: 760px) {
	.cphmc .cphmc__results { position: sticky; top: var(--cphmc-sticky-top, 24px); }
}
.cphmc .cphmc__result-label { margin: 0 0 4px; padding: 0; color: var(--cphmc-muted); font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.cphmc .cphmc__total { margin: 0 0 20px; padding: 0; font-family: var(--cphmc-font-display); font-size: var(--cphmc-total-size); font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.cphmc .cphmc__bar { display: flex; gap: 2px; height: 12px; margin: 0 0 20px; overflow: hidden; border-radius: 999px; }
.cphmc .cphmc__bar-part { flex: 0 1 0; min-width: 0; transition: flex-grow 280ms cubic-bezier(0.22, 0.61, 0.36, 1); }
.cphmc .cphmc__breakdown { display: grid; margin: 0 0 16px; padding: 0; }
.cphmc .cphmc__row { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--cphmc-rule); }
.cphmc .cphmc__row dt { display: flex; align-items: center; gap: 10px; margin: 0; font-weight: 400; }
.cphmc .cphmc__row dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.cphmc .cphmc__swatch { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.cphmc .cphmc__bar-part--principal_interest, .cphmc .cphmc__row--principal_interest .cphmc__swatch { background: var(--cphmc-part-1); }
.cphmc .cphmc__bar-part--tax, .cphmc .cphmc__row--tax .cphmc__swatch { background: var(--cphmc-part-2); }
.cphmc .cphmc__bar-part--insurance, .cphmc .cphmc__row--insurance .cphmc__swatch { background: var(--cphmc-part-3); }
.cphmc .cphmc__bar-part--hoa, .cphmc .cphmc__row--hoa .cphmc__swatch { background: var(--cphmc-part-4); }
.cphmc .cphmc__bar-part--mi, .cphmc .cphmc__row--mi .cphmc__swatch { background: var(--cphmc-part-5); }
.cphmc .cphmc__note { margin: 0 0 16px; padding: 0; color: var(--cphmc-muted); font-size: 14px; }
.cphmc button.cphmc__use,
.cphmc a.cphmc__cta-link {
	display: inline-flex; align-items: center; min-height: 48px; padding: 0 28px;
	background: var(--cphmc-accent); border: 1px solid var(--cphmc-accent); border-radius: 999px !important;
	color: var(--cphmc-on-accent); font: inherit; font-family: var(--cphmc-font-display); font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; text-decoration: none;
	cursor: pointer; box-shadow: none;
}
.cphmc button.cphmc__use:focus-visible,
.cphmc a.cphmc__cta-link:focus-visible { outline: 2px solid var(--cphmc-accent); outline-offset: 3px; }
.cphmc .cphmc__cta { margin: var(--cphmc-gap) 0 0; padding: 0; }
.cphmc .cphmc__disclaimer { margin: 24px 0 0; padding: 0; color: var(--cphmc-muted); font-size: 12px; line-height: 1.5; }

@media (prefers-reduced-motion: reduce) {
	.cphmc .cphmc__bar-part,
	.cphmc .cphmc__segment span { transition: none; }
}
