@import url("/assets/lexxy-overrides/lexxy-variables-498ad74f.css");

.lexxy-content,
.lexxy-editor__content {
  --lexxy-content-resolved-font-size: var(--lexxy-content-font-size, var(--font-size--body));
  --lexxy-content-resolved-line-height: var(--lexxy-content-line-height, var(--line-height--base));
  --lexxy-content-resolved-margin: var(--lexxy-content-margin, calc(var(--lexxy-content-resolved-font-size) * 1.15));
  --lexxy-content-resolved-list-indent: var(--lexxy-content-list-indent, calc(var(--lexxy-content-resolved-font-size) * 1.25));
  --lexxy-content-resolved-table-cell-padding: var(--lexxy-content-table-cell-padding, calc(var(--lexxy-content-resolved-font-size) * 0.75));
  --lexxy-content-resolved-media-max-block-size: var(--lexxy-content-media-max-block-size, 40rem);
  --lexxy-text-small: calc(var(--lexxy-content-resolved-font-size) * 0.875);

  font-size: var(--lexxy-content-resolved-font-size);
  line-height: var(--lexxy-content-resolved-line-height);

  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    margin-block: 0 var(--lexxy-content-resolved-margin);
    hyphens: auto;
    overflow-wrap: break-word;
    text-wrap: balance;
  }

  h1 { font-size: 2em; }
  h2 { font-size: 1.7143em; }
  h3 { font-size: 1.3714em; }
  h4 { font-size: 1.1429em; }
  h5 { font-size: 1em; }
  h6 { font-size: 0.7429em; }

  p,
  ul,
  ol,
  dl,
  blockquote,
  figure,
  .attachment,
  .attachment-gallery {
    margin-block: 0 var(--lexxy-content-resolved-margin);

    &:not(lexxy-editor &) {
      overflow-wrap: break-word;
      text-wrap: pretty;
    }
  }

  blockquote {
    border-inline-start-width: 0.125em;
    color: var(--color--aa-text);
    font-family: var(--font-family--blockquote);
    font-size: 0.9em;
    font-style: normal;
    font-weight: 400;
  }

  ol, ul:not(.lexxy-prompt-menu) {
    margin-inline-start: var(--lexxy-content-resolved-list-indent);
    padding: 0;
  }

  a {
    color: inherit;
    text-decoration: underline;
  }

  :is(s, del, strike, .lexxy-content__strikethrough) {
    text-decoration: line-through;
  }

  .lexxy-content__strikethrough.lexxy-content__underline {
    text-decoration: line-through underline;
  }

  img,
  video,
  embed,
  object {
    margin-inline: auto;
    max-block-size: var(--lexxy-content-resolved-media-max-block-size);
    object-fit: initial;
    outline: 1px solid rgb(153 153 153 / 0.13);
    outline-offset: -1px;
  }

  .lexxy-content__table-wrapper {
    margin-block: 0 var(--lexxy-content-resolved-margin);
    overflow-x: auto;
  }

  table {
    border-collapse: separate;
    border-spacing: 0;
    inline-size: 100%;
    margin: 0;

    th,
    td {
      background-color: var(--lexxy-color-canvas);
      border: 0;
      border-block-end: var(--border--light);
      border-inline-end: var(--border--light);
      min-inline-size: 8ch;
      max-inline-size: none;
      padding: var(--lexxy-content-resolved-table-cell-padding);
      text-align: left;
      vertical-align: top;
      word-break: normal;

      &:first-child {
        border-inline-start: var(--border--light);
      }

      > :last-child {
        margin-block-end: 0;
      }
    }

    th,
    .lexxy-content__table-cell--header {
      background-color: var(--lexxy-color-table-header-bg);
      font-size: inherit;
      font-weight: var(--font-weight--normal);
    }

    tr:first-child {
      th,
      td {
        border-block-start: var(--border--light);
      }
    }
  }

  .attachment.attachment--preview {
    display: block;
    width: 100%;
    padding: 0;

    img {
      max-width: 100%;
      border-radius: 2px;
    }
  }

  .attachment.attachment--preview .attachment__caption {
    display: block;
    padding-block-start: 0.5em;
    color: var(--color--aa-text);
    font-size: var(--lexxy-text-small);
  }

  .attachment-gallery {
    display: grid;
    gap: 0.75ch;
    grid-template-columns: repeat(2, minmax(0, 1fr));

    > action-text-attachment {
      display: block;
      min-inline-size: 0;
    }

    .attachment {
      inline-size: 100%;
      margin: 0;
      min-inline-size: 0;
      padding: 0;
    }

    .attachment--preview {
      img,
      video {
        width: 100% !important;
        inline-size: 100%;
      }
    }

    &.attachment-gallery--2,
    &.attachment-gallery--4 {
      grid-template-columns: repeat(2, minmax(0, 1fr));

      .attachment {
        inline-size: 100%;
      }
    }
  }

  .attachment--file {
    gap: 1ch;
  }

  .attachment--error {
    padding-block: 2ch;
  }

  > :last-child,
  > :last-child figure {
    margin-block-end: 0;
  }
}

.rich-text--comment {
  --lexxy-content-font-size: var(--font-size--small);
}

:where(.attachment__caption) {
  :is(input, textarea) {
    background: var(--lexxy-color-canvas);
    border: none;
    color: var(--lexxy-color-text);
    inline-size: 100%;
    max-inline-size: 100%;
    text-align: center;

    &:focus {
      outline: none;
    }

    @supports (field-sizing: content) {
      field-sizing: content;
      inline-size: auto;
      min-inline-size: 20ch;
    }
  }
}

:where(.attachment--preview) {
  img,
  video {
    display: block;
    margin-inline: auto;
    max-inline-size: 100%;
    user-select: none;
  }
}

:where(.horizontal-divider) {
  margin-block-end: 0.5em;
  padding: 1.5em 0 0.5em;

  hr {
    margin: 0;
  }
}

:where(action-text-attachment[content-type^="application/vnd.actiontext"]) {
  --lexxy-attachment-bg-color: transparent;
  --lexxy-attachment-image-size: 1em;
  --lexxy-attachment-text-color: currentColor;

  align-items: center;
  background: var(--lexxy-attachment-bg-color);
  border-radius: var(--lexxy-radius);
  box-shadow: -0.25ch 0 0 var(--lexxy-attachment-bg-color), 0.5ch 0 0 var(--lexxy-attachment-bg-color);
  color: var(--lexxy-attachment-text-color);
  display: inline-flex;
  gap: 0.25ch;
  margin: 0;
  padding: 0;
  position: relative;
  white-space: normal;

  img {
    block-size: var(--lexxy-attachment-image-size);
    border-radius: 50%;
    inline-size: var(--lexxy-attachment-image-size);
  }

  &.node--selected {
    --lexxy-attachment-bg-color: var(--lexxy-color-accent-dark);
    --lexxy-attachment-text-color: var(--lexxy-color-ink-inverted);
  }
}
