/*  PmSyntax: Syntax highlighting for PmWiki markup
    Copyright 2021 Petko Yotov https://www.pmwiki.org/support
    This file is part of PmWiki; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published
    by the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.  See pmwiki.php for full details.

    This file provides a color theme for syntax highlighting of PmWiki markup,
    to be used in the PmWiki documentation, and optionally in the edit form.

    The CSS variables can be redefined in skins and in local customization in 
    order to adapt to other color themes.
*/
#wikiedit #hwrap textarea#text, #wikiedit #htext, .pmhlt, #chk_hlt {
  /* base text color and background */
  --pmsyntax-color: inherit;
  --pmsyntax-bgcolor: inherit;

  /* [=Escaped text=], not processed by PmWiki */
  --pmsyntax-escaped: rgba(0,0,0,.7);
  --pmsyntax-escapedbg: rgba(0,0,0,.07);

  /* (:comment text:)*/
  --pmsyntax-comment: #777;

  /* core meta directives and wikistyles */
  --pmsyntax-meta: #279;
  --pmsyntax-metabg: #eff;

  /* other core and custom directives */
  --pmsyntax-directive: black;
  --pmsyntax-directivebg: #eee;

  /* markup expressions */
  --pmsyntax-mx: #470;
  --pmsyntax-mxbg: #efe;

  /* !! Headings */
  --pmsyntax-heading: #800;
  --pmsyntax-headingbg: #ffe7e1;

  /* list items, line breaks, indents */
  --pmsyntax-bullet: #470;
  --pmsyntax-bulletbg: #dfd;

  /* simple tables */
  --pmsyntax-table: #470;
  --pmsyntax-tablebg: #dfd;

  /* inline punctuation like '''bold''' */
  --pmsyntax-punct: #a00;

  /* i18n strings like $[Edit] or entities like &nbsp; */
  --pmsyntax-string: #800;

  /* attributes and values in directives and wikistyles */
  --pmsyntax-attr: #f70;
  --pmsyntax-value: #a00;

  /* page (text) variables, template variables, like {*$:Summary} */
  --pmsyntax-var: #f40;
  
  /* keyword in forms, templates, conditionals */
  --pmsyntax-keyword: #800;


  /* Link URLs, InterMap links */
  --pmsyntax-url: #37a;

  /* textarea of the edit form, and highlighted block under it */
  --pmsyntax-border: 1px inset #ccc;
  --pmsyntax-radpad: 3px;
  --pmsyntax-fontfamily: monospace;

  --pmsyntax-fontsize: .93333em;
  --pmsyntax-fontsize-editform: 14px;
  --pmsyntax-lineheight: 1.3;

  /* color of the blinking cursor in the textarea */
  --pmsyntax-caretcolor: red;
}

pre.pmhlt, .pmhlt pre, 
code.pmhlt, .pmhlt code, #htext.pmhlt {
  color: var(--pmsyntax-color);
  background-color: var(--pmsyntax-bgcolor);
  font-family: var(--pmsyntax-fontfamily);
  font-size: var(--pmsyntax-fontsize);
}
#htext.pmhlt, #htext.pmhlt code, #htext.pmhlt code.hljs {
  font-size: var(--pmsyntax-fontsize-editform);  
}
.pmhlt .pmtag, .pmhlt .pmpunct {
  font-weight: bold;
}
.pmhlt .pmcomment {
  color: var(--pmsyntax-comment);
}
.pmhlt .pmmx {
  color: var(--pmsyntax-mx);
  background-color: var(--pmsyntax-mxbg);
}
.pmhlt .pmdirective {
  color: var(--pmsyntax-directive);
  background-color: var(--pmsyntax-directivebg);
}
.pmhlt .pmstring {
  color: var(--pmsyntax-string);
}
.pmhlt .pmvar {
  color: var(--pmsyntax-var);
}
.pmhlt .pmmeta {
  color: var(--pmsyntax-meta);
  background-color: var(--pmsyntax-metabg);
}
.pmhlt .pmbullet {
  color: var(--pmsyntax-bullet);
  background-color: var(--pmsyntax-bulletbg);
}
.pmhlt .pmtable {
  color: var(--pmsyntax-table);
  background-color: var(--pmsyntax-tablebg);
}
.pmhlt .pmpunct {
  color: var(--pmsyntax-punct);
}
.pmhlt .pmurl{
  color: var(--pmsyntax-url);
}
.pmhlt .pmheading {
  background-color: var(--pmsyntax-headingbg);
}
.pmhlt .pmheading .pmtag:not(.pmcomment,.pmcomment>*,.pmescaped,.pmescaped>*,.pmdirective,.pmdirective>*,.pmmeta,.pmmeta>*,.pmmx,.pmmx>*),
.pmhlt .pmheading.pmtag {
  color: var(--pmsyntax-heading);
}
.pmhlt .pmescaped {
  color: var(--pmsyntax-escaped);
  background-color: var(--pmsyntax-escapedbg);
}
.pmhlt .pmattr {
  color: var(--pmsyntax-attr);
}
.pmhlt .pmkeyword {
  color: var(--pmsyntax-keyword);
  font-style: italic;
}
.pmhlt .pmvalue {
  color: var(--pmsyntax-value);
}
.pmhlt .pmnobg {
  background-color: transparent;
}

.pmhlt code.hljs {
  padding: 0;
  display: inline;
}

#wikiedit #hwrap {
  position: relative;
  border: none;
  padding: 0;
  margin: 0;
  width: 100%;
  display: inline-block; /*skins*/
}
#wikiedit #hwrap textarea#text, #wikiedit #htext {
  border: var(--pmsyntax-border);
  border-radius: var(--pmsyntax-radpad);
  padding: var(--pmsyntax-radpad);
  box-sizing: border-box;
  font-family: var(--pmsyntax-fontfamily);
  font-size: var(--pmsyntax-fontsize-editform);
  line-height: var(--pmsyntax-lineheight);
  background-color: transparent;
  width: 100%;
  max-width: 100%;
  margin: 0;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
#wikiedit #hwrap #htext {
  display: none;
  position: absolute;
  top: 0px;
  left: 0px;
  background-color: var(--pmsyntax-bgcolor);
  white-space: pre-wrap;
  border-color: transparent;
  overflow: auto;
  user-select: none;
}

#wikiedit #chk_hlt.pmhlt ~ * #htext {
  display: block;
}
#chk_hlt {
  float: right;
  font-size: var(--pmsyntax-fontsize);;
  cursor: pointer;
  user-select: none;
  position: relative;
  z-index: 3;
  font-family: var(--pmsyntax-fontfamily);
}
#wikiedit #chk_hlt.pmhlt ~ * #text,
#wikiedit #chk_hlt.pmhlt ~ #text {
  position: relative;
  z-index: 2;
  color: transparent;
  background-image: none;
  caret-color: var(--pmsyntax-caretcolor);
}

#wikiedit #hwrap textarea#text.dragging {
  color: var(--pmsyntax-color);
}
