/* writer-only Markdown source highlighter. Loaded with media="only screen".
   The textarea is the real editor; this layer only mirrors styled source text. */
.visual-editor-wrap {
  position: relative;
  min-height: 92vh;
}

.visual-editor-wrap .visual-editor,
.visual-editor-wrap textarea#content {
  font-family: "SFMono-Regular", "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 1.1rem;
  font-weight: 400;
  line-height: 1.25;
  letter-spacing: 0;
  tab-size: 4;
  -moz-tab-size: 4;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.he .visual-editor-wrap .visual-editor,
.he .visual-editor-wrap textarea#content,
[dir="rtl"] .visual-editor-wrap .visual-editor,
[dir="rtl"] .visual-editor-wrap textarea#content {
  font-family: "Calibri", "David", "SFMono-Regular", "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
}

.visual-editor-wrap .visual-editor {
  position: absolute;
  z-index: 0;
  inset: 0;
  overflow: hidden;
  padding: var(--space-sm) var(--space-md);
  color: var(--gray-800);
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  pointer-events: none;
}

.visual-editor-wrap textarea#content {
  position: relative;
  z-index: 1;
  min-height: 92vh;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent !important;
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: var(--gray-900);
  resize: vertical;
}

.visual-editor-wrap textarea#content:focus {
  background: transparent !important;
}

.visual-overlay-disabled .visual-editor-wrap .visual-editor {
  display: none;
}

.visual-overlay-disabled .visual-editor-wrap textarea#content {
  color: var(--gray-800);
  -webkit-text-fill-color: currentColor;
  background: var(--white) !important;
}

.visual-editor-wrap textarea#content::selection {
  background: rgba(139, 105, 20, 0.25);
}

.visual-editor-wrap .visual-editor.is-empty::before {
  content: attr(data-placeholder);
  color: var(--gray-400);
  white-space: pre-wrap;
}

.visual-editor-wrap .visual-editor .md-heading {
  color: var(--navy-800);
}

.visual-editor-wrap .visual-editor .md-h1,
.visual-editor-wrap .visual-editor .md-h2,
.visual-editor-wrap .visual-editor .md-h3 {
  text-decoration-line: underline;
  text-decoration-color: rgba(212, 168, 75, 0.75);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

.visual-editor-wrap .visual-editor .md-h1,
.visual-editor-wrap .visual-editor .md-h2 {
  color: var(--gold-700);
}

.visual-editor-wrap .visual-editor .md-list-line {
  color: var(--gray-900);
}

.visual-editor-wrap .visual-editor .md-marker {
  color: var(--gray-800);
}

.visual-editor-wrap .visual-editor .md-heading .md-marker {
  color: var(--gold-700);
  background: rgba(212, 168, 75, 0.24);
  border-radius: 0.15em;
}

.visual-editor-wrap .visual-editor .md-strong-marker,
.visual-editor-wrap .visual-editor .md-heading .md-strong-marker {
  color: rgba(45, 55, 72, 0.5);
  background: transparent;
}

.visual-editor-wrap .visual-editor strong {
  font-weight: inherit;
  color: var(--navy-700);
}

.visual-editor-wrap .visual-editor .md-code-text {
  color: #9f1239;
  background: var(--gray-100);
  border-radius: 0.15em;
}

::highlight(writer-bold) {
  color: var(--gold-700);
}

::highlight(writer-bold-marker) {
  color: rgba(45, 55, 72, 0.75);
}

::highlight(writer-heading-marker) {
  color: var(--gold-700);
  background-color: rgba(212, 168, 75, 0.24);
}

::highlight(writer-code) {
  color: #9f1239;
  background-color: var(--gray-100);
}

/* The source mirror must match the textarea exactly. The document's print
   justification option applies only to #output/#header, not to this editor. */
.visual-editor-wrap .visual-editor.justify {
  text-align: start;
}

@media (prefers-color-scheme: dark) {
  .visual-editor-wrap .visual-editor {
    color: var(--gray-100);
    background: var(--navy-900);
    border-color: var(--navy-600);
  }

  .visual-editor-wrap textarea#content {
    caret-color: var(--gray-100);
  }

  .visual-overlay-disabled .visual-editor-wrap textarea#content {
    color: var(--gray-100);
    -webkit-text-fill-color: currentColor;
    background: var(--navy-900) !important;
  }

  .visual-editor-wrap .visual-editor.is-empty::before {
    color: var(--gray-500);
  }

  .visual-editor-wrap .visual-editor .md-heading,
  .visual-editor-wrap .visual-editor .md-h1,
  .visual-editor-wrap .visual-editor .md-h2 {
    color: var(--gold-300);
  }

  .visual-editor-wrap .visual-editor .md-list-line {
    color: var(--gray-100);
  }

  .visual-editor-wrap .visual-editor .md-marker {
    color: var(--gray-200);
  }

  .visual-editor-wrap .visual-editor .md-heading .md-marker {
    color: var(--gold-200);
    background: rgba(212, 168, 75, 0.22);
  }

  .visual-editor-wrap .visual-editor .md-strong-marker,
  .visual-editor-wrap .visual-editor .md-heading .md-strong-marker {
    color: rgba(243, 244, 246, 0.5);
    background: transparent;
  }

  .visual-editor-wrap .visual-editor strong {
    color: var(--gold-200);
  }

  .visual-editor-wrap .visual-editor .md-code-text {
    color: #fecdd3;
    background: var(--navy-700);
  }

  ::highlight(writer-bold) {
    color: var(--gold-200);
  }

  ::highlight(writer-bold-marker) {
    color: rgba(243, 244, 246, 0.75);
  }

  ::highlight(writer-heading-marker) {
    color: var(--gold-200);
    background-color: rgba(212, 168, 75, 0.22);
  }

  ::highlight(writer-code) {
    color: #fecdd3;
    background-color: var(--navy-700);
  }
}
