/* Copy buttons */
button.runbtn {
  position: absolute;
  display: flex;
  bottom: 0.3em;
  right: 0.3em;
  width: 1.7em;
  height: 1.7em;
  user-select: none;
  padding: 0;
  border: none;
  outline: none;
  border-radius: 0.4em;
  /* The colors that GitHub uses */
  border: #1b1f2426 1px solid;
  background-color: #f6f8fa;
  color: #57606a;
}

div.highlight {
  position: relative;
}

.highlight button.runbtn:hover {
  background-color: rgb(235, 235, 235);
}

.highlight button.runbtn:active {
  background-color: rgb(187, 187, 187);
}

/**
 * A minimal CSS-only tooltip copied from:
 *   https://codepen.io/mildrenben/pen/rVBrpK
 *
 * To use, write HTML like the following:
 *
 * <p class="o-tooltip--left" data-tooltip="Hey">Short</p>
 */
.o-tooltip--left {
  position: relative;
}

.o-tooltip--left:after {
  opacity: 0;
  visibility: hidden;
  position: absolute;
  content: attr(data-tooltip);
  padding: 0.2em;
  font-size: 0.8em;
  left: -0.2em;
  background: grey;
  color: white;
  white-space: nowrap;
  z-index: 2;
  border-radius: 2px;
  transform: translateX(-102%) translateY(0);
  transition: opacity 0.2s cubic-bezier(0.64, 0.09, 0.08, 1),
    transform 0.2s cubic-bezier(0.64, 0.09, 0.08, 1);
}

.o-tooltip--left:has(.pyodide-alert-icon):after {
  opacity: 1;
  visibility: visible;
}

.o-tooltip--left:hover:after {
  display: block;
  opacity: 1;
  visibility: visible;
  transform: translateX(-100%) translateY(0);
  transition: opacity 0.2s cubic-bezier(0.64, 0.09, 0.08, 1),
    transform 0.2s cubic-bezier(0.64, 0.09, 0.08, 1);
  transition-delay: 0.5s;
}

/* By default the copy button shouldn't show up when printing a page */
@media print {
  button.runbtn {
    display: none;
  }
}

button.runbtn svg.pyodide-loading-icon {
  transform-box: fill-box;
  transform-origin: 50% 50%;
  animation-duration: 3s;
  animation-name: rotate;
  animation-iteration-count: infinite;
}

@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.pyodide-output {
  margin: 1em 0;
  overflow-x: auto;
}

.pyodide-output-wrapper {
  margin-left: 0.5em;
}

.pyodide-stderr {
  background-color: rgba(194, 103, 103, 0.35);
  border: indianred solid 1px;
  display: none;
}

.pyodide-stdout {
  display: none;
}

.pyodide-output.embedded {
  border-left: 0.5em solid darkgoldenrod;
  border-radius: 0.4em;
}

.pyodide-output.live {
  border-left: 0.5em solid green;
  border-radius: 0.5em;
}
