<?php
$post = $args['data'] ?? false;
$realisation_disable_link = ljn_get_option('realisation_disable_link');
if (isset($post->ID) && $post->ID > 0) :
	$data = get_fields($post->ID) ?? array();
	$url = get_permalink($post->ID);
	$disable_link = $data['disable_link'] ?? false;
	// var_dump($data);
	$class = '';
	if (isset($data['has_bg']) && $data['has_bg']) {
		$class .= ' card-has-bg green ';
	} else {
		if (isset($data['border_position']) && !empty($data['border_position'])) {
			$class .= ' ' . $data['border_position'] . ' ';
		}
		if (isset($data['border_color']) && !empty($data['border_color'])) {
			$class .= ' ' . $data['border_color'] . ' ';
		}
		if (isset($data['border_v_size']) && !empty($data['border_v_size'])) {
			$class .= ' v-' . $data['border_v_size'] . ' ';
		}
		if (isset($data['border_h_size']) && !empty($data['border_h_size'])) {
			$class .= ' h-' . $data['border_h_size'] . ' ';
		}
	}
?>
	<div class="card-post  <?php echo $class; ?> scroll-appear ">

		<div class="card-img scroll-appear scroll-appear-fade-up">
			<div class="card-banner"></div>
			<?php if (isset($data['vignette']) && $data['vignette'] > 0) : ?>
				<div class="img_container"><?php echo wp_get_attachment_image($data['vignette'], 'full', false, array('loading' => 'lazy', 'class' => '')); ?></div>
				<?php echo lnj_load_inline_svg('plus.svg'); ?>
			<?php endif; ?>
		</div>
		<div class="card-body  ">
			<?php if (isset($data['titre']) && !empty($data['titre'])) : ?>
				<h2 class="card-title">
					<?php echo $data['titre']; ?>
				</h2>
			<?php endif; ?>

			<?php if (isset($data['description']) && !empty($data['description'])) : ?>
				<p class="card-text">
					<?php echo $data['description']; ?>
				</p>
			<?php endif; ?>


			<?php if($disable_link) : ?>

				<span class="text-red"><?php echo $realisation_disable_link; ?></span>

			<?php else : ?>

				<a href="<?php echo $url; ?>" class="btn-primary stretched-link">
					<span><?php echo lnj_load_inline_svg('circle-left.svg'); ?></span>
					<span>Découvrir</span>
					<div class="icon">
						<?php echo lnj_load_inline_svg('plus.svg'); ?>
						<?php echo lnj_load_inline_svg('arrow-right.svg'); ?>
					</div>
				</a>

			<?php endif; ?>

		</div>

	</div>

<?php endif; ?>
