<?php

/**
 * @author : Webforia Studio
 */

namespace Retheme\Customizer;

use Retheme\Customizer_Base;
use \Kirki\Field as Control;

class Header extends Customizer_Base {

    public function __construct() {
        $this->set_section();
        $this->add_header_main();
        $this->add_header_mobile();
    }

    public function set_section() {

        $this->add_panel('header', [
            'title' => __('Header', 'jelajah-text'),
            'priority' => 60,
        ]);

        $this->add_section('header_desktop', [
            'title'       => __('Desktop Header', 'jelajah-text'),
            'panel'       => 'header',
        ]);

        $this->add_section('header_mobile', [
            'title'       => __('Mobile Header', 'jelajah-text'),
            'panel'       => 'header',
        ]);
    }

    public function add_header_main() {
        $section = 'header_desktop';

        $this->add_header([
            'label' => __('Main Header', 'jelajah-text'),
            'section' => $section,
        ]);

        $this->add_field([
            'type' => 'color',
            'choices' => ['alpha' => true],
            'label' => __('Text Color', 'jelajah-text'),
            'settings' => 'header_color',
            'default' => rt_get_theme('color')['body'],
            'section' => $section,
            'transport' => 'auto',
            'output' => [
                [
                    'element' => '.retheme-default-scheme .site-header__main',
                    'property' => '--wp--preset--color--body',
                ],
                [
                    'element' => '.retheme-default-scheme .site-header__main',
                    'property' => '--wp--preset--color--text-link',
                ],
            ],
        ]);

        $this->add_field([
            'type' => 'color',
            'choices' => ['alpha' => true],
            'label' => __('Accent Color', 'jelajah-text'),
            'description' => __('Text color on hover', 'jelajah-text'),
            'settings' => 'header_color_active',
            'default' => rt_get_theme('color')['text-link-active'],
            'section' => $section,
            'transport' => 'auto',
            'output' => [
                [
                    'element' => '.retheme-default-scheme .site-header__main',
                    'property' => '--wp--preset--color--text-link-active',
                ],
            ],
        ]);

        $this->add_field([
            'type' => 'color',
            'choices' => ['alpha' => true],
            'label' => __('Background Color', 'jelajah-text'),
            'settings' => 'header_background',
            'default' => rt_get_theme('color')['background'],
            'section' => $section,
            'transport' => 'auto',
            'output' => [
                [
                    'element' => '.retheme-default-scheme .site-header__main',
                    'property' => '--wp--preset--color--background',
                ],
            ],
        ]);

        $this->add_field([
            'type' => 'color',
            'choices' => ['alpha' => true],
            'label' => __('Border Color', 'jelajah-text'),
            'settings' => 'header_border_color',
            'default' => rt_get_theme('color')['outline'],
            'section' => $section,
            'transport' => 'auto',
            'output' => [
                [
                    'element' => '.retheme-default-scheme .site-header__main',
                    'property' => '--wp--preset--color--outline',
                ],
            ],
        ]);

        $this->add_header([
            'label' => __('Top Header', 'jelajah-text'),
            'section' => $section,
        ]);

        $this->add_field([
            'type' => 'toggle',
            'label' => __('Header Top Bar', 'jelajah-text'),
            'settings' => 'header_top',
            'section' => $section,
            'default' => true,
        ]);

        $this->add_field([
            'type' => 'color',
            'choices' => ['alpha' => true],
            'label' => __('Text Color', 'jelajah-text'),
            'settings' => 'header_top_color',
            'default' => '#ffffff',
            'section' => $section,
            'transport' => 'auto',
            'output' => [
                [
                    'element' => '.retheme-default-scheme .site-header__top',
                    'property' => '--wp--preset--color--body',
                ],
                [
                    'element' => '.retheme-default-scheme .site-header__top',
                    'property' => '--wp--preset--color--text-link',
                ],
            ],
        ]);

        $this->add_field([
            'type' => 'color',
            'choices' => ['alpha' => true],
            'label' => __('Accent Color', 'jelajah-text'),
            'description' => __('Text color on hover', 'jelajah-text'),
            'settings' => 'header_top_color_active',
            'default' => '#ffffff',
            'section' => $section,
            'transport' => 'auto',
            'output' => [
                [
                    'element' => '.retheme-default-scheme .site-header__top',
                    'property' => '--wp--preset--color--text-link-active',
                ],
            ],
        ]);

        $this->add_field([
            'type' => 'color',
            'choices' => ['alpha' => true],
            'label' => __('Background Color', 'jelajah-text'),
            'settings' => 'header_top_background',
            'default' => '#0071a7',
            'section' => $section,
            'transport' => 'auto',
            'output' => [
                [
                    'element' => '.retheme-default-scheme .site-header__top',
                    'property' => '--wp--preset--color--foreground',
                ],
            ],
        ]);

        $this->add_field([
            'type' => 'text',
            'label' => __('Phone', 'jelajah-text'),
            'settings' => 'header_top_phone',
            'section' => $section,
        ]);

        $this->add_field([
            'type' => 'text',
            'label' => __('Text Information', 'jelajah-text'),
            'settings' => 'header_top_text_info',
            'section' => $section,
        ]);
    }

    public function add_header_mobile() {
        $section = 'header_mobile';

        $this->add_field([
            'type' => 'color',
            'choices' => ['alpha' => true],
            'label' => __('Text Color', 'jelajah-text'),
            'settings' => 'header_mobile_color',
            'default' => rt_get_theme('color')['body'],
            'section' => $section,
            'transport' => 'auto',
            'output' => [
                [
                    'element' => '.retheme-default-scheme .site-header-mobile__main',
                    'property' => '--wp--preset--color--body',
                ],
                [
                    'element' => '.retheme-default-scheme .site-header-mobile__main',
                    'property' => '--wp--preset--color--text-link',
                ],
            ],
        ]);

        $this->add_field([
            'type' => 'color',
            'choices' => ['alpha' => true],
            'label' => __('Accent Color', 'jelajah-text'),
            'description' => __('Text color on hover', 'jelajah-text'),
            'settings' => 'header_mobile_color_active',
            'default' => rt_get_theme('color')['text-link-active'],
            'section' => $section,
            'transport' => 'auto',
            'output' => [
                [
                    'element' => '.site-header-mobile .site-header-mobile__main',
                    'property' => '--wp--preset--color--text-link-active',
                ],
            ],
        ]);

        $this->add_field([
            'type' => 'color',
            'choices' => ['alpha' => true],
            'label' => __('Background Color', 'jelajah-text'),
            'settings' => 'header_mobile_background',
            'default' => rt_get_theme('color')['background'],
            'section' => $section,
            'transport' => 'auto',
            'output' => [
                [
                    'element' => '.retheme-default-scheme .site-header-mobile__main',
                    'property' => '--wp--preset--color--background',
                ],
            ],
        ]);

        $this->add_field([
            'type' => 'color',
            'choices' => ['alpha' => true],
            'label' => __('Border Color', 'jelajah-text'),
            'settings' => 'header_mobile_border_color',
            'default' => rt_get_theme('color')['outline'],
            'section' => $section,
            'transport' => 'auto',
            'output' => [
                [
                    'element' => '.retheme-default-scheme .site-header-mobile__main',
                    'property' => '--wp--preset--color--outline',
                ],
            ],
        ]);
    }

    // end class
}

new Header;
