/**
 * Shared chrome for BHL calculators: form, date tabs and the index cards.
 * Scoped under .bhl-calc / .bhl-calc-index so it cannot leak into the theme.
 */

.bhl-calc-frame,
.bhl-calc {
	--bhl-calc-border: #e2e2e2;
	--bhl-calc-surface: #fff;
	--bhl-calc-muted: #666;
	--bhl-calc-accent: #1f6b4a;
	--bhl-calc-radius: 10px;
}

.bhl-calc {
	direction: rtl;
	text-align: right;
	max-width: 760px;
	margin: 0 auto;
	font-size: 17px;
	line-height: 1.7;
}

/*
 * The frame gives a calculator the shape of an instrument: a recessed display
 * across the top, and the controls seated below it on the body of the device.
 * The order is set in markup, so the display genuinely precedes the controls
 * for a screen reader too.
 */

.bhl-calc-frame {
	direction: rtl;
	max-width: 760px;
	margin: 0 auto;
	background: linear-gradient(#f2f5f3, #e7ece9);
	border: 1px solid #cdd6d1;
	border-radius: 18px;
	padding: 14px;
	box-shadow: 0 1px 1px rgba(255, 255, 255, .9) inset, 0 2px 4px rgba(16, 32, 24, .08), 0 18px 34px -18px rgba(16, 32, 24, .3);
}

.bhl-calc-frame .bhl-calc {
	max-width: none;
	margin: 0;
}

.bhl-calc-frame__nameplate {
	display: flex;
	align-items: center;
	gap: 9px;
	padding: 2px 6px 12px;
	color: #2c3b34;
	font-size: 19px;
	font-weight: 700;
	line-height: 1.4;
}

/* The display. Recessed rather than raised, so it reads as a screen set into
   the body of the device and not as another card stacked on the page. */
.bhl-calc-frame .bhl-calc__result {
	background: #fcfefd;
	border: 1px solid #c3cdc7;
	border-radius: 10px;
	padding: 20px;
	min-height: 104px;
	display: flex;
	flex-direction: column;
	justify-content: center;
	box-shadow: inset 0 2px 5px rgba(16, 32, 24, .13), 0 1px 0 rgba(255, 255, 255, .8);
}

.bhl-calc-frame .bhl-calc__error,
.bhl-calc-frame .bhl-calc__loading {
	margin-top: 0;
}

.bhl-calc__placeholder {
	margin: 0;
	text-align: center;
	color: #8d9a93;
	font-size: 15px;
}

/* The controls sit on the device body, so they lose the card they used to
   need when they stood alone on the page. */
.bhl-calc-frame .bhl-calc__form {
	border: 0;
	border-radius: 0;
	background: transparent;
	padding: 20px 6px 6px;
}

/* Raised against the body, the way keys are. */
.bhl-calc-frame .bhl-calc__option,
.bhl-calc-frame .bhl-calc__select select,
.bhl-calc-frame .bhl-calc__select input,
.bhl-calc-frame .bhl-calc__tab {
	background: #fff;
	border-color: #c8d1cc;
	box-shadow: 0 1px 1px rgba(16, 32, 24, .05);
}

.bhl-calc-frame .bhl-calc__tab.is-active {
	background: var(--bhl-calc-accent);
	border-color: var(--bhl-calc-accent);
}

.bhl-calc-frame .bhl-calc__submit {
	box-shadow: 0 2px 3px rgba(16, 32, 24, .18);
}

.bhl-calc__form {
	background: var(--bhl-calc-surface);
	border: 1px solid var(--bhl-calc-border);
	border-radius: var(--bhl-calc-radius);
	padding: 22px;
}

.bhl-calc__field {
	border: 0;
	margin: 0 0 22px;
	padding: 0;
}

.bhl-calc__field:last-of-type {
	margin-bottom: 16px;
}

.bhl-calc__legend {
	font-weight: 700;
	font-size: 18px;
	margin-bottom: 10px;
	padding: 0;
}

.bhl-calc__options {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
	gap: 10px;
}

.bhl-calc__option {
	display: flex;
	align-items: flex-start;
	gap: 9px;
	border: 1px solid var(--bhl-calc-border);
	border-radius: 8px;
	padding: 11px 13px;
	cursor: pointer;
	transition: border-color .15s, background-color .15s;
}

.bhl-calc__option:hover {
	border-color: #bdbdbd;
}

.bhl-calc__option:has(input:checked) {
	border-color: var(--bhl-calc-accent);
	background: #f3f9f6;
}

.bhl-calc__option input {
	margin: 6px 0 0;
	flex: none;
}

.bhl-calc__option-text {
	display: flex;
	flex-direction: column;
}

.bhl-calc__option-label {
	font-weight: 600;
}

.bhl-calc__option-hint {
	font-size: 14px;
	color: var(--bhl-calc-muted);
	line-height: 1.5;
}

.bhl-calc__tabs {
	display: flex;
	gap: 6px;
	margin-bottom: 14px;
}

/*
 * Every row of controls runs the full width of the frame, so they share one
 * left edge and one right edge and read as the face of an instrument. Widths
 * are shared out in proportion rather than fixed, so a longer label stretches
 * its control instead of overflowing it.
 */
.bhl-calc__tab {
	flex: 1;
	background: #f4f4f4;
	border: 1px solid var(--bhl-calc-border);
	border-radius: 8px;
	padding: 8px 16px;
	font: inherit;
	font-size: 16px;
	text-align: center;
	cursor: pointer;
	color: #333;
}

.bhl-calc__tab.is-active {
	background: var(--bhl-calc-accent);
	border-color: var(--bhl-calc-accent);
	color: #fff;
}

.bhl-calc__selects {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
}

.bhl-calc__select {
	display: flex;
	flex-direction: column;
	gap: 5px;
	font-size: 15px;
	color: var(--bhl-calc-muted);
	flex: 1 1 0;
	min-width: 0;
}

.bhl-calc__select--wide {
	min-width: 220px;
}

.bhl-calc__select select,
.bhl-calc__select input {
	font: inherit;
	font-size: 17px;
	color: #222;
	padding: 9px 11px;
	border: 1px solid var(--bhl-calc-border);
	border-radius: 8px;
	background: #fff;
	min-height: 44px;
}

.bhl-calc__converted {
	margin: 12px 0 0;
	font-weight: 600;
}

.bhl-calc__sunset {
	margin: 8px 0 0;
	font-size: 14px;
	line-height: 1.6;
	color: var(--bhl-calc-muted);
	background: #fbf8ef;
	border-right: 3px solid #d9c27d;
	padding: 9px 12px;
	border-radius: 6px;
}

/* The equals key: the widest control, and the last thing in the column. */
.bhl-calc__submit {
	font: inherit;
	font-size: 18px;
	font-weight: 600;
	background: var(--bhl-calc-accent);
	color: #fff;
	border: 0;
	border-radius: 8px;
	padding: 12px 34px;
	min-height: 48px;
	width: 100%;
	cursor: pointer;
}

.bhl-calc__submit:hover {
	background: #175539;
}

.bhl-calc__error {
	margin-top: 18px;
	background: #fdf1f1;
	border-right: 3px solid #c0392b;
	padding: 12px 14px;
	border-radius: 6px;
}

.bhl-calc__loading {
	margin-top: 18px;
	color: var(--bhl-calc-muted);
}

/* Index of calculators. */

.bhl-calc-index {
	direction: rtl;
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
	gap: 14px;
	max-width: 900px;
	margin: 0 auto;
}

.bhl-calc-card {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	border: 1px solid #e2e2e2;
	border-radius: 10px;
	padding: 18px;
	text-decoration: none;
	color: inherit;
	background: #fff;
	transition: border-color .15s, transform .15s;
}

.bhl-calc-card:hover {
	border-color: #1f6b4a;
	transform: translateY(-2px);
}

.bhl-calc-card__icon {
	font-size: 26px;
	line-height: 1;
}

.bhl-calc-card__body {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.bhl-calc-card__title {
	font-weight: 700;
	font-size: 18px;
}

.bhl-calc-card__text {
	font-size: 15px;
	color: #666;
	line-height: 1.6;
}

@media (max-width: 600px) {
	.bhl-calc {
		font-size: 16px;
	}

	.bhl-calc__form {
		padding: 16px;
	}

	.bhl-calc-frame {
		border-radius: 14px;
		padding: 10px;
	}

	.bhl-calc-frame__nameplate {
		font-size: 18px;
		padding: 2px 4px 10px;
	}

	.bhl-calc-frame .bhl-calc__form {
		padding: 16px 4px 4px;
	}

	.bhl-calc-frame .bhl-calc__result {
		padding: 16px;
		min-height: 88px;
	}

	.bhl-calc__selects {
		gap: 8px;
	}
}
