<?php

/**
 * Dynamic CSS
 */
function construktly_dynamic_css() {
	$default_color         = construktly_get_default_color();

	$primary_color         = get_theme_mod( 'primary_color', $default_color['primary'] );
	$secondary_color       = get_theme_mod( 'secondary_color', $default_color['secondary'] );
	$header_font           = get_theme_mod( 'construktly_header_font', 'Roboto' );
	$body_font             = get_theme_mod( 'construktly_body_font', 'Roboto' );
	$site_title_font       = get_theme_mod( 'construktly_site_title_font', 'Roboto' );
	$site_description_font = get_theme_mod( 'construktly_site_description_font', 'Roboto' );

	$custom_css  = '';
	$custom_css .= '
    /* Color */
    :root {
        --primary-color: ' . esc_attr( $primary_color ) . ';
        --secondary-color: ' . esc_attr( $secondary_color ) . ';
    }
    ';

	$custom_css .= '
    /* Typograhpy */
    :root {
        --font-heading: "' . esc_attr( $header_font ) . '", serif;
        --font-main: -apple-system, BlinkMacSystemFont,"' . esc_attr( $body_font ) . '", "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    }

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

	.site-title a {
        font-family: "' . esc_attr( $site_title_font ) . '", serif;
	}
    
	.site-description {
        font-family: "' . esc_attr( $site_description_font ) . '", serif;
	}
    ';

	wp_add_inline_style( 'construktly-style', $custom_css );

}
add_action( 'wp_enqueue_scripts', 'construktly_dynamic_css', 99 );
