/*
 * LAPObesity Tools — calculator styles.
 *
 * Theme-independent: everything is scoped under .lapo-tool and driven by custom
 * properties, so the LAPObesity theme (or any other) can restyle the tools by
 * overriding the --lapo-* variables without touching this file.
 * Fonts are inherited from the theme; the plugin loads none.
 */

.lapo-tool {
	--lapo-primary: #2f5d50;
	--lapo-primary-hover: #244a3f;
	--lapo-primary-soft: #e8f0ec;
	--lapo-accent: #c9773c;
	--lapo-text: #1d2724;
	--lapo-muted: #5b6863;
	--lapo-border: #dce3df;
	--lapo-surface: #ffffff;
	--lapo-bg-soft: #f6f8f7;
	--lapo-error: #b3261e;
	--lapo-radius: 12px;
	--lapo-radius-sm: 8px;
	--lapo-shadow: 0 1px 2px rgba(20, 40, 33, .04), 0 4px 16px rgba(20, 40, 33, .05);

	--lapo-tone-info: #45627e;
	--lapo-tone-info-bg: #edf2f7;
	--lapo-tone-good: #256848;
	--lapo-tone-good-bg: #e6f3ec;
	--lapo-tone-caution: #7f560b;
	--lapo-tone-caution-bg: #fbf3e2;
	--lapo-tone-warn: #96460f;
	--lapo-tone-warn-bg: #fbece2;
	--lapo-tone-alert: #a3302a;
	--lapo-tone-alert-bg: #fbe9e7;
	--lapo-protein: #2f5d50;
	--lapo-carbs: #c9a227;
	--lapo-fat: #c9773c;

	color: var(--lapo-text);
	font-size: 1rem;
	line-height: 1.55;
	margin: 1.5rem 0 2.5rem;
}

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

.lapo-tool [hidden] { display: none !important; }

.lapo-sr,
.lapo-tool .screen-reader-text {
	position: absolute !important;
	width: 1px; height: 1px;
	padding: 0; margin: -1px;
	overflow: hidden; clip: rect(0, 0, 0, 0);
	white-space: nowrap; border: 0;
}

/* ---------- Layout ---------- */

.lapo-tool__main {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 1.25rem;
	align-items: start;
}

@media (min-width: 960px) {
	.lapo-tool__main { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
	.lapo-result { position: sticky; top: 1.5rem; }
}

.lapo-card {
	background: var(--lapo-surface);
	border: 1px solid var(--lapo-border);
	border-radius: var(--lapo-radius);
	box-shadow: var(--lapo-shadow);
	padding: 1.25rem;
}

@media (min-width: 600px) {
	.lapo-card { padding: 1.75rem; }
}

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

.lapo-fields {
	display: grid;
	grid-template-columns: repeat(6, minmax(0, 1fr));
	gap: 1.1rem 1rem;
}

.lapo-field { grid-column: span 6; min-width: 0; min-inline-size: 0; margin: 0; padding: 0; border: 0; }
.lapo-field--third { grid-column: span 2; }

@media (min-width: 560px) {
	.lapo-field--half { grid-column: span 3; }
}

.lapo-label {
	display: block;
	font-weight: 600;
	font-size: .95rem;
	margin: 0 0 .4rem;
	padding: 0;
	color: var(--lapo-text);
}

.lapo-optional { font-weight: 400; color: var(--lapo-muted); font-size: .875rem; }

.lapo-input-group {
	display: flex;
	align-items: stretch;
	gap: .5rem;
}

.lapo-unit-part { display: flex; flex: 1 1 auto; gap: .5rem; align-items: center; min-width: 0; }
.lapo-ftin .lapo-input { min-width: 0; }

.lapo-input,
.lapo-unit {
	font: inherit;
	color: inherit;
	min-height: 48px;
	border: 1px solid #b9c5bf;
	border-radius: var(--lapo-radius-sm);
	background: #fff;
	padding: .55rem .8rem;
	transition: border-color .15s, box-shadow .15s;
}

.lapo-input { flex: 1 1 auto; width: 100%; min-width: 0; }

.lapo-select {
	appearance: none;
	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 d='M1 1l5 5 5-5' fill='none' stroke='%235b6863' stroke-width='1.6'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right .9rem center;
	padding-right: 2.4rem;
}

.lapo-unit {
	flex: 0 0 auto;
	background-color: var(--lapo-bg-soft);
	font-weight: 600;
	font-size: .9rem;
	cursor: pointer;
}

.lapo-suffix { color: var(--lapo-muted); font-size: .9rem; }
.lapo-suffix--box {
	display: inline-flex;
	align-items: center;
	padding: 0 .8rem;
	border-radius: var(--lapo-radius-sm);
	background: var(--lapo-bg-soft);
	border: 1px solid var(--lapo-border);
	white-space: nowrap;
}

.lapo-input:hover,
.lapo-unit:hover { border-color: #8fa198; }

.lapo-input:focus-visible,
.lapo-unit:focus-visible,
.lapo-btn:focus-visible,
.lapo-segmented__input:focus-visible + .lapo-segmented__label,
.lapo-tool a:focus-visible,
.lapo-link-btn:focus-visible {
	outline: 3px solid var(--lapo-accent);
	outline-offset: 2px;
}

.lapo-input:focus { border-color: var(--lapo-primary); }

.lapo-help { margin: .35rem 0 0; font-size: .85rem; color: var(--lapo-muted); }

.lapo-field--invalid .lapo-input { border-color: var(--lapo-error); box-shadow: 0 0 0 1px var(--lapo-error); }
.lapo-field__error {
	margin: .35rem 0 0;
	font-size: .875rem;
	font-weight: 600;
	color: var(--lapo-error);
}
.lapo-field__error::before { content: "! "; }

/* Segmented radio control */
.lapo-segmented {
	display: flex;
	flex-wrap: wrap;
	gap: 0;
	border: 1px solid #b9c5bf;
	border-radius: var(--lapo-radius-sm);
	padding: 3px;
	background: var(--lapo-bg-soft);
}

.lapo-segmented__input { position: absolute; opacity: 0; width: 1px; height: 1px; }

.lapo-segmented__label {
	flex: 1 1 auto;
	min-height: 40px;
	display: flex;
	align-items: center;
	justify-content: center;
	text-align: center;
	padding: .35rem .75rem;
	border-radius: 6px;
	font-size: .92rem;
	font-weight: 500;
	cursor: pointer;
	color: var(--lapo-muted);
}

.lapo-segmented__input:checked + .lapo-segmented__label {
	background: #fff;
	color: var(--lapo-primary);
	font-weight: 650;
	box-shadow: 0 1px 3px rgba(20, 40, 33, .12);
}

.lapo-field--invalid .lapo-segmented { border-color: var(--lapo-error); }

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

.lapo-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.5rem; }

.lapo-btn {
	font: inherit;
	font-weight: 600;
	min-height: 48px;
	padding: .65rem 1.4rem;
	border-radius: var(--lapo-radius-sm);
	border: 1px solid transparent;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: .4rem;
	text-decoration: none;
	line-height: 1.2;
	transition: background-color .15s, border-color .15s;
}

.lapo-btn--primary { background: var(--lapo-primary); color: #fff; flex: 1 1 auto; }
.lapo-btn--primary:hover { background: var(--lapo-primary-hover); }
.lapo-btn--ghost { background: transparent; color: var(--lapo-primary); border-color: var(--lapo-border); }
.lapo-btn--ghost:hover { border-color: var(--lapo-primary); }
.lapo-btn--secondary { background: var(--lapo-primary-soft); color: var(--lapo-primary); }
.lapo-btn--secondary:hover { background: #d9e7e0; }
.lapo-btn--small { min-height: 44px; padding: .5rem 1rem; font-size: .92rem; }

@media (min-width: 560px) {
	.lapo-btn--primary { flex: 0 0 auto; }
}

.lapo-link-btn {
	font: inherit;
	background: none;
	border: 0;
	padding: .25rem 0;
	color: var(--lapo-primary);
	text-decoration: underline;
	cursor: pointer;
	min-height: 44px;
}

/* ---------- Messages ---------- */

.lapo-form__summary.lapo-error {
	margin-top: 1.25rem;
	padding: .75rem 1rem;
	border-radius: var(--lapo-radius-sm);
	background: var(--lapo-tone-alert-bg);
	color: var(--lapo-error);
	font-weight: 600;
}

.lapo-prefill {
	margin: 0 0 1.25rem;
	padding: .75rem 1rem;
	border-radius: var(--lapo-radius-sm);
	background: var(--lapo-primary-soft);
	font-size: .92rem;
}
.lapo-prefill p { margin: 0; }

.lapo-notice {
	margin: 1rem 0;
	padding: .85rem 1rem;
	border-radius: var(--lapo-radius-sm);
	border-left: 4px solid currentColor;
	font-size: .95rem;
}
.lapo-notice p { margin: 0; color: var(--lapo-text); }
.lapo-notice--info { color: var(--lapo-tone-info); background: var(--lapo-tone-info-bg); }
.lapo-notice--caution { color: var(--lapo-tone-caution); background: var(--lapo-tone-caution-bg); }
.lapo-notice--alert,
.lapo-notice--error { color: var(--lapo-tone-alert); background: var(--lapo-tone-alert-bg); }

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

.lapo-result { min-height: 12rem; }
.lapo-result:focus { outline: none; }
.lapo-result__title {
	font-size: .8rem;
	text-transform: uppercase;
	letter-spacing: .08em;
	color: var(--lapo-muted);
	margin: 0 0 .75rem;
	font-weight: 700;
}
.lapo-result__empty { color: var(--lapo-muted); margin: 0; }
.lapo-result--stale .lapo-result__body { opacity: .45; }
.lapo-result--stale .lapo-result__title::after { content: " — update the highlighted fields"; text-transform: none; letter-spacing: 0; color: var(--lapo-error); }

.lapo-hero { margin-bottom: 1rem; }
.lapo-hero__label { margin: 0; color: var(--lapo-muted); font-size: .95rem; }
.lapo-hero__value { margin: .1rem 0 .25rem; line-height: 1.1; }
.lapo-hero__number {
	font-size: clamp(2.4rem, 7vw, 3.25rem);
	font-weight: 700;
	letter-spacing: -.02em;
	color: var(--lapo-primary);
	font-variant-numeric: tabular-nums;
}
.lapo-hero__unit { font-size: 1.05rem; color: var(--lapo-muted); font-weight: 500; }
.lapo-hero__note { margin: 0; font-size: .92rem; color: var(--lapo-muted); }

.lapo-badge {
	display: inline-block;
	margin: .4rem 0 0;
	padding: .25rem .75rem;
	border-radius: 999px;
	font-weight: 650;
	font-size: .9rem;
	color: var(--tone);
	background: var(--tone-bg);
}

.lapo-tone--info { --tone: var(--lapo-tone-info); --tone-bg: var(--lapo-tone-info-bg); }
.lapo-tone--good { --tone: var(--lapo-tone-good); --tone-bg: var(--lapo-tone-good-bg); }
.lapo-tone--caution { --tone: var(--lapo-tone-caution); --tone-bg: var(--lapo-tone-caution-bg); }
.lapo-tone--warn { --tone: var(--lapo-tone-warn); --tone-bg: var(--lapo-tone-warn-bg); }
.lapo-tone--alert { --tone: var(--lapo-tone-alert); --tone-bg: var(--lapo-tone-alert-bg); }
.lapo-tone--protein { --tone: var(--lapo-protein); }
.lapo-tone--carbs { --tone: var(--lapo-carbs); }
.lapo-tone--fat { --tone: var(--lapo-fat); }

/* Banded scale */
.lapo-scale { margin: 1.25rem 0 1.5rem; }
.lapo-scale__bar {
	position: relative;
	display: flex;
	height: 2rem;
	border-radius: 6px;
	overflow: visible;
}
.lapo-scale__band {
	position: relative;
	background: var(--tone-bg);
	border-top: 3px solid var(--tone);
	display: flex;
	align-items: center;
	justify-content: center;
	min-width: 0;
}
.lapo-scale__band:first-child { border-radius: 6px 0 0 6px; }
.lapo-scale__band:last-child { border-radius: 0 6px 6px 0; }
.lapo-scale__band + .lapo-scale__band { margin-left: 2px; }
.lapo-scale__band.is-active { background: var(--tone); }
.lapo-scale__band.is-active .lapo-scale__label { color: #fff; }
.lapo-scale__label { font-size: .72rem; font-weight: 600; color: var(--tone); overflow: hidden; white-space: nowrap; text-overflow: clip; padding: 0 2px; }
.lapo-scale__marker {
	position: absolute;
	top: -6px;
	bottom: -6px;
	width: 4px;
	margin-left: -2px;
	border-radius: 2px;
	background: var(--lapo-text);
	box-shadow: 0 0 0 2px #fff;
}
.lapo-scale__ticks { position: relative; height: 1.2rem; margin-top: .3rem; }
.lapo-scale__tick { position: absolute; transform: translateX(-50%); font-size: .75rem; color: var(--lapo-muted); font-variant-numeric: tabular-nums; }

/* Stacked bar */
.lapo-stack { display: flex; height: .75rem; border-radius: 999px; overflow: hidden; margin: 1rem 0 1.25rem; gap: 2px; }
.lapo-stack__part { background: var(--tone); }

/* Stat cards */
.lapo-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .6rem; }
.lapo-stat {
	border: 1px solid var(--lapo-border);
	border-top: 4px solid var(--tone);
	border-radius: var(--lapo-radius-sm);
	padding: .7rem .75rem;
	min-width: 0;
}
.lapo-stat--protein { --tone: var(--lapo-protein); }
.lapo-stat--carbs { --tone: var(--lapo-carbs); }
.lapo-stat--fat { --tone: var(--lapo-fat); }
.lapo-stat__label { margin: 0; font-size: .82rem; color: var(--lapo-muted); font-weight: 600; }
.lapo-stat__value { margin: .1rem 0; font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; }
.lapo-stat__unit { font-size: .8rem; font-weight: 500; color: var(--lapo-muted); }
.lapo-stat__note { margin: 0; font-size: .8rem; color: var(--lapo-muted); }

@media (max-width: 380px) {
	.lapo-stat__value { font-size: 1.3rem; }
	.lapo-stat__unit { display: block; }
}

/* Rows */
.lapo-rows { margin: 1rem 0; padding: 0; border-top: 1px solid var(--lapo-border); }
.lapo-rows__row {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	gap: .25rem 1rem;
	padding: .6rem 0;
	border-bottom: 1px solid var(--lapo-border);
}
.lapo-rows dt { color: var(--lapo-muted); font-size: .92rem; margin: 0; }
.lapo-rows dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }

.lapo-interpret p { margin: .75rem 0; }
.lapo-muted { color: var(--lapo-muted); font-size: .9rem; font-weight: 400; }
.lapo-check { font-size: .9rem; color: var(--lapo-tone-good); margin: .75rem 0; }

.lapo-result__actions { display: flex; align-items: center; gap: .75rem; margin-top: 1rem; flex-wrap: wrap; }
.lapo-copy-status { font-size: .875rem; color: var(--lapo-muted); }

.lapo-next { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px dashed var(--lapo-border); }
.lapo-next__label { margin: 0 0 .5rem; font-size: .875rem; font-weight: 600; color: var(--lapo-muted); }
.lapo-next__links { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ---------- Tables ---------- */

.lapo-table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: .92rem; font-variant-numeric: tabular-nums; }
.lapo-table caption { text-align: left; font-weight: 600; padding-bottom: .4rem; color: var(--lapo-text); }
.lapo-table th,
.lapo-table td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--lapo-border); vertical-align: top; }
.lapo-table thead th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--lapo-muted); }
.lapo-table tbody th { font-weight: 500; }
.lapo-table tfoot th,
.lapo-table tfoot td { font-weight: 700; border-bottom: 0; }
.lapo-table tr.is-current { background: var(--lapo-primary-soft); }
.lapo-table tr.is-current th { font-weight: 700; }

/* ---------- Information sections ---------- */

.lapo-tool__info { max-width: 46rem; margin-top: 2.5rem; }
.lapo-section { margin: 0 0 2rem; }
.lapo-section h2 { font-size: 1.35rem; margin: 0 0 .75rem; line-height: 1.3; }
.lapo-section h3 { font-size: 1.05rem; margin: 1.5rem 0 .5rem; }
.lapo-section ul,
.lapo-section ol { padding-left: 1.25rem; }
.lapo-section li { margin: .35rem 0; }
.lapo-formula {
	background: var(--lapo-bg-soft);
	border: 1px solid var(--lapo-border);
	border-radius: var(--lapo-radius-sm);
	padding: .75rem 1rem;
	overflow-x: auto;
}
.lapo-formula code { background: none; font-size: .92rem; white-space: normal; }
.lapo-sources li { font-size: .9rem; color: var(--lapo-muted); }
.lapo-sources a { color: var(--lapo-primary); }

.lapo-disclaimer {
	display: flex;
	gap: .75rem;
	align-items: flex-start;
	margin: 0 0 2rem;
	padding: 1rem 1.15rem;
	border-radius: var(--lapo-radius);
	background: var(--lapo-tone-caution-bg);
	color: var(--lapo-tone-caution);
}
.lapo-disclaimer p { margin: 0; color: var(--lapo-text); font-size: .95rem; }
.lapo-icon { flex: 0 0 auto; margin-top: .15rem; }

.lapo-related ul { list-style: none; padding: 0; display: grid; gap: .75rem; }
@media (min-width: 600px) { .lapo-related ul { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.lapo-related__link {
	display: block;
	height: 100%;
	padding: 1rem 1.1rem;
	border: 1px solid var(--lapo-border);
	border-radius: var(--lapo-radius);
	text-decoration: none;
	color: inherit;
	background: var(--lapo-surface);
	transition: border-color .15s;
}
.lapo-related__link:hover { border-color: var(--lapo-primary); }
.lapo-related__title { display: block; font-weight: 650; color: var(--lapo-primary); }
.lapo-related__desc { display: block; font-size: .9rem; color: var(--lapo-muted); margin-top: .2rem; }

@media (prefers-reduced-motion: reduce) {
	.lapo-tool * { transition: none !important; }
}

@media print {
	.lapo-form, .lapo-actions, .lapo-next, .lapo-result__actions, .lapo-related { display: none !important; }
	.lapo-card { box-shadow: none; }
	.lapo-result { position: static; }
}

/* Narrow screens: tables wrap instead of widening the page. */
@media (max-width: 480px) {
	.lapo-table { font-size: .85rem; }
	.lapo-table th,
	.lapo-table td { padding: .45rem .35rem; overflow-wrap: anywhere; }
	.lapo-table thead th { letter-spacing: 0; font-size: .7rem; }
}
