/**
 * Transformer Calculators
 * Version 1.0.0
 */

.tc-calculator {
	--tc-border-color: #d9dde2;
	--tc-border-strong: #b8bec6;
	--tc-background: #ffffff;
	--tc-background-soft: #f5f7f8;
	--tc-text: #20252b;
	--tc-text-muted: #606a75;

	--tc-accent: rgb(15, 37, 65);
	--tc-accent-dark: rgb(10, 27, 48);
	--tc-slider-color: rgb(15, 37, 65);
	--tc-total-background: rgb(170, 24, 44);
	--tc-baseline-border: rgb(170, 24, 44);
	--tc-best-border: #126817;

	--tc-error-background: #fff4f1;
	--tc-error-border: #d46a54;
	--tc-radius: 8px;
	--tc-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);

	box-sizing: border-box;
	width: 100%;
	color: var(--tc-text);
	font-family: inherit;
}

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


/* =========================================================
   Header
   ========================================================= */

.tc-calculator__header {
	margin-bottom: 24px;
}

.tc-calculator__title {
	margin: 0;
	font-size: clamp(1.5rem, 2vw, 2rem);
	line-height: 1.2;
}

.tc-calculator__information {
	margin: -12px 0 28px;
	font-size: 0.875rem;
	line-height: 1.55;
	color: var(--tc-text-muted);
}


/* =========================================================
   Inputs
   ========================================================= */

.tc-calculator__inputs {
	display: grid;
	grid-template-columns: repeat(5, minmax(0, 1fr));
	gap: 20px;

	margin-bottom: 32px;
	padding: 24px;

	border: 1px solid var(--tc-border-color);
	border-radius: var(--tc-radius);

	background: var(--tc-background-soft);
}

.tc-field {
	min-width: 0;
}

.tc-field__heading {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 10px;
}

.tc-field__label {
	display: block;
	margin-bottom: 10px;

	font-size: 0.875rem;
	font-weight: 700;
	line-height: 1.35;

	color: var(--tc-text);
}

.tc-field__heading .tc-field__label {
	margin-bottom: 0;
}

.tc-field__value {
	flex: 0 0 auto;

	font-size: 0.875rem;
	font-weight: 700;
	white-space: nowrap;

	color: var(--tc-accent);
}

.tc-field__control {
	width: 100%;
}

.tc-select,
.tc-number-input {
	display: block;

	width: 100%;
	min-height: 46px;

	margin: 0;
	padding: 10px 12px;

	border: 1px solid var(--tc-border-strong);
	border-radius: 5px;

	background: var(--tc-background);
	color: var(--tc-text);

	font: inherit;
	font-size: 1rem;
	line-height: 1.3;
}

.tc-select:focus,
.tc-number-input:focus {
	border-color: var(--tc-accent);
	outline: 2px solid rgba(15, 37, 65, 0.18);
	outline-offset: 1px;
}

.tc-input-with-unit {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	align-items: stretch;
}

.tc-input-with-unit .tc-number-input {
	border-radius: 5px 0 0 5px;
}

.tc-input-with-unit__unit {
	display: flex;
	align-items: center;
	justify-content: center;

	padding: 8px 12px;

	border: 1px solid var(--tc-border-strong);
	border-left: 0;
	border-radius: 0 5px 5px 0;

	background: #e9edef;

	font-size: 0.875rem;
	font-weight: 700;
	white-space: nowrap;

	color: var(--tc-text-muted);
}


/* =========================================================
   Range inputs
   ========================================================= */

.tc-range {
	width: 100%;
	height: 22px;

	margin: 0;
	padding: 0;

	cursor: pointer;

	accent-color: var(--tc-slider-color);
}

.tc-range:focus-visible {
	outline: 2px solid var(--tc-accent);
	outline-offset: 3px;
}

.tc-range-scale {
	display: flex;
	justify-content: space-between;

	margin-top: 5px;

	font-size: 0.75rem;

	color: var(--tc-text-muted);
}


/* =========================================================
   Results grid
   Maximum 4 models per row
   ========================================================= */

.tc-calculator .tc-results {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	align-items: stretch;

	gap: 20px;

	width: 100%;
}


/* =========================================================
   Result cards
   ========================================================= */

.tc-calculator .tc-result-card {
	display: flex;
	flex-direction: column;

	min-width: 0;
	overflow: hidden;

	border: 2px solid var(--tc-border-color);
	border-radius: var(--tc-radius);

	background: var(--tc-background);

	box-shadow: var(--tc-shadow);
}

.tc-calculator .tc-result-card__header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;

	gap: 12px;

	min-height: 64px;

	padding: 18px 20px;

	border-bottom: 1px solid var(--tc-border-color);

	background: var(--tc-background-soft);
}

.tc-calculator .tc-result-card__title {
	margin: 0;

	font-size: 1.125rem;
	font-weight: 700;
	line-height: 1.25;

	color: var(--tc-text);
}

.tc-calculator .tc-result-card__values {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;

	margin: 0;
	padding: 0;

	background: var(--tc-background);
}

/* =========================================================
   Result rows
   ========================================================= */

.tc-calculator .tc-result-row {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;

	gap: 18px;

	margin: 0;
	padding: 13px 20px;

	border-bottom: 1px solid var(--tc-border-color);

	background: var(--tc-background);
}

.tc-calculator .tc-result-row:last-child {
	border-bottom: 0;
}

.tc-calculator .tc-result-row dt,
.tc-calculator .tc-result-row dd {
	margin: 0;
}

.tc-calculator .tc-result-row dt {
	max-width: 63%;

	font-size: 0.875rem;
	font-weight: 500;
	line-height: 1.4;

	color: var(--tc-text-muted);
}

.tc-calculator .tc-result-row dd {
	flex: 0 0 auto;

	text-align: right;

	font-size: 0.9375rem;
	font-weight: 700;
	line-height: 1.4;
	white-space: nowrap;

	color: var(--tc-text);
}

.tc-calculator .tc-result-row--highlight {
	background: var(--tc-background-soft);
}

.tc-calculator .tc-result-row--highlight dt,
.tc-calculator .tc-result-row--highlight dd {
	font-weight: 700;
	color: var(--tc-text);
}


/* =========================================================
Lifetime total
========================================================= */

.tc-calculator .tc-result-row--total {
	margin-top: auto;

	background: var(--tc-total-background);
}

.tc-calculator .tc-result-card--best .tc-result-row--total {
	background: #126817;
}

.tc-calculator .tc-result-row--total dt,
.tc-calculator .tc-result-row--total dd,
.tc-calculator .tc-result-row--total span,
.tc-calculator .tc-result-row--total .tc-unit {
	color: #ffffff;
}

.tc-calculator .tc-result-row--total dt,
.tc-calculator .tc-result-row--total dd {
	font-weight: 700;
}


/* =========================================================
   Units
   ========================================================= */

.tc-calculator .tc-unit {
	margin-left: 3px;

	font-size: 0.78em;
	font-weight: 600;

	color: var(--tc-text-muted);
}


/* =========================================================
   Unavailable model
   ========================================================= */

.tc-calculator .tc-result-card__unavailable {
	margin: 20px;
	padding: 16px;

	border-left: 4px solid var(--tc-error-border);

	background: var(--tc-error-background);

	font-size: 0.9375rem;
	line-height: 1.5;
}

.tc-calculator .tc-result-card--unavailable {
	box-shadow: none;
}

/* =========================================================
Comparison baseline
========================================================= */

.tc-calculator .tc-result-card--baseline {
	border: 2px solid var(--tc-baseline-border);
}


/* =========================================================
Best model
========================================================= */

.tc-calculator .tc-result-card--best {
	border: 2px solid var(--tc-best-border);

	box-shadow: 0 3px 14px rgba(60, 135, 70, 0.12);
}

.tc-calculator .tc-result-card--best .tc-result-card__header {
	background: var(--tc-background-soft);
}

.tc-calculator .tc-result-card__best-badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;

	flex: 0 0 auto;

	width: 112px;
	min-height: 40px;

	margin: 0;
	padding: 5px 9px;

	border: 0;
	border-radius: 999px;

	background: #126817;
	color: #ffffff;

	font-family: inherit;
	font-size: 0.72rem;
	font-weight: 700;
	line-height: 1.15;

	text-align: center;
	white-space: normal;
}

.tc-calculator .tc-result-card__best-badge[hidden] {
	display: none;
}


/* =========================================================
   Actions / PDF
   ========================================================= */

.tc-calculator .tc-calculator__actions {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	justify-content: flex-end;

	gap: 10px;

	width: 100%;

	margin-top: 28px;
}

.tc-calculator .tc-button,
.tc-calculator button.tc-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;

	width: auto;
	min-width: 180px;
	min-height: 46px;

	margin: 0;
	padding: 11px 22px;

	border: 1px solid var(--tc-accent);
	border-radius: 5px;

	background: var(--tc-accent);
	color: #ffffff;

	font-family: inherit;
	font-size: 1rem;
	font-weight: 700;
	line-height: 1.2;

	text-align: center;
	text-decoration: none;

	appearance: none;
	-webkit-appearance: none;

	cursor: pointer;

	transition:
		background-color 160ms ease,
		border-color 160ms ease,
		opacity 160ms ease;
}

.tc-calculator .tc-button:hover:not(:disabled),
.tc-calculator button.tc-button:hover:not(:disabled) {
	border-color: var(--tc-accent-dark);

	background: var(--tc-accent-dark);
	color: #ffffff;
}

.tc-calculator .tc-button:focus-visible,
.tc-calculator button.tc-button:focus-visible {
	outline: 2px solid var(--tc-accent);
	outline-offset: 3px;
}

.tc-calculator .tc-button:disabled,
.tc-calculator button.tc-button:disabled {
	opacity: 0.45;

	cursor: not-allowed;
}

.tc-calculator .tc-pdf-status {
	width: 100%;
	margin: 0;
	text-align: center;

	font-size: 0.875rem;
	line-height: 1.4;

	color: var(--tc-text-muted);
}


/* =========================================================
   General messages
   ========================================================= */

.tc-message {
	padding: 16px;

	border-radius: var(--tc-radius);
}

.tc-message--error {
	border-left: 4px solid var(--tc-error-border);

	background: var(--tc-error-background);
}

.tc-calculator .tc-pdf-status--rate-limit {
	color: rgb(170, 24, 44);
	font-size: 1.1rem;
	font-weight: 700;
	line-height: 1.4;
}

@media (max-width: 767px) {

	.tc-calculator .tc-pdf-status--rate-limit {
		font-size: 1rem;
	}
}

/* =========================================================
   Tablet
   ========================================================= */

@media (max-width: 1100px) {

	.tc-calculator__inputs {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.tc-field:last-child {
		grid-column: span 2;
	}

	.tc-calculator .tc-results {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

}


/* =========================================================
   Mobile
   ========================================================= */

@media (max-width: 767px) {

	.tc-field__label,
	.tc-range-scale {
		font-size: 1.2rem;
	}

}

@media (max-width: 640px) {

	.tc-calculator__header {
		margin-bottom: 18px;
	}

	.tc-calculator__inputs {
		grid-template-columns: minmax(0, 1fr);

		gap: 22px;

		margin-bottom: 24px;
		padding: 18px;
	}

	.tc-field:last-child {
		grid-column: auto;
	}

	.tc-calculator .tc-results {
		grid-template-columns: minmax(0, 1fr);
	}

	.tc-calculator .tc-result-row {
		gap: 12px;

		padding: 12px 16px;
	}

	.tc-calculator .tc-result-card__header {
		padding: 16px;
	}

	.tc-calculator .tc-result-row dt {
		max-width: 60%;
	}

	.tc-calculator .tc-calculator__actions {
		justify-content: stretch;
	}

	.tc-calculator .tc-button,
	.tc-calculator button.tc-button {
		width: 100%;
	}

}



/* =========================================================
   Reduced motion
   ========================================================= */

@media (prefers-reduced-motion: reduce) {

	.tc-calculator .tc-button {
		transition: none;
	}

}
