<?php

function car_booking_enqueue_fonts() {
    $car_booking_default_font_content = 'saira';
    $car_booking_default_font_heading = 'saira';

    $car_booking_font_content = esc_attr(get_theme_mod('car_booking_content_typography_font', $car_booking_default_font_content));
    $car_booking_font_heading = esc_attr(get_theme_mod('car_booking_heading_typography_font', $car_booking_default_font_heading));

    $car_booking_css = '';

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

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

    // Add inline style
    wp_add_inline_style('car-booking-style-font-general', $car_booking_css);
}
add_action('wp_enqueue_scripts', 'car_booking_enqueue_fonts', 50);