/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */

.editor-wrapper {
  --debug-expression-background: rgba(202, 227, 255, 0.5);
  --debug-line-error-border: rgb(255, 0, 0);
  --debug-expression-error-background: rgba(231, 116, 113, 0.3);
  --line-exception-background: hsl(344, 73%, 97%);
}

.theme-dark .editor-wrapper {
  --debug-expression-background: rgba(202, 227, 255, 0.3);
  --line-exception-background: hsl(345, 23%, 24%);
}

.editor-wrapper .CodeMirror-linewidget {
  margin-right: -7px;
}

.editor-wrapper {
  min-width: 0 !important;
}

.CodeMirror.cm-s-mozilla,
.CodeMirror-scroll,
.CodeMirror-sizer {
  overflow-anchor: none;
}

/* Prevents inline preview from shifting source height (#1576163) */
.CodeMirror-linewidget {
  padding: 0;
  display: flow-root;
}

/**
 * There's a known codemirror flex issue with chrome that this addresses.
 * BUG https://github.com/firefox-devtools/debugger/issues/63
 */
.editor-wrapper {
  width: calc(100% - 1px);
  overflow-y: auto;
  grid-area: editor;
}

html[dir="rtl"] .editor-mount {
  direction: ltr;
}

.function-search {
  max-height: 300px;
  overflow: hidden;
}

.function-search .results {
  height: auto;
}

.editor.hit-marker {
  height: 15px;
}

.editor-wrapper .highlight-lines {
  background: var(--theme-selection-background-hover);
}

.CodeMirror {
  width: 100%;
  height: 100%;
}

.editor-wrapper .editor-mount {
  width: 100%;
  background-color: var(--theme-body-background);
  font-size: var(--theme-code-font-size);
  line-height: var(--theme-code-line-height);
}

.theme-dark .editor-wrapper .CodeMirror-line .cm-comment {
  color: var(--theme-comment);
}

/* Is debug-expression is only used in CM5? */
.debug-expression {
  background-color: var(--debug-expression-background);
  border-style: solid;
  border-color: var(--debug-expression-background);
  border-width: 1px 0 1px 0;
  position: relative;
}

.debug-expression::before {
  content: "";
  line-height: 1px;
  border-top: 1px solid var(--blue-50);
  background: transparent;
  position: absolute;
  top: -2px;
  left: 0;
  width: 100%;
}

.debug-expression::after {
  content: "";
  line-height: 1px;
  border-bottom: 1px solid var(--blue-50);
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
}

/**
 * This is the "paused" caret displaying at what particular column we are currently paused.
 */
.paused-location {
  position: relative;
  width: 1px;
  height: 1.2em;
  margin-bottom: -0.2em;
  display: inline-block;

  .triangle {
    position: absolute;
    left: -6px;
    right: 0;
    top: -1px;
    bottom: 0;
    display: inline-block;
    width: 1em;
    height: 1em;

    &.first-column {
      /* When the caret is set on the first non-space column,
         we can shift it further on the left empty space
         in order to prevent shifting the code content.
         Also shift the caret one pixel closer to the token (-3 to -4px right)
         in order to avoid showing too far right when on the very first column. */
      margin-left: -7px;
      margin-right: -4px;
    }

    .column-breakpoint + &.first-column {
      /* When the caret is on the first column, but there is a column breakpoint displayed before
        reset back the first-column margins as we may display the caret over the breakpoint marker. */
      margin-left: -4px;
      margin-right: -4px;
    }

    background-image: url("chrome://devtools/skin/images/dropmarker.svg");
    background-repeat: no-repeat;
    background-position: center top;
    background-size: 100%;
    -moz-context-properties: fill;
    fill: var(--paused-line-border);
  }
}

.to-line-end ~ .CodeMirror-widget {
  background-color: var(--debug-expression-background);
}

.debug-expression-error {
  background-color: var(--debug-expression-error-background);
}

.new-debug-line-error > .CodeMirror-line,
/* For CM6 */
.cm-editor .cm-line.new-debug-line-error {
  background-color: var(--debug-expression-error-background) !important;
  outline: var(--debug-line-error-border) solid 1px;
}

/* Don't display the highlight color since the debug line
  is already highlighted */
.new-debug-line-error .CodeMirror-activeline-background {
  display: none;
}

.visible {
  visibility: visible;
}

/* Code folding */
.editor-wrapper .CodeMirror-foldgutter-open {
  color: var(--grey-40);
}

.editor-wrapper .CodeMirror-foldgutter-open,
.editor-wrapper .CodeMirror-foldgutter-folded {
  fill: var(--grey-40);
}

.editor-wrapper .CodeMirror-foldgutter-open::before,
.editor-wrapper .CodeMirror-foldgutter-open::after {
  border-top: none;
}

.editor-wrapper .CodeMirror-foldgutter-folded::before,
.editor-wrapper .CodeMirror-foldgutter-folded::after {
  border-left: none;
}

.editor-wrapper .CodeMirror-foldgutter .CodeMirror-linenumber {
  text-align: left;
  padding: 0 0 0 2px;
}

/* Exception line */
.line-exception {
  background-color: var(--line-exception-background);
}

.mark-text-exception {
  text-decoration: var(--red-50) wavy underline;
  text-decoration-skip-ink: none;
}
