<?php
/**
 * Displays header site branding
 *
 * @package BlogAura
 */

$blog_info    = get_bloginfo('name');
$description  = get_bloginfo('description', 'display');
$hide_title   = blogaura_get_option('hide_title');
$hide_tagline = blogaura_get_option('hide_tagline');
$header_class = $hide_title ? 'screen-reader-text' : 'site-title';
?>

<div class="site-branding">
    <?php if (has_custom_logo()) : ?>
        <div class="site-logo">
            <?php the_custom_logo(); ?>
        </div>
    <?php endif; ?>

    <?php if ($blog_info) : ?>
    <?php
    // Use h1 only on the main blog page, div elsewhere
    $tag = (is_front_page() && is_home()) ? 'h1' : 'div';
    ?>
    <<?php echo $tag; ?> class="<?php echo esc_attr($header_class); ?>">
    <a href="<?php echo esc_url(home_url('/')); ?>" rel="home">
        <span class="hide-on-desktop"><?php bloginfo('name'); ?></span>
        <svg xmlns="http://www.w3.org/2000/svg" class="site-branding-svg hide-on-mobile hide-on-tablet">
            <text x="50%" y="0.82em" stroke="var(--wpi--base-bg-color)" text-anchor="middle" stroke-width="<?php echo esc_attr(get_theme_mod('storygrid_site_title_outline', '2')); ?>">
                <?php echo esc_html($blog_info); ?>
            </text>
        </svg>
    </a>
</<?php echo $tag; ?>>
<?php endif; ?>

<?php if ($description && !$hide_tagline) : ?>
    <div class="site-description">
        <span><?php echo $description; // phpcs:ignore WordPress.Security.EscapeOutput ?></span>
    </div>
<?php endif; ?>
</div><!-- .site-branding -->