/**
 * Riva Platform widget styles.
 *
 * Everything is scoped under .riva-calc / .riva-apply so it cannot leak into
 * the rest of the theme. Colours come from custom properties that the Elementor
 * Style tab overrides on the widget wrapper.
 */

.riva-calc,
.riva-apply {
	--riva-surface: #15151a;
	--riva-ink: #0f0f12;
	--riva-text: #f6f5f2;
	--riva-muted: #9b9ba4;
	--riva-faint: #6e6e77;
	--riva-accent: #c9a961;
	--riva-accent-hi: #e6cb90;
	--riva-line: rgba(201, 169, 97, 0.2);
	--riva-line-soft: rgba(255, 255, 255, 0.08);
	--riva-good: #6fbf8b;
	--riva-bad: #d97a6c;
	--riva-display: "Montserrat", "Helvetica Neue", Arial, sans-serif;
	--riva-body: "Inter", "Helvetica Neue", Arial, sans-serif;

	color: var(--riva-text);
	font-family: var(--riva-body);
	line-height: 1.6;

	/* Self-constrain. Without this the widget inherits the width of a
	   full-width Elementor section and the fields run to the viewport edge.
	   Inside a narrower column the cap simply never applies. */
	width: 100%;
	margin-inline: auto;
}

/* Same box as .rv-wrap on the landing page - 1140px outer, 20px gutters,
   1100px of content - so the widget lines up with the headings above it at
   every width, with no dependence on the wrapper Elementor puts around it.
   container-type makes every breakpoint below respond to the width this
   widget actually has, not the width of the browser window. A 640px theme
   column on a 1920px monitor then lays out like a 640px screen. */
.riva-calc,
.riva-apply {
	max-width: 1140px;
	padding-inline: 20px;
}

.riva-calc {
	container-type: inline-size;
	container-name: rivacalc;
}

.riva-calc__inner {
	display: grid;
	grid-template-columns: minmax(0, 400px) minmax(0, 1fr);
	gap: 32px;
	align-items: start;
}

/* A form never reads well wider than this, whatever it is dropped into.
   The cap sits on the form, not the wrapper, so the wrapper keeps the
   gutters that align it with the rest of the page. */
.riva-apply__form,
.riva-apply__thanks {
	max-width: 620px;
	margin-inline: auto;
}

.riva-calc,
.riva-apply,
.riva-calc *,
.riva-apply * {
	box-sizing: border-box;
	min-width: 0;
}

/* ---------- light band variant ----------
   The widget adds .rv-light to its own wrapper, so this re-points the same
   tokens rather than restyling any component. The win/loss pair is re-picked
   for a light ground: the dark-band green and red both fall under 3:1 on
   off-white, and those two figures carry the whole comparison. */

.rv-light .riva-calc,
.rv-light .riva-apply {
	--riva-surface: #ffffff;
	--riva-ink: #faf8f4;
	--riva-text: #16161a;
	--riva-muted: #56565f;
	--riva-faint: #6a6a74;
	--riva-accent: #866a2d;
	--riva-accent-hi: #6d5523;
	--riva-line: rgba(134, 106, 45, 0.3);
	--riva-line-soft: rgba(22, 22, 26, 0.12);
	--riva-good: #2e7d52;
	--riva-bad: #b2402c;
}

.rv-light .riva-calc__tab[aria-selected="true"] {
	background: #c9a961;
	color: #121008;
}

.rv-light .riva-calc input[type="range"]::-webkit-slider-runnable-track {
	background: rgba(22, 22, 26, 0.18);
}

.rv-light .riva-calc input[type="range"]::-moz-range-track {
	background: rgba(22, 22, 26, 0.18);
}

.rv-light .riva-calc input[type="range"]::-webkit-slider-thumb {
	background: #866a2d;
}

.rv-light .riva-calc input[type="range"]::-moz-range-thumb {
	background: #866a2d;
}

.rv-light .riva-calc__cell--now {
	background: linear-gradient(160deg, rgba(178, 64, 44, 0.1), rgba(178, 64, 44, 0.02));
}

.rv-light .riva-calc__cell--win {
	background: linear-gradient(160deg, rgba(46, 125, 82, 0.12), rgba(46, 125, 82, 0.02));
}

.rv-light .riva-calc__pill {
	background: rgba(46, 125, 82, 0.14);
}

.rv-light .riva-calc__pill.is-negative {
	background: rgba(178, 64, 44, 0.14);
}

.rv-light .riva-calc__row.is-total {
	background: rgba(201, 169, 97, 0.12);
}

.rv-light .riva-apply__button {
	background: #c9a961;
	border-color: #c9a961;
	color: #121008;
}

/* ---------- calculator ---------- */

.riva-calc__controls {
	background: var(--riva-surface);
	border: 1px solid var(--riva-line);
	padding: clamp(18px, 2.6cqi, 30px);
	min-width: 0;
}

.riva-calc__tabs {
	display: flex;
	border: 1px solid var(--riva-line);
	margin-bottom: 26px;
}

.riva-calc__tab {
	flex: 1;
	background: transparent;
	border: 0;
	color: var(--riva-muted);
	font-family: var(--riva-display);
	font-weight: 700;
	font-size: 12px;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	padding: 13px 8px;
	cursor: pointer;
	line-height: 1.2;
}

.riva-calc__tab[aria-selected="true"] {
	background: var(--riva-accent);
	color: #121008;
}

.riva-calc__field {
	margin-bottom: 26px;
}

.riva-calc__field:last-child {
	margin-bottom: 0;
}

.riva-calc__field-top {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 12px;
	margin-bottom: 10px;
}

.riva-calc__field-top label {
	font-size: 13px;
	color: var(--riva-muted);
	margin: 0;
}

.riva-calc__field-top output {
	font-family: var(--riva-display);
	font-weight: 700;
	font-size: 21px;
	color: var(--riva-text);
	font-variant-numeric: tabular-nums;
}

.riva-calc input[type="range"] {
	width: 100%;
	-webkit-appearance: none;
	appearance: none;
	background: transparent;
	height: 22px;
	cursor: pointer;
	display: block;
	margin: 0;
	padding: 0;
	border: 0;
}

.riva-calc input[type="range"]::-webkit-slider-runnable-track {
	height: 2px;
	background: var(--riva-line-soft);
}

.riva-calc input[type="range"]::-moz-range-track {
	height: 2px;
	background: var(--riva-line-soft);
}

.riva-calc input[type="range"]::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: var(--riva-accent);
	margin-top: -7px;
	border: 0;
}

.riva-calc input[type="range"]::-moz-range-thumb {
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: var(--riva-accent);
	border: 0;
}

.riva-calc input[type="range"]:focus-visible {
	outline: 2px solid var(--riva-accent-hi);
	outline-offset: 4px;
}

.riva-calc__scale {
	display: flex;
	justify-content: space-between;
	font-size: 11px;
	color: var(--riva-faint);
	font-variant-numeric: tabular-nums;
}

.riva-calc__results {
	min-width: 0;
}

.riva-calc__headline {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 1px;
	background: var(--riva-line-soft);
	border: 1px solid var(--riva-line-soft);
}

.riva-calc__cell {
	background: var(--riva-ink);
	padding: clamp(16px, 2.4cqi, 28px);
	min-width: 0;
}

/* The two headline figures are colour coded against each other: what the
   current firm leaves you reads as the loss, what Riva leaves you as the gain.
   The gold accent stays on the rest of the panel so the brand still leads. */
.riva-calc__cell--now {
	background: linear-gradient(160deg, rgba(217, 122, 108, 0.16), rgba(217, 122, 108, 0.03));
	box-shadow: inset 3px 0 0 var(--riva-bad);
}

.riva-calc__cell--win {
	background: linear-gradient(160deg, rgba(111, 191, 139, 0.16), rgba(111, 191, 139, 0.03));
	box-shadow: inset 3px 0 0 var(--riva-good);
}

.riva-calc__label {
	font-family: var(--riva-display);
	font-size: 10.5px;
	font-weight: 700;
	letter-spacing: 0.18em;
	text-transform: uppercase;
	color: var(--riva-muted);
	margin: 0 0 12px;
}

.riva-calc__cell--now .riva-calc__label {
	color: var(--riva-bad);
}

.riva-calc__cell--win .riva-calc__label {
	color: var(--riva-good);
}

.riva-calc__num {
	font-family: var(--riva-display);
	font-weight: 800;
	font-size: clamp(23px, 3.6cqi, 40px);
	font-variant-numeric: tabular-nums;
	letter-spacing: -0.03em;
	line-height: 1.05;
	margin: 0;
}

.riva-calc__cell--now .riva-calc__num {
	color: var(--riva-bad);
}

.riva-calc__cell--win .riva-calc__num {
	color: var(--riva-good);
}

.riva-calc__unit {
	font-size: 12.5px;
	color: var(--riva-muted);
	margin: 6px 0 0;
}

.riva-calc__delta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 14px;
	border: 1px solid var(--riva-line);
	border-top: 0;
	background: var(--riva-ink);
	padding: 18px clamp(16px, 2.4cqi, 28px);
}

.riva-calc__pill {
	font-family: var(--riva-display);
	font-weight: 700;
	font-size: 13px;
	padding: 6px 12px;
	background: rgba(111, 191, 139, 0.14);
	color: var(--riva-good);
	font-variant-numeric: tabular-nums;
}

.riva-calc__pill.is-negative {
	background: rgba(217, 122, 108, 0.14);
	color: var(--riva-bad);
}

.riva-calc__delta-text {
	font-size: 14px;
	color: var(--riva-muted);
	margin: 0;
	min-width: 0;
}

.riva-calc__delta-text b {
	color: var(--riva-text);
	font-variant-numeric: tabular-nums;
}

.riva-calc__ledger {
	border: 1px solid var(--riva-line-soft);
	border-top: 0;
	background: var(--riva-ink);
}

.riva-calc__row {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 16px;
	padding: 13px clamp(16px, 2.4cqi, 28px);
	border-bottom: 1px solid var(--riva-line-soft);
	font-size: 14px;
}

.riva-calc__row:last-child {
	border-bottom: 0;
}

.riva-calc__row span {
	color: var(--riva-muted);
	min-width: 0;
}

.riva-calc__row small {
	display: block;
	font-size: 11.5px;
	color: var(--riva-faint);
}

.riva-calc__row b {
	font-variant-numeric: tabular-nums;
	font-family: var(--riva-display);
	font-weight: 600;
	white-space: nowrap;
}

.riva-calc__row.is-total {
	background: rgba(201, 169, 97, 0.06);
}

.riva-calc__row.is-total b {
	color: var(--riva-accent-hi);
}

.riva-calc__note {
	font-size: 11.5px;
	color: var(--riva-faint);
	margin: 14px 0 0;
}

/* ---------- application form ---------- */

.riva-apply__grid {
	display: grid;
	/* Container driven, not viewport driven: the form reflows to one column
	   whenever the space it actually has drops below ~2 x 220px, whether that
	   is a phone or a narrow Elementor column on a desktop. */
	grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
	gap: 16px;
}

.riva-apply__field {
	display: flex;
	flex-direction: column;
	gap: 7px;
	min-width: 0;
}

.riva-apply__field--full {
	grid-column: 1 / -1;
}

.riva-apply__field label {
	font-size: 12px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	font-family: var(--riva-display);
	font-weight: 600;
	color: var(--riva-muted);
	margin: 0;
}

.riva-apply__field input,
.riva-apply__field select {
	background: var(--riva-ink);
	border: 1px solid var(--riva-line-soft);
	color: var(--riva-text);
	padding: 13px 14px;
	font-family: var(--riva-body);
	font-size: 14.5px;
	border-radius: 2px;
	width: 100%;
	max-width: 100%;
	min-width: 0;
	line-height: 1.4;
}

/* iOS zooms the page in on focus for any field under 16px. */
@media (max-width: 782px) {
	.riva-apply__field input,
	.riva-apply__field select {
		font-size: 16px;
	}
}

.riva-apply__field input:focus,
.riva-apply__field select:focus {
	border-color: var(--riva-accent);
	outline: none;
}

.riva-apply__consent {
	display: flex;
	gap: 10px;
	align-items: flex-start;
	font-size: 12.5px;
	color: var(--riva-faint);
	grid-column: 1 / -1;
	margin: 0;
	cursor: pointer;
}

.riva-apply__consent input {
	accent-color: var(--riva-accent);
	margin-top: 3px;
	width: auto;
	flex: 0 0 auto;
}

.riva-apply__error {
	grid-column: 1 / -1;
	margin: 0;
	font-size: 13.5px;
	color: var(--riva-bad);
	border-left: 2px solid var(--riva-bad);
	padding-left: 12px;
}

.riva-apply__button {
	width: 100%;
	font-family: var(--riva-display);
	font-weight: 700;
	font-size: 13px;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	padding: 17px 26px;
	border-radius: 2px;
	border: 1px solid var(--riva-accent);
	background: var(--riva-accent);
	color: #121008;
	cursor: pointer;
	transition: background 0.18s, border-color 0.18s;
}

.riva-apply__button:hover:not(:disabled) {
	background: var(--riva-accent-hi);
	border-color: var(--riva-accent-hi);
}

.riva-apply__button:disabled {
	opacity: 0.6;
	cursor: wait;
}

.riva-apply__thanks {
	border: 1px solid var(--riva-accent);
	background: rgba(201, 169, 97, 0.08);
	padding: 30px;
	text-align: center;
}

.riva-apply__thanks h3 {
	font-family: var(--riva-display);
	font-size: 22px;
	font-weight: 800;
	text-transform: uppercase;
	color: var(--riva-accent);
	margin: 0 0 10px;
}

.riva-apply__thanks p {
	color: var(--riva-muted);
	font-size: 14.5px;
	margin: 0;
}

.riva-apply [hidden] {
	display: none !important;
}

/* ---------- responsive ---------- */

/* Container queries: these fire on the widget's own width, so the layout is
   correct inside a narrow theme column, a half-width Elementor column, or a
   phone alike. */

@container rivacalc (max-width: 860px) {
	.riva-calc__inner {
		grid-template-columns: minmax(0, 1fr);
		gap: 24px;
	}
}

@container rivacalc (max-width: 560px) {
	.riva-calc__headline {
		grid-template-columns: minmax(0, 1fr);
	}

	.riva-calc__row {
		flex-wrap: wrap;
		gap: 2px 16px;
	}

	.riva-calc__row b {
		white-space: normal;
	}

	.riva-calc__tab {
		font-size: 11px;
		letter-spacing: 0.06em;
		padding: 12px 6px;
	}

	.riva-calc__field-top {
		flex-wrap: wrap;
		gap: 2px 12px;
	}
}

/* Baseline for browsers without container query support. */
@supports not (container-type: inline-size) {
	@media (max-width: 1024px) {
		.riva-calc__inner {
			grid-template-columns: minmax(0, 1fr);
			gap: 24px;
		}
	}

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

@media (max-width: 640px) {
	.riva-apply__grid {
		grid-template-columns: 1fr;
	}
}

@media (prefers-reduced-motion: reduce) {
	.riva-apply__button {
		transition: none;
	}
}
