<!DOCTYPE html>
<?php
$dir  = is_rtl() ? 'rtl' : 'ltr';
$lang = get_bloginfo('language');

if ( ! function_exists('caffito_meta_description') ) {
    function caffito_meta_description() {
        if ( defined('WPSEO_VERSION') || defined('RANK_MATH_VERSION') ) {
            return;
        }
        if ( is_singular() ) {
            $excerpt = get_the_excerpt();
            if ( empty($excerpt) ) {
                $excerpt = wp_strip_all_tags( get_the_content(), true );
            }
        } elseif ( is_home() || is_front_page() ) {
            $excerpt = get_bloginfo('description');
        } else {
            $excerpt = get_bloginfo('name') . ' - ' . get_bloginfo('description');
        }
        $excerpt = wp_trim_words( $excerpt, 25, '' );
        echo '<meta name="description" content="' . esc_attr( $excerpt ) . '">' . "\n";
    }
}
?>
<html lang="<?php echo esc_attr($lang); ?>" dir="<?php echo esc_attr($dir); ?>">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />

    <?php
    if ( ! current_theme_supports('title-tag') ) :
        echo '<title>' . esc_html( wp_get_document_title() ) . '</title>';
    endif;
    caffito_meta_description();
    ?>
    <link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
    <script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>

    <?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>

<?php if ( has_nav_menu('header-menu') ) : ?>
    <header class="nav-pill" dir="rtl">
        <button class="nav-toggle" aria-expanded="false" aria-controls="nav-menu" aria-label="Toggle menu">
            <i class="ph ph-list icon-open"></i>
            <i class="ph ph-x icon-close"></i>
        </button>
        <nav id="nav-menu" class="nav-menu" aria-hidden="true">
            <?php
            wp_nav_menu([
                'theme_location' => 'header-menu',
                'container'      => false,
                'menu_class'     => 'menu',
            ]);
            ?>
        </nav>
    </header>
<?php endif; ?>

<main class="site-main">