/**
 * Flexo Hydraulic Calculators
 *
 * Inherits the site's Elementor kit via CSS custom properties, with
 * fallbacks matching flexo-tekniikka.fi's current kit values.
 *
 * Every rule is scoped under .fhc. Themes style bare elements through
 * selectors like ".single-content p" (specificity 0,1,1), which would
 * otherwise beat a lone ".fhc-warning" and reset our margins.
 */

.fhc {
	--fhc-primary: var(--e-global-color-primary, #1d68b3);
	--fhc-accent: var(--e-global-color-accent, #11a8ff);
	--fhc-heading: var(--e-global-color-text, #1c244b);
	--fhc-text: #666666;
	--fhc-border: #e5e8ee;
	--fhc-surface: #ffffff;
	--fhc-surface-alt: #f7f9fc;
	--fhc-radius: 10px;
	--fhc-font: var(--e-global-typography-text-font-family, "Poppins"), sans-serif;

	font-family: var(--fhc-font);
	color: var(--fhc-text);
}

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

.fhc .fhc-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
	gap: 28px;
	align-items: start;
}

.fhc .fhc-grid--single {
	grid-template-columns: minmax(280px, 480px);
}

/* Full width: the card uses whatever room the Elementor column gives it. */
.fhc[data-fhc-layout="wide"] .fhc-grid--single {
	grid-template-columns: minmax(0, 1fr);
}

/*
 * Input columns.
 *
 * auto-fit + minmax() reacts to the container, not the viewport, so a
 * calculator in a narrow column collapses to one field per row on its
 * own. The max() term keeps each track at least 1/n of the row, which
 * caps the count at --fhc-cols on wide screens.
 */
.fhc .fhc-fields {
	--fhc-cols: 1;
	--fhc-col-gap: 20px;
	display: grid;
	gap: 0 var(--fhc-col-gap);
	grid-template-columns: repeat(
		auto-fit,
		minmax(
			max(
				220px,
				calc((100% - (var(--fhc-cols) - 1) * var(--fhc-col-gap)) / var(--fhc-cols))
			),
			1fr
		)
	);
}

.fhc[data-fhc-cols="2"] .fhc-fields {
	--fhc-cols: 2;
}

.fhc[data-fhc-cols="3"] .fhc-fields {
	--fhc-cols: 3;
}

/* Conditional groups hand their fields to the grid above. */
.fhc .fhc-subgroup {
	display: contents;
}

.fhc .fhc-subgroup[hidden] {
	display: none;
}

/* Card */
.fhc .fhc-card {
	background: var(--fhc-surface);
	border: 1px solid var(--fhc-border);
	border-radius: var(--fhc-radius);
	padding: 28px 26px 26px;
	box-shadow: 0 6px 24px rgba(28, 36, 75, 0.06);
}

.fhc .fhc-card__title {
	font-family: var(--e-global-typography-primary-font-family, "Poppins"), sans-serif;
	font-weight: var(--e-global-typography-primary-font-weight, 600);
	color: var(--fhc-heading);
	font-size: 1.15em;
	line-height: 1.3;
	margin: 0 0 22px;
	padding-bottom: 14px;
	border-bottom: 2px solid var(--fhc-primary);
}

/* Fields */
.fhc .fhc-field {
	margin-bottom: 16px;
}

.fhc .fhc-field__label {
	display: block;
	font-size: 0.85em;
	font-weight: 500;
	color: var(--fhc-heading);
	margin-bottom: 6px;
}

.fhc .fhc-input-group {
	display: flex;
	align-items: stretch;
}

.fhc .fhc-input {
	flex: 1 1 auto;
	min-width: 0;
	width: 100%;
	font-family: inherit;
	font-size: 1em;
	color: var(--fhc-heading);
	background: var(--fhc-surface);
	border: 1px solid var(--fhc-border);
	border-right: 0;
	border-radius: 8px 0 0 8px;
	padding: 11px 14px;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
	appearance: none;
}

.fhc .fhc-input:focus {
	outline: none;
	border-color: var(--fhc-primary);
	box-shadow: 0 0 0 3px rgba(29, 104, 179, 0.12);
	position: relative;
	z-index: 1;
}

.fhc .fhc-input::placeholder {
	color: #b6bcc9;
}

.fhc .fhc-unit {
	flex: 0 0 auto;
	font-family: inherit;
	font-size: 0.9em;
	font-weight: 500;
	color: var(--fhc-heading);
	background-color: var(--fhc-surface-alt);
	border: 1px solid var(--fhc-border);
	border-radius: 0 8px 8px 0;
	padding: 0 30px 0 12px;
	cursor: pointer;
	appearance: none;
	-webkit-appearance: none;
	background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23666' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 11px center;
	transition: border-color 0.15s ease;
}

.fhc .fhc-unit:focus {
	outline: none;
	border-color: var(--fhc-primary);
	box-shadow: 0 0 0 3px rgba(29, 104, 179, 0.12);
	position: relative;
	z-index: 1;
}

/* Hints & errors */
.fhc .fhc-hint {
	font-size: 0.8em;
	margin: -6px 0 14px;
	color: var(--fhc-text);
}

.fhc .fhc-hint[hidden],
.fhc .fhc-error[hidden] {
	display: none;
}

.fhc .fhc-error {
	font-size: 0.8em;
	margin: -6px 0 14px;
	color: #c0392b;
}

.fhc .fhc-warning {
	font-size: 0.8em;
	margin: 14px 0 0;
	padding: 10px 14px;
	color: #7a5410;
	background: #fdf6e7;
	border: 1px solid #f0dcb0;
	border-radius: 8px;
}

.fhc .fhc-warning::before {
	content: "⚠ ";
}

.fhc .fhc-warning[hidden] {
	display: none;
}

/* Result */
.fhc .fhc-result {
	margin-top: 22px;
	background: var(--fhc-surface-alt);
	border: 1px solid var(--fhc-border);
	border-left: 4px solid var(--fhc-primary);
	border-radius: 8px;
	padding: 14px 18px;
}

.fhc .fhc-result__label {
	display: block;
	font-size: 0.8em;
	font-weight: 500;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--fhc-text);
	margin-bottom: 4px;
}

.fhc .fhc-result__row {
	display: flex;
	align-items: center;
	gap: 12px;
}

.fhc .fhc-result__value {
	font-family: var(--e-global-typography-primary-font-family, "Poppins"), sans-serif;
	font-size: 1.7em;
	font-weight: 600;
	line-height: 1.2;
	color: var(--fhc-primary);
	min-width: 2ch;
}

.fhc .fhc-unit--result {
	border-radius: 8px;
	background-color: var(--fhc-surface);
	padding-top: 8px;
	padding-bottom: 8px;
	align-self: center;
	height: auto;
}

/* Sub-headings (input groups / result groups) */
.fhc .fhc-subheading {
	font-family: var(--e-global-typography-primary-font-family, "Poppins"), sans-serif;
	font-size: 0.75em;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--fhc-primary);
	margin: 20px 0 10px;
}

.fhc .fhc-subheading--results {
	margin-top: 16px;
	margin-bottom: 2px;
}

/* Letter badge in field labels, matches the diagram letters */
.fhc .fhc-letter {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 1.5em;
	height: 1.5em;
	margin-left: 6px;
	border-radius: 50%;
	background: var(--fhc-primary);
	color: #ffffff;
	font-size: 0.78em;
	font-weight: 600;
	line-height: 1;
	vertical-align: middle;
}

/* Result rows (multi-output calculators) */
.fhc .fhc-results {
	margin-top: 22px;
	background: var(--fhc-surface-alt);
	border: 1px solid var(--fhc-border);
	border-left: 4px solid var(--fhc-primary);
	border-radius: 8px;
	padding: 8px 18px 12px;
}

.fhc .fhc-outrow {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
	padding: 9px 0;
	border-bottom: 1px dashed var(--fhc-border);
}

.fhc .fhc-outrow:last-child {
	border-bottom: 0;
}

.fhc .fhc-outrow--sub {
	padding-top: 0;
	margin-top: -7px;
	border-bottom: 1px dashed var(--fhc-border);
}

.fhc .fhc-outrow__label {
	font-size: 0.85em;
	color: var(--fhc-text);
}

.fhc .fhc-outrow__value {
	white-space: nowrap;
}

.fhc .fhc-outrow__value output {
	font-family: var(--e-global-typography-primary-font-family, "Poppins"), sans-serif;
	font-size: 1.1em;
	font-weight: 600;
	color: var(--fhc-heading);
}

.fhc .fhc-outrow--sub .fhc-outrow__value output {
	font-size: 0.95em;
	color: var(--fhc-text);
	font-weight: 500;
}

.fhc .fhc-outrow__unit {
	font-size: 0.8em;
	color: var(--fhc-text);
	margin-left: 2px;
}

/*
 * Wide layout: the three readouts read better as tiles across the card
 * than as full-width rows. The 1px gap over a border-coloured background
 * draws the separators, so they work in both row and column directions.
 */
.fhc[data-fhc-layout="wide"] .fhc-results {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
	gap: 1px;
	padding: 0;
	overflow: hidden;
	background: var(--fhc-border);
}

.fhc[data-fhc-layout="wide"] .fhc-outrow {
	display: block;
	padding: 12px 18px;
	border-bottom: 0;
	background: var(--fhc-surface-alt);
}

.fhc[data-fhc-layout="wide"] .fhc-outrow__label {
	display: block;
	margin-bottom: 2px;
}

.fhc[data-fhc-layout="wide"] .fhc-outrow__value output {
	font-size: 1.25em;
}

/* Link from a simple calculator to the detailed one */
.fhc .fhc-goto {
	margin: 14px 0 0;
	font-size: 0.85em;
}

.fhc .fhc-goto[hidden] {
	display: none;
}

.fhc .fhc-goto__link {
	color: var(--fhc-primary);
	font-weight: 500;
	text-decoration: none;
	border-bottom: 1px solid transparent;
	transition: border-color 0.15s ease;
}

.fhc .fhc-goto__link:hover,
.fhc .fhc-goto__link:focus {
	color: var(--fhc-primary);
	border-bottom-color: var(--fhc-primary);
}

/* Pipe/hose segmented toggle */
.fhc .fhc-toggle {
	display: flex;
	gap: 0;
	margin-bottom: 20px;
	border: 1px solid var(--fhc-border);
	border-radius: 8px;
	overflow: hidden;
}

.fhc .fhc-toggle__option {
	flex: 1 1 0;
	margin: 0;
}

.fhc .fhc-toggle__option input {
	position: absolute;
	opacity: 0;
	pointer-events: none;
}

.fhc .fhc-toggle__option span {
	display: block;
	text-align: center;
	padding: 10px 12px;
	font-size: 0.9em;
	font-weight: 500;
	color: var(--fhc-heading);
	background: var(--fhc-surface-alt);
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease;
}

.fhc .fhc-toggle__option input:checked + span {
	background: var(--fhc-primary);
	color: #ffffff;
}

.fhc .fhc-toggle__option input:focus-visible + span {
	box-shadow: inset 0 0 0 3px rgba(29, 104, 179, 0.35);
}

/* Full-width select used as an input (fluid, temperature, roughness) */
.fhc .fhc-input--select {
	border-right: 1px solid var(--fhc-border);
	border-radius: 8px;
	padding: 11px 34px 11px 14px;
	cursor: pointer;
	appearance: none;
	-webkit-appearance: none;
	background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23666' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 13px center;
}

/* Static unit suffix (cSt, kg/m³, mm) */
.fhc .fhc-unit--static {
	display: flex;
	align-items: center;
	cursor: default;
	background-image: none;
	padding: 0 14px;
}

/* Flow type chip */
.fhc .fhc-chip {
	display: inline-block;
	width: 10px;
	height: 10px;
	border-radius: 50%;
	margin-right: 7px;
	vertical-align: baseline;
}

.fhc .fhc-chip--lam {
	background: #2e9e5b;
}

.fhc .fhc-chip--trans {
	background: #e2a13c;
}

.fhc .fhc-chip--turb {
	background: #c0392b;
}

/* Cylinder diagram */
.fhc .fhc-diagram {
	margin: 4px 0 6px;
}

.fhc .fhc-svg {
	display: block;
	width: 100%;
	height: auto;
}

.fhc .fhc-svg__barrel {
	fill: #eef2f8;
	stroke: var(--fhc-heading);
	stroke-width: 2.5;
}

.fhc .fhc-svg__port {
	fill: #cfd8e6;
	stroke: var(--fhc-heading);
	stroke-width: 1.5;
}

.fhc .fhc-svg__piston {
	fill: var(--fhc-primary);
}

.fhc .fhc-svg__rod {
	fill: #9aa5b8;
}

.fhc .fhc-svg__rodend {
	fill: #7d8aa1;
}

.fhc .fhc-svg__gland {
	fill: #cfd8e6;
	stroke: var(--fhc-heading);
	stroke-width: 1.5;
}

.fhc .fhc-svg__dim,
.fhc .fhc-svg__ext,
.fhc .fhc-svg__leader {
	stroke: var(--fhc-heading);
	stroke-width: 1.2;
	opacity: 0.55;
}

.fhc .fhc-svg__arrow {
	fill: var(--fhc-heading);
	opacity: 0.55;
}

.fhc .fhc-svg__flow {
	stroke: var(--fhc-accent);
	stroke-width: 3;
}

.fhc .fhc-svg__flowarrow {
	fill: var(--fhc-accent);
}

.fhc .fhc-svg__badge {
	fill: var(--fhc-primary);
}

.fhc .fhc-svg__badgetext {
	fill: #ffffff;
	font-family: var(--e-global-typography-primary-font-family, "Poppins"), sans-serif;
	font-size: 12px;
	font-weight: 600;
	text-anchor: middle;
}

@media (max-width: 480px) {
	.fhc .fhc-card {
		padding: 22px 18px 20px;
	}
}
