/*  Code blocks structurally look like: 

<pre class='shiki lsp twoslash [theme-name]'>
  <div class='language-id'>[lang-id]</div>
  <div class='code-container'>
    <code>[the code as a series of spans]</code>
    <a href='playground...'>Try</a> (optional)
  </div>
</pre>

Styles based from https://github.com/shikijs/twoslash/blob/main/packages/shiki-twoslash/style.css
*/

:root {
  --shiki-padding: 1.2rem;
}

pre.shiki {
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  tab-size: 2;
}

pre.shiki .copy-code-block {
  color: white;
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  border-radius: 4px;
  padding: 4px 10px;
  border: 1px solid #3a3a3a;
  background: #1e1e1e;
  transition: background-color .25s,opacity .25s;
  opacity: 0;
}

pre.shiki:hover .copy-code-block {
  opacity: 1;
}

pre.shiki .copy-code-block:hover {
  background: #111111;
}

pre.shiki .copy-code-block:focus {
  background: black;
}

pre.shiki .copy-code-block::before {
  content: 'Copy'
}

pre.shiki .copy-code-block:focus::before {
  content: 'Copied';
}

pre.shiki .code-container {
  padding: var(--shiki-padding) 0;
  overflow: auto;
}

pre.shiki div.line,
pre.shiki div.meta-line {
  padding-left: var(--shiki-padding);
  padding-right: var(--shiki-padding);
}

pre.shiki.with-title {
  padding-top: var(--shiki-padding);
}

pre.shiki div.dim {
  opacity: 0.7;
  /* filter: grayscale(1); */
  transition: opacity 200ms ease-in-out;
}

pre.shiki:hover .dim {
  opacity: 1;
}

pre.shiki div.dim,
pre.shiki div.highlight {
  margin: 0;
}

pre.shiki div.highlight {
  background-color: hsla(210, 100%, 100%, 10%);
}

pre.shiki div.line {
  min-height: 1rem;
}

pre.shiki .language-id, pre.shiki .code-title {
  position: absolute;
  user-select: none;
  top: 10px;
  opacity: .5;
  font-size: 87%;
}

pre.shiki .language-id {
  right: var(--shiki-padding);
}

pre.shiki .code-title {
  left: var(--shiki-padding);
  font-style: italic;
}

/* The try button */
pre.shiki .code-container > a {
  position: absolute;
  right: 8px;
  bottom: 8px;
  border-radius: 4px;
  border: 1px solid #719af4;
  padding: 0 8px;
  color: #719af4;
  text-decoration: none;
  opacity: 0;
  transition-timing-function: ease;
  transition: opacity 0.3s;
}

/* Respect no animations */
@media (prefers-reduced-motion: reduce) {
  pre.shiki .code-container > a {
    transition: none;
  }
}

pre.shiki .code-container > a:hover {
  color: white;
  background-color: #719af4;
}

pre.shiki .code-container:hover a {
  opacity: 1;
}

pre.shiki code {
  font-size: 15px;
  font-family: "JetBrains Mono", Menlo, Monaco, Consolas, Courier New, monospace;
  ;
  white-space: pre;
  -webkit-overflow-scrolling: touch;
}

pre.shiki code a {
  text-decoration: none;
}

pre.shiki data-err {
  /* Extracted from VS Code */
  background: url("data:image/svg+xml,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%206%203'%20enable-background%3D'new%200%200%206%203'%20height%3D'3'%20width%3D'6'%3E%3Cg%20fill%3D'%23c94824'%3E%3Cpolygon%20points%3D'5.5%2C0%202.5%2C3%201.1%2C3%204.1%2C0'%2F%3E%3Cpolygon%20points%3D'4%2C0%206%2C2%206%2C0.6%205.4%2C0'%2F%3E%3Cpolygon%20points%3D'0%2C2%201%2C3%202.4%2C3%200%2C0.6'%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E") repeat-x bottom left;
  padding-bottom: 3px;
}

pre.shiki .query {
  margin-bottom: 10px;
  color: #137998;
  display: inline-block;
}

/* In order to have the 'popped out' style design and to not break the layout
  /* we need to place a fake and un-selectable copy of the error which _isn't_ broken out
  /* behind the actual error message.

  /* This sections keeps both of those two in in sync  */

pre.shiki .error,
pre.shiki .error-behind {
  /* margin-left: -1.2rem; */
  margin-top: 8px;
  margin-bottom: 4px;
  padding: 6px;
  padding-left: calc(var(--shiki-padding) - 4px);
  width: 100%;
  white-space: pre-wrap;
  display: block;
}

pre.shiki .error {
  position: absolute;
  background-color: #fee;
  border-left: 4px solid #bf1818;
  border-right: 2px solid #bf1818;
  /* Give the space to the error code */
  display: flex;
  align-items: center;
  color: black;
}

pre.shiki .error .code {
  display: none;
}

pre.shiki .error-behind {
  user-select: none;
  visibility: transparent;
  color: #fee;
}

/* Queries */
pre.shiki .arrow {
  /* Transparent background */
  background-color: #eee;
  position: relative;
  top: -6px;
  margin-left: 0.1rem;
  /* Edges */
  border-left: 1px solid #eee;
  border-top: 1px solid #eee;
  transform: translateY(25%) rotate(45deg);
  /* Size */
  height: 8px;
  width: 8px;
}

pre.shiki .popover {
  margin-bottom: 10px;
  background-color: #eee;
  display: inline-block;
  padding: 0 0.5rem 0.3rem;
  margin-top: 10px;
  border-radius: 3px;
}

/* Completion */
pre.shiki .inline-completions ul.dropdown {
  display: inline-block;
  position: absolute;
  width: 240px;
  background-color: gainsboro;
  color: grey;
  padding-top: 4px;
  font-family: var(--code-font);
  font-size: 0.8rem;
  margin: 0;
  padding: 0;
  border-left: 4px solid #4b9edd;
}

pre.shiki .inline-completions ul.dropdown::before {
  background-color: #4b9edd;
  width: 2px;
  position: absolute;
  top: -1.2rem;
  left: -3px;
  content: " ";
}

pre.shiki .inline-completions ul.dropdown li {
  overflow-x: hidden;
  padding-left: 4px;
  margin-bottom: 4px;
}

pre.shiki .inline-completions ul.dropdown li.deprecated {
  text-decoration: line-through;
}

pre.shiki .inline-completions ul.dropdown li span.result-found {
  color: #4b9edd;
}

pre.shiki .inline-completions ul.dropdown li span.result {
  width: 100px;
  color: black;
  display: inline-block;
}

data-lsp {
  /* Ensures there's no 1px jump when the hover happens */
  border-bottom: 1px dotted hsla(0, 0%, 45%, 60%);
  /* Fades in unobtrusively */
  transition-timing-function: ease;
  transition: border-color 0.3s;
}

/* Respect people's wishes to not have animations */
@media (prefers-reduced-motion: reduce) {
  data-lsp {
    transition: none;
  }
}

data-err data-lsp {
  border: none;
}

/** When you mouse over the pre, show the underlines */
pre.twoslash:hover data-lsp {
  border-color: hsla(0, 0%, 45%, 100%);
}

/** The tooltip-like which provides the LSP response */
pre.twoslash data-lsp:hover::before {
  content: attr(lsp);
  position: absolute;
  transform: translate(0, 1rem);

  background-color: #3f3f3f;
  color: #fff;
  text-align: left;
  padding: 5px 8px;
  border-radius: 2px;
  font-family: "JetBrains Mono", Menlo, Monaco, Consolas, Courier New, monospace;
  font-size: 14px;
  white-space: pre-wrap;
  z-index: 100;
}

/** Annotations support, providing a tool for meta commentary */
.tag-container {
  position: relative;
}

.tag-container .twoslash-annotation {
  position: absolute;
  font-family: "JetBrains Mono", Menlo, Monaco, Consolas, Courier New, monospace;
  right: -10px;
  /** Default annotation text to 200px */
  width: 200px;
  color: #187abf;
  background-color: #fcf3d9 bb;
}

.tag-container .twoslash-annotation p {
  text-align: left;
  font-size: 0.8rem;
  line-height: 0.9rem;
}

.tag-container .twoslash-annotation svg {
  float: left;
  margin-left: -44px;
}

.tag-container .twoslash-annotation.left {
  right: auto;
  left: -200px;
}

.tag-container .twoslash-annotation.left svg {
  float: right;
  margin-right: -5px;
}

/** Support for showing console log/warn/errors inline */
pre.shiki .logger {
  display: flex;
  align-items: center;
  color: black;
  padding: 6px;
  padding-left: 8px;
  width: calc(100% - 19px);
  white-space: pre-wrap;
}

pre.shiki .logger svg {
  margin-right: 9px;
}

pre.shiki .logger.error-log {
  background-color: #fee;
  border-left: 2px solid #bf1818;
}

pre.shiki .logger.warn-log {
  background-color: #ffe;
  border-left: 2px solid #eae662;
}

pre.shiki .logger.log-log {
  background-color: #e9e9e9;
  border-left: 2px solid #ababab;
}

pre.shiki .logger.log-log svg {
  margin-left: 6px;
  margin-right: 9px;
}