<?php
/**
 * Dynamic CSS
 */
function design_studio_dynamic_css() {
	$design_studio_primary_color = get_theme_mod( 'design_studio_primary_color', '#29C684' );

	$design_studio_site_title_font       = get_theme_mod( 'design_studio_site_title_font', 'Sora' );
	$design_studio_site_description_font = get_theme_mod( 'design_studio_site_description_font', 'DM Sans' );
	$design_studio_header_font           = get_theme_mod( 'design_studio_header_font', 'Sora' );
	$design_studio_content_font          = get_theme_mod( 'design_studio_content_font', 'DM Sans' );

	// Enqueue Google Fonts
	$design_studio_fonts_url = design_studio_get_fonts_url();
	if ( ! empty( $design_studio_fonts_url ) ) {
		wp_enqueue_style( 'design-studio-google-fonts', esc_url( $design_studio_fonts_url ), array(), null );
	}

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

	$design_studio_custom_css .= '
    /* Typography */
    :root {
        --font-heading: "' . esc_attr( $design_studio_header_font ) . '", sans-serif;
        --font-second: "' . esc_attr( $design_studio_content_font ) . '", sans-serif;
    }


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

	.site-identity p.site-title, h1.site-title a, h1.site-title, p.site-title a, .site-branding h1.site-title a, header.site-header .header-main-wrapper:not(.transparent-header) .bottom-header-outer-wrapper .bottom-header-part .bottom-header-part-wrapper .site-branding .site-identity .site-title .slider-text {
        font-family: "' . esc_attr( $design_studio_site_title_font ) . '", serif;
	}
    
	p.site-description {
        font-family: "' . esc_attr( $design_studio_site_description_font ) . '", sans-serif !important;
	}
    ';

	wp_add_inline_style( 'design-studio-style', $design_studio_custom_css );
}
add_action( 'wp_enqueue_scripts', 'design_studio_dynamic_css', 99 );