// Name:            HTML editor
// Description:     Defines styles for an HTML editor
//
// Component:       `wk-htmleditor`
//
// Sub-objects:     `wk-htmleditor-navbar`
//                  `wk-htmleditor-navbar-nav`
//                  `wk-htmleditor-navbar-flip`
//                  `wk-htmleditor-button-code
//                  `wk-htmleditor-button-preview`
//                  `wk-htmleditor-content`
//                  `wk-htmleditor-code`
//                  `wk-htmleditor-preview`
//                  `wk-htmleditor-iframe`
//
// Modifier:        `wk-htmleditor-fullscreen`
//                  `[data-mode='tab']`
//                  `[data-mode='split']`
//
// States:          `wk-active`
//
// ========================================================================


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

@htmleditor-navbar-background:                  #eee;

@htmleditor-navbar-nav-height:                  40px;
@htmleditor-navbar-nav-padding-horizontal:      15px;
@htmleditor-navbar-nav-line-height:             @htmleditor-navbar-nav-height;
@htmleditor-navbar-nav-color:                   #444;

@htmleditor-navbar-nav-hover-background:        #f5f5f5;
@htmleditor-navbar-nav-hover-color:             #444;
@htmleditor-navbar-nav-onclick-background:      #ddd;
@htmleditor-navbar-nav-onclick-color:           #444;
@htmleditor-navbar-nav-active-background:       #f5f5f5;
@htmleditor-navbar-nav-active-color:            #444;

@htmleditor-content-border:                     #ddd;
@htmleditor-content-background:                 #fff;
@htmleditor-content-padding:                    20px;
@htmleditor-content-split-border:               #eee;

@htmleditor-fullscreen-z-index:                 990;
@htmleditor-fullscreen-content-top:             @htmleditor-navbar-nav-height;
@htmleditor-fullscreen-icon-resize:             "\f066";


/* ========================================================================
   Component: HTML editor
 ========================================================================== */

.wk-htmleditor {
    .hook-htmleditor;
}


/* Sub-object `wk-htmleditor-navbar`
 ========================================================================== */

.wk-htmleditor-navbar {
    background: @htmleditor-navbar-background;
    .hook-htmleditor-navbar;
}

/*
 * Micro clearfix
 */

.wk-htmleditor-navbar:before,
.wk-htmleditor-navbar:after {
    content: "";
    display: table;
}

.wk-htmleditor-navbar:after { clear: both; }


/* Sub-object `wk-htmleditor-navbar-nav`
 ========================================================================== */

.wk-htmleditor-navbar-nav {
    margin: 0;
    padding: 0;
    list-style: none;
    float: left;
}

.wk-htmleditor-navbar-nav > li { float: left; }

/*
 * 1. Dimensions
 * 2. Style
 */

.wk-htmleditor-navbar-nav > li > a {
    display: block;
    box-sizing: border-box;
    text-decoration: none;
    /* 1 */
    height: @htmleditor-navbar-nav-height;
    padding: 0 @htmleditor-navbar-nav-padding-horizontal;
    line-height: @htmleditor-navbar-nav-line-height;
    /* 2 */
    color: @htmleditor-navbar-nav-color;
    font-size: 11px;
    cursor: pointer;
    .hook-htmleditor-navbar-nav;
}

/*
 * Hover
 * 1. Apply hover style also to focus state
 * 2. Remove default focus style
 */

.wk-htmleditor-navbar-nav > li:hover > a,
.wk-htmleditor-navbar-nav > li > a:focus { // 1
    background-color: @htmleditor-navbar-nav-hover-background;
    color: @htmleditor-navbar-nav-hover-color;
    outline: none; /* 2 */
    .hook-htmleditor-navbar-nav-hover;
}

/* OnClick */
.wk-htmleditor-navbar-nav > li > a:active {
    background-color: @htmleditor-navbar-nav-onclick-background;
    color: @htmleditor-navbar-nav-onclick-color;
    .hook-htmleditor-navbar-nav-onclick;
}

/* Active */
.wk-htmleditor-navbar-nav > li.wk-active > a {
    background-color: @htmleditor-navbar-nav-active-background;
    color: @htmleditor-navbar-nav-active-color;
    .hook-htmleditor-navbar-nav-active;
}


/* Sub-object: `wk-htmleditor-navbar-flip`
 ========================================================================== */

 .wk-htmleditor-navbar-flip { float: right; }


/* Sub-object for special buttons
 ========================================================================== */

[data-mode='split'] .wk-htmleditor-button-code,
[data-mode='split'] .wk-htmleditor-button-preview { display: none; }


/* Sub-object `wk-htmleditor-content`
 ========================================================================== */

.wk-htmleditor-content {
    border-left: 1px solid @htmleditor-content-border;
    border-right: 1px solid @htmleditor-content-border;
    border-bottom: 1px solid @htmleditor-content-border;
    background: @htmleditor-content-background;
    .hook-htmleditor-content;
}

/*
 * Micro clearfix
 */

.wk-htmleditor-content:before,
.wk-htmleditor-content:after {
    content: "";
    display: table;
}

.wk-htmleditor-content:after { clear: both; }


/* Modifier `wk-htmleditor-fullscreen`
 ========================================================================== */

.wk-htmleditor-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: @htmleditor-fullscreen-z-index;
}

.wk-htmleditor-fullscreen .wk-htmleditor-content {
    position: absolute;
    top: @htmleditor-fullscreen-content-top;
    left: 0;
    right: 0;
    bottom: 0;
}


.wk-htmleditor-fullscreen .wk-icon-expand:before { content: @htmleditor-fullscreen-icon-resize; }


/* Sub-objects `wk-htmleditor-code` and `wk-htmleditor-preview`
 ========================================================================== */

.wk-htmleditor-code,
.wk-htmleditor-preview { box-sizing: border-box; }

.wk-htmleditor-preview {
    padding: @htmleditor-content-padding;
    overflow-y: scroll;
    position: relative;
}

/*
 * Tab view
 */

[data-mode='tab'][data-active-tab='code'] .wk-htmleditor-preview,
[data-mode='tab'][data-active-tab='preview'] .wk-htmleditor-code { display: none; }

/*
 * Split view
 */

[data-mode='split'] .wk-htmleditor-code,
[data-mode='split'] .wk-htmleditor-preview {
    float: left;
    width: 50%;
}

[data-mode='split'] .wk-htmleditor-code { border-right: 1px solid @htmleditor-content-split-border; }


/* Sub-object `wk-htmleditor-iframe`
 ========================================================================== */

.wk-htmleditor-iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}


/* CodeMirror modifications
 ========================================================================== */

.wk-htmleditor .CodeMirror {
    padding: 10px;
    box-sizing: border-box;
}


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

.hook-htmleditor-misc;

.hook-htmleditor() {}
.hook-htmleditor-navbar() {}
.hook-htmleditor-navbar-nav() {}
.hook-htmleditor-navbar-nav-hover() {}
.hook-htmleditor-navbar-nav-onclick() {}
.hook-htmleditor-navbar-nav-active() {}
.hook-htmleditor-content() {}
.hook-htmleditor-misc() {}