/* tab-size */
#editor {
	position: relative;
	color: var(--color-text);
	tab-size: 4;
}

/* image */
#editor img {
  display: block;
  margin: 0 auto;
  height: auto;
  max-width: 100%;

  -webkit-user-drag: none;
  -khtml-user-drag: none;
  -moz-user-drag: none;
  -o-user-drag: none;
  user-drag: none;
}

#editor img::before {
  content: "Failed to Load Image\A(url: " attr(src) ")";
  padding: 0.5em;
  white-space: pre;
  background-color: var(--color-bg-error);
  display: block;
  text-align: center;
  font-family: var(--code-font);
}

/* images should snuggle up between paragraphs */
#editor p + img { margin-top: -0.5em; }
#editor .directive > p:first-child + img { margin-top: 0.5em; }
#editor img + p { margin-top: 0.5em;  }

#editor p {
	margin-left: 0.5em;
	font-family: var(--font-editor);
	font-size: var(--font-size);
	line-height: var(--line-height);
}

/* code */
#editor pre      { font-family: var(--code-font); display: block; }
#editor code     { font-family: var(--code-font); background-color: var(--editor-codeblock-bg); }
#editor pre code { display: block; }

/* inline code */
#editor p code {
	display: inline;
	padding: 0.1rem 0.2rem;
}

#editor h1 code { padding: 0.2rem; }
#editor h2 code { padding: 0.2rem; }
#editor h3 code { padding: 0.2rem; }
#editor h4 code { padding: 0.2rem; }
#editor h5 code { padding: 0.2rem; }
#editor h6 code { padding: 0.2rem; }

#editor .error-block code, #editor .error-inline {
	background-color: var(--color-bg-error);
}

/* code block */
#editor code {
	padding: 0.5em;
	background-color: var(--color-bg-2);
	font-family: "Consolas", "Ubuntu Mono", monospace;
	text-align: left;
}

/* blockquote */

#editor blockquote {
  border-left: 2px solid hsl(210, 50%, 80%);
  color: #224;
  background-color: hsl(210, 80%, 97%);
  margin: 0;
  padding: 0.2em 0.2em;
  padding-left: 0.6em;
  padding-right: 0.6em;
}

/* definition */
#editor dfn, #editor .definition {
	color: var(--color-definition);
	font-weight: bold;
}

/* links */
#editor a { color: var(--color-link); text-decoration: none; }

/* underline */
#editor em.ul {
	font-style: normal;
	text-decoration: underline;
}

/* == Style Modifications when CTRL is Pressed ========== */

/* active when CTRL key pressed */
.user-ctrl a               { cursor: pointer; }
.user-ctrl .tag            { cursor: pointer; }
.user-ctrl .wikilink       { cursor: pointer; }
.user-ctrl .citation       { cursor: pointer; }
.user-ctrl a:hover         { text-decoration: underline !important; background-color: var(--color-bg-highlight); }
.user-ctrl .tag:hover      { text-decoration: underline; background-color: var(--color-bg-highlight);}
.user-ctrl .wikilink:hover { text-decoration: underline; background-color: var(--color-bg-highlight);}
.user-ctrl .citation:hover { text-decoration: underline; background-color: var(--color-bg-highlight);}

/* == List Styles ======================================= */

#editor li p {
	margin: 0;
	text-align: left;
}

#editor ul {
	padding-left: 2em;
	position: relative;
	list-style-type: none;
	line-height: var(--line-height-list);
}

#editor ul li {
	margin-bottom: 0.2em;
}

/* -- List Bullet --------------------------------------- */

#editor ul li::before {
	content: "\2022";
	display: inline-block;
	position: absolute;
	left: 0;
	width: 1em;
	margin-left: -1em;
}

#editor ul li[data-bullet]::before {
	content: attr(data-bullet);
	font-weight: bold;
}
#editor ul[data-bullet="*"] > li:not(data-bullet)::before { content: "\2022"; }
#editor ul[data-bullet="-"] > li:not(data-bullet)::before { content: "\2212"; }
#editor ul[data-bullet="+"] > li:not(data-bullet)::before { content: "+"; }
#editor ul li[data-bullet="*"]::before { content: "\2022"; }
#editor ul li[data-bullet="-"]::before { content: "\2212"; }

/* Semantic List Items */
#editor ul[data-bullet="+"] > li:not(data-bullet) { color: var(--color-good);     }
#editor ul[data-bullet="-"] > li:not(data-bullet) { color: var(--color-bad);      }
#editor ul[data-bullet="?"] > li:not(data-bullet) { color: var(--color-question); }
#editor ul li[data-bullet="+"] { color: var(--color-good);     }
#editor ul li[data-bullet="-"] { color: var(--color-bad);      }
#editor ul li[data-bullet="?"] { color: var(--color-question); }


/* -- Task Lists ---------------------------------------- */

/* @todo (2021-06-12) are tasklist styles used? */

/* task lists */
li.task-list-item {
	list-style-type: none;
	left: -1em;
}

li.task-list-item input[type='checkbox'] {
	position: relative;
	left: -1em;
}

/* == WYSIWYM =========================================== */

/* @todo bundle this css with the wysiwym plugins */

.node-wysiwym {
	min-width: 1em;
	min-height: 1em;
}

.node-wysiwym.pm-selected              { outline: none; }
.node-wysiwym.pm-selected .node-src    { display: inline-block; }
.node-wysiwym.pm-selected .node-render { display: none;   }


.node-wysiwym .node-src { display: none; }

.node-wysiwym .node-render {
	display: inline;
	cursor: pointer;
}

/* == CODEMIRROR ======================================== */

.codeView {
  margin: 1em 0;
}

/* ---- code -------------------------------------------- */

.codeView-code {
  position: relative;
}

.codeView-code.hidden {
  display: none;
}

.codeView-code .langLabel {
  display: inline-block;
  position: absolute;
  z-index: 10;
  width: 7em;
  right: 0.4em;
  top: 0.4em;
  color: var(--editor-codeblock-langLabel);
  font-size: 0.8em;
  font-family: var(--code-font);

  background: none;
  border: none;
  text-align: right;
  outline: none;
}

.codeView-code:focus-within .langLabel {
  text-decoration: underline;
}

.codeView-code .cm-editor {
  background-color: var(--editor-codeblock-bg);
}

/* ---- preview ----------------------------------------- */

.codeView-preview {
  min-height: 1em;
  background-color: white;
  user-select: none;
}

.codeView-preview.hidden {
  display: none;
}

/** TODO (Ben @ 2023/04/09) move this to plugin css */
.codeView-preview svg {
  display: block;
  margin: 0 auto;
}


/* == MATH ============================================== */

.math-src                           { color: var(--color-math-src)   !important; }
.math-src::before, .math-src::after { color: var(--color-text-faint) !important; }

math-display {
	margin: 1em 0 1em 0;
}

math-inline {
	/* empty */
}

math-display.ProseMirror-selectednode {
	background-color: var(--color-bg-1) !important;
}

.reactiveAtom {
	padding: 10px;
	background-color: #ffa;
	height: 4em;
	min-width: 2em;
}

/* == DIRECTIVES ======================================== */

.directive {
    margin-top: 1em;
    padding: 1em;
    background-color: #ffffff;
    border: 1px solid #dfdfdf;
    border-radius: 0.5em;
}

.directive-label {
	font-weight: bold;
	text-transform: capitalize;
}

/* TODO (2022/05/06) simplify formatting for first paragraph in directive */
.directive > p:first-child { margin: 1em 0 0 0; }
.directive > *:last-child  { margin-bottom: 0;  }

.directive p:not(:first-child) {
  margin-left:  0 !important;
  margin-right: 0 !important;
  margin-top:  1.0em;
}

.directive::before {
  content: attr(data-name) ".";
  text-transform: capitalize;
  font-weight: bold;
}

.directive > p:first-child {
  display: inline;
}

.directive[data-name="example"] {
}

.directive[data-name="definition"] {
}
.directive[data-name="remark"] {
}

/* ==== Error ==== */

.directive[data-name="error"] {
  color: var(--color-bad);
  background-color: var(--color-bg-error);
  border: none;
}

/* ==== Warning / Caution ==== */

.directive[data-name="warning"], .directive[data-name="caution"] {
  color: var(--color-warning);
  background-color: var(--color-bg-warning);
  border: none;
}

/* ==== Theorem ==== */

.directive:focus-within {
  border: 1px solid red;
}

.directive[data-name="theorem"] ol {
  list-style-type: upper-roman;
}

/* ==== Proof ==== */

.directive[data-name="proof"]::before {
  font-weight: normal;
  font-style: italic;
}

/* top-level proof */
.ProseMirror > .directive[data-name="proof"] {
  padding: 0.5em;
}

.directive[data-name="proof"] {
  position: relative;
  padding: 1.0em 0.5em 0.5em 0;
  border: none;
  border-radius: 0;
  border-top: 1px solid #ccc;
  border-bottom: 1px solid #ccc;
  /* prevents border wiggle https://stackoverflow.com/a/11661286/1444650 */
  overflow: auto;
  background-color: unset;

  text-align: justify;
}

.directive[data-name="proof"]:last-child {
  border-bottom: none;
}
/* .directive[data-name="proof"] > p:last-child::after {
  content: "";
  display: inline-block;
  border: 1px solid;
  width: 0.5em;
  height: 0.5em;
  margin-left: 0.5em;
} */

/* proof qed */
.directive[data-name="proof"]::after {
  content: "";
  display: block;

  position: absolute;
  right: 0.5em;
  bottom: 0.7em;

  border: 1px solid;
  width: 0.6em;
  height: 0.6em;
}

/* == EMBEDDED FILES ==================================== */

.embed {
	position: relative;
	padding: 0.5em 0.5em 0.5em 0;
	border: 1px solid #d0d0d0;
	border-radius: 6px;
	transition: 0.2s;
}

.embed input {
	position: absolute;
	top: -0.5em;
	right: 2em;
	border: 1px solid dodgerblue;
	color: dodgerblue;
	border-radius: 4px;
	font-family: var(--code-font);

	display: none;
}

.embed:focus-within {
	border: 1px solid dodgerblue;
}

.embed:focus-within input {
	display: block;
	animation: anim-embed-focus-input;
	animation-duration: 0.2s;
}

@keyframes anim-embed-focus-input {
	from {
		border-color: rgba(dodgerblue, 0);
		color: #00880000;
	}
	to {
		border-color: rgba(dodgerblue, 1);
		color: rgba(dodgerblue, 1);
	}
}

/* -- Adjustments to Embedded Elements ------------------ */

.embed p:first-of-type {
	margin-top: 0;
}
.embed p:last-of-type {
	margin-bottom: 0;
}

.embed h1 {
	margin-top: 0;
}

/* == REGION ============================================ */

.region {
	position: relative;
	padding: 0.5em 0.5em 0.5em 0;
	border: 1px solid #d0d0d0;
	border-radius: 6px;
	transition: 0.2s;
}

.region::before {
	content: attr(data-region);
	position: absolute;
	top: -0.5em;
	right: 2em;
	border: 1px solid dodgerblue;
	color: dodgerblue;
	background-color: white;
	padding: 1px;
	border-radius: 4px;
	font-family: var(--code-font);
}

.region:focus-within {
	border: 1px solid dodgerblue;
}

.region:focus-within::before {
	display: block;
	animation: anim-embed-focus-input;
	animation-duration: 0.2s;
}

/* -- Adjustments to Embedded Elements ------------------ */

.region p:first-of-type {
	margin-top: 0;
}
.region p:last-of-type {
	margin-bottom: 0;
}

.region h1 {
	margin-top: 0;
}

/* == YAML METADATA EDITOR ============================== */

.meta-editor {
	padding: 1em 0;
	margin: 0 0.5em 1em 0.5em;
	font-family: var(--code-font);
	color: var(--color-text-fainter);
	border-bottom: 1px dashed var(--color-text-fainter);
}

.meta-editor .ProseMirror-focused {
	color: var(--color-text);
}

.meta-editor .ProseMirror-focused dd {
	border-color: var(--color-text-fainter);
}
.meta-editor .ProseMirror-focused dt {
	border-color: var(--color-text-fainter);
}

.meta-editor dl {
	display: grid;
	grid-auto-flow: row;
	grid-template-columns: auto 5fr;
	grid-template-rows: 1fr;
	column-gap: 1em;

	margin: 0;
	font-size: 0.8em;

	overflow: hidden;
}

.meta-editor dt {
	font-weight: bold;
	min-width: 4em;
	max-width: 20vw;
}

.meta-editor dt, .meta-editor dd {
	margin: 0;
	padding: 1px;
	border-width: 0 1px 1px 1px;
	border-style: dotted;
	border-color: transparent;
}

.meta-editor dt:first-of-type, .meta-editor dd:first-of-type {
	border-width: 1px;
}

/* == BIBLIOGRAPHY ====================================== */

#bibliography {

}
