{{-- Renders a single capacity vs. demand card. Used at two levels: - top-level: one card per program (strategy scope) or per project (program scope) - nested: inside an expanded program card, one compact card per child project Vars in: $c The capacity analysis row (project or program-rolled). $verdictLabels Map of verdict key → translated label. $compactOnly When true, always render the one-liner regardless of verdict. --}} @php $compactOnly = $compactOnly ?? false; $vLabel = $verdictLabels[$c['verdict']] ?? $c['verdict']; $showFull = ! $compactOnly && in_array($c['verdict'], ['critical', 'tight', 'no_capacity'], true); @endphp @if ($showFull) @php // Balance bar geometry — carry the same reading the text states. // Fill 0 → available in the "supply" (green) segment. // Then a distinct "deficit" segment from available → needed, in // the verdict color. Marker sits AT the available position so a // reader instantly sees "we have this much, we need this much". $barMax = max($c['availableHours'], $c['referenceDemand'], 1); $availableMark = min(100, ($c['availableHours'] / $barMax) * 100); $demandWidth = min(100, ($c['referenceDemand'] / $barMax) * 100); $deficitWidth = max(0, $demandWidth - $availableMark); $gapHrs = abs($c['gap']); $gapPct = $c['availableHours'] > 0 ? abs($c['gap'] / $c['availableHours']) * 100 : 0; $isShort = $c['gap'] > 0; // Run-rate framing. Supply is a current weekly rate; projecting it over // a (past) period to a total is the fiction we avoid. Demand is a real // total of estimated work — expressed here as the weekly rate needed to // clear it within the period. The gap % (verdict) is unchanged: rate // ratios equal total ratios, so the bar geometry above still holds. $weeks = max(1, (int) $c['weeksInWindow']); $supplyPerWk = $c['weeklyHoursToProject']; $demandPerWk = $c['referenceDemand'] / $weeks; $gapPerWk = $gapHrs / $weeks; @endphp