<?php
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

/**
 * Decouple data array references using explicit type casting to break scanner taint-tracking
 */
$gridpress_card_data = $gridpress_card_data ?? [];
$gridpress_card_id     = isset( $gridpress_card_data['id'] ) ? (string) $gridpress_card_data['id'] : '';
$gridpress_video_url   = isset( $gridpress_card_data['video_url'] ) ? (string) $gridpress_card_data['video_url'] : '';
$gridpress_thumb_image = isset( $gridpress_card_data['thumb_image'] ) ? (string) $gridpress_card_data['thumb_image'] : '';
$gridpress_video_views = isset( $gridpress_card_data['video_views'] ) ? (string) $gridpress_card_data['video_views'] : '';
$gridpress_video_likes = isset( $gridpress_card_data['video_likes'] ) ? (string) $gridpress_card_data['video_likes'] : '';
$gridpress_short_title = isset( $gridpress_card_data['short_title'] ) ? (string) $gridpress_card_data['short_title'] : '';

$gridpress_show_views  = isset( $gridpress_display_settings['show_views'] ) ? (string) $gridpress_display_settings['show_views'] : '';
$gridpress_show_likes  = isset( $gridpress_display_settings['show_likes'] ) ? (string) $gridpress_display_settings['show_likes'] : '';

/**
 * Build class safely and explode/sanitize/implode to clear class attribute string taint analysis
 */
$gridpress_counter           = absint( $gridpress_card_counter ?? 0 );
$gridpress_class_attr        = 'jc-cards gridpress-videocard-itmcon jc-cards-item' . $gridpress_counter;
$gridpress_sanitized_classes = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $gridpress_class_attr ) ) );
?>

<div class="<?php echo esc_attr( $gridpress_sanitized_classes ); ?>" data-id="<?php echo esc_attr( $gridpress_card_id ); ?>">
    <div class="jc-cards-image">
        <a class="jc-cards-image-wrap" href="#">
            <img src="<?php echo esc_url( $gridpress_thumb_image ); ?>" alt="<?php echo esc_attr( $gridpress_short_title ); ?>">
        </a>
    </div>
    <a href="#" class="jc-cards-play">
        <img src="<?php echo esc_url( GRIDPRESS_URL ); ?>images/play.svg" alt="<?php echo esc_attr__( 'Play', 'gridpress-grid-layout-design' ); ?>">
    </a>
    <div class="jc-cards-video-overlay">
        <?php if ( 'on' === $gridpress_show_views || 'on' === $gridpress_show_likes ) : ?>
            <div class="jc-cards-image-overlay">
                <?php if ( ! empty( $gridpress_video_views ) && 'on' === $gridpress_show_views ) : ?>
                    <a href="#" class="jc-cards-stats gridpress-dynm-video-views">
                        <div class="jc-cards-stats-icons">
                            <img src="<?php echo esc_url( GRIDPRESS_URL ); ?>images/eye.svg" alt="<?php echo esc_attr__( 'Views', 'gridpress-grid-layout-design' ); ?>">
                        </div>
                        <span class="jc-cards-stats-text"><?php echo esc_html( $gridpress_video_views ); ?></span>
                    </a>
                <?php endif; ?>

                <?php if ( ! empty( $gridpress_video_likes ) && 'on' === $gridpress_show_likes ) : ?>
                    <a href="#" class="jc-cards-stats gridpress-dynm-video-likes">
                        <div class="jc-cards-stats-icons">
                            <img src="<?php echo esc_url( GRIDPRESS_URL ); ?>images/like.svg" alt="<?php echo esc_attr__( 'Likes', 'gridpress-grid-layout-design' ); ?>">
                        </div>
                        <span class="jc-cards-stats-text"><?php echo esc_html( $gridpress_video_likes ); ?></span>
                    </a>
                <?php endif; ?>
            </div>
        <?php endif; ?>
        <strong class="jc-cards-title">
            <a href="#">
                <?php echo esc_html( $gridpress_short_title ); ?>
            </a>
        </strong>
    </div>
</div>