.code-container {
  position: relative;
  cursor: pointer;
}

.code-container--inline {
  display: inline-block;
}

.code-container code {
  border-radius: 4px;
  line-height: 1.5;
}

.code-container .copy-btn,
.code-container .copy-message {
  position: absolute;
  padding: 10px 16px;
  border-radius: 4px;
  font-weight: 500;
  line-height: 1.5;
}

.code-container .copy-btn {
  background-color: var(--copy-bg-color);
  z-index: 1;
}

.code-container .copy-message {
  background-color: var(--success-bg-color);
}

.code-container:not(.code-container--inline) .copy-btn,
.code-container:not(.code-container--inline) .copy-message {
  top: 10px;
  right: 10px;
}

.code-container .copy-btn,
.code-container .copy-message {
  font-family: var(--hljs-inherit-body-font);
}

.code-container--inline .copy-btn,
.code-container--inline .copy-message {
  top: -52px;
  right: 0;
  left: 0;
  display: flex;
  margin-inline: auto;
  width: fit-content;
}

.code-container--inline .copy-btn::after,
.code-container--inline .copy-message::after {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 0;
  margin-bottom: -7px;
  margin-left: -7px;
  content: "";
  border: 7px solid transparent;
  border-bottom: 0;
}

.code-container--inline .copy-btn::after {
  border-top-color: var(--copy-bg-color);
}

.code-container--inline .copy-message::after {
  border-top-color: var(--success-bg-color);
}

/* Initially hide the copy button and hide it when success message is present */
.code-container .copy-message:empty,
.code-container .copy-btn {
  opacity: 0;
}

/* Show the copy button on container hover or button hover */
.code-container:hover .copy-btn,
.code-container .copy-btn:hover {
  opacity: 100;
}

/* Hide the button when the .copy-message element is not empty. */
.code-container:has(.copy-message:not(:empty)) .copy-btn {
  display: none;
}
