<?php
/**
 * Single post.
 *
 * @package Iliya
 */

get_header();
?>

<div class="container mx-auto max-w-[820px] py-12">
    <?php
    while (have_posts()) :
        the_post();
        ?>
        <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
            <?php get_template_part('template-parts/breadcrumb'); ?>

            <header class="mb-8">
                <h1 class="mb-4 text-3xl font-bold leading-tight text-dark font-dana"><?php the_title(); ?></h1>
                <div class="flex flex-wrap items-center gap-4 text-sm text-muted">
                    <span><?php echo esc_html(get_the_date()); ?></span>
                    <span><?php the_author(); ?></span>
                    <?php
                    $cats = get_the_category_list('، ');
                    if ($cats) {
                        echo '<span>' . wp_kses_post($cats) . '</span>';
                    }
                    ?>
                </div>
            </header>

            <?php if (has_post_thumbnail()) : ?>
                <div class="mb-8">
                    <?php the_post_thumbnail('large', ['class' => 'w-full']); ?>
                </div>
            <?php endif; ?>

            <div class="prose-iliya">
                <?php
                the_content();
                wp_link_pages([
                    'before' => '<div class="mt-6 flex gap-2">',
                    'after'  => '</div>',
                ]);
                ?>
            </div>

            <?php
            $tags = get_the_tag_list('<div class="mt-8 flex flex-wrap gap-2 text-sm">', '', '</div>');
            if ($tags) {
                echo wp_kses_post($tags);
            }
            ?>
        </article>

        <nav class="mt-10 flex justify-between border-t border-border pt-6 text-sm">
            <div><?php previous_post_link('%link', __('« قبلی', 'iliya')); ?></div>
            <div><?php next_post_link('%link', __('بعدی »', 'iliya')); ?></div>
        </nav>

        <?php
        if (comments_open() || get_comments_number()) {
            comments_template();
        }
        ?>
        <?php
    endwhile;
    ?>
</div>

<?php
get_footer();
