@import url("https://fonts.googleapis.com/css?family=Roboto|Roboto+Mono");
@import (less) "../../../node_modules/ace/lib/ace/ext/static.css";
@import (less) "../../../node_modules/ace/lib/ace/theme/textmate.css";


@toolbar-height: 40px;
@toolbar-bg-color: #2b3e50;
@toolbar-fg-color: #ebebeb;
@toolbar-active-bg-color: #df691a;
@toolbar-active-fg-color: #ffffff;
@font-size: 14px;
    
.make-code-toggle(@i, @rules) when (@i > 0) {
    .make-code-toggle(@i - 1, @rules);
    
    .code-toggle:nth-child(@{i}):checked ~ .embed-wrapper &:nth-child(@{i}) {
        @rules();
    }
}

body, html {
    margin: 0;
    padding: 0;
    overflow: hidden;
    box-sizing: border-box;
    font-family: 'Roboto', sans-serif;
    font-size: @font-size;
    height: 100vh;
    width: 100vw;
}
*, *:before, *:after {
    box-sizing: inherit;
}
.embed-wrapper {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    height: 100vh;
    width: 100vw;
    position: relative;
    
    & > .toolbar-wrapper {
        flex: 0 0 3em;
    }
    
    & > .content-wrapper {
        flex: 1 1 auto;
    }
}

.toolbar-wrapper {
    display: flex;
    flex-direction: row;
    
    background-color: @toolbar-bg-color;
    color: @toolbar-fg-color;
    overflow: hidden;
    box-shadow: #999 0 2px 4px;
    z-index: 1;
    
    & > .toolbar-left {
        flex: 1 1 1px;
    }
    
    & > .toobar-right {
        flex: 0 0 auto;
    }
}

.toolbar-left {
    display: flex;
    flex-direction: row;
    align-items: center;
    
    & > .title {
        color: #fff;
        font-weight: bold;
        line-height: @toolbar-height;
        white-space: nowrap;
        overflow-x: hidden;
        text-overflow: ellipsis;
        text-decoration: none;
        
        &:hover {
            text-decoration: underline;
        }
    }
    
    & > .logo {
        display: inline-block;
        background: url('https://plnkr.co/img/plunker.png') no-repeat;
        background-size: 2.8em 2.8em;
        background-position: center center;
        padding: 0 2em 0;
        line-height: @toolbar-height;
        height: @toolbar-height;
    }
}


.toolbar-right {
    display: flex;
    flex-direction: row;
    align-items: center;
    
    & > .toolbar-button {
        flex: 0 0 auto;
        border-left: 1px solid #fff;
        
        &:hover {
            background-color: lighten(@toolbar-bg-color, 10%);
        }
        
        &.-preview {
            #toggle-preview:checked ~ .embed-wrapper & {
                background-color: @toolbar-active-bg-color;
                color: @toolbar-active-fg-color;
                
                &:hover {
                    background-color: darken(@toolbar-active-bg-color, 10%);
                }
            }
        }
        
        &.-code {
            #toggle-preview:not(:checked) ~ .embed-wrapper & {
                background-color: @toolbar-active-bg-color;
                color: @toolbar-active-fg-color;
                
                &:hover {
                    background-color: darken(@toolbar-active-bg-color, 10%);
                }
            }
        }
    }
}

.toolbar-button {
    display: inline-block;
    margin: 0;
    padding: 0.5em 1em;
    background: @toolbar-bg-color;
    border: 0;
    color: inherit;
    outline: 0;
    font-family: 'Roboto', sans-serif;
    font-size: @font-size;
    line-height: 2em;
    text-decoration: none;
    white-space: nowrap;
    vertical-align: middle;
    
    &:hover, &:active {
        cursor: pointer;
        text-decoration: none;
    }
}

.content-wrapper {
    display: flex;
    flex-direction: column;
    position: relative;
    
    & > .plunk-preview {
        flex: 1 1 auto;
        display: none;
        margin: 0;
        padding: 0;
        border: 0;
        overflow: auto;
        width: 100%;
        height: 100%;
        
        #toggle-preview:checked ~ .embed-wrapper & {
            display: block;
        }
    }
    
    & > .code-view {
        flex: 1 1 auto;
        display: none;
        
        .make-code-toggle(100, {
            display: block;
        });
    }
    
    & > .file-listing {
        flex: 1 1 auto;
        display: none;
        
        #toggle-files:checked ~ .embed-wrapper & {
            display: block;
        }
    }
}

.code-view, .file-listing {
    margin: 0;
    padding: 0;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    overflow: auto;
}

.code-view {
    .ace_static_highlight {
        font-family: 'Roboto Mono', 'Monaco','Menlo','Ubuntu Mono','Consolas','source-code-pro','Droid Sans Mono',monospace;
        font-size: 13px;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
    
        & > .ace_line {
            white-space: pre;
        }
    }
    
    & > .filename {
        position: absolute;
        top: 1em;
        right: 1em;
        color: #666;
        z-index: 1;
        text-shadow: #aaa 0 2px 4px;
    }
}

.content-switcher {
    display: none;
}

.file-listing {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    
    & > .file-selector {
        flex: 0 0 auto;
    }
}

.file-selector {
    display: block;
    margin: 0;
    padding: 0.5em 1em;
    background: none;
    border: 0;
    color: inherit;
    outline: 0;
    font-family: 'Roboto', sans-serif;
    font-size: @font-size;
    line-height: 2em;
    text-decoration: none;
    white-space: nowrap;
    vertical-align: middle;
    
    &:hover, &:active {
        cursor: pointer;
        text-decoration: none;
    }
    
    &:hover {
        background-color: lighten(@toolbar-bg-color, 60%);
    }
}