<?php
  global $syrus;
  // THEME MOD
  $font_sizes = [
    'small' => "1em",
    'medium' => "1.35em",
    'large' => "1.5em"
  ];

  $general_font_size = get_theme_mod("general-font-size") ? get_theme_mod("general-font-size") : "medium";
  $general_font_size = $font_sizes[$general_font_size];

  if(is_home() && get_query_var('paged') > 1) { ?>
    <div class="top-home">
      <div class="category-title">
        <h1><?php echo get_bloginfo('name') ?> - <?php echo get_query_var('paged') ?></h1>
      </div>
    </div>
  <?php }

  if(is_category()){?>
    <div class="top-home">
      <div class="category-title">
        <h1>
          <?php echo get_cat_name(get_query_var('cat')); ?>
          <?php if(get_query_var('paged') > 1) { ?>
           - <?php echo get_query_var('paged') ?>
          <?php } ?>
        </h1>
      </div>
      <div class="category-description">
        <?php echo category_description(get_query_var('cat')) ;?>
      </div>
    </div>
  <?php
  }
?>

<style media="screen">
  p.news-excerpt{
    font-size: <?php echo $general_font_size ;?> !important;
  } 
  /*modifico il colore della sottolineatura dinamicamente*/
  .news-title::after{
    background-color: <?php echo sanitize_text_field(get_theme_mod("color-underline-title-article")); ?> !important;
  }
</style>

<?php if($the_query->have_posts()){ $i = 0; ?>
  <?php while($the_query->have_posts()){ $the_query->the_post(); $alt = $the_query->current_post % 2 == 0 ? false : true; ?>
    <div class="row row-articolo <?php echo wp_is_mobile() ? 'mt-5' : '' ?>">
      <div class="col-12 <?php echo wp_is_mobile() ? 'p-0' : '' ;?>">
        <article class="news-container <?php echo $alt && has_post_thumbnail() ? 'alt' : '' ;?> <?php echo wp_is_mobile() ? 'is-mobile' : '' ;?>">
          <div <?php post_class(); ?>>
            <div class="row">
              
              <?php $syrus->thumb_img([
                'alternate' => $alt,
                'with_link' => false,
                'lazy_loading' => ($i > 2 ? true : false)
              ]); ?>

              <div class="news-content-container order-md-<?php echo $alt ? '1' : '2' ;?> col-md-<?php echo has_post_thumbnail() ? '6' : '12' ;?> <?php echo wp_is_mobile() ? 'is-mobile' : '' ;?> <?php echo !has_post_thumbnail() ? 'no-image' : '' ;?>">
                <a href="<?php the_permalink(); ?>" title="<?php echo wp_kses_post(get_the_title()); ?>" class="href-news">
                  <p class="news-title <?php echo wp_is_mobile() ? 'is-mobile' : '' ;?>">
                    <?php echo wp_kses_post(get_the_title()); ?>
                  </p>
                </a>

                <?php $syrus->post_category_list() ?>

                <?php $syrus->post_author(); ?>

                <span class="news-date"><?php echo esc_html( get_the_date() ) ;?></span>

                <?php $syrus->post_reading_time(); ?>
                
                <?php $syrus->post_excerpt(); ?>
                
              </div>

            </div>
          </div> 
        </article>
      </div>
    </div>
  <?php $i++; } ?>

  <?php if($syrus->get_option("generali","infinite_scroll_home") != 1 || (!is_home() && !isset($args['is_ajax']))) { ?>
    <?php echo str_replace('h2', 'p', get_the_posts_pagination()); ?>
  <?php } else { ?>
    <div id="fine-articoli-home-page" class="page-<?php echo $args['paged'] ?>"></div>
  <?php } ?>

  <?php wp_link_pages([]); ?>
<?php } ?>
