/* Shared markdown rendering — links, code blocks, inline code and copy buttons. */

.shared-md-link,
.shared-md-link:visited,
.shared-md-link:hover,
.shared-md-link:active {
  color: var(--theme-color-primary);
  text-decoration: none;
}

.shared-md-link-icon {
  display: inline-flex;
  align-items: center;
  margin-left: 0.25em;
  vertical-align: middle;
}

/* Multilingual text reference — the `[label](text?pk)` button rendered inline. */
.shared-md-text-ref {
  display: inline;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  color: var(--theme-color-primary);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
  cursor: pointer;
}

.shared-md-text-ref:hover {
  text-decoration-style: solid;
}

.shared-md-text-ref-body > :first-child {
  margin-top: 0;
}

.shared-md-text-ref-body > :last-child {
  margin-bottom: 0;
}

.shared-md-text-ref-empty {
  color: var(--theme-text-secondary);
  font-style: italic;
}

.shared-md-text-ref-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 96px;
}

.shared-md-text-ref-spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  color: var(--theme-color-primary);
  animation: shared-md-text-ref-spin 0.65s linear infinite;
}

@keyframes shared-md-text-ref-spin {
  to { transform: rotate(360deg); }
}


.shared-md-blockquote {
  margin: var(--theme-space-3) 0;
  padding: var(--theme-space-3) var(--theme-space-4);
  background: color-mix(in srgb, var(--theme-color-primary) 10%, var(--theme-surface-raised));
  border-left: 4px solid var(--theme-color-primary);
  border-radius: 0 var(--theme-radius-md) var(--theme-radius-md) 0;
  color: var(--theme-text-primary);
}

.shared-md-blockquote > :first-child {
  margin-top: 0;
}

.shared-md-blockquote > :last-child {
  margin-bottom: 0;
}


.shared-md-table-wrap {
  margin: var(--theme-space-3) 0;
  overflow-x: auto;
}

.shared-md-table {
  border-collapse: collapse;
  width: 100%;
  font-size: var(--theme-font-sm);
}

.shared-md-table th,
.shared-md-table td {
  padding: var(--theme-space-2) var(--theme-space-3);
  border: 1px solid var(--theme-border-subtle);
  text-align: left;
  vertical-align: top;
}

.shared-md-table th {
  background: var(--theme-surface-raised);
  color: var(--theme-text-primary);
  font-weight: 600;
}


.shared-md-code-block {
  position: relative;
  margin: var(--theme-space-3) 0;
}

.shared-md-code-block pre {
  margin: 0;
  padding: var(--theme-space-4);
  padding-right: var(--theme-space-8);
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--theme-bg-tertiary);
  border: 1px solid var(--theme-border-subtle);
  border-radius: var(--theme-radius-md);
  font-family: var(--theme-font-mono);
  font-size: var(--theme-font-sm);
  line-height: var(--theme-line-height-base);
}

.shared-md-code-block pre code {
  background: none;
  padding: 0;
  border: 0;
  font: inherit;
  color: var(--theme-text-primary);
}

.shared-md-code-inline {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.shared-md-code-inline code {
  background: var(--theme-bg-tertiary);
  border: 1px solid var(--theme-border-subtle);
  border-radius: var(--theme-radius-sm);
  padding: 0.1em 0.4em;
  font-family: var(--theme-font-mono);
  font-size: 0.9em;
  color: var(--theme-text-primary);
  overflow-wrap: anywhere;
}

.shared-md-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--theme-text-secondary);
  background: var(--theme-surface-raised);
  border: 1px solid var(--theme-border-subtle);
  border-radius: var(--theme-radius-sm);
  box-shadow: var(--theme-shadow-sm);
  cursor: pointer;
  transition: color 0.15s ease, opacity 0.15s ease;
}

.shared-md-copy:hover {
  color: var(--theme-text-primary);
}

.shared-md-code-block .shared-md-copy {
  position: absolute;
  top: var(--theme-space-2);
  right: var(--theme-space-2);
  padding: var(--theme-space-1);
}

.shared-md-code-inline .shared-md-copy {
  position: absolute;
  top: 0;
  right: 0;
  transform: translate(50%, -50%);
  padding: 2px;
  opacity: 0;
}

.shared-md-code-inline:hover .shared-md-copy,
.shared-md-copy:focus-visible {
  opacity: 1;
}

/* KaTeX: keep long display equations from overflowing the feature container. */
.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.25rem 0;
}
