@import "app/styles/mixins"
@import "app/styles/bootstrap/variables"

@mixin editor-height($extraHeight)
  width: 98%
  height: 83%
  height: unquote("-webkit-calc(100% - 100px -")$extraHeight unquote(")")
  height: unquote("calc(100% - 100px -")$extraHeight unquote(")")

#spell-view
  margin-top: 10px
  padding-top: 20px
  padding-left: 30px
  padding-bottom: 95px
  display: none
  position: relative
  z-index: 1

  &.shown
    display: block

  .code-background
    position: absolute
    top: -68px
    left: 0px
    height: 100%
    right: -10px
    border: 1px solid transparent

  span.code-background
    border-width: 115px 76px 64px 40px
    border-image: url(/images/level/code_editor_background_border.png) 124 76 64 40 fill stretch

  img.code-background
    display: none
    width: 100%

  .save-status
    display: none
    position: absolute
    top: 10px
    left: 20px
    z-index: 4

  .programming-language-container
    position: absolute
    top: 10px
    right: 26px
    z-index: 4
    font-family: "Open Sans Condensed", "Helvetica Neue", Helvetica, Arial, sans-serif
    font-size: 14px
    padding: 0px 10px
    .programming-language-label
      color: #6E654B
      font-weight: bold
      text-transform: uppercase
    .programming-language
      color: darkred

  .firepad
    // When Firepad is active, it wraps .ace_editor in .firepad.
    @include editor-height(0px)
    width: 94%

    .ace_editor
      width: 100%
      height: 100%

    .powered-by-firepad
      display: none

  .ace_editor
    // When Firepad isn't active, .ace_editor needs the width/height set itself.
    @include editor-height(0px)
    margin-top: 10px
    width: 94%
    position: relative
    background-color: transparent
    line-height: 20px
    overflow: visible
    // https://github.com/codecombat/codecombat/issues/1411#issuecomment-60492750 -- trying to make sure system defaults don't mess up our monospace font.
    font-family: Monaco, Menlo, Ubuntu Mono, Consolas, "source-code-pro", monospace !important
    @include transition(height 0.25s ease-in-out)

    &.disabled
      @include opacity(0.8)
      .ace_cursor, .executing, .ace_active-line, .ace_gutter-active-line
        @include opacity(0.1)

    .ace_gutter
      background-color: transparent
      border-right: 1px solid rgb(195, 178, 156)
      //background-color: rgba(255, 255, 255, 0.25)
      width: 47px
      margin-left: 4px
      
    // override ace visible to get the experimental large current line executing arrow visible
    .ace_gutter
      overflow: visible
      
    .ace_layer
      overflow: visible
    // End experiment....

    .ace_scroller
      background-color: transparent
      //padding-left: 10px  // Interrupts gutter and line highlighting

    .ace_active-line, .ace_gutter-active-line
      background-color: rgba(255, 255, 255, 0.4)

    .ace_content
      .executing, .executed, .problem-marker-info, .problem-marker-warning, .problem-marker-error, .problem-line
        position: absolute
    .executing
      // https://github.com/codecombat/codecombat/issues/6
      background-color: rgba(255, 255, 255, 0.75)
      @include gradient-striped()
      outline: 2px outset #0099ff
      @include box-shadow(1px 1px 4px black)
    &.playback-ended .executing, &.user-code-problem .executing
      background-color: rgba(50, 255, 80, 0.65)
      outline: 0
      @include box-shadow(0 0 0px black)
    .executed
      background-color: rgba(110, 110, 110, 0.12)

    +keyframes(pulseRedBackground)
      from
        background-color: rgba(255, 45, 27, 0.4)
      50%
        background-color: rgba(255, 45, 27, 0.2)
      to
        background-color: rgba(255, 45, 27, 0.4)

    // problem-marker-#{@aetherProblem.level} set in Problem.coffee
    .problem-marker-info
      background-color: rgba(196, 163, 184, 0.25)
    .problem-marker-warning
      background-color: rgba(100, 65, 20, 0.25)
    .problem-marker-error
      background-color: rgba(255, 45, 27, 0.5)
    .problem-line
      // TODO: Pulses too quickly during playback
      @include animation(pulseRedBackground 1s infinite)

    &:not(.playback-ended):not(.user-code-problem)
      .executing:not(.ace_gutter-cell)
        background-size: 40px 40px
        @include animation(progress-bar-stripes 0.5s linear infinite)

    &:not(.user-code-problem)
      .ace_gutter-cell.executing:not(.ace_error):not(.ace_warning):not(.ace_info)
        margin-left: 1px
        background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA2hpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG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AAiElEQVR42mL8//8/AzUBEwOVweA3kAWboI2jCyhgDwBx4ZH9ey5Qy4UOQHweaHg/EAtQ08sFUIMDqBmGCkC8HmgoCCtQM1ICoK5toGYsg8KzHmjo+UGbDj8AcSMwORkSnQ7xgA3QtPmApISNBTyAGrSBGl6eAMSGxBhGyIVkZT3G0fKQYgAQYACL+C2ZM6PC7AAAAABJRU5ErkJggg==)
        background-position: 0px center

    .ace_gutter-cell.executed:not(.ace_error):not(.ace_warning):not(.ace_info)
      margin-left: 1px
      background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAANhJREFUeNpi/P//PwM1ARMDlcHgMrA428MAiANQBEFhSA4uynIXAOJ+dHFKXDgfiDdSxctAbzYAqQ+9U3ccQJdjIcMwByCVD8SGFEcK0DAFILUeiCcCXfeAIgOBhglADfsAxBNwqSPFy/1AbADEiUDXfSApHQJdcx+I9yPxE4AUCB8AGrYAn62M6HkZ6rX3UG4jEG8A4vNQviO2mMXrQqh3GqHcemi4gcACQobhixRQoMNiUQEaEY1k52WoKwuRhHAmE6KTDdCADdDwu4AvmRCMlOFfwAIEGAD4On+N4aXlhgAAAABJRU5ErkJggg==)
      background-position: 0px center

    .ace_gutter-cell.entry-point:after
      content: " "
      display: inline-block
      position: relative
      width: 49px
      top: -30px
      height: 38px
      overflow: visible

      background-image: url(data:image/png;base64,[encoded data, 4760 characters])

    .ace_gutter-cell.entry-point:not(.next-entry-point):after
      opacity: 0.5

    .ace_gutter-cell.entry-point.entry-point-indent-0:after
      left: -25px
    .ace_gutter-cell.entry-point.entry-point-indent-4:after
      left: 5px
    .ace_gutter-cell.entry-point.entry-point-indent-8:after
      left: 33px
    .ace_gutter-cell.entry-point.entry-point-indent-12:after
      left: 61px
    .ace_gutter-cell.entry-point.entry-point-indent-16:after
      left: 89px

    .ace_gutter-cell.ace_error
      background-image: url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ICAgICAgIDxkYzpmb3JtYXQ+aW1hZ2UvcG5nPC9kYzpmb3JtYXQ+CiAgICAgIDwvcmRmOkRlc2NyaXB0aW9uPgogICA8L3JkZjpSREY+CjwveDp4bXBtZXRhPgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDUdUmQAAAD5SURBVDiNpZMxagMxEEWfgiCXcB3IbXwD7zbaM0nNyjdIl1O4Dk7pbsslEFbEZFKsJsiJrGDy4YM0M//zRyAoINAJyB8cS43RwwIdMFrvaeE8DADxXqQ3Jstn6GaQ5L3M0GQxsyaZoJtA3r2XCS6o+FkvZkdOIG/eywl+UVHrqcYm4BNIjb1rPdXYBTivj3gVtZ5q/p8gAfPhcLOBamzKcW41UI1dgA/qez4bU6muUE0zwVYEgKeKkWruEnTHENg4R8pFZblCyY1zHEMgQTQAe9gB8cE5XkO4GhugmIk76L+z+Wzy6FzT4CWLXf5MF8upSdMB4gC9Xr4AiezTJHGxdq0AAAAASUVORK5CYII=)

    .ace_marker-layer
      .ace_bracket
        // Override faint gray
        border-color: #BFF

      .locked-code
        border: 1px dashed rgba(53, 45, 34, 0.5)
        background-color: transparent
        @include transition(background-color 0.25s ease-in-out)

        &:after
          content: "Locked"
          opacity: 0
          display: block
          text-align: right
          @include transition(opacity 4s ease-in-out)
          font-size: 24px

        &.pulsating
          background-color: rgba(53, 45, 34, 0.5)

          &:after
            opacity: 1

    // Decided it wasn't useful to show what can be hovered, since almost anything can, so we have to make it too faint to be useful if we don't want it to be really distracting.
    //.ace_identifier
    //  border-bottom: 1px dotted rgba(0, 51, 255, 0.25)

    .ace_text-layer .ace_comment
      color: #1900AD

    .ace_text-layer .ace_variable
      // https://github.com/codecombat/codecombat/issues/6
      color: rgb(145, 48, 50)

    .ace_search
      background-color: rgba(216, 187, 165, 1)
      border: 0
      @include box-shadow(1px 2px 1px #444)
      
      .ace_search_field
        width: 190px

      .ace_searchbtn, .ace_replacebtn
        padding: 0px 4px


html.no-borderimage
  #spell-view
    span.code-background
      display: none
    img.code-background
      display: block
