/**
 * Debugger
 * ========
 * A flat colored debugger
 */


/**
 * Global tools
 * ------------
 * 1. Variables
 * 2. Code highlighter styling
 * 3. The dumper styles
 */

@import "debugger/variables"; // 1
@import "debugger/highlight"; // 2
@import "dumper"; // 3


/**
 * Mixins
 * ------
 * 1. Transition mixin
 */

@mixin transition($content) { // 1
  -webkit-transition: $content;
  -moz-transition: $content;
  -ms-transition: $content;
  -o-transition: $content;
  transition: $content;
}


/**
 * Box-sizing
 * ------
 * Box sizing border-box all elements for this page
 */

body * {
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}

// Hidden class to hide stuff
.hidden {
  display: none !important;
}

// Main
body {
  margin: 0;
  padding: 0;
  font-family: Helvetica, Arial, sans-serif;
  background: $base1_accent--dark;
  color: $base03;
}

#error_page {
  &:before,
  &:after {
    display: table;
    content: " ";
  }
  &:after {
    clear: both;
  }
}

// Base styling
h2, h3, h4 {
  margin: 0 0 $spacing 0;
  padding: 0;
  color: $blue;
}

table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
}

table td {
  background: #fff;
  border: 1px solid $base1_accent--dark;
  padding: 10px;
}

table td code {
  color: $magenta;
}

code,
pre {
  margin: 0;
}

// Sticky class for sidebar
.sticky {
  position: fixed;
  top: 0;
  left: 0;
}

// Code font
.page_message,
.error_container__header,
.trace__item .trace__item__file {
  font-family: Monaco, Menlo, Consolas, "Courier New", monospace;
  font-size: 13px;
  font-weight: normal;
  line-height: 1.5em;
}

// Word breaking
.page_header__exception,
.page_message__text,
.arguments,
.error_container__header {
  white-space: normal;
  word-wrap: break-word;
  word-break: break-all;

  .linenumber {
    white-space: nowrap;
    display: inline;
  }
}

// Page header & message
.error_page__head {
  position: relative;
  z-index: 9;
}

.page_header,
.page_message {
  display: table;
  width: 100%;
  margin: 0;
  padding: 0;
  font-weight: normal;
}

.page_header__exception,
.page_header__code,
.page_message__text,
.page_message__button {
  display: table-cell;
  padding: $spacing;
}

.page_header {
  background: $red;
  color: #fff;
  position: relative;
  z-index: 2;
  font-size: 1em;
  text-shadow: -1px -1px 0 darken($red, 10%);
  box-shadow: 0 3px 3px rgba(0, 0, 0, .2);

  // Add to old-ie at the bottom as well
  @media screen and (min-width: 600px) {
    font-size: 1.5em;
  }
}

.page_header__code,
.page_message__button {
  text-align: right;
  padding-left: 0;
}

.page_header__exception {
  color: #fff;
  text-decoration: none;

  &:hover {
    text-decoration: underline;
  }
}

.page_message {
  background: $base02;
  color: $base2;
  text-shadow: -1px -1px 0 $base03;
  position: relative;
  z-index: 1;
}

.page_message__button {
  cursor: pointer;
}

// The main error
#the_error {
  .error_container__code {
    overflow: hidden;
  }

  .error_container__header {
    background: $blue;
    color: #fff;
    padding: 10px $spacing;

    .linenumber {
      color: $highlight;
    }
  }
}

// Linenumber
.linenumber {
  color: $blue;
  font-weight: bold;

  // Add to old-ie at the bottom as well
  @media screen and (min-width: 600px) {
    color: $highlight;
  }
}

// The source container
.error_container__code {
  margin: 0 0 $spacing 0;
}

.source {
  display: block;
  width: auto;
  line-height: 0;
  font-size: 0;
  overflow: hidden;
  overflow-x: auto;
  background: $base03;
  color: $base0;
  border: none;
  outline: none;

  code {
    min-width: 100%;
    max-width: none;
    width: auto;
    display: inline-block;
    font-size: 13px;
    line-height: 1.5em;
    border: none;
    outline: none;
  }

  .line {
    display: block;
    padding: 0;
  }

  .highlight {
    background: $base02;
  }
}

// Layout
.trace_container, .codes_container {
  display: block;
  float: left;
  margin: 0;
}

// The stacktrace container
.trace_container {
  display: none;

  // Add to old-ie at the bottom as well
  @media screen and (min-width: 600px) {
    display: block;
  }
}

.trace_container {
  width: 33%;
  min-height: 10px;
  word-wrap: break-word;
  list-style: none;
}

.trace_container .trace__item {
  display: block;
  counter-increment: trace-counter -1;
  position: relative;
  background: #fff;
  color: $base03;
  margin-bottom: 1px;
  padding: 15px;
  cursor: pointer;
  line-height: 1.5em;
  text-decoration: none;
  @include transition(all .1s ease-in-out);
}

.trace__item .trace__item__file {
  display: block;
  margin: 0;
}

.trace__item .trace__item__header {
  display: block;
  color: $blue;
  font-weight: bold;
  margin: 0;
}

.trace__item.active_trace_item .trace__item__header {
  color: $highlight;
}

.trace__item:hover {
  background: $highlight;
}

.trace__item.active_trace_item {
  background: $blue;
  color: #fff;
}

.trace_container .trace__item:before {
  content: counter(trace-counter);
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 12px;
  color: $base00;
}

.trace_container .trace__item.active_trace_item:before {
  color: lighten($blue, 35%);
}

// The error container
.codes_container {
  width: 100%;
  background: $base1_accent--light;
  border-left: 1px solid $base1_accent--dark;

  // Add to old-ie at the bottom as well
  @media screen and (min-width: 600px) {
    width: 67%;
  }
}

.codes_container__item {

  margin-top: -68px;
  padding-top: 68px;

  .codes_container__content {
    padding: $spacing;
    border-top: 1px solid #fff;
    border-bottom: 1px solid $base1_accent--dark;
    position: relative;
    @include transition(all .1s ease-in-out);

    &:hover {
      background: #fff;
    }

    // Add to old-ie at the bottom as well
    @media screen and (min-width: 600px) {
      &:hover {
        background: transparent;
        cursor: default;
      }

      .error_container__header {
        background: $blue;
        color: #fff;
        padding: 10px $spacing;
      }
    }

    &.active_source_item {
      background: #fff;

      &:before {
        display: block;
        content: " ";
        position: absolute;
        width: 4px;
        top: -1px;
        bottom: -1px;
        left: -1px;
        background: $blue;
      }
    }

    .error_container__code {
      display: none;

      // Add to old-ie at the bottom as well
      @media screen and (min-width: 600px) {
        display: block;
      }
    }

    h3 {
      counter-increment: source-counter -1;
      cursor: pointer;

      &:before {
        content: counter(source-counter) ". ";
      }

      &:after {
        content: " ☰";
      }

      // Add to old-ie at the bottom as well
      @media screen and (min-width: 600px) {
        cursor: default;

        &:after {
          display: none;
        }
      }
    }

    // Arguments
    div.args {
      display: none;

      // Add to old-ie at the bottom as well
      @media screen and (min-width: 600px) {
        display: block;
      }
    }
  }
}

.error_container__header {
  a {
    color: $base03;

    &:hover {
      text-decoration: none;
    }

    // Add to old-ie at the bottom as well
    @media screen and (min-width: 600px) {
      color: #fff;
    }
  }
}

.error_page__head,
.codes_container__content.visible {
  a {
    color: #fff;
  }
}

// Page data
.page_data {
  background: $base3;
  padding: 30px;
  height: auto;
  max-width: 100%;
  color: $yellow;
  text-align: center;
  text-shadow: 1px 1px 0 white;
}

// Visible class
.visible {
  display: block !important;
}

.visible .error_container__code,
.visible div.args {
  display: block !important;
}

.visible .error_container__header {
  background: $blue;
  color: #fff;
  padding: 10px $spacing;
}

.visible .linenumber {
  color: $highlight;
}


// Old ie specific classes
.old-ie {
  min-width: 600px;

  #error_page {
    .page_header {
      font-size: 1.5em;
    }

    .trace_container {
      display: block;
    }

    .codes_container {
      width: 67%;
    }

    .codes_container__item {
      &:hover {
        background: transparent;
        cursor: default;
      }

      .error_container__header {
        background: $blue;
        color: #fff;
        padding: 10px $spacing;

        .linenumber {
          color: $highlight;
        }
      }

      .error_container__code {
        display: block;
      }

      h3 {
        cursor: default;
      }

      div.args {
        display: block;
      }
    }

    .error_container__header {
      a {
        color: #fff;
      }
    }
  }
}