/*
  Markdown a bot wrote, inside a message bubble.

  Everything here is scoped to .message__markdown, so a person's rich text keeps
  the look it always had. The colors are the app's own tokens, which redefine
  themselves for a dark scheme in colors.css — there is nothing to flip here.

  A message is not a page: headings are scaled a little rather than a lot, and
  the outermost blocks lose their margins so the bubble stays the size of what's
  in it.
*/

.message__markdown {
  --md-space: 0.66em;

  display: flow-root;
  min-inline-size: 0;

  > * {
    margin-block: var(--md-space);
  }

  > :first-child {
    margin-block-start: 0;
  }

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

  a {
    color: var(--color-link);
  }

  img {
    max-inline-size: 100%;
    block-size: auto;
  }

  :is(h1, h2, h3, h4, h5, h6) {
    font-size: 1em;
    font-weight: 600;
    line-height: 1.3;
  }

  h1 {
    font-size: 1.2em;
  }

  h2 {
    font-size: 1.1em;
  }

  h3 {
    font-size: 1.05em;
  }

  ul,
  ol {
    margin-inline: 0;
    padding-inline-start: var(--inline-space-double);
  }

  li {
    margin-block: 0.15em;

    > :is(ul, ol, p) {
      margin-block: 0.15em;
    }
  }

  blockquote {
    border: 0 solid var(--color-border-darker);
    border-inline-start-width: var(--inline-space-half);
    margin-inline: 0;
    padding-inline-start: 1.5ch;
  }

  hr {
    border: 0;
    border-block-start: 1px solid var(--color-border-darker);
    margin-block: var(--md-space);
  }

  code {
    background-color: var(--color-bg);
    border: 1px solid var(--color-border-dark);
    border-radius: 0.3em;
    font-size: 0.85em;
    padding: 0.15em 0.4em;
  }

  pre {
    background-color: var(--color-bg);
    border: 1px solid var(--color-border-dark);
    border-radius: 0.5em;
    line-height: 1.45;
    overflow-x: auto;
    padding: var(--block-space-half) var(--inline-space);

    code {
      background: none;
      border: 0;
      border-radius: 0;
      font-size: inherit;
      font-weight: inherit;
      padding: 0;
    }
  }

  /* A wide table scrolls inside the bubble instead of pushing it off-screen. */
  .md-scroll {
    max-inline-size: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
  }

  table {
    border-collapse: collapse;
    font-size: 0.9em;
    line-height: 1.4;
  }

  :is(th, td) {
    border: 1px solid var(--color-border-darker);
    padding: 0.25em 0.75ch;
    text-align: start;
    white-space: nowrap;
  }

  th {
    background-color: var(--color-bg);
    font-weight: 600;
  }
}
