/* Shared rich-content rendering and editor styles. */

.ak-generic-rich-content {
  display: flow-root;
}

.ak-generic-rich-block + .ak-generic-rich-block:not(.ak-generic-rich-block--asset) {
  margin-top: 1rem;
}

.ak-generic-rich-block--asset {
  margin-block: 2rem;
}

.ak-rich-text,
.ak-rich-text-editor {
  --ak-rich-editor-border: var(--bs-border-color, var(--border-color, #dee2e6));
  --ak-rich-editor-bg: var(--bs-body-bg, var(--body-bg, #fff));
  --ak-rich-editor-muted: var(--bs-secondary-color, var(--body-quiet-color, #6c757d));
  --ak-rich-editor-toolbar-bg: rgba(var(--bs-tertiary-bg-rgb, 248, 249, 250), .72);
  --ak-rich-editor-toolbar-hover-bg: rgba(var(--bs-secondary-bg-rgb, 233, 236, 239), .85);
  --ak-rich-editor-toolbar-active-border: rgba(var(--bs-primary-rgb, 13, 110, 253), .42);
  --ak-rich-editor-toolbar-active-bg: rgba(var(--bs-primary-rgb, 13, 110, 253), .12);
  --ak-rich-editor-toolbar-active-fg: var(--bs-primary, #0d6efd);
}

.ak-rich-text-editor {
  border: 1px solid var(--ak-rich-editor-border);
  border-radius: .375rem;
  background: var(--ak-rich-editor-bg);
}

.ak-rich-text-editor__toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem;
  align-items: center;
  padding: .375rem;
  border-bottom: 1px solid var(--ak-rich-editor-border);
  background: var(--ak-rich-editor-toolbar-bg);
}

.ak-rich-text-editor__toolbar-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  min-height: 2rem;
  padding: .25rem .45rem;
  border: 1px solid transparent;
  border-radius: .25rem;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: .875rem;
  line-height: 1;
}

.ak-rich-text-editor__toolbar-button .bi {
  font-size: 1rem;
  line-height: 1;
  pointer-events: none;
}

.ak-rich-text-editor__toolbar-button:hover,
.ak-rich-text-editor__toolbar-button:focus {
  border-color: var(--ak-rich-editor-border);
  background: var(--ak-rich-editor-toolbar-hover-bg);
}

.ak-rich-text-editor__toolbar-button.is-active {
  border-color: var(--ak-rich-editor-toolbar-active-border);
  background: var(--ak-rich-editor-toolbar-active-bg);
  color: var(--ak-rich-editor-toolbar-active-fg);
}

.ak-rich-text-editor__toolbar-button:disabled {
  color: var(--ak-rich-editor-muted);
  cursor: not-allowed;
  opacity: .55;
}

.ak-rich-text-editor__toolbar-separator {
  align-self: stretch;
  width: 1px;
  margin: .15rem;
  background: var(--ak-rich-editor-border);
}

.ak-rich-text-editor__surface,
.ak-rich-text-editor__content {
  min-height: 10rem;
}

.ak-rich-text-editor__content {
  padding: .75rem;
  outline: 0;
}

.ak-rich-text-editor__content p,
.ak-rich-text > p:empty,
.ak-rich-text > p:has(> br:only-child) {
  min-height: 1.5rem;
}

.ak-rich-text-editor__content > :first-child,
.ak-rich-text > :first-child {
  margin-top: 0;
}

.ak-rich-text-editor__content > :last-child,
.ak-rich-text > :last-child {
  margin-bottom: 0;
}

.ak-rich-text-editor__content a,
.ak-rich-text a {
  text-decoration: underline;
}

.ak-rich-text-editor__content ul,
.ak-rich-text-editor__content ol,
.ak-rich-text ul,
.ak-rich-text ol {
  padding-left: 1.5rem;
}

.ak-rich-text-editor__content li > p,
.ak-rich-text li > p {
  min-height: 0;
  margin-top: 0;
  margin-bottom: .25rem;
}

.ak-rich-text-editor__content li > p:last-child,
.ak-rich-text li > p:last-child {
  margin-bottom: 0;
}

.ak-rich-text-editor__content li + li,
.ak-rich-text li + li {
  margin-top: .25rem;
}

.ak-rich-text-editor__content li > ul,
.ak-rich-text-editor__content li > ol,
.ak-rich-text li > ul,
.ak-rich-text li > ol {
  margin-top: .25rem;
  margin-bottom: .25rem;
}

.ak-rich-text-editor__content blockquote,
.ak-rich-text blockquote {
  margin: 0 0 1rem;
  padding-left: .85rem;
  border-left: .25rem solid var(--ak-rich-editor-border);
  color: var(--ak-rich-editor-muted);
}

.ak-rich-text-editor__content blockquote p,
.ak-rich-text blockquote p {
  min-height: 0;
  margin-top: 0;
  margin-bottom: .5rem;
}

.ak-rich-text-editor__content blockquote p:last-child,
.ak-rich-text blockquote p:last-child {
  margin-bottom: 0;
}

.ak-rich-asset {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.ak-rich-asset__link {
  display: block;
  max-width: 100%;
}

.ak-rich-asset__media {
  display: block;
  width: 100%;
  max-width: 100%;
  max-height: min(44rem, 70vh);
  object-fit: contain;
}

.ak-rich-asset__caption {
  margin-top: .5rem;
  color: var(--bs-secondary-color);
  font-size: .875rem;
  text-align: center;
}

.ak-rich-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .35rem;
  text-align: center;
}

.ak-rich-link__anchor {
  max-width: 100%;
  overflow-wrap: anywhere;
}

.ak-rich-link__description {
  max-width: 42rem;
  color: var(--bs-secondary-color);
}
