/**
 * Added to make line numbering and higlight selection work:
 * https://github.com/timlrx/rehype-prism-plus#styling
 */
pre {
  overflow-x: auto;
}

/**
 * Inspired by gatsby remark prism - https://www.gatsbyjs.com/plugins/gatsby-remark-prismjs/
 * 1. Make the element just wide enough to fit its content.
 * 2. Always fill the visible space in .code-highlight.
 */
.code-highlight {
  float: left; /* 1 */
  min-width: 100%; /* 2 */
}

.code-line {
  display: block;
  padding-left: 16px;
  padding-right: 16px;
  margin-left: -16px;
  margin-right: -16px;
  border-left: 4px solid
    rgba(
      0,
      0,
      0,
      0
    ); /* Set placeholder for highlight accent border color to transparent */
}

.code-line.inserted {
  background-color: rgba(16, 185, 129, 0.2); /* Set inserted line (+) color */
}

.code-line.deleted {
  background-color: rgba(239, 68, 68, 0.2); /* Set deleted line (-) color */
}

.highlight-line {
  margin-left: -16px;
  margin-right: -16px;
  background-color: rgba(55, 65, 81, 0.5); /* Set highlight bg color */
  border-left: 4px solid
    rgb(59, 130, 246); /* Set highlight accent border color */
}

.line-number::before {
  display: inline-block;
  width: 1rem;
  text-align: right;
  margin-right: 16px;
  margin-left: -8px;
  color: var(--prism-syntax-gutter); /* Line number color */
  content: attr(line);
}

/**
 * One Dark theme for prism.js
 * Based on Atom's One Dark theme: https://github.com/atom/atom/tree/master/packages/one-dark-syntax
 */

@media (prefers-color-scheme: light) {
  :root {
    /* One Light colours */
    --prism-mono-1: hsl(230, 8%, 24%);
    --prism-mono-2: hsl(230, 6%, 44%);
    --prism-mono-3: hsl(230, 4%, 64%);
    --prism-hue-1: hsl(198, 99%, 37%);
    --prism-hue-2: hsl(221, 87%, 60%);
    --prism-hue-3: hsl(301, 63%, 32%);
    --prism-hue-4: hsl(119, 34%, 47%);
    --prism-hue-5: hsl(5, 74%, 59%);
    --prism-hue-5-2: hsl(344, 84%, 43%);
    --prism-hue-6: hsl(35, 99%, 36%);
    --prism-hue-6-2: hsl(35, 99%, 40%);
    --prism-syntax-fg: hsl(230, 8%, 24%);
    --prism-syntax-bg: hsl(230, 1%, 98%);
    --prism-syntax-gutter: hsl(230, 1%, 62%);
    --prism-syntax-guide: hsla(230, 8%, 24%, 0.2);
    --prism-syntax-accent: hsl(230, 100%, 66%);
    --prism-syntax-selection-color: hsl(230, 1%, 90%);
    --prism-syntax-gutter-background-color-selected: hsl(230, 1%, 92%);
    --prism-syntax-cursor-line: hsla(230, 8%, 24%, 0.04);
  }

  /* Global code block overrides for light mode */
  pre.grid,
  code.code-highlight {
    color: var(--prism-syntax-fg) !important;
    background: var(--prism-syntax-bg) !important;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    /* One Dark colours (accurate as of commit 8ae45ca on 6 Sep 2018) */
    --prism-mono-1: hsl(220, 14%, 71%);
    --prism-mono-2: hsl(220, 9%, 55%);
    --prism-mono-3: hsl(220, 10%, 40%);
    --prism-hue-1: hsl(187, 47%, 55%);
    --prism-hue-2: hsl(207, 82%, 66%);
    --prism-hue-3: hsl(286, 60%, 67%);
    --prism-hue-4: hsl(95, 38%, 62%);
    --prism-hue-5: hsl(355, 65%, 65%);
    --prism-hue-5-2: hsl(5, 48%, 51%);
    --prism-hue-6: hsl(29, 54%, 61%);
    --prism-hue-6-2: hsl(39, 67%, 69%);
    --prism-syntax-fg: hsl(220, 14%, 71%);
    --prism-syntax-bg: hsl(220, 13%, 18%);
    --prism-syntax-gutter: hsl(220, 14%, 45%);
    --prism-syntax-guide: hsla(220, 14%, 71%, 0.15);
    --prism-syntax-accent: hsl(220, 100%, 66%);
    --prism-syntax-selection-color: hsl(220, 13%, 28%);
    --prism-syntax-gutter-background-color-selected: hsl(220, 13%, 26%);
    --prism-syntax-cursor-line: hsla(220, 55%, 36%, 0.04);
  }

  /* Global code block overrides for dark mode */
  code,
  code::before,
  code::after {
    color: var(--prism-syntax-fg) !important;
  }
}

code[class*="language-"],
pre[class*="language-"] {
  background: var(--prism-syntax-bg);
  color: var(--prism-syntax-fg);
  text-shadow: 0 1px rgba(0, 0, 0, 0.3);
  font-family:
    "Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  direction: ltr;
  text-align: left;
  white-space: pre;
  word-spacing: normal;
  word-break: normal;
  line-height: 1.5;
  -moz-tab-size: 2;
  -o-tab-size: 2;
  tab-size: 2;
  -webkit-hyphens: none;
  -moz-hyphens: none;
  -ms-hyphens: none;
  hyphens: none;
}

/* Selection */
code[class*="language-"]::-moz-selection,
code[class*="language-"] *::-moz-selection,
pre[class*="language-"] *::-moz-selection {
  background: var(--prism-syntax-selection-color);
  color: inherit;
  text-shadow: none;
}

code[class*="language-"]::selection,
code[class*="language-"] *::selection,
pre[class*="language-"] *::selection {
  background: var(--prism-syntax-selection-color);
  color: inherit;
  text-shadow: none;
}

/* Code blocks */
pre[class*="language-"] {
  margin: 0.5em 0;
  overflow: auto;
  border-radius: 0.3em;
}

/* Inline code */
:not(pre) > code[class*="language-"] {
  padding: 0.2em 0.3em;
  border-radius: 0.3em;
  white-space: normal;
}

/* Print */
@media print {
  code[class*="language-"],
  pre[class*="language-"] {
    text-shadow: none;
  }
}

.token.comment,
.token.prolog,
.token.cdata {
  color: var(--prism-mono-3);
}

.token.doctype,
.token.punctuation,
.token.entity {
  color: var(--prism-mono-1);
}

.token.attr-name,
.token.class-name,
.token.boolean,
.token.constant,
.token.number,
.token.atrule {
  color: var(--prism-hue-6);
}

.token.keyword {
  color: var(--prism-hue-3);
}

.token.property,
.token.tag,
.token.symbol,
.token.deleted,
.token.important {
  color: var(--prism-hue-5);
}

.token.selector,
.token.string,
.token.char,
.token.builtin,
.token.inserted,
.token.regex,
.token.attr-value,
.token.attr-value > .token.punctuation {
  color: var(--prism-hue-4);
}

.token.variable,
.token.operator,
.token.function {
  color: var(--prism-hue-2);
}

.token.url {
  color: var(--prism-hue-1);
}

/* HTML overrides */
.token.attr-value > .token.punctuation.attr-equals,
.token.special-attr > .token.attr-value > .token.value.css {
  color: var(--prism-mono-1);
}

/* CSS overrides */
.language-css .token.selector {
  color: var(--prism-hue-5);
}

.language-css .token.property {
  color: var(--prism-mono-1);
}

.language-css .token.function,
.language-css .token.url > .token.function {
  color: var(--prism-hue-1);
}

.language-css .token.url > .token.string.url {
  color: var(--prism-hue-4);
}

.language-css .token.important,
.language-css .token.atrule .token.rule {
  color: var(--prism-hue-3);
}

/* JS overrides */
.language-javascript .token.operator {
  color: var(--prism-hue-3);
}

.language-javascript
  .token.template-string
  > .token.interpolation
  > .token.interpolation-punctuation.punctuation {
  color: var(--prism-hue-5-2);
}

/* JSON overrides */
.language-json .token.operator {
  color: var(--prism-mono-1);
}

.language-json .token.null.keyword {
  color: var(--prism-hue-6);
}

/* MD overrides */
.language-markdown .token.url,
.language-markdown .token.url > .token.operator,
.language-markdown .token.url-reference.url > .token.string {
  color: var(--prism-mono-1);
}

.language-markdown .token.url > .token.content {
  color: var(--prism-hue-2);
}

.language-markdown .token.url > .token.url,
.language-markdown .token.url-reference.url {
  color: var(--prism-hue-1);
}

.language-markdown .token.blockquote.punctuation,
.language-markdown .token.hr.punctuation {
  color: var(--prism-mono-3);
  font-style: italic;
}

.language-markdown .token.code-snippet {
  color: var(--prism-hue-4);
}

.language-markdown .token.bold .token.content {
  color: var(--prism-hue-6);
}

.language-markdown .token.italic .token.content {
  color: var(--prism-hue-3);
}

.language-markdown .token.strike .token.content,
.language-markdown .token.strike .token.punctuation,
.language-markdown .token.list.punctuation,
.language-markdown .token.title.important > .token.punctuation {
  color: var(--prism-hue-5);
}

/* General */
.token.bold {
  font-weight: bold;
}

.token.comment,
.token.italic {
  font-style: italic;
}

.token.entity {
  cursor: help;
}

.token.namespace {
  opacity: 0.8;
}

/* Plugin overrides */
/* Selectors should have higher specificity than those in the plugins' default stylesheets */

/* Show Invisibles plugin overrides */
.token.token.tab:not(:empty):before,
.token.token.cr:before,
.token.token.lf:before,
.token.token.space:before {
  color: var(--prism-syntax-guide);
  text-shadow: none;
}

/* Toolbar plugin overrides */
/* Space out all buttons and move them away from the right edge of the code block */
div.code-toolbar > .toolbar.toolbar > .toolbar-item {
  margin-right: 0.4em;
}

/* Styling the buttons */
div.code-toolbar > .toolbar.toolbar > .toolbar-item > button,
div.code-toolbar > .toolbar.toolbar > .toolbar-item > a,
div.code-toolbar > .toolbar.toolbar > .toolbar-item > span {
  background: var(--prism-syntax-gutter-background-color-selected);
  color: var(--prism-mono-2);
  padding: 0.1em 0.4em;
  border-radius: 0.3em;
}

div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:hover,
div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:focus,
div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:hover,
div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:focus,
div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:hover,
div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:focus {
  background: var(--prism-syntax-selection-color);
  color: var(--prism-mono-1);
}

/* Line Highlight plugin overrides */
/* The highlighted line itself */
.line-highlight.line-highlight {
  background: var(--prism-syntax-cursor-line);
}

/* Default line numbers in Line Highlight plugin */
.line-highlight.line-highlight:before,
.line-highlight.line-highlight[data-end]:after {
  background: var(--prism-syntax-gutter-background-color-selected);
  color: var(--prism-mono-1);
  padding: 0.1em 0.6em;
  border-radius: 0.3em;
  box-shadow: 0 2px 0 0 rgba(0, 0, 0, 0.2); /* same as Toolbar plugin default */
}

/* Hovering over a linkable line number (in the gutter area) */
/* Requires Line Numbers plugin as well */
pre[id].linkable-line-numbers.linkable-line-numbers
  span.line-numbers-rows
  > span:hover:before {
  background-color: var(--prism-syntax-cursor-line);
}

/* Line Numbers and Command Line plugins overrides */
/* Line separating gutter from coding area */
.line-numbers.line-numbers .line-numbers-rows,
.command-line .command-line-prompt {
  border-right-color: var(--prism-syntax-guide);
}

/* Stuff in the gutter */
.line-numbers .line-numbers-rows > span:before,
.command-line .command-line-prompt > span:before {
  color: var(--prism-syntax-gutter);
}

/* Match Braces plugin overrides */
/* Note: Outline colour is inherited from the braces */
.rainbow-braces .token.token.punctuation.brace-level-1,
.rainbow-braces .token.token.punctuation.brace-level-5,
.rainbow-braces .token.token.punctuation.brace-level-9 {
  color: var(--prism-hue-5);
}

.rainbow-braces .token.token.punctuation.brace-level-2,
.rainbow-braces .token.token.punctuation.brace-level-6,
.rainbow-braces .token.token.punctuation.brace-level-10 {
  color: var(--prism-hue-4);
}

.rainbow-braces .token.token.punctuation.brace-level-3,
.rainbow-braces .token.token.punctuation.brace-level-7,
.rainbow-braces .token.token.punctuation.brace-level-11 {
  color: var(--prism-hue-2);
}

.rainbow-braces .token.token.punctuation.brace-level-4,
.rainbow-braces .token.token.punctuation.brace-level-8,
.rainbow-braces .token.token.punctuation.brace-level-12 {
  color: var(--prism-hue-3);
}

/* Diff Highlight plugin overrides */
/* Taken from https://github.com/atom/github/blob/master/styles/variables.less */
pre.diff-highlight > code .token.token.deleted:not(.prefix),
pre > code.diff-highlight .token.token.deleted:not(.prefix) {
  background-color: hsla(353, 100%, 66%, 0.15);
}

pre.diff-highlight > code .token.token.deleted:not(.prefix)::-moz-selection,
pre.diff-highlight > code .token.token.deleted:not(.prefix) *::-moz-selection,
pre > code.diff-highlight .token.token.deleted:not(.prefix)::-moz-selection,
pre > code.diff-highlight .token.token.deleted:not(.prefix) *::-moz-selection {
  background-color: hsla(353, 95%, 66%, 0.25);
}

pre.diff-highlight > code .token.token.deleted:not(.prefix)::selection,
pre.diff-highlight > code .token.token.deleted:not(.prefix) *::selection,
pre > code.diff-highlight .token.token.deleted:not(.prefix)::selection,
pre > code.diff-highlight .token.token.deleted:not(.prefix) *::selection {
  background-color: hsla(353, 95%, 66%, 0.25);
}

pre.diff-highlight > code .token.token.inserted:not(.prefix),
pre > code.diff-highlight .token.token.inserted:not(.prefix) {
  background-color: hsla(137, 100%, 55%, 0.15);
}

pre.diff-highlight > code .token.token.inserted:not(.prefix)::-moz-selection,
pre.diff-highlight > code .token.token.inserted:not(.prefix) *::-moz-selection,
pre > code.diff-highlight .token.token.inserted:not(.prefix)::-moz-selection,
pre > code.diff-highlight .token.token.inserted:not(.prefix) *::-moz-selection {
  background-color: hsla(135, 73%, 55%, 0.25);
}

pre.diff-highlight > code .token.token.inserted:not(.prefix)::selection,
pre.diff-highlight > code .token.token.inserted:not(.prefix) *::selection,
pre > code.diff-highlight .token.token.inserted:not(.prefix)::selection,
pre > code.diff-highlight .token.token.inserted:not(.prefix) *::selection {
  background-color: hsla(135, 73%, 55%, 0.25);
}

/* Previewers plugin overrides */
/* Based on https://github.com/atom-community/atom-ide-datatip/blob/master/styles/atom-ide-datatips.less and https://github.com/atom/atom/blob/master/packages/one-dark-ui */
/* Border around popup */
.prism-previewer.prism-previewer:before,
.prism-previewer-gradient.prism-previewer-gradient div {
  border-color: hsl(224, 13%, 17%);
}

/* Angle and time should remain as circles and are hence not included */
.prism-previewer-color.prism-previewer-color:before,
.prism-previewer-gradient.prism-previewer-gradient div,
.prism-previewer-easing.prism-previewer-easing:before {
  border-radius: 0.3em;
}

/* Triangles pointing to the code */
.prism-previewer.prism-previewer:after {
  border-top-color: hsl(224, 13%, 17%);
}

.prism-previewer-flipped.prism-previewer-flipped.after {
  border-bottom-color: hsl(224, 13%, 17%);
}

/* Background colour within the popup */
.prism-previewer-angle.prism-previewer-angle:before,
.prism-previewer-time.prism-previewer-time:before,
.prism-previewer-easing.prism-previewer-easing {
  background: hsl(219, 13%, 22%);
}

/* For angle, this is the positive area (eg. 90deg will display one quadrant in this colour) */
/* For time, this is the alternate colour */
.prism-previewer-angle.prism-previewer-angle circle,
.prism-previewer-time.prism-previewer-time circle {
  stroke: var(--prism-mono-1);
  stroke-opacity: 1;
}

/* Stroke colours of the handle, direction point, and vector itself */
.prism-previewer-easing.prism-previewer-easing circle,
.prism-previewer-easing.prism-previewer-easing path,
.prism-previewer-easing.prism-previewer-easing line {
  stroke: var(--prism-mono-1);
}

/* Fill colour of the handle */
.prism-previewer-easing.prism-previewer-easing circle {
  fill: transparent;
}
