/**
 * Benefit Bridge Calculator
 *
 * Every rule is scoped under `.bbcalc` so the plugin cannot reach into the
 * surrounding theme. Colours, fonts and radii come from custom properties that
 * the plugin prints inline from the settings page — the fallbacks below are the
 * brand defaults from benefit-bridge-website/app/globals.css.
 *
 * Mobile-first: the stacked layout is the base, wider viewports opt in.
 */

.bbcalc {
	--bbcalc-page: #fcfcfc;
	--bbcalc-surface: #ffffff;
	--bbcalc-cream: #f2f4f8;
	--bbcalc-ink: #191751;
	--bbcalc-primary: #2a2e72;
	--bbcalc-accent: #213f99;
	--bbcalc-brand-blue: #5c75b4;
	--bbcalc-silver: #cbcbcb;
	--bbcalc-eyebrow: #d8af6d;
	--bbcalc-kicker: #d8af6d;
	--bbcalc-muted: #5a6ba2;
	--bbcalc-hairline: #d8dde8;
	--bbcalc-on-dark: #f7f7fb;
	--bbcalc-danger: #b42318;
	/*
	 * Manrope for both roles — the font benefit-bridge.gr serves. Deliberately
	 * no bare var(): a var() with no fallback pointing at an undefined custom
	 * property invalidates the whole font-family declaration at computed-value
	 * time, so the font silently reverts to inherited and the setting does
	 * nothing. Both stacks used to have exactly that bug.
	 */
	--bbcalc-font-sans: Manrope, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	--bbcalc-font-display: Manrope, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	--bbcalc-radius: 20px;
	--bbcalc-radius-pill: 999px;

	/*
	 * Container defaults: nothing. No background, no width cap, no padding — so
	 * dropped into an Elementor container, a theme section or a block wrapper,
	 * the calculator fills the box it is given and that box keeps control of its
	 * own surroundings. All three are overridden per instance from the settings
	 * page or a shortcode attribute.
	 */
	--bbcalc-bg: transparent;
	--bbcalc-max-width: none;
	--bbcalc-pad-y: 0px;
	--bbcalc-pad-x: 0px;

	/* Slider fill, updated by JS. */
	--bbcalc-progress: 0%;

	/*
	 * One gap for the whole composition: between the two columns, between the
	 * cards stacked inside a column, and under the result band. Declared once so
	 * the band can never drift out of step with the grid below it.
	 */
	--bbcalc-gap: 20px;

	/*
	 * Card lift, carried over from the original standalone design file. The
	 * band gets a deeper one: it is dark, so the same wash that reads as a lift
	 * under a white card disappears under it.
	 */
	--bbcalc-shadow: 0 8px 24px rgba(18, 25, 54, 0.06);
	--bbcalc-shadow-band: 0 12px 28px rgba(18, 25, 54, 0.14);

	/*
	 * No `container-type` here, deliberately.
	 *
	 * Container queries would be the obvious way to make the layout respond to
	 * the calculator's own width rather than the viewport, but `container-type:
	 * inline-size` brings size containment with it, and a contained element
	 * contributes nothing to its parent's intrinsic width. Elementor wraps a
	 * shortcode in `.elementor-shortcode` inside a flex-row container, where the
	 * wrapper is a shrink-to-fit flex item — with nothing to measure it collapses
	 * to zero, and the whole calculator disappears into a 0px column.
	 *
	 * `.bbcalc__layout` gets the same behaviour from flex-wrap and a flex-basis
	 * threshold instead: it breaks to one column when there is not room for two,
	 * measured against the space actually available, with no containment and no
	 * browser-support caveat.
	 */
	box-sizing: border-box;
	width: 100%;
	color: var(--bbcalc-ink);
	background-color: var(--bbcalc-bg);
	font-family: var(--bbcalc-font-sans);
	font-size: 16px;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
}

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

.bbcalc h2,
.bbcalc h3,
.bbcalc p {
	margin: 0;
	padding: 0;
}

/*
 * Edge-to-edge tint, for a calculator dropped into a constrained content column.
 *
 * `100vw` includes the classic scrollbar, so on Windows/Linux this can push a
 * few pixels of horizontal scroll onto a theme whose page wrapper does not clip
 * overflow. Off by default for that reason; if you turn it on and see a
 * horizontal scrollbar, add `overflow-x: clip` to the theme's page wrapper (or
 * use the block's wide/full alignment instead).
 */
.bbcalc--full-bleed {
	width: 100vw;
	max-width: 100vw;
	margin-left: calc(50% - 50vw);
	margin-right: calc(50% - 50vw);
}

.bbcalc__wrap {
	width: 100%;
	max-width: var(--bbcalc-max-width);
	margin-inline: auto;
	padding: var(--bbcalc-pad-y) var(--bbcalc-pad-x);
}

.bbcalc__sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	border: 0;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
}

/* ---------------------------------------------------------------- Heading -- */

.bbcalc__heading {
	margin-bottom: 28px;
}

/*
 * The line above the heading. Its own colour rather than the result eyebrow's:
 * the two sit in different places on the page and a site may well want one gold
 * and the other not.
 */
.bbcalc__kicker {
	display: block;
	margin-bottom: 12px;
	color: var(--bbcalc-kicker);
	font-family: var(--bbcalc-font-sans);
	font-size: 0.75rem;
	font-weight: 600;
	line-height: 1.2;
	letter-spacing: 0.16em;
	text-transform: uppercase;
}

.bbcalc__title {
	max-width: 20ch;
	color: var(--bbcalc-ink);
	font-family: var(--bbcalc-font-display);
	font-size: clamp(2rem, 1.4rem + 2.6vw, 3.25rem);
	font-weight: 500;
	line-height: 1.06;
	letter-spacing: -0.02em;
}

.bbcalc__subtitle {
	max-width: 62ch;
	margin-top: 12px;
	color: var(--bbcalc-muted);
	font-size: 1.0625rem;
	line-height: 1.55;
}

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

/*
 * `align-items: stretch` (the default, restated because it is load-bearing):
 * both columns run to the height of the taller one, so the two cards line up
 * top and bottom instead of the shorter one ending mid-air.
 */
.bbcalc__layout {
	display: flex;
	flex-wrap: wrap;
	gap: var(--bbcalc-gap);
	align-items: stretch;
}

/*
 * Two columns when there is room for 380 + 420 + gap, one when there is not —
 * decided by the space actually available, in any parent, with no containment.
 * The uneven flex-grow reproduces the 0.85 / 1.15 split of the original design
 * once the columns share the leftover width.
 */
.bbcalc__column {
	display: grid;
	gap: var(--bbcalc-gap);
	align-content: stretch;
	flex: 1 1 380px;
	min-width: 0;
}

.bbcalc__column--results {
	flex-grow: 1.35;
	flex-basis: 420px;
}

.bbcalc__card {
	background-color: var(--bbcalc-surface);
	border: 1px solid var(--bbcalc-hairline);
	border-radius: var(--bbcalc-radius);
	box-shadow: var(--bbcalc-shadow);
}

/* ------------------------------------------------------------- Input card -- */

.bbcalc__panel {
	padding: 24px 22px;
}

.bbcalc__panel-title {
	padding-bottom: 18px;
	border-bottom: 1px solid var(--bbcalc-hairline);
	color: var(--bbcalc-ink);
	font-family: var(--bbcalc-font-display);
	font-size: 1.5rem;
	font-weight: 500;
	line-height: 1.2;
	letter-spacing: -0.015em;
}

.bbcalc__field {
	padding-top: 20px;
}

.bbcalc__field + .bbcalc__field {
	margin-top: 20px;
	padding-top: 20px;
	border-top: 1px solid var(--bbcalc-hairline);
}

.bbcalc__field-head {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 16px;
	align-items: baseline;
	justify-content: space-between;
}

.bbcalc__label {
	color: var(--bbcalc-ink);
	font-size: 0.875rem;
	font-weight: 600;
	line-height: 1.3;
}

.bbcalc__figure,
.bbcalc__number {
	color: var(--bbcalc-primary);
	font-family: var(--bbcalc-font-display);
	font-size: 1.75rem;
	font-weight: 500;
	line-height: 1;
	letter-spacing: -0.01em;
	white-space: nowrap;
}

.bbcalc__number {
	width: 6ch;
	min-height: 40px;
	padding: 4px 2px;
	border: 1px solid transparent;
	border-bottom-color: var(--bbcalc-hairline);
	border-radius: 6px;
	background-color: transparent;
	font-family: var(--bbcalc-font-display);
	text-align: right;
	appearance: textfield;
	-moz-appearance: textfield;
}

.bbcalc__number::-webkit-outer-spin-button,
.bbcalc__number::-webkit-inner-spin-button {
	margin: 0;
	appearance: none;
	-webkit-appearance: none;
}

.bbcalc__number:hover {
	border-bottom-color: var(--bbcalc-brand-blue);
}

.bbcalc__number[aria-invalid="true"] {
	border-bottom-color: var(--bbcalc-danger);
	color: var(--bbcalc-danger);
}

/* Brand focus ring — mirrors the :focus-visible rule in globals.css. */
.bbcalc :focus-visible {
	outline: 2px solid var(--bbcalc-accent);
	outline-offset: 3px;
}

/* -------------------------------------------------------------- Range input */

.bbcalc__range {
	display: block;
	width: 100%;
	height: 28px;
	margin: 20px 0 6px;
	background-color: transparent;
	cursor: pointer;
	appearance: none;
	-webkit-appearance: none;
}

.bbcalc__range:focus-visible {
	outline-offset: 6px;
}

/* The fill is painted on the track via a hard-stop gradient at --bbcalc-progress. */
.bbcalc__range::-webkit-slider-runnable-track {
	height: 6px;
	border-radius: var(--bbcalc-radius-pill);
	background-image: linear-gradient(
		to right,
		var(--bbcalc-primary) 0,
		var(--bbcalc-primary) var(--bbcalc-progress),
		var(--bbcalc-hairline) var(--bbcalc-progress),
		var(--bbcalc-hairline) 100%
	);
}

.bbcalc__range::-moz-range-track {
	height: 6px;
	border-radius: var(--bbcalc-radius-pill);
	background-image: linear-gradient(
		to right,
		var(--bbcalc-primary) 0,
		var(--bbcalc-primary) var(--bbcalc-progress),
		var(--bbcalc-hairline) var(--bbcalc-progress),
		var(--bbcalc-hairline) 100%
	);
}

/* 24px keeps the thumb at the minimum comfortable touch target. */
.bbcalc__range::-webkit-slider-thumb {
	width: 24px;
	height: 24px;
	margin-top: -9px;
	border: 3px solid var(--bbcalc-surface);
	border-radius: 50%;
	background-color: var(--bbcalc-primary);
	box-shadow: 0 2px 8px rgba(25, 23, 81, 0.28);
	cursor: grab;
	appearance: none;
	-webkit-appearance: none;
}

.bbcalc__range::-moz-range-thumb {
	width: 24px;
	height: 24px;
	border: 3px solid var(--bbcalc-surface);
	border-radius: 50%;
	background-color: var(--bbcalc-primary);
	box-shadow: 0 2px 8px rgba(25, 23, 81, 0.28);
	cursor: grab;
}

.bbcalc__range:active::-webkit-slider-thumb {
	background-color: var(--bbcalc-accent);
	cursor: grabbing;
}

.bbcalc__range:active::-moz-range-thumb {
	background-color: var(--bbcalc-accent);
	cursor: grabbing;
}

.bbcalc__scale {
	display: flex;
	justify-content: space-between;
	color: var(--bbcalc-muted);
	font-size: 0.75rem;
	font-weight: 500;
	line-height: 1;
}

.bbcalc__note {
	margin-top: 10px;
	color: var(--bbcalc-muted);
	font-size: 0.8125rem;
	line-height: 1.5;
}

.bbcalc__error {
	margin-top: 10px;
	color: var(--bbcalc-danger);
	font-size: 0.8125rem;
	font-weight: 500;
	line-height: 1.4;
}

.bbcalc__error[hidden] {
	display: none;
}

/* -------------------------------------------------------------- Aside card -- */

.bbcalc__aside {
	padding: 20px 22px;
	background-color: var(--bbcalc-cream);
	border-left: 3px solid var(--bbcalc-accent);
}

.bbcalc__aside-title {
	margin-bottom: 8px;
	color: var(--bbcalc-ink);
	font-size: 0.9375rem;
	font-weight: 700;
	line-height: 1.3;
}

.bbcalc__aside-body {
	color: var(--bbcalc-muted);
	font-size: 0.875rem;
	line-height: 1.6;
}

/* ----------------------------------------------------------- Result band -- */

/*
 * The headline sits above the two columns and runs the full width of the grid
 * below it, so the number reads as the answer to the whole calculator rather
 * than as the top of the right-hand column. Its content is centred inside that
 * width, which keeps the band from reading as an empty stretch of navy with a
 * figure parked in one corner.
 */
.bbcalc__result {
	display: flex;
	flex-direction: column;
	gap: 12px;
	align-items: center;
	margin-bottom: var(--bbcalc-gap);
	padding: 30px 26px;
	color: var(--bbcalc-on-dark);
	background-color: var(--bbcalc-ink);
	border-color: var(--bbcalc-ink);
	box-shadow: var(--bbcalc-shadow-band);
	text-align: center;
}

.bbcalc__result-main {
	max-width: 100%;
	min-width: 0;
}

/*
 * The brand's `.mono-label` treatment — uppercase, tracked out — but set in the
 * sans stack rather than a monospace family. Greek coverage in monospace fonts
 * is patchy, and "ΚΑΘΑΡΟ ΕΤΗΣΙΟ ΟΦΕΛΟΣ" falling through to a system mono would
 * be a worse outcome than losing the mono texture.
 */
.bbcalc__eyebrow {
	display: block;
	color: var(--bbcalc-eyebrow);
	font-family: var(--bbcalc-font-sans);
	font-size: 0.6875rem;
	font-weight: 500;
	line-height: 1.2;
	letter-spacing: 0.16em;
	text-transform: uppercase;
}

.bbcalc__result-value {
	display: block;
	margin-top: 14px;
	color: var(--bbcalc-on-dark);
	font-family: var(--bbcalc-font-display);
	font-size: clamp(2.75rem, 1.9rem + 3.6vw, 4.25rem);
	font-weight: 500;
	line-height: 0.98;
	letter-spacing: -0.03em;
	overflow-wrap: anywhere;
}

/*
 * No rule above the note: centred text under a centred figure reads as one
 * block, and a hairline across a band this wide would cut it in two.
 */
.bbcalc__result-note {
	max-width: 60ch;
	color: var(--bbcalc-silver);
	font-size: 0.9375rem;
	line-height: 1.5;
}

/* ----------------------------------------------------------- Compare card -- */

/*
 * A column so the card can absorb the height it is stretched to. The bars take
 * the slack (see `.bbcalc__bars`), which keeps the call to action on the bottom
 * edge, level with the end of the input panel beside it.
 */
.bbcalc__compare {
	display: flex;
	flex-direction: column;
	padding: 26px 22px 22px;
}

.bbcalc__compare-title {
	color: var(--bbcalc-ink);
	font-family: var(--bbcalc-font-display);
	font-size: 1.5rem;
	font-weight: 500;
	line-height: 1.2;
	letter-spacing: -0.015em;
}

/*
 * `margin-bottom: auto` eats the free space in the stretched card rather than
 * an `auto` margin on the CTA, which would have replaced the 24px minimum and
 * let the button ride up against the bars whenever there is no slack.
 */
.bbcalc__bars {
	display: grid;
	gap: 20px;
	margin-top: 24px;
	margin-bottom: auto;
}

/*
 * Horizontal bars rather than the original's vertical columns: at narrow widths
 * a vertical pair collapses into two unreadable stubs, while a full-width
 * horizontal bar keeps its proportion and its label at any size.
 */
.bbcalc__bar-row {
	display: grid;
	grid-template-areas:
		"label value"
		"track track";
	grid-template-columns: minmax(0, 1fr) auto;
	gap: 8px 12px;
	align-items: baseline;
}

.bbcalc__bar-label {
	grid-area: label;
	color: var(--bbcalc-ink);
	font-size: 0.875rem;
	font-weight: 600;
	line-height: 1.25;
}

.bbcalc__bar-label small {
	display: block;
	margin-top: 2px;
	color: var(--bbcalc-muted);
	font-size: 0.75rem;
	font-weight: 500;
}

.bbcalc__bar-value {
	grid-area: value;
	color: var(--bbcalc-ink);
	font-size: 0.9375rem;
	font-weight: 700;
	line-height: 1.2;
	white-space: nowrap;
}

.bbcalc__bar-track {
	grid-area: track;
	display: block;
	width: 100%;
	height: 12px;
	border-radius: var(--bbcalc-radius-pill);
	background-color: var(--bbcalc-cream);
	overflow: hidden;
}

.bbcalc__bar {
	display: block;
	height: 100%;
	min-width: 4px;
	border-radius: inherit;
	transition: width 240ms cubic-bezier(0.22, 1, 0.36, 1);
}

.bbcalc__bar--payroll {
	background-color: var(--bbcalc-silver);
}

.bbcalc__bar--bridge {
	background-color: var(--bbcalc-accent);
}

/* -------------------------------------------------------------------- CTA -- */

.bbcalc__cta {
	display: flex;
	flex-wrap: wrap;
	gap: 14px;
	align-items: center;
	justify-content: space-between;
	margin-top: 24px;
	padding-top: 20px;
	border-top: 1px solid var(--bbcalc-hairline);
}

.bbcalc__cta-text {
	display: grid;
	gap: 8px;
	flex: 1 1 220px;
	min-width: 0;
}

/* The card's bottom line: what the comparison above it adds up to. */
.bbcalc__saving {
	color: var(--bbcalc-muted);
	font-size: 0.9375rem;
	line-height: 1.35;
}

.bbcalc__saving-label,
.bbcalc__saving-value {
	display: block;
}

.bbcalc__saving-label {
	font-size: 0.8125rem;
}

.bbcalc__saving-value {
	margin-top: 4px;
	color: var(--bbcalc-accent);
	font-size: 1.25rem;
	font-weight: 700;
	letter-spacing: -0.01em;
}

.bbcalc__saving-value strong {
	font-weight: inherit;
	white-space: nowrap;
}

.bbcalc__saving-suffix {
	font-weight: 500;
}

.bbcalc__button {
	flex: 0 0 auto;
}

/*
 * Standalone CTA card, used when the comparison is switched off — the button
 * used to live inside the comparison, so hiding that card silently removed the
 * only call to action on the page.
 */
.bbcalc__cta-card {
	padding: 22px;
}

.bbcalc__cta--standalone {
	margin-top: 0;
	padding-top: 0;
	border-top: 0;
}

.bbcalc__cta-copy {
	color: var(--bbcalc-muted);
	font-size: 0.875rem;
	line-height: 1.5;
}

/* Brand pill button: deepest navy, vivid blue on hover. */
.bbcalc__button {
	display: inline-flex;
	gap: 10px;
	align-items: center;
	justify-content: center;
	min-height: 48px;
	padding: 12px 24px;
	border: 0;
	border-radius: var(--bbcalc-radius-pill);
	color: var(--bbcalc-on-dark);
	background-color: var(--bbcalc-ink);
	font-family: inherit;
	font-size: 0.9375rem;
	font-weight: 500;
	line-height: 1.2;
	text-align: center;
	text-decoration: none;
	cursor: pointer;
	transition: background-color 200ms ease, transform 200ms ease;
}

.bbcalc__button-arrow {
	flex: 0 0 auto;
	transition: transform 200ms ease;
}

.bbcalc__button:hover .bbcalc__button-arrow,
.bbcalc__button:focus-visible .bbcalc__button-arrow {
	transform: translateX(3px);
}

.bbcalc__button:hover,
.bbcalc__button:focus-visible {
	color: var(--bbcalc-on-dark);
	background-color: var(--bbcalc-accent);
	text-decoration: none;
	transform: translateY(-1px);
}

.bbcalc__disclaimer {
	max-width: 92ch;
	margin-top: 24px;
	color: var(--bbcalc-muted);
	font-size: 0.75rem;
	line-height: 1.6;
}

/* ------------------------------------------------------------ Breakpoints -- */

@media (min-width: 640px) {
	.bbcalc__panel,
	.bbcalc__compare {
		padding-inline: 28px;
	}

	.bbcalc__result {
		padding: 36px 32px;
	}

	.bbcalc__aside {
		padding-inline: 26px;
	}

	.bbcalc__cta-card {
		padding: 26px 28px;
	}
}

/* --------------------------------------------------------- User settings -- */

@media (prefers-reduced-motion: reduce) {
	.bbcalc *,
	.bbcalc *::before,
	.bbcalc *::after {
		transition-duration: 0.01ms !important;
		animation-duration: 0.01ms !important;
	}
}

@media (prefers-contrast: more) {
	.bbcalc__card {
		border-color: var(--bbcalc-ink);
	}

	.bbcalc__number {
		border-color: var(--bbcalc-ink);
	}

	.bbcalc__subtitle,
	.bbcalc__note,
	.bbcalc__cta-copy,
	.bbcalc__disclaimer,
	.bbcalc__aside-body {
		color: var(--bbcalc-primary);
	}
}

@media print {
	.bbcalc {
		background-color: transparent;
	}

	.bbcalc__range,
	.bbcalc__button {
		display: none;
	}

	.bbcalc__card {
		box-shadow: none;
		break-inside: avoid;
	}
}
