<?php

if ( ! function_exists( 'ginevra_core_dependency_for_mobile_menu_typography_options' ) ) {
	/**
	 * Function that set dependency values for module global options
	 *
	 * @return array
	 */
	function ginevra_core_dependency_for_mobile_menu_typography_options() {
		return apply_filters( 'ginevra_core_filter_mobile_menu_typography_hide_option', array() );
	}
}

if ( ! function_exists( 'ginevra_core_set_mobile_header_styles' ) ) {
	/**
	 * Function that generates module inline styles
	 *
	 * @param string $style
	 *
	 * @return string
	 */
	function ginevra_core_set_mobile_header_styles( $style ) {
		$opener_styles    = array();
		$opener_color     = ginevra_core_get_post_value_through_levels( 'qodef_mobile_header_opener_color' );
		$opener_icon_size = ginevra_core_get_post_value_through_levels( 'qodef_mobile_header_opener_size' );

		if ( ! empty( $opener_color ) ) {
			$opener_styles['color'] = $opener_color;
		}

		if ( ! empty( $opener_icon_size ) ) {
			if ( qode_framework_string_ends_with_typography_units( $opener_icon_size ) ) {
				$opener_styles['font-size'] = $opener_icon_size;
			} else {
				$opener_styles['font-size'] = intval( $opener_icon_size ) . 'px';
			}
		}

		if ( ! empty( $opener_styles ) ) {
			$style .= qode_framework_dynamic_style( '#qodef-page-mobile-header .qodef-mobile-header-opener', $opener_styles );
		}

		$opener_svg_styles = array();

		if ( ! empty( $opener_icon_size ) ) {
			$opener_svg_styles['width'] = intval( $opener_icon_size ) . 'px';
		}

		if ( ! empty( $opener_svg_styles ) ) {
			$style .= qode_framework_dynamic_style( '#qodef-page-mobile-header .qodef-mobile-header-opener svg', $opener_svg_styles );
		}

		$opener_hover_styles = array();
		$opener_hover_color  = ginevra_core_get_post_value_through_levels( 'qodef_mobile_header_opener_hover_color' );

		if ( ! empty( $opener_hover_color ) ) {
			$opener_hover_styles['color'] = $opener_hover_color;
		}

		if ( ! empty( $opener_hover_styles ) ) {
			$style .= qode_framework_dynamic_style(
				array(
					'#qodef-page-mobile-header .qodef-mobile-header-opener:hover',
					'#qodef-page-mobile-header .qodef-mobile-header-opener.qodef--opened',
				),
				$opener_hover_styles
			);
		}

        $mobile_nav_lvl_underline_color   = ginevra_core_get_post_value_through_levels('qodef_mobile_menu_1st_lvl_underline_color');

        if ( ! empty( $mobile_nav_lvl_underline_color )) {
            $style .= qode_framework_dynamic_style( '.qodef-mobile-header-navigation ul li a .qodef-menu-item-text .qodef-menu-item-wave', array('color' => $mobile_nav_lvl_underline_color  ) );
        }

		return $style;
	}

	add_filter( 'ginevra_filter_add_inline_style', 'ginevra_core_set_mobile_header_styles' );
}
