/* bituch calculators. Mobile first, RTL. Colours, font and radii come from the theme (theme.json presets),
   with palette A as the fallback, exactly like bituch-leads.css: the same card, pills, button and gauge as
   calculator 1 (מתי בדקתם את התיק?). The only yellow on a calculator is its primary button. */

.bc {
	--bc-ink: var(--wp--preset--color--ink, #221D37);
	--bc-ink-soft: var(--wp--preset--color--ink-soft, #524E69);
	--bc-canvas: var(--wp--preset--color--canvas, #FBFAF6);
	--bc-surface: var(--wp--preset--color--surface, #FFFEFB);
	--bc-rule: var(--wp--preset--color--rule, #D7D4D7);
	--bc-line: var(--wp--preset--color--line, #8A8496);
	--bc-brand: var(--wp--preset--color--brand, #624BBC);
	--bc-brand-deep: var(--wp--preset--color--brand-deep, #432C8B);
	--bc-lilac: var(--wp--preset--color--lilac, #E2D9FF);
	--bc-soft: var(--wp--preset--color--soft, #F7F4FC);
	--bc-marker: var(--wp--preset--color--marker, #FFE228);
	--bc-marker-deep: #E8C506;
	--bc-font: var(--wp--preset--font-family--plex, "IBM Plex Sans Hebrew", "Segoe UI", "Arial Hebrew", "Noto Sans Hebrew", Arial, sans-serif);
	--bc-r-pill: var(--wp--custom--radius--pill, 999px);
	--bc-r-card: var(--wp--custom--radius--card, 16px);
	--bc-r-quiz: var(--wp--custom--radius--quiz, 20px);
	--bc-error: #C2272D;
	--bc-error-tint: #FFEBE9;
	/* Gauge colours from the canvas Calc boards (as in bituch-leads .blc). */
	--bc-good: #1D7D3E;
	--bc-mid: #036EAE;
	--bc-high: #975D00;
	--bc-good-tint: #E3F6E6;
	--bc-mid-tint: #E1EFF8;
	--bc-high-tint: #FBEFD9;

	container-type: inline-size;
	direction: rtl;
	font-family: var(--bc-font);
	font-weight: 400;
	line-height: 1.55;
	color: var(--bc-ink);
	text-align: start;
}

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

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

.bc p,
.bc h2,
.bc h3,
.bc ul,
.bc ol,
.bc dl,
.bc dd,
.bc fieldset { margin: 0; }

.bc a { color: var(--bc-brand); }
.bc a:hover { color: var(--bc-brand-deep); }

.bc :focus-visible {
	outline: 3px solid var(--bc-brand);
	outline-offset: 2px;
}

.bc [tabindex="-1"]:focus { outline: none; }

.bc-sr {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

/* The card. */
.bc-card {
	display: flex;
	flex-direction: column;
	gap: 18px;
	padding: 18px 16px;
	border: 1px solid var(--bc-rule);
	border-radius: var(--bc-r-quiz);
	background: var(--bc-surface);
}

.bc-stack-s { display: flex; flex-direction: column; gap: 8px; }

/* Text. */
.bc-h { font-size: 22px; font-weight: 700; line-height: 1.3; letter-spacing: 0; }
.bc-legend { margin: 0 0 10px; padding: 0; font-size: 18px; font-weight: 700; line-height: 1.4; }
.bc-body { font-size: 16px; line-height: 1.6; }
.bc-body-s { font-size: 15px; line-height: 1.55; color: var(--bc-ink-soft); }
.bc-muted { font-size: 15px; line-height: 1.5; color: var(--bc-ink-soft); }
.bc-small { font-size: 13px; line-height: 1.5; color: var(--bc-ink-soft); }
.bc-strong { font-weight: 700; }
.bc-help { font-size: 13px; line-height: 1.5; color: var(--bc-ink-soft); }

.bc-i { flex-shrink: 0; margin-top: 2px; }

.bc-why {
	display: flex;
	gap: 8px;
	align-items: flex-start;
	font-size: 13px;
	line-height: 1.5;
	color: var(--bc-ink-soft);
}

.bc-why .bc-i { color: var(--bc-brand); }

.bc-note,
.bc-notice {
	display: flex;
	gap: 8px;
	align-items: flex-start;
	padding: 10px 12px;
	border-radius: 12px;
	background: var(--bc-soft);
	font-size: 14px;
	line-height: 1.5;
}

.bc-note .bc-i { color: var(--bc-brand); }
.bc-notice { display: block; font-size: 13px; }

/* Choices: real inputs inside pill labels. Selected is lilac; 44px targets. */
.bc-form { display: flex; flex-direction: column; gap: 24px; }
.bc-fs { display: flex; flex-direction: column; gap: 10px; min-width: 0; padding: 0; border: 0; }
.bc-wrap { display: flex; flex-wrap: wrap; gap: 8px; }

.bc-pill {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 44px;
	padding: 0 16px;
	border: 1.5px solid var(--bc-line);
	border-radius: var(--bc-r-pill);
	background: var(--bc-surface);
	font-size: 15px;
	line-height: 1.25;
	cursor: pointer;
}

.bc-pill:hover { border-color: var(--bc-ink); }
.bc-pill input { flex-shrink: 0; width: 18px; height: 18px; margin: 0; accent-color: var(--bc-brand); }

/* Where :has() works, the whole pill shows the state and the focus ring. Elsewhere the native
   radio or checkbox shows both, and its own focus ring is never removed. */
@supports selector(:has(*)) {
	.bc-pill:has(input:checked) { border-color: var(--bc-ink); background: var(--bc-lilac); font-weight: 700; }
	.bc-pill:has(input[aria-invalid="true"]) { border-color: var(--bc-error); }
	.bc-pill:has(input:focus-visible) { outline: 3px solid var(--bc-brand); outline-offset: 2px; }
	.bc-pill input:focus-visible { outline: none; }
}

/* Errors. */
.bc-err {
	display: flex;
	gap: 6px;
	align-items: flex-start;
	font-size: 13px;
	line-height: 1.5;
	color: var(--bc-error);
}

.bc-formerr {
	display: flex;
	gap: 8px;
	align-items: flex-start;
	padding: 10px 12px;
	border-radius: 12px;
	background: var(--bc-error-tint);
	font-size: 14px;
	line-height: 1.5;
}

.bc-formerr:empty { display: none; }
.bc-formerr .bc-i { color: var(--bc-error); }

/* The button. */
.bc-primary {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	width: 100%;
	min-height: 48px;
	padding: 0 22px;
	border: 1.5px solid var(--bc-marker);
	border-radius: var(--bc-r-pill);
	background: var(--bc-marker);
	color: var(--bc-ink);
	font: inherit;
	font-size: 16px;
	font-weight: 700;
	cursor: pointer;
}

.bc-primary:hover { border-color: var(--bc-marker-deep); background: var(--bc-marker-deep); }
.bc-primary .bc-i { margin-top: 0; }

/* The result. */
.bc-result {
	display: flex;
	flex-direction: column;
	gap: 16px;
	padding: 18px 16px;
	border-radius: var(--bc-r-card);
	background: var(--bc-soft);
}

.bc-stale .bc-result { outline: 2px dashed var(--bc-line); outline-offset: 3px; } /* An answer changed since: the button reads "לעדכון התוצאה". */
.bc-kicker { font-size: 14px; font-weight: 700; color: var(--bc-brand-deep); }

.bc-gauge {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 6px;
	padding: 0;
	list-style: none;
}

.bc-gauge li {
	display: flex;
	flex-direction: column;
	gap: 6px;
	font-size: 13px;
	line-height: 1.35;
	text-align: center;
	color: var(--bc-ink-soft);
}

.bc-here {
	visibility: hidden;
	align-self: center;
	padding: 0 8px;
	border-radius: var(--bc-r-pill);
	background: var(--bc-ink);
	color: var(--bc-canvas);
	font-size: 12px;
	font-weight: 700;
	white-space: nowrap;
}

.bc-bar { display: block; height: 10px; border-radius: var(--bc-r-pill); background: var(--bc-rule); }
.bc-gauge li[data-on] { color: var(--bc-ink); font-weight: 700; }
.bc-gauge li[data-on] .bc-here { visibility: visible; }
.bc-gauge li[data-tone="good"][data-on] .bc-bar { background: var(--bc-good); }
.bc-gauge li[data-tone="mid"][data-on] .bc-bar { background: var(--bc-mid); }
.bc-gauge li[data-tone="high"][data-on] .bc-bar { background: var(--bc-high); }

.bc-block,
.bc-list,
.bc-groups { display: flex; flex-direction: column; gap: 10px; }

/* Rows: a name, a status chip, a line of text. */
.bc-rows { display: flex; flex-direction: column; gap: 8px; padding: 0; list-style: none; }

.bc-row {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	gap: 4px 10px;
	align-items: center;
	padding: 12px 14px;
	border-radius: 12px;
	background: var(--bc-surface);
}

.bc-row-name { font-size: 15px; font-weight: 700; line-height: 1.4; }
.bc-row-text { grid-column: 1 / -1; font-size: 14px; line-height: 1.55; color: var(--bc-ink-soft); }

.bc-chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 2px 10px;
	border-radius: var(--bc-r-pill);
	background: var(--bc-canvas);
	color: var(--bc-ink);
	font-size: 13px;
	font-weight: 700;
	line-height: 1.5;
	white-space: nowrap;
}

.bc-chip::before {
	content: "";
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--bc-line);
}

.bc-tone-good { background: var(--bc-good-tint); }
.bc-tone-good::before { background: var(--bc-good); }
.bc-tone-mid { background: var(--bc-mid-tint); }
.bc-tone-mid::before { background: var(--bc-mid); }
.bc-tone-high { background: var(--bc-high-tint); }
.bc-tone-high::before { background: var(--bc-high); }

/* Key numbers. */
.bc-metrics { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }

.bc-metric {
	display: flex;
	flex-direction: column;
	gap: 4px;
	padding: 12px 14px;
	border-radius: 12px;
	background: var(--bc-surface);
}

.bc-metric dt { font-size: 14px; color: var(--bc-ink-soft); }
.bc-value { font-size: 18px; font-weight: 700; line-height: 1.4; }
.bc-metric dd { display: flex; flex-direction: column; gap: 4px; }
.bc-mnote { font-size: 13px; line-height: 1.5; color: var(--bc-ink-soft); }
.bc-meta { font-size: 13px; line-height: 1.5; color: var(--bc-ink-soft); }

/* Tables: short numbers, so they wrap to fit a phone; sideways scroll only as a fallback. */
.bc-tablewrap { overflow-x: auto; border-radius: 12px; background: var(--bc-surface); }

.bc-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 14px;
	line-height: 1.45;
	font-variant-numeric: tabular-nums;
}

.bc-table caption { padding: 12px 14px 4px; font-weight: 700; text-align: start; }
.bc-table th,
.bc-table td { padding: 8px 10px; border-bottom: 1px solid var(--bc-rule); text-align: start; vertical-align: top; }
.bc-table th:first-child,
.bc-table td:first-child { padding-inline-start: 14px; }
.bc-table thead th { font-size: 13px; color: var(--bc-ink-soft); }
.bc-table tbody th { font-weight: 700; }
.bc-table tbody tr:last-child th,
.bc-table tbody tr:last-child td { border-bottom: 0; }

/* Lists. */
.bc-list { padding: 14px 16px; border-radius: 12px; background: var(--bc-surface); }
.bc-list ul { display: flex; flex-direction: column; gap: 10px; padding: 0; padding-inline-start: 20px; font-size: 15px; line-height: 1.55; }
.bc-list li::marker { color: var(--bc-brand); }
.bc-links { display: flex; flex-direction: column; gap: 6px; padding: 0; list-style: none; }

/* "הראו לי טווח" and the sources: native disclosure, works without JS. */
.bc-range,
.bc-sources {
	padding: 12px 14px;
	border-radius: 12px;
	background: var(--bc-surface);
}

.bc-range summary,
.bc-sources summary {
	min-height: 44px;
	display: flex;
	align-items: center;
	font-weight: 700;
	color: var(--bc-brand);
	cursor: pointer;
}

.bc-range[open] { display: flex; flex-direction: column; gap: 6px; }
.bc-sources ul { display: flex; flex-direction: column; gap: 6px; padding: 0; padding-inline-start: 20px; font-size: 13px; line-height: 1.5; }

.bc-result .bc-note { background: var(--bc-surface); }

/* The soft offer after the result. */
.bc-cta {
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 14px 16px;
	border: 1px solid var(--bc-rule);
	border-radius: 12px;
	background: var(--bc-surface);
}

.bc-cta-link {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 44px;
	font-weight: 700;
	text-decoration: none;
}

/* Wider containers. 420px: a desktop card; a phone (about 358px inside the gutters) stays one column. */
@container (min-width: 420px) {
	.bc-card { padding: 22px; }
	.bc-primary { width: auto; align-self: flex-start; }
	.bc-result { padding: 22px 24px; }
}

@container (min-width: 640px) {
	.bc-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (forced-colors: active) {
	/* Separate rules: a selector list with :has() would drop the whole rule where :has() is unknown. */
	.bc-gauge li[data-on] .bc-bar,
	.bc-chip { outline: 2px solid CanvasText; }
	.bc-pill:has(input:checked) { outline: 3px solid CanvasText; }
	.bc-primary { border-color: ButtonText; }
}

@media print {
	.bc-form { display: none; }
	.bc-range,
	.bc-sources { break-inside: avoid; }
}
