<?php
/**
 * 
 *
 * @see moral_magazine_custom_header_setup().
 */
function moral_magazine_header_text_style() {
	// If we get this far, we have custom styles. Let's do this.
	$header_text_display = get_theme_mod( 'moral_magazine_header_text_display' );

	$h1_h6_font_family = explode( '-', get_theme_mod( 'moral_magazine_h1_h6_font_option'  ) );
    $h1_h6_font_family = implode( ' ', array_map( 'ucfirst', $h1_h6_font_family ) );

    $body_font_family = explode( '-', get_theme_mod( 'moral_magazine_body_font_option'  ) );
    $body_font_family = implode( ' ', array_map( 'ucfirst', $body_font_family ) );

    $color = get_theme_mod( 'moral_magazine_custom_color_scheme' );

    $sections = array( 'breaking_news', 'hero_banner', 'featured_news', 'editorial', 'slider', 'travel_news', 'business_news', 'education_news', 'trip_news', 'three_column', 'have_missed', 'post_slider', 'cta', 'sport', 'extra_news', 'grid_post', 'two_column', 'featured_post', 'latest_news', 'travel_advice' );
	?>
	<style type="text/css">

	<?php foreach ( $sections as $section ): ?>

		<?php if ( !empty( get_theme_mod( 'moral_magazine_'.$section.'_top_padding', '' ) ) ): ?>
			
			.relative.<?php echo $section ?>{
				padding-top: <?php echo esc_attr( get_theme_mod( 'moral_magazine_'.$section.'_top_padding' ) ); ?>px !important;
			}
		<?php endif ?>

		<?php if ( !empty( get_theme_mod( 'moral_magazine_'.$section.'_bottom_padding', '' ) ) ): ?>
			.relative.<?php echo $section ?>{
				padding-bottom: <?php echo esc_attr( get_theme_mod( 'moral_magazine_'.$section.'_bottom_padding' ) ); ?>px !important;
			}
		<?php endif ?>
	<?php endforeach ?>

	<?php if ( ! is_active_sidebar( 'main-post-left-sidebar' ) && ! is_active_sidebar( 'main-post-right-sidebar' ) ): ?>
		@media screen and (min-width: 1025px){
			#main-post-wrapper #primary {
			    width: 100%;
			    padding: 0;
			}
		}			
	<?php endif ?>

	<?php if ( is_active_sidebar( 'main-post-left-sidebar' ) || is_active_sidebar( 'main-post-right-sidebar' ) ): ?>
		@media screen and (min-width: 1025px){
			#main-post-wrapper #primary {
			    width: 75%;
			}
		}			
	<?php endif ?>

	<?php if ( is_active_sidebar( 'main-post-left-sidebar' ) && is_active_sidebar( 'main-post-right-sidebar' ) ): ?>
		@media screen and (min-width: 1025px){
			#main-post-wrapper #primary {
			    width: 50%;
			}
		}			
	<?php endif ?>

	<?php if ( !is_active_sidebar( 'main-post-left-sidebar' ) && is_active_sidebar( 'main-post-right-sidebar' ) ): ?>
		@media screen and (min-width: 1025px){
			#main-post-wrapper #primary {
			    width: 75%;
			    padding: 0 30px 0 0;
			}
		}			
	<?php endif ?>

	<?php if ( is_active_sidebar( 'main-post-left-sidebar' ) && !is_active_sidebar( 'main-post-right-sidebar' ) ): ?>
		@media screen and (min-width: 1025px){
			#main-post-wrapper #primary {
			    width: 75%;
			    padding: 0 0 0 30px;
			}
		}			
	<?php endif ?>

	<?php if ( get_theme_mod( 'moral_magazine_topbar_social_menu', false ) == false  ) { ?> 
		@media screen and (min-width: 1025px){
			.icon-wrapper .entry-meta:after {
			    content: none;
			}
		}

	<?php } ?>


	.site-title a{
		color: #<?php echo esc_attr( get_header_textcolor() ); ?>;
	}

	.site-description {
		color: <?php echo esc_attr( get_theme_mod( 'moral_magazine_header_tagline', '#2e2e2e' ) ); ?>;
	}

	</style>

	<?php
}
add_action( 'wp_head', 'moral_magazine_header_text_style' );