/*
 * Limelight Calculators — modern Ontario-specific design
 *
 * Companion to:
 *   public_html/wp-content/mu-plugins/limelight-calculators.php  (HTML)
 *   public_html/wp-content/themes/realEstate/assets/js/lt-calculators.js (logic)
 *
 * Design principles:
 *   - Mobile-first single column. Splits into two columns at >=992px
 *     (form left, sticky results card on the right).
 *   - All inputs use the SAME .lt-field shell so spacing stays consistent.
 *   - Numbers inside results are typeset in tabular-nums so live updates
 *     don't shift width and feel jittery.
 *   - Colors lean on system tokens already present in
 *     `realtypress-modern.css` so the visual language stays cohesive
 *     across the site, but each token is redefined here as a fallback in
 *     case `realtypress-modern.css` is unloaded for this URL.
 */

:root {
	--lt-calc-brand:        #1f2a44;
	--lt-calc-brand-soft:   #eef1f8;
	--lt-calc-accent:       #6ab75a;        /* Limelight brand green (matches typography-overrides --lt-green-text) */
	--lt-calc-accent-dark:  #5aa44a;        /* hover (matches --lt-green-strong) */
	--lt-calc-text:         #1f2937;
	--lt-calc-muted:        #5b6470;
	--lt-calc-border:       #e2e6ee;
	--lt-calc-bg:           #f7f8fb;
	--lt-calc-card:         #ffffff;
	--lt-calc-shadow:       0 4px 12px rgba(15, 23, 42, 0.06);
	--lt-calc-shadow-lg:    0 10px 30px rgba(15, 23, 42, 0.08);
	--lt-calc-radius:       12px;
	--lt-calc-radius-sm:    8px;
	--lt-calc-success:      #15803d;
	--lt-calc-success-bg:   #e8f5ee;
	--lt-calc-warn:         #b45309;
	--lt-calc-warn-bg:      #fdf6e3;
	--lt-calc-danger:       #b91c1c;
	--lt-calc-danger-bg:    #fde8e8;
}

/* ===========================================================
 *  Outer shell
 * ===========================================================*/
.lt-calc {
	box-sizing: border-box;
	max-width: 1180px;
	margin: 32px auto;
	padding: 24px;
	color: var(--lt-calc-text);
	font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	background: var(--lt-calc-bg);
	border-radius: var(--lt-calc-radius);
}
.lt-calc *,
.lt-calc *::before,
.lt-calc *::after {
	box-sizing: inherit;
}
.lt-calc__header {
	margin-bottom: 24px;
	text-align: left;
}
.lt-calc__title {
	margin: 0 0 6px;
	color: var(--lt-calc-brand);
	font-size: clamp(1.6rem, 1.2rem + 1.2vw, 2.2rem);
	font-weight: 700;
	letter-spacing: -0.01em;
	line-height: 1.15;
}
.lt-calc__intro {
	margin: 0;
	max-width: 720px;
	color: var(--lt-calc-muted);
	font-size: 1rem;
}

/* ===========================================================
 *  Layout: mobile-first stacked, desktop two-column
 * ===========================================================*/
.lt-calc__layout {
	display: grid;
	grid-template-columns: 1fr;
	gap: 24px;
}
@media (min-width: 992px) {
	.lt-calc__layout {
		grid-template-columns: 1fr 1fr;
		gap: 32px;
		align-items: start;
	}
	.lt-calc__results {
		position: sticky;
		top: 24px;
	}
}

/* ===========================================================
 *  Inputs panel
 * ===========================================================*/
.lt-calc__inputs {
	display: flex;
	flex-direction: column;
	gap: 18px;
	padding: 24px;
	background: var(--lt-calc-card);
	border: 1px solid var(--lt-calc-border);
	border-radius: var(--lt-calc-radius);
	box-shadow: var(--lt-calc-shadow);
}

/* ===========================================================
 *  Field
 * ===========================================================*/
.lt-field {
	display: flex;
	flex-direction: column;
	gap: 6px;
}
.lt-field > label {
	font-weight: 600;
	font-size: 0.95rem;
	color: var(--lt-calc-text);
	text-transform: none;
	letter-spacing: 0;
}
.lt-field__input {
	display: flex;
	align-items: stretch;
	height: 48px;
	background: #fff;
	border: 1px solid var(--lt-calc-border);
	border-radius: var(--lt-calc-radius-sm);
	overflow: hidden;
	transition: border-color 120ms ease, box-shadow 120ms ease;
}
.lt-field__input:focus-within {
	border-color: var(--lt-calc-brand);
	box-shadow: 0 0 0 3px rgba(31, 42, 68, 0.12);
}
.lt-field__input input,
.lt-field select {
	flex: 1 1 auto;
	min-width: 0;
	padding: 0 12px;
	border: 0;
	background: transparent;
	color: var(--lt-calc-text);
	font: inherit;
	font-size: 1rem;
	font-variant-numeric: tabular-nums;
	-moz-appearance: textfield;
}
.lt-field__input input::-webkit-outer-spin-button,
.lt-field__input input::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}
.lt-field__input input:focus,
.lt-field select:focus {
	outline: none;
}
.lt-field__prefix,
.lt-field__suffix {
	display: inline-flex;
	align-items: center;
	padding: 0 12px;
	color: var(--lt-calc-muted);
	background: var(--lt-calc-bg);
	font-weight: 600;
	font-size: 0.95rem;
	white-space: nowrap;
}
.lt-field__prefix {
	border-right: 1px solid var(--lt-calc-border);
}
.lt-field__suffix {
	border-left: 1px solid var(--lt-calc-border);
}

/* Native <select> styling */
.lt-field select {
	appearance: none;
	-webkit-appearance: none;
	-moz-appearance: none;
	height: 48px;
	padding: 0 36px 0 12px;
	background:
		linear-gradient(45deg, transparent 50%, var(--lt-calc-muted) 50%) calc(100% - 18px) 18px / 6px 6px no-repeat,
		linear-gradient(135deg, var(--lt-calc-muted) 50%, transparent 50%) calc(100% - 12px) 18px / 6px 6px no-repeat,
		#fff;
	border: 1px solid var(--lt-calc-border);
	border-radius: var(--lt-calc-radius-sm);
	font-size: 1rem;
	cursor: pointer;
	transition: border-color 120ms ease, box-shadow 120ms ease;
}
.lt-field select:focus {
	border-color: var(--lt-calc-brand);
	box-shadow: 0 0 0 3px rgba(31, 42, 68, 0.12);
}

/* Paired down-payment field (% + $) */
.lt-field__paired-inputs {
	display: grid;
	grid-template-columns: 1fr 1.5fr;
	gap: 10px;
}
.lt-field__hint {
	font-size: 0.85rem;
	color: var(--lt-calc-muted);
	min-height: 1.2em;
}
.lt-field__hint--warn {
	color: var(--lt-calc-warn);
}
.lt-field__hint--ok {
	color: var(--lt-calc-success);
}

/* Range slider */
.lt-slider {
	width: 100%;
	margin-top: 2px;
	accent-color: var(--lt-calc-brand);
}

/* Checkbox row */
.lt-field--checkbox {
	flex-direction: row;
	align-items: flex-start;
	gap: 10px;
	padding: 12px;
	background: var(--lt-calc-brand-soft);
	border-radius: var(--lt-calc-radius-sm);
}
.lt-field--checkbox input[type="checkbox"] {
	width: 20px;
	height: 20px;
	margin-top: 2px;
	accent-color: var(--lt-calc-brand);
	flex: 0 0 auto;
}
.lt-field--checkbox label {
	font-weight: 500;
	font-size: 0.92rem;
	color: var(--lt-calc-text);
	line-height: 1.4;
	text-transform: none;
}

/* <details> optional sections */
.lt-calc__optional {
	border: 1px dashed var(--lt-calc-border);
	border-radius: var(--lt-calc-radius-sm);
	background: #fff;
}
.lt-calc__optional > summary {
	padding: 12px 14px;
	cursor: pointer;
	font-weight: 600;
	color: var(--lt-calc-brand);
	list-style: none;
}
.lt-calc__optional > summary::-webkit-details-marker { display: none; }
.lt-calc__optional > summary::after {
	content: "+";
	float: right;
	font-weight: 400;
	color: var(--lt-calc-muted);
	font-size: 1.2rem;
	line-height: 1;
}
.lt-calc__optional[open] > summary::after { content: "−"; }
.lt-calc__optional > .lt-field {
	padding: 0 14px 14px;
}
.lt-calc__optional > .lt-field:first-of-type {
	padding-top: 0;
}

/* ===========================================================
 *  Results panel
 * ===========================================================*/
.lt-calc__results {
	display: flex;
	flex-direction: column;
	gap: 16px;
}
.lt-result-card {
	padding: 20px 22px;
	background: var(--lt-calc-card);
	border: 1px solid var(--lt-calc-border);
	border-radius: var(--lt-calc-radius);
	box-shadow: var(--lt-calc-shadow);
}
.lt-result-card--primary {
	background: linear-gradient(135deg, var(--lt-calc-brand) 0%, #2a3a5e 100%);
	color: #fff;
	border: 0;
	box-shadow: var(--lt-calc-shadow-lg);
	text-align: center;
	padding: 28px 22px;
}
.lt-result-card__label {
	font-size: 0.92rem;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	opacity: 0.85;
}
.lt-result-card__value {
	margin: 6px 0 4px;
	font-size: clamp(2rem, 1.4rem + 2.4vw, 3rem);
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	letter-spacing: -0.02em;
	line-height: 1.1;
	transition: transform 200ms ease;
}
.lt-result-card__subtext {
	font-size: 0.95rem;
	opacity: 0.85;
}

/* ===========================================================
 *  CTA panel (rendered when [lt-mortgage-calculator] is given
 *  pre-approval-url and/or app-url attributes)
 * ===========================================================*/
.lt-cta-panel {
	display: flex;
	flex-direction: column;
	gap: 12px;
	padding: 18px 18px 16px;
	background: var(--lt-calc-card);
	border: 1px solid var(--lt-calc-border);
	border-radius: var(--lt-calc-radius);
	box-shadow: var(--lt-calc-shadow);
}
.lt-cta-panel__heading {
	margin: 0;
	font-size: 0.78rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--lt-calc-brand);
}
.lt-cta-panel__buttons {
	display: flex;
	flex-direction: column;
	gap: 10px;
}
.lt-cta-btn {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 14px;
	padding: 14px 18px;
	border-radius: var(--lt-calc-radius-sm);
	text-decoration: none;
	transition: transform 140ms ease, box-shadow 140ms ease, background-color 140ms ease, border-color 140ms ease;
	will-change: transform;
}
.lt-cta-btn:hover,
.lt-cta-btn:focus-visible {
	transform: translateY(-1px);
	text-decoration: none;
}
.lt-cta-btn:focus-visible {
	outline: 3px solid rgba(31, 42, 68, 0.3);
	outline-offset: 2px;
}
.lt-cta-btn__text {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}
.lt-cta-btn__label {
	font-weight: 700;
	font-size: 1rem;
	line-height: 1.2;
	letter-spacing: -0.005em;
}
.lt-cta-btn__sub {
	font-size: 0.82rem;
	font-weight: 500;
	line-height: 1.3;
	opacity: 0.85;
}
.lt-cta-btn__arrow {
	flex: 0 0 auto;
	font-size: 1.25rem;
	font-weight: 700;
	line-height: 1;
	transition: transform 140ms ease;
}
.lt-cta-btn:hover .lt-cta-btn__arrow,
.lt-cta-btn:focus-visible .lt-cta-btn__arrow {
	transform: translateX(3px);
}
.lt-cta-btn--primary {
	background: var(--lt-calc-accent);
	color: #ffffff;
	border: 1px solid var(--lt-calc-accent-dark);
	box-shadow: 0 4px 14px rgba(14, 122, 38, 0.22);
}
.lt-cta-btn--primary:hover,
.lt-cta-btn--primary:focus-visible {
	background: var(--lt-calc-accent-dark);
	color: #ffffff;
	box-shadow: 0 6px 20px rgba(14, 122, 38, 0.32);
}
.lt-cta-btn--secondary {
	background: #fff;
	color: var(--lt-calc-brand);
	border: 1px solid var(--lt-calc-border);
}
.lt-cta-btn--secondary:hover,
.lt-cta-btn--secondary:focus-visible {
	background: var(--lt-calc-brand-soft);
	color: var(--lt-calc-brand);
	border-color: var(--lt-calc-brand);
}
@media (prefers-reduced-motion: reduce) {
	.lt-cta-btn,
	.lt-cta-btn__arrow {
		transition: none;
	}
	.lt-cta-btn:hover,
	.lt-cta-btn:focus-visible,
	.lt-cta-btn:hover .lt-cta-btn__arrow,
	.lt-cta-btn:focus-visible .lt-cta-btn__arrow {
		transform: none;
	}
}
/* Print: drop the CTA buttons (they're not useful on paper) */
@media print {
	.lt-cta-panel { display: none; }
}

.lt-result-section {
	padding: 18px 22px;
	background: var(--lt-calc-card);
	border: 1px solid var(--lt-calc-border);
	border-radius: var(--lt-calc-radius);
	box-shadow: var(--lt-calc-shadow);
}
.lt-result-section h3 {
	margin: 0 0 12px;
	font-size: 0.9rem;
	font-weight: 700;
	color: var(--lt-calc-brand);
	letter-spacing: 0.06em;
	text-transform: uppercase;
}
.lt-result-section__intro {
	margin: 0 0 10px;
	font-size: 0.88rem;
	color: var(--lt-calc-muted);
}

.lt-result-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
}
.lt-result-list li {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 12px;
	padding: 8px 0;
	font-size: 0.95rem;
	border-bottom: 1px dashed var(--lt-calc-border);
}
.lt-result-list li:last-child {
	border-bottom: 0;
}
.lt-result-list li > span:first-child {
	color: var(--lt-calc-muted);
}
.lt-result-list li > span:last-child {
	color: var(--lt-calc-text);
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	text-align: right;
}
.lt-result-list__total {
	margin-top: 6px;
	padding-top: 12px !important;
	border-top: 1px solid var(--lt-calc-border) !important;
	border-bottom: 0 !important;
	font-size: 1.05rem !important;
}
.lt-result-list__total > span:first-child {
	color: var(--lt-calc-text) !important;
	font-weight: 700;
}
.lt-result-list__total > span:last-child {
	color: var(--lt-calc-brand);
	font-size: 1.15rem;
	font-weight: 700;
}

/* CMHC status badge */
.lt-badge {
	display: inline-block;
	padding: 4px 10px;
	border-radius: 999px;
	background: var(--lt-calc-brand-soft);
	color: var(--lt-calc-brand);
	font-size: 0.82rem;
	font-weight: 600;
	letter-spacing: 0.02em;
}
.lt-badge--insured  { background: var(--lt-calc-success-bg); color: var(--lt-calc-success); }
.lt-badge--conv     { background: var(--lt-calc-brand-soft); color: var(--lt-calc-brand); }
.lt-badge--blocked  { background: var(--lt-calc-danger-bg); color: var(--lt-calc-danger); }

/* Amortization toggle + table */
.lt-calc__amort-toggle {
	width: 100%;
	padding: 12px 16px;
	background: #fff;
	color: var(--lt-calc-brand);
	border: 1px solid var(--lt-calc-border);
	border-radius: var(--lt-calc-radius-sm);
	box-shadow: var(--lt-calc-shadow);
	font: inherit;
	font-weight: 600;
	font-size: 0.95rem;
	cursor: pointer;
	transition: background-color 120ms ease;
}
.lt-calc__amort-toggle:hover {
	background: var(--lt-calc-brand-soft);
}
.lt-calc__amort-toggle::after {
	content: " ▾";
	color: var(--lt-calc-muted);
}
.lt-calc__amort-toggle[aria-expanded="true"]::after {
	content: " ▴";
}

.lt-calc__amort {
	overflow-x: auto;
	background: var(--lt-calc-card);
	border: 1px solid var(--lt-calc-border);
	border-radius: var(--lt-calc-radius);
	box-shadow: var(--lt-calc-shadow);
}
.lt-calc__amort-table {
	width: 100%;
	min-width: 520px;
	border-collapse: collapse;
	font-size: 0.9rem;
	font-variant-numeric: tabular-nums;
}
.lt-calc__amort-table th,
.lt-calc__amort-table td {
	padding: 10px 14px;
	text-align: right;
	border-bottom: 1px solid var(--lt-calc-border);
}
.lt-calc__amort-table th:first-child,
.lt-calc__amort-table td:first-child {
	text-align: left;
}
.lt-calc__amort-table thead th {
	background: var(--lt-calc-brand-soft);
	color: var(--lt-calc-brand);
	font-weight: 700;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	font-size: 0.78rem;
}
.lt-calc__amort-table tbody tr:nth-child(even) td {
	background: #fafbfd;
}

.lt-calc__disclaimer {
	margin: 4px 6px 0;
	font-size: 0.82rem;
	color: var(--lt-calc-muted);
	line-height: 1.5;
}

/* ===========================================================
 *  LTT calculator: same shell, slightly tighter result card
 * ===========================================================*/
.lt-ltt-calc .lt-result-card--primary {
	padding: 24px 22px;
}
.lt-ltt-calc .lt-result-card__value {
	font-size: clamp(1.8rem, 1.2rem + 2vw, 2.6rem);
}

/* Tabular-num enforcement on every output cell */
[data-out] {
	font-variant-numeric: tabular-nums;
}

/* Subtle bump animation when result number updates (JS sets this class) */
.lt-result-card__value.is-flash {
	animation: lt-flash 360ms ease;
}
@keyframes lt-flash {
	0%   { transform: scale(1); }
	30%  { transform: scale(1.04); }
	100% { transform: scale(1); }
}

/* Reduce motion respect */
@media (prefers-reduced-motion: reduce) {
	.lt-result-card__value.is-flash {
		animation: none;
	}
}

/* Print: print only the numeric outputs cleanly */
@media print {
	.lt-calc {
		background: #fff;
		box-shadow: none;
	}
	.lt-calc__inputs,
	.lt-calc__amort-toggle {
		display: none;
	}
	.lt-calc__layout {
		grid-template-columns: 1fr;
	}
}
