<?php

function air_ticket_booking_enqueue_fonts() {
    $air_ticket_booking_default_font_content = 'montserrat';
    $air_ticket_booking_default_font_heading = 'montserrat';

    $air_ticket_booking_font_content = esc_attr(get_theme_mod('air_ticket_booking_content_typography_font', $air_ticket_booking_default_font_content));
    $air_ticket_booking_font_heading = esc_attr(get_theme_mod('air_ticket_booking_heading_typography_font', $air_ticket_booking_default_font_heading));

    $air_ticket_booking_css = '';

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

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

    // Add inline style
    wp_add_inline_style('air-ticket-booking-style-font-general', $air_ticket_booking_css);
}
add_action('wp_enqueue_scripts', 'air_ticket_booking_enqueue_fonts', 50);