<?php
/**
 * Bookmark control (UI shell — no persistence in Phase 1).
 *
 * @package Kutby
 * @since   2.9.0
 */

declare(strict_types=1);

namespace Kutby\Cards\Parts;

use Kutby\Cards\Contracts\CardPartInterface;
use Kutby\Cards\Support\CardContext;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Class Bookmark
 */
final class Bookmark implements CardPartInterface {

	/**
	 * {@inheritdoc}
	 */
	public static function render( CardContext $ctx, array $args = array() ): void {
		if ( ! $ctx->bool( 'show_bookmark' ) ) {
			return;
		}

		$post_id = (int) $ctx->post()->ID;
		?>
		<button
			type="button"
			class="kutby-card__bookmark"
			data-kutby-bookmark
			data-post-id="<?php echo esc_attr( (string) $post_id ); ?>"
			aria-pressed="false"
			aria-label="<?php echo esc_attr( 'حفظ المقال: ' . get_the_title( $ctx->post() ) ); ?>"
		>
			<span aria-hidden="true">☆</span>
		</button>
		<?php
	}
}
