<?php

function travel_destination_enqueue_fonts() {
    $travel_destination_default_font_content = 'Roboto';
    $travel_destination_default_font_heading = 'Outfit';

    $travel_destination_font_content = esc_attr(get_theme_mod('travel_destination_content_typography_font', $travel_destination_default_font_content));
    $travel_destination_font_heading = esc_attr(get_theme_mod('travel_destination_heading_typography_font', $travel_destination_default_font_heading));

    $travel_destination_css = '';

    // Always enqueue main font
    $travel_destination_css .= '
    :root {
        --font-main: ' . $travel_destination_font_content . ', ' . (in_array($travel_destination_font_content, ['bitter', 'charis-sil']) ? 'serif' : 'sans-serif') . '!important;
    }';
    wp_enqueue_style('travel-destination-style-font-general', get_template_directory_uri() . '/fonts/' . $travel_destination_font_content . '/font.css');

    // Always enqueue header font
    $travel_destination_css .= '
    :root {
        --font-head: ' . $travel_destination_font_heading . ', ' . (in_array($travel_destination_font_heading, ['bitter', 'charis-sil']) ? 'serif' : 'sans-serif') . '!important;
    }';
    wp_enqueue_style('travel-destination-style-font-h', get_template_directory_uri() . '/fonts/' . $travel_destination_font_heading . '/font.css');

    // Add inline style
    wp_add_inline_style('travel-destination-style-font-general', $travel_destination_css);
}
add_action('wp_enqueue_scripts', 'travel_destination_enqueue_fonts', 50);