/* ===== Basic ===== */
@theme {
  --color-twoslash-error-foreground: #d45656;
  --color-twoslash-error: #d4565620;
  --color-twoslash-tag-foreground: #3772cf;
  --color-twoslash-tag: #3772cf20;
  --color-twoslash-tag-warn-foreground: #c37d0d;
  --color-twoslash-tag-warn: #c37d0d20;
  --color-twoslash-tag-annotate-foreground: #1ba673;
  --color-twoslash-tag-annotate: #1ba67320;
}

.twoslash-meta-line {
  display: flex;
}

.twoslash-completion-list,
.twoslash-popup-container {
  position: relative;
  user-select: none;
  display: flex;
  margin-top: 8px;
  width: 20rem;
  margin-right: -20rem;
  flex-direction: column;
  white-space: normal;
  box-shadow:
    0 4px 6px -1px rgb(0 0 0 / 0.1),
    0 2px 4px -2px rgb(0 0 0 / 0.1);
  border: 1px solid var(--color-fd-border);
  border-radius: 6px;
  padding: 8px;
  z-index: 8;
  color: var(--color-fd-popover-foreground);
  background-color: var(--color-fd-popover);
}

.twoslash-completion-cursor {
  display: inline-flex;
  flex-direction: column;
}

.twoslash-completion-list:hover {
  user-select: auto;
}

.twoslash-popup-arrow {
  position: absolute;
  top: -4px;
  left: 1em;
  transform: rotate(-45deg);
  pointer-events: none;
  width: 6px;
  height: 6px;
  border-top-width: 1px;
  border-right-width: 1px;
  border-color: var(--color-fd-primary);
  background-color: var(--color-fd-popover);
}

.twoslash-popup-docs-tag {
  display: flex;
  flex-direction: row;
  gap: 0.5em;
}

.twoslash-popup-docs-tag-name {
  font-weight: 600;
}

.twoslash-popup-code {
  font-size: 13px !important;
  overflow-wrap: anywhere;
}

.twoslash-popup-code .line {
  padding-left: 0 !important;
}

.twoslash-popup-docs,
.twoslash-popup-docs-tags {
  font-size: 14px !important;
  line-height: 20px !important;
  margin-top: 8px !important;
}

/* ===== Hover Info ===== */
.twoslash:hover .twoslash-hover {
  border-color: currentColor;
}

.twoslash .twoslash-hover {
  /* Reset button styles to make it behave like inline text */
  all: unset;

  /* Restore the original hover indicator styles */
  position: relative;
  transition: border 300ms;
  border-bottom: 1px dotted;
  border-color: transparent;
}

/* ===== Error Line ===== */
.twoslash .twoslash-error-line {
  position: relative;
  background-color: var(--twoslash-error-bg);
  border-left: 3px solid var(--color-twoslash-error-foreground);
  color: var(--color-twoslash-error-foreground);
  padding: 6px 12px;
  margin: 0.2em 0;
}

.twoslash .twoslash-error {
  text-decoration: wavy underline var(--color-twoslash-error-foreground);
  padding-bottom: 2px;
}

/* ===== Completions ===== */
.twoslash-completion-cursor::before {
  width: 1px;
  height: 1.4em;
  content: ' ';
  background-color: var(--color-fd-foreground);
}

.twoslash-completion-list {
  display: inline-flex;
}

.twoslash-completion-list li {
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  gap: 0.5rem;
}

.twoslash-completion-list li span.twoslash-completions-unmatched {
  color: var(--color-fd-muted-foreground);
}

.twoslash-completion-list .deprecated {
  text-decoration: line-through;
  opacity: 0.5;
}

/* Icons */
.twoslash-completion-list .twoslash-completions-icon {
  width: 1em;
  flex: none;
  color: var(--color-fd-muted-foreground);
}

/* Custom Tags */
.twoslash .twoslash-tag-line {
  position: relative;
  background-color: var(--color-twoslash-tag);
  border-left: 3px solid var(--color-twoslash-tag-foreground);
  color: var(--color-twoslash-tag-foreground);
  padding: 6px 10px;
  margin: 0.2em 0;
  display: flex;
  align-items: center;
  gap: 0.3em;
}

.twoslash .twoslash-tag-line .twoslash-tag-icon {
  width: 1.1em;
  color: inherit;
}

.twoslash .twoslash-tag-line.twoslash-tag-error-line {
  background-color: var(--color-twoslash-error);
  border-left: 3px solid var(--color-twoslash-error-foreground);
  color: var(--color-twoslash-error-foreground);
}

.twoslash .twoslash-tag-line.twoslash-tag-warn-line {
  background-color: var(--color-twoslash-tag-warn);
  border-left: 3px solid var(--color-twoslash-tag-warn-foreground);
  color: var(--color-twoslash-tag-warn-foreground);
}

.twoslash .twoslash-tag-line.twoslash-tag-annotate-line {
  background-color: var(--color-twoslash-tag-annotate);
  border-left: 3px solid var(--color-twoslash-tag-annotate-foreground);
  color: var(--color-twoslash-tag-annotate-foreground);
}

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

.fd-twoslash-popover {
  z-index: 50;
  min-width: 240px;
  max-width: min(450px, 96vw);
  max-height: 400px;
  overflow: auto;
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-fd-border);
  background-color: var(--color-fd-popover);
  padding: calc(var(--spacing) * 3);
  font-size: var(--text-sm);
  color: var(--color-fd-popover-foreground);
  box-shadow: var(--shadow-md);
  transform-origin: var(--transform-origin);
}

.fd-twoslash-popover[data-open] {
  animation: var(--animate-fd-popover-in);
}

.fd-twoslash-popover[data-closed] {
  animation: var(--animate-fd-popover-out);
}

.fd-twoslash-popover:focus-visible {
  outline-style: none;
}
