/* Fundraising Progress Bar */
@property --fpb-pct {
	syntax: "<percentage>";
	inherits: true;
	initial-value: 0%;
}

.fpb {
	--fpb-primary: #6366f1;
	--fpb-secondary: #06b6d4;
	--fpb-track: rgba(120, 130, 150, 0.16);
	--fpb-text: inherit;
	--fpb-font: inherit;
	--fpb-on-fill: #fff;
	--fpb-bubble: #111827;
	--fpb-bubble-text: #fff;
	--fpb-height: 38px;
	--fpb-radius: 999px;
	--fpb-fill: linear-gradient(90deg, var(--fpb-primary), var(--fpb-secondary));
	--fpb-duration: 1.8s;

	box-sizing: border-box;
	width: 100%;
	margin: 1.5em 0;
	font-family: var(--fpb-font);
	color: var(--fpb-text);
	line-height: 1.4;
	animation: fpb-grow var(--fpb-duration) cubic-bezier(0.22, 1, 0.36, 1) both;
}
.fpb *,
.fpb *::before,
.fpb *::after { box-sizing: border-box; }

@keyframes fpb-grow { from { --fpb-pct: 0%; } }

/* Hold the animation until the bar scrolls into view (set by the script). */
.fpb.fpb--waiting { animation-play-state: paused; }
/* After the intro, later updates glide to the new value. */
.fpb.fpb--ready { animation: none; transition: --fpb-pct 1.2s cubic-bezier(0.22, 1, 0.36, 1); }

.fpb__title {
	margin: 0 0 0.35em;
	font-size: 1.25em;
	font-weight: 700;
	letter-spacing: -0.01em;
	line-height: 1.25;
}

.fpb__bar {
	position: relative;
	padding-top: 2.5em; /* room for the percentage bubble */
}

/* Percentage bubble that rides the progress mark */
.fpb__marker {
	position: absolute;
	top: 0;
	left: clamp(1.75em, var(--fpb-pct), calc(100% - 1.75em));
	transform: translateX(-50%);
	pointer-events: none;
}
.fpb__pct {
	position: relative;
	display: inline-block;
	padding: 0.2em 0.6em;
	border-radius: 6px;
	background: var(--fpb-bubble);
	color: var(--fpb-bubble-text);
	font-size: 0.85em;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
	box-shadow: 0 4px 12px rgba(17, 24, 39, 0.18);
}
.fpb__pct::after {
	content: "";
	position: absolute;
	left: 50%;
	bottom: -5px;
	width: 10px;
	height: 10px;
	background: inherit;
	transform: translateX(-50%) rotate(45deg);
	border-radius: 0 0 2px 0;
	z-index: -1;
}

.fpb__track {
	position: relative;
	height: var(--fpb-height);
	border-radius: var(--fpb-radius);
	background: var(--fpb-track);
	overflow: hidden;
}

.fpb__fill {
	position: absolute;
	inset: 0 auto 0 0;
	width: var(--fpb-pct);
	border-radius: inherit;
	background: var(--fpb-fill);
	overflow: hidden;
}

/* Amount shown inside the bar (moves just outside the fill if it won't fit) */
.fpb__amount {
	position: absolute;
	top: 50%;
	left: 0.9em;
	transform: translateY(-50%);
	color: var(--fpb-on-fill);
	font-size: 0.95em;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
	text-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}
.fpb--amount-outside .fpb__amount {
	left: calc(var(--fpb-pct) + 0.6em);
	color: inherit;
	text-shadow: none;
}

.fpb__footer {
	display: flex;
	justify-content: flex-end;
	margin-top: 0.5em;
	font-size: 0.95em;
	opacity: 0.85;
}
.fpb__goal strong { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---- Style: Clean gradient ---- */
.fpb--gradient .fpb__track { box-shadow: inset 0 1px 3px rgba(15, 23, 42, 0.1); }
.fpb--gradient .fpb__fill,
.fpb--brand .fpb__fill { box-shadow: 0 0 16px -2px color-mix(in srgb, var(--fpb-primary) 55%, transparent); }
.fpb--gradient .fpb__fill::after,
.fpb--brand .fpb__fill::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.35) 50%, transparent 80%);
	transform: translateX(-100%);
	animation: fpb-shine 3.2s ease-in-out 1.8s infinite;
}
@keyframes fpb-shine {
	0% { transform: translateX(-100%); }
	45%, 100% { transform: translateX(100%); }
}

/* ---- Style: Minimal flat ---- */
.fpb--flat {
	--fpb-primary: #2563eb;
	--fpb-fill: var(--fpb-primary);
	--fpb-height: 28px;
	--fpb-radius: 6px;
	--fpb-bubble: var(--fpb-primary);
}
.fpb--flat .fpb__pct { box-shadow: none; border-radius: 4px; }
.fpb--flat .fpb__amount { font-size: 0.85em; }

/* ---- Style: Match my brand (colors come from settings) ---- */
.fpb--brand {
	--fpb-radius: 12px;
	--fpb-bubble: var(--fpb-primary);
}

@media (max-width: 480px) {
	.fpb { --fpb-height: 32px; }
	.fpb__title { font-size: 1.1em; }
}

@media (prefers-reduced-motion: reduce) {
	.fpb, .fpb.fpb--ready { animation: none; transition: none; }
	.fpb__fill::after { display: none; }
}
