<?php
$realisations = $args['realisations'] ?? array();
$nb_realisations = count($realisations);
?>

<?php if (is_array($realisations) && $nb_realisations > 0) : ?>
	<section class="section-posts py-20 lg:py-32 xl:pb-[120px] xl:pt-10 px-5 lg:px-10">
		<div class="posts-grid">
			<!-- MOBILE -->
			<div class="columns-1 md:columns-2 [column-gap:1.25rem] lg:[column-gap-2.5rem] xl:hidden">
				<?php
				for ($i = 0; $i < sizeof($realisations); $i++) :
					$realisation = $realisations[$i] ?? null;
					if (!$realisation) {
						continue;
					}
				?>
					<div class="break-inside-avoid mb-5">
						<?php get_template_part('template-parts/components/cards/card', 'realisation', array('data' => $realisation)); ?>
					</div>
				<?php endfor; ?>
			</div>
			<div class=" hidden xl:grid xl:grid-cols-4 xl:gap-5 2xl:gap-10 pt-20">
				<div class="col flex flex-col gap-8 2xl:gap-10 rellax" data-rellax-speed="2">
					<?php
					for ($i = 0; $i < $nb_realisations; $i += 4) :
						$realisation = $realisations[$i] ?? null;
						if (!$realisation) {
							continue;
						}
						get_template_part('template-parts/components/cards/card', 'realisation', array('data' => $realisation));
					endfor;
					?>
				</div>
				<div class="col flex flex-col gap-8 2xl:gap-10 rellax" data-rellax-speed="-2">
					<?php
					for ($i = 1; $i < $nb_realisations; $i += 4) :
						$realisation = $realisations[$i] ?? null;
						if (!$realisation) {
							continue;
						}
						get_template_part('template-parts/components/cards/card', 'realisation', array('data' => $realisation));
					endfor;
					?>
				</div>
				<div class="col flex flex-col gap-8 2xl:gap-10 rellax" data-rellax-speed="2">
					<?php
					for ($i = 2; $i < $nb_realisations; $i += 4) :
						$realisation = $realisations[$i] ?? null;
						if (!$realisation) {
							continue;
						}
						get_template_part('template-parts/components/cards/card', 'realisation', array('data' => $realisation));
					endfor;
					?>
				</div>
				<div class="col flex flex-col gap-8 2xl:gap-10 rellax" data-rellax-speed="-2">
					<?php
					for ($i = 3; $i < $nb_realisations; $i += 4) :
						$realisation = $realisations[$i] ?? null;
						if (!$realisation) {
							continue;
						}
						get_template_part('template-parts/components/cards/card', 'realisation', array('data' => $realisation));
					endfor;
					?>
				</div>
			</div>
		</div>
	</section>
	<div class="hidden xl:grid p-20 m-10"></div>
<?php endif; ?>
