<?php

function omega_hair_salon_enqueue_fonts() {
    $omega_hair_salon_default_font_content = 'outfit';
    $omega_hair_salon_default_font_heading = 'outfit';

    $omega_hair_salon_font_content = esc_attr(get_theme_mod('omega_hair_salon_content_typography_font', $omega_hair_salon_default_font_content));
    $omega_hair_salon_font_heading = esc_attr(get_theme_mod('omega_hair_salon_heading_typography_font', $omega_hair_salon_default_font_heading));

    $omega_hair_salon_css = '';

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

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

    // Add inline style
    wp_add_inline_style('omega-hair-salon-style-font-general', $omega_hair_salon_css);
}
add_action('wp_enqueue_scripts', 'omega_hair_salon_enqueue_fonts', 50);