<?php

	function newscope_inline_style() {
		wp_enqueue_style('newscope-inline', get_template_directory_uri() . '/assets/css/inline-style.css', array(), NEWSCOPE_VERSION, 'all');

		$newscope_inline = '
        	input[type="search"]::-webkit-search-decoration,
			input[type="search"]::-webkit-search-cancel-button,
			input[type="search"]::-webkit-search-results-button,
			input[type="search"]::-webkit-search-results-decoration {
				display: none;
			}
		';
        // Custom primary Color
		if ( true === get_theme_mod( 'primary_color_enable', false ) && !empty( get_theme_mod( 'theme_primary_color' ) ) ) {
                $newscope_primary_color = get_theme_mod( 'theme_primary_color' );
			if (!empty($newscope_primary_color)) {
				$newscope_inline .= '
                :root {
						--color-primary: ' . esc_attr($newscope_primary_color) . ';
					}
				';
				$newscope_inline .= '
					{
						background-color: var(--color-primary);
					}
				';
				$newscope_inline .= '
					{
						color: var(--color-primary);
					}
				';
				$newscope_inline .= '
					{
						border-color: var(--color-primary);
					}
				';
			}
		}

        if ( true === get_theme_mod( 'secondary_color_enable', false ) && !empty( get_theme_mod( 'theme_secondary_color' ) ) ) {
            $newscope_secondary_color = get_theme_mod( 'theme_secondary_color' );
            if (!empty($newscope_secondary_color)) {
                $newscope_inline .= '
                :root {
                        --color-secondary: ' . esc_attr($newscope_secondary_color) . ';
                    }
                ';
                $newscope_inline .= '
                    {
                        background-color: var(--color-secondary);
                    }
                ';
                $newscope_inline .= '
                    {
                        color: var(--color-secondary);
                    }
                ';
                $newscope_inline .= '
                    {
                        border-color: var(--color-secondary);
                    }
                ';
            }
        }
		wp_add_inline_style('newscope-inline', $newscope_inline);
	}

add_action('wp_enqueue_scripts', 'newscope_inline_style', 99);