<?php

function beauty_parlour_salon_enqueue_fonts() {
    $beauty_parlour_salon_default_font_content = 'outfit';
    $beauty_parlour_salon_default_font_heading = 'outfit';

    $beauty_parlour_salon_font_content = esc_attr(get_theme_mod('beauty_parlour_salon_content_typography_font', $beauty_parlour_salon_default_font_content));
    $beauty_parlour_salon_font_heading = esc_attr(get_theme_mod('beauty_parlour_salon_heading_typography_font', $beauty_parlour_salon_default_font_heading));

    $beauty_parlour_salon_css = '';

    // Always enqueue main font
    $beauty_parlour_salon_css .= '
    :root {
        --font-main: ' . $beauty_parlour_salon_font_content . ', ' . (in_array($beauty_parlour_salon_font_content, ['bitter', 'charis-sil']) ? 'serif' : 'sans-serif') . '!important;
    }';
    wp_enqueue_style('beauty-parlour-salon-style-font-general', get_template_directory_uri() . '/fonts/' . $beauty_parlour_salon_font_content . '/font.css');

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

    // Add inline style
    wp_add_inline_style('beauty-parlour-salon-style-font-general', $beauty_parlour_salon_css);
}
add_action('wp_enqueue_scripts', 'beauty_parlour_salon_enqueue_fonts', 50);