/**
 * Custom theme for developer.wordpress.org.
 * Forked from a11y-dark theme by ericwbailey, which was based on the okaidia theme.
 *
 * https://github.com/PrismJS/prism-themes/blob/master/themes/prism-a11y-dark.css
 * https://github.com/PrismJS/prism/blob/gh-pages/themes/prism-okaidia.css
 */
code[class*="language-"],
pre[class*="language-"] {
  color: #101517;
  background: none;
  font-family: Hack, "Fira Code", Consolas, Menlo, Monaco, "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Liberation Mono", "Nimbus Mono L", "Courier New", Courier, monospace;
  text-align: left;
  white-space: pre;
  word-spacing: normal;
  word-break: normal;
  word-wrap: normal;
  line-height: 1.5;
  -moz-tab-size: 4;
  -o-tab-size: 4;
  tab-size: 4;
  -webkit-hyphens: none;
  -moz-hyphens: none;
  -ms-hyphens: none;
  hyphens: none;
  transition: height 500ms;
}

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

:not(pre) > code[class*="language-"],
pre[class*="language-"] {
  background: #f6f7f7;
}

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

.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: #007017;
}

.token.punctuation {
  color: #50575e;
}

.token.property,
.token.tag,
.token.constant,
.token.symbol,
.token.deleted {
  color: #043959;
}

.token.boolean,
.token.number {
  color: #101517;
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
  color: #2271b1;
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string,
.token.variable {
  color: #a85f00;
}

.token.function {
  color: #b8236d;
}

.token.keyword {
  color: #135e96;
  font-weight: 600;
}

.token.atrule,
.token.attr-value,
.token.function-definition {
  color: #101517;
}

.token.important,
.token.bold {
  font-weight: 700;
}

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

.token.entity {
  cursor: help;
}

@media screen and (-ms-high-contrast: active) {
  code[class*="language-"],
  pre[class*="language-"] {
    color: windowText;
    background: window;
  }
  :not(pre) > code[class*="language-"],
  pre[class*="language-"] {
    background: window;
  }
  .token.important {
    background: highlight;
    color: window;
    font-weight: 700;
  }
  .token.atrule,
  .token.attr-value,
  .token.function,
  .token.keyword,
  .token.operator,
  .token.selector {
    font-weight: 700;
  }
  .token.attr-value,
  .token.comment,
  .token.doctype,
  .token.function,
  .token.keyword,
  .token.operator,
  .token.property,
  .token.string {
    color: highlight;
  }
  .token.attr-value,
  .token.url {
    font-weight: 700;
  }
}

/* Line Numbers */
pre.line-numbers {
  position: relative;
  padding-left: 3.8em;
  counter-reset: linenumber;
}

pre.line-numbers > code {
  position: relative;
}

.line-numbers .line-numbers-rows {
  position: absolute;
  pointer-events: none;
  top: 0;
  font-size: 100%;
  left: -3.8em;
  width: 4em;
  /* works for line-numbers below 10000 lines */
  letter-spacing: -1px;
  border-right: 0;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.line-numbers-rows > span {
  pointer-events: none;
  display: block;
  counter-increment: linenumber;
}

.line-numbers-rows > span::before {
  content: counter(linenumber);
  color: #5c6370;
  display: block;
  padding-right: 0.8em;
  text-align: right;
}

/* Copy button */
.wp-code-block-button-container {
  position: sticky;
  top: calc(var(--wp-global-header-height) + var(--wp-admin--admin-bar--height));
  z-index: 1;
  display: flex;
  justify-content: right;
  padding: 1rem;
  background: #fff;
  border-width: 1px 1px 0;
  border-style: solid;
  border-color: #dcdcde;
  border-top-left-radius: 0.3em;
  border-top-right-radius: 0.3em;
}

@media screen and (max-width: 889px) {
  .wp-code-block-button-container {
    top: var(--wp-admin--admin-bar--height);
  }
}

@media screen and (max-width: 600px) {
  .wp-code-block-button-container {
    top: 0;
  }
}

.wp-code-block-button-container button {
  font-size: 1.2rem !important;
}

.wp-code-block-button-container button + button {
  margin-left: 0.5em;
}

.wp-code-block-button-container + pre {
  margin-top: 0;
  border-width: 0 1px 1px;
  border-style: solid;
  border-color: #dcdcde;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

/*
 * Make the sticky wp-code-block-button-container not overlap its parent's border.
 * A trikcy way is used here (plus and minus margin-bottom),
 * as we can't just adjust the pre in _global.scss,
 * or page like https://developer.wordpress.org/resource/dashicons/#randomize would be affected.
 */
.wporg-developer-code-block {
  display: flex;
  flex-direction: column;
  margin-bottom: 1.6em;
  font-size: 16px;
}

.wporg-developer-code-block::after {
  content: "";
  /* Since the margin-bottom of the pre defined in _global.scss is 1.6em,
		 * -1.63em is set here to make the shape of the rounded corners at the bottom of
		 * the code block complete when the sticky wp-code-block-button-container is scolled there.
		 *
		 * See https://github.com/WordPress/wporg-developer/pull/148#issuecomment-1289595980
		 */
  margin-bottom: -1.63em;
}
