<?php
/**
 * Project Stat Card Component
 *
 * Renders one stat tile. Reads $label, $value, and optional $icon from
 * get_query_var(), because get_template_part() does not forward its $args
 * parameter into the partial's local scope. $icon MUST be aria-hidden
 * decorative markup; the label is the accessible name.
 *
 * @package KsPortfolio
 */

namespace KsPortfolio;

$stat_label = get_query_var( 'label' );
$stat_value = get_query_var( 'value' );
$icon       = get_query_var( 'icon' );

if ( ! isset( $stat_label ) || ! isset( $stat_value ) ) {
	return;
}

$stat_label = (string) $stat_label;
$stat_value = (string) $stat_value;
?>

<div class="stat-card" role="group" aria-label="<?php echo esc_attr( $stat_label ); ?>">
	<?php if ( ! empty( $icon ) ) : ?>
		<span class="stat-card__icon" aria-hidden="true"><?php echo $icon; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- icon is hardcoded decorative SVG in callers. ?></span>
	<?php endif; ?>

    <span class="stat-card__value"><?php echo esc_html( $stat_value ); ?></span>
	<span class="stat-card__label"><?php echo esc_html( $stat_label ); ?></span>
</div>
