/**
 * Baby Brezza Formula Finder — frontend styles.
 * Clean functional default; theme-agnostic and mobile-first.
 */

.bbff-finder {
	--bbff-accent: #0a7c86;
	--bbff-accent-dark: #075c63;
	--bbff-accent-rgb: 10, 124, 134;
	--bbff-text: #1d2327;
	--bbff-muted: #6b7280;
	--bbff-border: #d9dde1;
	--bbff-bg: #ffffff;
	--bbff-radius: 12px;
	width: 100%;
	max-width: 760px;
	margin: 0 auto;
	padding: clamp(1.25rem, 4vw, 3rem);
	background: #f8fafb;
	border: 1px solid #dfe5e8;
	border-radius: clamp(16px, 2.5vw, 24px);
	box-shadow: 0 18px 50px rgba(29, 35, 39, 0.08);
	color: var(--bbff-text);
	font-size: 16px;
	line-height: 1.5;
	position: relative;
}

.bbff-finder *,
.bbff-finder *::before,
.bbff-finder *::after {
	box-sizing: border-box;
	min-width: 0;
}

.bbff-finder,
.bbff-finder p,
.bbff-finder li,
.bbff-finder label,
.bbff-finder button,
.bbff-finder th,
.bbff-finder td {
	overflow-wrap: anywhere;
}

/*
 * The [hidden] attribute must always win. Author rules that set `display`
 * (e.g. the loading overlay's `display:flex`) otherwise override the browser
 * default `[hidden]{display:none}`, leaving toggled elements permanently
 * visible. This guarantees hidden means hidden for every element the JS toggles.
 */
.bbff-finder [hidden] {
	display: none !important;
}

/* Progress */
.bbff-progress {
	height: 6px;
	background: #eef1f3;
	border-radius: 999px;
	overflow: hidden;
	margin-bottom: 1.5rem;
}
.bbff-progress__bar {
	display: block;
	height: 100%;
	width: 20%;
	background: var(--bbff-accent);
	transition: width 0.3s ease;
}

/* Steps */
.bbff-step { animation: bbff-fade 0.25s ease; outline: none; }
.bbff-step__title { font-size: clamp(1.35rem, 3vw, 1.75rem); line-height: 1.2; margin: 0 0 0.5rem; }
.bbff-step__lead { color: var(--bbff-muted); margin: 0 0 1.25rem; }

@keyframes bbff-fade {
	from { opacity: 0; transform: translateY(6px); }
	to { opacity: 1; transform: none; }
}

/* Fields — scoped with .bbff-finder so the widget's look wins over the theme. */
.bbff-finder .bbff-field { margin-bottom: 1.1rem; }
.bbff-finder .bbff-field label {
	display: block;
	font-weight: 600;
	margin-bottom: 0.4rem;
	color: var(--bbff-text);
}
.bbff-finder .bbff-field input[type="text"],
.bbff-finder .bbff-field input[type="email"],
.bbff-finder .bbff-field select {
	width: 100%;
	box-sizing: border-box;
	min-height: 48px;
	margin: 0;
	padding: 0.7rem 0.9rem;
	border: 1px solid var(--bbff-border);
	border-radius: var(--bbff-radius);
	font-size: 1rem;
	line-height: 1.4;
	background-color: #fff;
	color: var(--bbff-text);
	box-shadow: none;
}
/* Custom chevron + native affordance reset for selects */
.bbff-finder .bbff-field select {
	appearance: none;
	-webkit-appearance: none;
	-moz-appearance: none;
	cursor: pointer;
	padding-right: 2.5rem;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%236b7280' stroke-width='1.6' d='M1 1.5 6 6.5 11 1.5'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 0.95rem center;
	background-size: 12px 8px;
}
.bbff-finder .bbff-field select:disabled {
	background-color: #f3f4f6;
	color: var(--bbff-muted);
	cursor: not-allowed;
	opacity: 1;
}
.bbff-finder .bbff-field input::placeholder { color: var(--bbff-muted); opacity: 1; }
.bbff-finder .bbff-field input:focus,
.bbff-finder .bbff-field select:focus {
	outline: none;
	border-color: var(--bbff-accent);
	box-shadow: 0 0 0 3px rgba(var(--bbff-accent-rgb), 0.18);
}
.bbff-field--check label { font-weight: 400; display: flex; align-items: center; gap: 0.5rem; }
.bbff-field--inline { display: flex; gap: 0.6rem; align-items: stretch; }
.bbff-field--inline input { flex: 1 1 auto; min-width: 0; }
.bbff-field--inline .bbff-btn { flex: 0 0 auto; white-space: nowrap; }

.bbff-hint {
	margin: 0.4rem 0 0;
	padding: 0.5rem 0.75rem;
	background: #f4fafb;
	border-left: 3px solid var(--bbff-accent);
	border-radius: 6px;
	font-size: 0.9rem;
	color: var(--bbff-muted);
}

/* Buttons */
.bbff-finder .bbff-btn {
	max-width: 100%;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 48px;
	border: 0;
	border-radius: var(--bbff-radius);
	padding: 0.7rem 1.4rem;
	font-size: 1rem;
	font-weight: 600;
	line-height: 1.2;
	cursor: pointer;
	text-align: center;
	text-decoration: none;
	text-transform: none; /* honour the translated casing; theme forces capitalize */
	white-space: normal;
	transition: background 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
.bbff-finder .bbff-btn--primary { background: var(--bbff-accent); color: #fff; }
.bbff-finder .bbff-btn--primary:hover { background: var(--bbff-accent-dark); box-shadow: 0 4px 12px rgba(var(--bbff-accent-rgb), 0.25); }
.bbff-finder .bbff-btn--secondary { background: #eef1f3; color: var(--bbff-text); }
.bbff-finder .bbff-btn--secondary:hover { background: #e2e6e9; }
.bbff-finder .bbff-btn--link {
	min-height: 0;
	background: none;
	color: var(--bbff-accent);
	text-decoration: underline;
	padding: 0.5rem 0.25rem;
}
.bbff-finder .bbff-btn--link:hover { color: var(--bbff-accent-dark); }
.bbff-finder .bbff-btn:focus-visible { outline: 2px solid var(--bbff-accent-dark); outline-offset: 2px; }

.bbff-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 0.75rem; margin-top: 1.5rem; }

/* Machine hero image — centred under the title, sized to the block, responsive */
.bbff-machine-hero {
	display: flex;
	align-items: center;
	justify-content: center;
	margin: 0.75rem 0 1.5rem;
	text-align: center;
}
.bbff-machine-hero img {
	display: block;
	width: min(100%, 420px);
	height: auto;
	max-width: 68%;
	max-height: 390px;
	margin: 0;
	object-fit: contain;
}

/* Choices — fully scoped/explicit so the host theme's button styles can't
   override the colours (otherwise white-on-white text can appear). */
.bbff-choices { display: grid; gap: 0.75rem; }
.bbff-finder .bbff-choice {
	display: block;
	width: 100%;
	border: 2px solid var(--bbff-border);
	background: #fff;
	color: var(--bbff-text);
	border-radius: var(--bbff-radius);
	padding: 1.25rem;
	cursor: pointer;
	font-size: 1.1rem;
	font-weight: 600;
	text-align: center;
	text-transform: none;
	transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.bbff-finder .bbff-choice:hover,
.bbff-finder .bbff-choice:focus {
	background: #fff;
	color: var(--bbff-text);
	border-color: var(--bbff-accent);
	box-shadow: 0 2px 10px rgba(var(--bbff-accent-rgb), 0.12);
	outline: none;
}
.bbff-finder .bbff-choice__title { color: inherit; }

/* Panels + divider */
.bbff-panel { padding: clamp(1rem, 3vw, 1.5rem); border: 1px solid var(--bbff-border); border-radius: var(--bbff-radius); margin-bottom: 0.5rem; background: #fff; box-shadow: 0 1px 2px rgba(29, 35, 39, 0.03); }
.bbff-panel__title { margin: 0 0 1rem; font-size: 1.1rem; font-weight: 700; }
.bbff-divider { text-align: center; position: relative; margin: 1.5rem 0; }
.bbff-divider::before { content: ""; position: absolute; top: 50%; left: 0; right: 0; height: 1px; background: var(--bbff-border); }
.bbff-divider span { position: relative; background: #fff; padding: 0 0.85rem; color: var(--bbff-muted); text-transform: uppercase; font-size: 0.8rem; letter-spacing: 0.05em; }

/* Scanner */
.bbff-scan { margin-bottom: 1rem; }
.bbff-scan .bbff-btn--secondary { width: 100%; }
.bbff-reader { width: 100%; max-width: 100%; margin-bottom: 0.85rem; border-radius: var(--bbff-radius); overflow: hidden; }
.bbff-scan:not(.is-scanning) .bbff-reader { display: none; }
.bbff-scan.is-scanning .bbff-reader {
	display: block;
	min-height: 220px;
	background: #111;
}
.bbff-reader > div,
.bbff-reader video,
.bbff-reader canvas,
.bbff-reader img,
.bbff-reader select,
.bbff-reader button {
	max-width: 100% !important;
}

/* Compact visual cue between camera scanning and manual barcode entry. */
.bbff-finder .bbff-barcode-guide {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	margin: 0.85rem 0 1rem;
	padding: 0.35rem 0;
	text-align: center;
}
.bbff-finder .bbff-barcode-guide img {
	display: block;
	width: 220px;
	max-width: 52%;
	height: auto;
	margin: 0;
	object-fit: contain;
}

/* Result */
.bbff-result__formula { font-weight: 600; color: var(--bbff-muted); margin: 0 0 1rem; }
.bbff-result__settings { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.25rem; }
.bbff-dial {
	background: linear-gradient(180deg, #f4fafb, #eaf4f5);
	border: 1px solid var(--bbff-border);
	border-radius: var(--bbff-radius);
	padding: 1.25rem;
	text-align: center;
}
.bbff-dial__label { display: block; text-transform: uppercase; font-size: 0.8rem; letter-spacing: 0.05em; color: var(--bbff-muted); margin-bottom: 0.35rem; }
.bbff-dial__value { display: block; font-size: 2.6rem; font-weight: 800; color: var(--bbff-accent-dark); line-height: 1; }

/* Result body: stage table, then a centred product image below it (all sizes).
   Centre via text-align on a full-width figure (not margin:auto) so a host
   theme that forces figure side-margins to 0 can't push it left. */
.bbff-result__body { margin-bottom: 1.5rem; }
.bbff-finder .bbff-result__media {
	display: block;
	width: auto;
	margin: 1.75rem 0 0;
	text-align: center;
}
.bbff-finder .bbff-result__media img {
	display: inline-block;
	width: 220px;
	max-width: 70%;
	height: auto;
	max-height: 240px;
	object-fit: contain;
	vertical-align: top;
	border: 1px solid var(--bbff-border);
	border-radius: var(--bbff-radius);
	background: #fff;
	padding: 0.6rem;
}

/* Stage → setting table */
.bbff-stages-table {
	table-layout: fixed;
	width: 100%;
	border-collapse: collapse;
	margin: 0;
	border: 1px solid var(--bbff-border);
	border-radius: var(--bbff-radius);
	overflow: hidden;
}
.bbff-stages-table th,
.bbff-stages-table td {
	padding: 0.75rem 1rem;
	text-align: left;
	border-bottom: 1px solid var(--bbff-border);
	word-break: break-word;
}
.bbff-stages-table thead th {
	background: #f4fafb;
	text-transform: uppercase;
	font-size: 0.78rem;
	letter-spacing: 0.05em;
	color: var(--bbff-muted);
}
.bbff-stages-table tbody tr:last-child td { border-bottom: 0; }
.bbff-stages-table__stage { font-weight: 600; }
.bbff-stages-table__value { font-weight: 800; font-size: 1.35rem; color: var(--bbff-accent-dark); }
.bbff-result__empty {
	background: #fff8e6;
	border-left: 3px solid #e0a800;
	padding: 0.85rem 1rem;
	border-radius: 6px;
	margin: 0 0 1.25rem;
}
.bbff-result__notes { margin: 1.5rem 0 0; background: #fff8e6; border-left: 3px solid #e0a800; padding: 0.75rem 1rem; border-radius: 6px; }
.bbff-reminders { margin-top: 1.25rem; }
.bbff-reminders h3 { margin: 0 0 0.5rem; font-size: 1rem; }
.bbff-reminders ul { margin: 0; padding-left: 1.15rem; color: var(--bbff-muted); }
.bbff-reminders li { margin-bottom: 0.4rem; }
.bbff-funnel-link { color: var(--bbff-accent); }

/* Footnote / hint under the finder */
.bbff-note {
	margin: 1.5rem 0 0;
	padding-top: 1rem;
	border-top: 1px solid var(--bbff-border);
	font-size: 0.85rem;
	line-height: 1.55;
	color: var(--bbff-muted);
}

/* Errors */
.bbff-error { color: #b32d2e; margin: 0.5rem 0 0; font-size: 0.9rem; }

/* Loading overlay */
.bbff-loading {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	background: rgba(255,255,255,0.7);
	border-radius: var(--bbff-radius);
	color: var(--bbff-muted);
	z-index: 5;
}
.bbff-spinner {
	width: 22px; height: 22px;
	border: 3px solid var(--bbff-border);
	border-top-color: var(--bbff-accent);
	border-radius: 50%;
	animation: bbff-spin 0.8s linear infinite;
}
@keyframes bbff-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
	.bbff-finder *,
	.bbff-finder *::before,
	.bbff-finder *::after {
		scroll-behavior: auto !important;
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}
}

.screen-reader-text {
	position: absolute !important;
	width: 1px; height: 1px;
	overflow: hidden;
	clip: rect(1px,1px,1px,1px);
	white-space: nowrap;
}

@media (max-width: 480px) {
	.bbff-finder {
		padding: 1rem;
		border-radius: 14px;
		box-shadow: 0 10px 30px rgba(29, 35, 39, 0.07);
	}
	.bbff-field--inline {
		flex-direction: column;
	}
	.bbff-finder .bbff-barcode-guide {
		margin: 0.7rem 0 0.85rem;
	}
	.bbff-finder .bbff-barcode-guide img {
		width: 180px;
		max-width: 68%;
	}
	.bbff-scan.is-scanning .bbff-reader {
		min-height: 190px;
	}
	.bbff-machine-hero {
		margin: 0.65rem 0 1.15rem;
	}
	.bbff-machine-hero img {
		width: min(100%, 280px);
		max-width: 78%;
		max-height: 280px;
	}
	.bbff-field--inline .bbff-btn,
	.bbff-actions .bbff-btn {
		width: 100%;
	}
	.bbff-finder .bbff-btn--link {
		padding-left: 0.5rem;
		padding-right: 0.5rem;
	}
	.bbff-stages-table th,
	.bbff-stages-table td {
		padding: 0.65rem 0.7rem;
	}
	.bbff-result__settings { grid-template-columns: 1fr; }
	.bbff-dial__value { font-size: 2.2rem; }
}

/*
 * The finder keeps its own stable light palette regardless of the visitor's
 * OS colour scheme — it is embedded in a light-themed page, so following
 * prefers-color-scheme would render dark controls on a white background.
 * Force the light values even when the host theme sets a dark scheme.
 */
.bbff-finder {
	color-scheme: light;
}
