<?php

/**
 * Dynamic CSS
 */
function doctor_physician_dynamic_css() {
	$doctor_physician_primary_color = get_theme_mod( 'doctor_physician_primary_color', '#235DA5' );

	$doctor_physician_site_title_font       = get_theme_mod( 'doctor_physician_site_title_font', 'Nunito' );
	$doctor_physician_site_description_font = get_theme_mod( 'doctor_physician_site_description_font', 'Nunito' );
	$doctor_physician_header_font           = get_theme_mod( 'doctor_physician_header_font', 'Poppins' );
	$doctor_physician_content_font             = get_theme_mod( 'doctor_physician_content_font', 'Nunito' );

	// Enqueue Google Fonts
	$fonts_url = doctor_physician_get_fonts_url();
	if ( ! empty( $fonts_url ) ) {
		wp_enqueue_style( 'doctor-physician-google-fonts', esc_url( $fonts_url ), array(), null );
	}

	$doctor_physician_custom_css  = '';
	$doctor_physician_custom_css .= '
    /* Color */
    :root {
        --primary-color: ' . esc_attr( $doctor_physician_primary_color ) . ';
        --header-text-color: ' . esc_attr( '#' . get_header_textcolor() ) . ';
    }
    ';

	$doctor_physician_custom_css .= '
    /* Typography */
    :root {
        --font-heading: "' . esc_attr( $doctor_physician_header_font ) . '", serif;
        --font-main: -apple-system, BlinkMacSystemFont, "' . esc_attr( $doctor_physician_content_font ) . '", "Segoe UI",Nunito, Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    }

    body,
	button, input, select, optgroup, textarea, p {
        font-family: "' . esc_attr( $doctor_physician_content_font ) . '", serif;
	}

	.site-identity p.site-title, h1.site-title a, h1.site-title, p.site-title a, .site-branding h1.site-title a {
        font-family: "' . esc_attr( $doctor_physician_site_title_font ) . '", serif;
	}
    
	p.site-description {
        font-family: "' . esc_attr( $doctor_physician_site_description_font ) . '", serif !important;
	}
    ';

	wp_add_inline_style( 'doctor-physician-style', $doctor_physician_custom_css );
}
add_action( 'wp_enqueue_scripts', 'doctor_physician_dynamic_css', 99 );