/*
 * Food Substitution Calculator page.
 * Loaded only on the calculator page, after style.css, so these rules take over
 * from the older "Food Calculator" block in style.css.
 */

/* ---------- Form layout ---------- */

#food-calculator #fc_wrapper fieldset {
	text-align: left;
	padding: 4px 0 0;
}

#food-calculator #fc_wrapper fieldset > br {
	display: none;
}

#food-calculator #fc_wrapper label {
	display: block;
	position: relative;
	width: 100%;
	margin: 0 0 18px;
	font-size: 14px;
	font-weight: 700;
	line-height: 1.4;
	letter-spacing: 0.01em;
	color: #111;
	box-sizing: border-box;
}

/* The replacement field is swapped in by the search and arrives wrapped in its own label. */
#food-calculator #fc_wrapper label label {
	margin: 0;
}

/* ---------- Text boxes and the replacement dropdown ---------- */

#food-calculator #fc_name,
#food-calculator #fc_units,
#food-calculator #fc_replace {
	display: block;
	width: 100%;
	height: 48px;
	margin: 6px 0 0;
	padding: 0 14px;
	box-sizing: border-box;
	background-color: #333;
	border: 1px solid #555;
	border-radius: 5px;
	color: #fff;
	font-family: 'Open Sans Condensed', 'Open Sans', Arial, sans-serif;
	font-size: 21px;
	font-weight: 700;
	line-height: 46px;
	letter-spacing: 1px;
	text-transform: uppercase;
	text-shadow: none;
	box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
	transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
	-webkit-appearance: none;
	appearance: none;
}

#food-calculator #fc_name:hover,
#food-calculator #fc_units:hover,
#food-calculator #fc_replace:hover {
	border-color: #777;
}

#food-calculator #fc_name:focus,
#food-calculator #fc_units:focus,
#food-calculator #fc_replace:focus {
	outline: 0;
	background-color: #2b2b2b;
	border-color: #5b8cff;
	box-shadow: 0 0 0 3px rgba(0, 56, 169, 0.45);
}

#food-calculator #fc_wrapper ::placeholder {
	color: #a9a9a9;
	font-weight: 400;
	letter-spacing: 0.5px;
	text-transform: none;
	opacity: 1;
}

#food-calculator select#fc_replace {
	padding-right: 44px;
	cursor: pointer;
	background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1 1l6 6 6-6' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 16px center;
}

#food-calculator select#fc_replace option {
	background: #fff;
	color: #111;
	font-family: 'Open Sans', Arial, sans-serif;
	font-size: 15px;
	font-weight: 400;
	letter-spacing: 0;
	text-transform: none;
}

/* Small spinner at the right of the box while a search is running. */
#food-calculator #fc_wrapper label.fc-busy::after {
	content: "";
	position: absolute;
	right: 14px;
	bottom: 15px;
	width: 16px;
	height: 16px;
	border: 2px solid rgba(255, 255, 255, 0.25);
	border-top-color: #fff;
	border-radius: 50%;
	animation: fc-spin 0.7s linear infinite;
	pointer-events: none;
}

@keyframes fc-spin {
	to {
		transform: rotate(360deg);
	}
}

/* ---------- Buttons ---------- */

#food-calculator #fc_wrapper fieldset > div {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 10px;
	margin: 6px 0 22px;
}

#food-calculator #fc_wrapper input[type="submit"],
#food-calculator #fc_wrapper input[type="reset"] {
	display: inline-block;
	width: auto;
	height: 44px;
	min-width: 130px;
	margin: 0;
	padding: 0 22px;
	box-sizing: border-box;
	border: 1px solid #002a80;
	border-radius: 5px;
	background: #0038a9;
	color: #fff;
	font-family: 'Open Sans', Arial, sans-serif;
	font-size: 15px;
	font-weight: 700;
	letter-spacing: 0.04em;
	line-height: 42px;
	text-transform: uppercase;
	cursor: pointer;
	opacity: 1;
	transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
	-webkit-appearance: none;
	appearance: none;
}

#food-calculator #fc_wrapper input[type="submit"]:hover {
	height: 44px;
	background: #0a4bd6;
	opacity: 1;
}

#food-calculator #fc_wrapper input[type="reset"] {
	background: #4a4a4a;
	border-color: #333;
}

#food-calculator #fc_wrapper input[type="reset"]:hover {
	height: 44px;
	background: #5c5c5c;
	opacity: 1;
}

#food-calculator #fc_wrapper input[type="submit"]:focus-visible,
#food-calculator #fc_wrapper input[type="reset"]:focus-visible {
	outline: 0;
	box-shadow: 0 0 0 3px rgba(0, 56, 169, 0.45);
}

/* ---------- Suggestions list ---------- */

#food-calculator .fc_suggest {
	position: absolute;
	top: 100%;
	left: 0;
	z-index: 1000 !important;
	display: block;
	width: 100%;
	max-height: 344px;
	margin: 6px 0 0;
	padding: 5px;
	box-sizing: border-box;
	overflow-y: auto;
	overscroll-behavior: contain;
	list-style: none;
	background: #fff;
	border: 1px solid #c5cad3;
	border-radius: 8px;
	box-shadow: 0 14px 34px rgba(0, 0, 0, 0.38), 0 2px 6px rgba(0, 0, 0, 0.2);
	scrollbar-width: thin;
	scrollbar-color: #b4bac4 transparent;
}

#food-calculator .fc_suggest li {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 14px;
	margin: 0;
	padding: 9px 12px;
	list-style: none;
	background: transparent;
	border-radius: 5px;
	color: #1c2330;
	font-family: 'Open Sans', Arial, sans-serif;
	font-size: 15px;
	font-weight: 400;
	line-height: 1.35;
	letter-spacing: 0;
	text-transform: none;
	cursor: pointer;
}

#food-calculator .fc_suggest li + li {
	margin-top: 1px;
}

#food-calculator .fc_suggest li.selected {
	background: #e7efff;
	box-shadow: inset 3px 0 0 #0038a9;
}

#food-calculator .fc_suggest .fc-name {
	flex: 1 1 auto;
	min-width: 0;
	overflow-wrap: anywhere;
}

/* The typed words, picked out inside each name. */
#food-calculator .fc_suggest mark {
	padding: 0;
	background: none;
	color: #0038a9;
	font-weight: 700;
}

#food-calculator .fc_suggest .category {
	flex: 0 0 auto;
	padding: 3px 9px;
	border-radius: 999px;
	background: #eceff3;
	color: #414a58;
	font-size: 11px;
	font-weight: 700;
	line-height: 1.3;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	white-space: nowrap;
}

#food-calculator .fc_suggest .category:empty {
	display: none;
}

#food-calculator .fc_suggest .category.cat-protein {
	background: #fde5e5;
	color: #8f1a1a;
}

#food-calculator .fc_suggest .category.cat-carbs {
	background: #fff1cc;
	color: #7a4f00;
}

#food-calculator .fc_suggest .category.cat-fat {
	background: #e0f2e4;
	color: #1b5e2e;
}

#food-calculator .fc_suggest li.no-result {
	display: block;
	padding: 12px;
	color: #414a58;
	cursor: default;
}

#food-calculator .fc_suggest li.no-result a {
	color: #0038a9;
	font-weight: 700;
	text-decoration: underline;
}

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

#food-calculator #result-wrapper {
	margin: 4px 0 26px;
	padding: 22px 20px 18px;
	background: #fff;
	border: 1px solid #c5cad3;
	border-radius: 8px;
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
	text-align: center;
}

#food-calculator #result-wrapper h2 {
	margin: 0 0 16px;
	padding: 0;
	background: none;
	color: #111;
	font-size: 21px;
	font-style: normal;
	font-weight: 700;
	line-height: 1.4;
	text-align: center;
}

#food-calculator #result-wrapper h3 {
	display: none;
}

#food-calculator #result-wrapper p {
	margin: 12px 0 0;
	text-align: center;
}

#food-calculator #result-wrapper p a {
	display: inline-block;
	padding: 9px 18px;
	border-radius: 5px;
	background: #0038a9;
	color: #fff;
	font-size: 13px;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-decoration: none;
	text-transform: uppercase;
}

#food-calculator #result-wrapper p a:hover {
	background: #0a4bd6;
}

#food-calculator #conversion-info {
	width: 100%;
	margin: 0 auto;
	background: none;
	border: 1px solid #d5d9e0;
	border-collapse: separate;
	border-spacing: 0;
	border-radius: 6px;
	overflow: hidden;
}

#food-calculator #conversion-info th {
	padding: 10px 12px;
	background: #1a1a1a;
	color: #fff;
	font: 700 12px/1.3 'Open Sans', Arial, sans-serif;
	letter-spacing: 0.06em;
	text-align: right;
	text-transform: uppercase;
}

#food-calculator #conversion-info th:first-child {
	text-align: left;
}

#food-calculator #conversion-info td {
	padding: 11px 12px;
	background: #fff;
	border: 0;
	border-top: 1px solid #e3e6eb;
	color: #1c2330;
	font: 400 15px/1.35 'Open Sans', Arial, sans-serif;
	text-align: right;
}

#food-calculator #conversion-info tr:nth-child(odd) td {
	background: #f6f7f9;
}

#food-calculator #conversion-info td.label {
	font-weight: 700;
	text-align: left;
}

#food-calculator #conversion-info td.unit {
	text-align: right;
	white-space: nowrap;
}

/* ---------- Small screens ---------- */

@media (max-width: 600px) {
	#food-calculator #fc_name,
	#food-calculator #fc_units,
	#food-calculator #fc_replace {
		font-size: 18px;
	}

	#food-calculator #fc_wrapper input[type="submit"],
	#food-calculator #fc_wrapper input[type="reset"] {
		flex: 1 1 130px;
	}

	#food-calculator .fc_suggest {
		max-height: 290px;
	}

	#food-calculator .fc_suggest li {
		padding: 10px;
	}

	#food-calculator #result-wrapper {
		padding: 18px 10px 14px;
		overflow-x: auto;
	}

	#food-calculator #conversion-info th,
	#food-calculator #conversion-info td {
		padding: 9px 7px;
		font-size: 13px;
	}
}

@media (prefers-reduced-motion: reduce) {
	#food-calculator #fc_wrapper label.fc-busy::after {
		animation: none;
	}

	#food-calculator #fc_name,
	#food-calculator #fc_units,
	#food-calculator #fc_replace,
	#food-calculator #fc_wrapper input[type="submit"],
	#food-calculator #fc_wrapper input[type="reset"] {
		transition: none;
	}
}
