<?php

/*----------------------------------------------------------------------------------*/

$cargo_ships_common_inline_css = '';

$cargo_ships_scroll_top_alignment = get_theme_mod('cargo_ships_scroll_top_alignment', 'Right');

$cargo_ships_alignment_styles = [
    'Left' => 'left: 20px;',
    'Center' => 'right: 0; left: 0; margin: 0 auto;',
    'Right' => 'right: 20px;'
];

$cargo_ships_alignment_style = $cargo_ships_alignment_styles[$cargo_ships_scroll_top_alignment] ?? $cargo_ships_alignment_styles['Right'];

$cargo_ships_common_inline_css .= "a.scrollup,button#scroll_2 { $cargo_ships_alignment_style }";

/*----------------------------------------------------------------------------------*/

$cargo_ships_footer_background_color = get_theme_mod('cargo_ships_footer_background_color', 'var(--first-color)');

if (!empty($cargo_ships_footer_background_color)) {
    $cargo_ships_common_inline_css .= ".footer-widgets { background: " . esc_attr($cargo_ships_footer_background_color) . "}";
}

/*----------------------------------------------------------------------------------*/

$cargo_ships_footer_background_image = get_theme_mod('cargo_ships_footer_background_image', '');

if (!empty($cargo_ships_footer_background_image)) {
    $cargo_ships_common_inline_css .= ".footer-widgets { background-image: url('" . esc_url($cargo_ships_footer_background_image) . "') !important; background-size: cover; background-repeat: no-repeat; }";
}

/*----------------------------------------------------------------------------------*/

$cargo_ships_copyright_alignment = get_theme_mod('cargo_ships_copyright_alignment', 'Center');

$cargo_ships_copyright_alignment_styles = [
    'Left' => 'text-align: left;',
    'Center' => 'text-align: center;',
    'Right' => 'text-align: right;'
];

$alignment_style = $cargo_ships_copyright_alignment_styles[$cargo_ships_copyright_alignment] ?? $cargo_ships_copyright_alignment_styles['Center'];

$cargo_ships_common_inline_css .= "#footer-copyright p { $alignment_style }";

/*----------------------------------------------------------------------------------*/

$cargo_ships_container_width = get_theme_mod('cargo_ships_container_width');

if (!empty($cargo_ships_container_width)) {
    $cargo_ships_common_inline_css .= "@media (min-width: 1024px) { 
        body, .navbar-area.header-fixed, .admin-bar .header-fixed,.loading { 
            width: " . esc_attr($cargo_ships_container_width) . "%; 
            margin: 0 auto; 
        } 
        .admin-bar .header-fixed { 
            margin-top: 32px; 
        } 
    }";
}

/*----------------------------------------------------------------------------------*/   

$cargo_ships_responsive_scroll_to_top_setting = get_theme_mod( 'cargo_ships_responsive_scroll_to_top_setting', true );

if ( $cargo_ships_responsive_scroll_to_top_setting == true && get_theme_mod( 'cargo_ships_scroll_to_top_setting', true ) != true ) {
    $cargo_ships_common_inline_css .= "a.scrollup,button#scroll_2 {
        display: none !important;
    }";
}

if ( $cargo_ships_responsive_scroll_to_top_setting == true ) {
    $cargo_ships_common_inline_css .= "@media screen and (max-width: 768px) {
        a.scrollup,button#scroll_2 {
            display: block !important;
        }
    }";
} elseif ( $cargo_ships_responsive_scroll_to_top_setting == false ) {
    $cargo_ships_common_inline_css .= "@media screen and (max-width: 768px) {
        a.scrollup,button#scroll_2 {
            display: none !important;
        }
    }";
}

/*----------------------------------------------------------------------------------*/ 

$cargo_ships_responsive_preloader_setting = get_theme_mod( 'cargo_ships_responsive_preloader_setting', false );

if ( $cargo_ships_responsive_preloader_setting == true && get_theme_mod( 'cargo_ships_preloader_setting', false ) == false ) {
    $cargo_ships_common_inline_css .= "@media screen and (min-width: 768px) {
        .loading {
            display: none !important;
        }
    }";
}

if ( $cargo_ships_responsive_preloader_setting == false ) {
    $cargo_ships_common_inline_css .= "@media screen and (max-width: 768px) {
        .loading {
            display: none !important;
        }
    }";
}

/*---------------------------Global Color-------------------*/

$cargo_ships_theme_color_1 = get_theme_mod('cargo_ships_theme_color_1');
$cargo_ships_theme_color_2 = get_theme_mod('cargo_ships_theme_color_2');

/*--- First Global Color ---*/

if ($cargo_ships_theme_color_1) {
  $cargo_ships_common_inline_css .= ':root {';
  $cargo_ships_common_inline_css .= '--first-color: ' . esc_attr($cargo_ships_theme_color_1) . ' !important;';
  $cargo_ships_common_inline_css .= '} ';
}

/*--- Second Global Color ---*/

if ($cargo_ships_theme_color_2) {
  $cargo_ships_common_inline_css .= ':root {';
  $cargo_ships_common_inline_css .= '--second-color: ' . esc_attr($cargo_ships_theme_color_2) . ' !important;';
  $cargo_ships_common_inline_css .= '} ';
}