// Name:            Search
// Description:     Defines a search component
//
// Component:       `wk-search`
//
// Sub-objects:     `wk-search-field`
//
// Modifier:        (Nav) `wk-nav-search`
//                  (Dropdown) `wk-dropdown-search`
//
// States:          `wk-active`
//                  `wk-loading`
//
// Uses:            Animation
//                  Icon: FontAwesome
//                  Navbar: `wk-navbar-flip`
//
// Used by:         Off-canvas
//
// Markup:
//
// <!-- wk-search -->
// <form class="wk-search" data-wk-search>
//     <input class="wk-search-field" type="search" placeholder="">
// </form>
//
// ========================================================================


// Variables
// ========================================================================

@search-width:                                  120px;
@search-focus-width:                            180px;
@search-height:                                 30px;
@search-padding:                                30px;
@search-border:                                 rgba(0,0,0,0);
@search-border-width:                           1px;
@search-background:                             rgba(0,0,0,0);
@search-color:                                  #444;
@search-placeholder-color:                      #999;

@search-icon:                                   "\f002";
@search-icon-size:                              14px;
@search-icon-color:                             rgba(0,0,0,0.2);

// Dropdown modifier
@dropdown-search-width:                         300px;
@dropdown-search-margin-top:                    0;
@dropdown-search-background:                    #f5f5f5;
@dropdown-search-color:                         #444;
@dropdown-search-animation:                     wk-slide-top-fixed;
@dropdown-search-navbar-margin-top:             5px;
@dropdown-search-navbar-margin-right:           -15px;

// Nav modifier
@nav-search-color:                              #444;
@nav-search-active-background:                  #00a8e6;
@nav-search-active-color:                       #fff;
@nav-search-header-color:                       #999;
@nav-search-divider-border:                     #ddd;
@nav-search-divider-border-width:               1px;
@nav-search-nested-color:                       #07D;
@nav-search-nested-hover-color:                 #059;

// Search in offcanvas
@offcanvas-search-margin:                       20px 15px;
@offcanvas-search-background:                   #1a1a1a;
@offcanvas-search-border:                       rgba(0,0,0,0);
@offcanvas-search-color:                        #ccc;
@offcanvas-search-placeholder-color:            #777;
@offcanvas-search-icon-color:                   #777;


/* ========================================================================
   Component: Search
 ========================================================================== */

/*
 * 1. Create position context for dropdowns
 * 2. Needed for `form` element
 */

.wk-search {
    display: inline-block;
    /* 1 */
    position: relative;
    /* 2 */
    margin: 0;
    .hook-search;
}

/*
 * Icon
 */

.wk-search:before {
    content: @search-icon;
    position: absolute;
    top: 0;
    left: 0;
    width: @search-padding;
    line-height: @search-height;
    text-align: center;
    font-family: FontAwesome;
    font-size: @search-icon-size;
    color: @search-icon-color;
    .hook-search-icon;
}


/* Sub-object `wk-search-field`
 ========================================================================== */

/*
 * Removes inner padding and border in Firefox 4+.
 */

.wk-search-field::-moz-focus-inner {
    border: 0;
    padding: 0;
}

/*
 * Remove inner padding and search cancel button in Chrome, Safari and Opera on OS X.
 */

.wk-search-field::-webkit-search-cancel-button,
.wk-search-field::-webkit-search-decoration { -webkit-appearance: none; }

/*
 * Removes cancel button in IE10
 */

.wk-search-field::-ms-clear { display: none; }

/*
 * Removes placeholder transparency in Firefox.
 */

.wk-search-field::-moz-placeholder { opacity: 1; }

/*
 * 1. Define consistent box sizing.
 * 2. Address margins set differently in Firefox/IE and Chrome/Safari/Opera.
 * 3. Remove `border-radius` in iOS.
 * 4. Correct `font` properties and `color` not being inherited.
 * 5. Remove default style in iOS.
 * 6. Style
 */

.wk-search-field {
    /* 1 */
    box-sizing: border-box;
    /* 2 */
    margin: 0;
    /* 3 */
    border-radius: 0;
    /* 4 */
    font: inherit;
    color: @search-color;
    /* 5 */
    -webkit-appearance: none;
    /* 6 */
    width: @search-width;
    height: @search-height;
    padding: 0 0 0 @search-padding;
    border: @search-border-width solid @search-border;
    background: @search-background;
    -webkit-transition: all 0.2s linear;
    transition: all 0.2s linear;
    vertical-align: middle;
    .hook-search-field;
}

/* Placeholder */
.wk-search-field:-ms-input-placeholder { color: @search-placeholder-color !important; }
.wk-search-field::-moz-placeholder { color: @search-placeholder-color; }
.wk-search-field::-webkit-input-placeholder { color: @search-placeholder-color; }

/* Focus */
.wk-search-field:focus {
    outline: 0;
    .hook-search-field-focus;
}

/* Focus + Active */
.wk-search-field:focus,
.wk-search.wk-active .wk-search-field { width: @search-focus-width; }


/* Dropdown modifier: `wk-dropdown-search`
 ========================================================================== */

.wk-dropdown-search {
    width: @dropdown-search-width;
    margin-top: @dropdown-search-margin-top;
    background: @dropdown-search-background;
    color: @dropdown-search-color;
    .hook-dropdown-search;
}

.wk-open > .wk-dropdown-search {
    -webkit-animation: @dropdown-search-animation 0.2s ease-in-out;
    animation: @dropdown-search-animation 0.2s ease-in-out;
}

/*
 * Dependency `wk-navbar-flip`
 */

.wk-navbar-flip .wk-dropdown-search {
    margin-top: @dropdown-search-navbar-margin-top;
    margin-right: @dropdown-search-navbar-margin-right;
}


/* Nav modifier `wk-nav-search`
 ========================================================================== */

/*
 * Items
 */

.wk-nav-search > li > a {
    color: @nav-search-color;
    .hook-nav-search;
}

/*
 * Active
 * 1. Remove default focus style
 */

.wk-nav-search > li.wk-active > a {
    background: @nav-search-active-background;
    color: @nav-search-active-color;
    /* 1 */
    outline: none;
    .hook-nav-search-active;
}

/*
 * Sub-object: `wk-nav-header`
 */

.wk-nav-search .wk-nav-header {
    color: @nav-search-header-color;
    .hook-nav-search-header;
}

/*
 * Sub-object: `wk-nav-divider`
 */

.wk-nav-search .wk-nav-divider {
    border-top: @nav-search-divider-border-width solid @nav-search-divider-border;
    .hook-nav-search-divider;
}

/*
 * Nested items
 */

.wk-nav-search ul a { color: @nav-search-nested-color; }
.wk-nav-search ul a:hover { color: @nav-search-nested-hover-color; }


/* Search in offcanvas
 ========================================================================== */

.wk-offcanvas .wk-search {
    display: block;
    margin: @offcanvas-search-margin;
}

.wk-offcanvas .wk-search:before { color: @offcanvas-search-icon-color; }

.wk-offcanvas .wk-search-field {
    width: 100%;
    border-color: @offcanvas-search-border;
    background: @offcanvas-search-background;
    color: @offcanvas-search-color;
    .hook-offcanvas-search-field;
}

.wk-offcanvas .wk-search-field:-ms-input-placeholder { color: @offcanvas-search-placeholder-color !important; }
.wk-offcanvas .wk-search-field::-moz-placeholder { color: @offcanvas-search-placeholder-color; }
.wk-offcanvas .wk-search-field::-webkit-input-placeholder { color: @offcanvas-search-placeholder-color; }


// Hooks
// ========================================================================

.hook-search-misc;

.hook-search() {}
.hook-search-icon() {}
.hook-search-field() {}
.hook-search-field-focus() {}

.hook-dropdown-search() {}
.hook-nav-search() {}
.hook-nav-search-active() {}
.hook-nav-search-header() {}
.hook-nav-search-divider() {}
.hook-offcanvas-search-field() {}

.hook-search-misc() {}
