/* ==UserStyle==
@name           Element reply chain
@namespace      bkil.hu
@version        2023.12.04
@description    Condense reply chain to a single line
@author         bkil
==/UserStyle== */
@-moz-document domain("app.element.io"),
url-prefix("https://riot."),
url-prefix("https://matrix."),
url-prefix("https://element.") {
    /* collapse the whole reply change to a single inline line */
    .mx_ReplyChain_wrapper div,
    .mx_ReplyChain_wrapper p,
    .mx_ReplyChain_wrapper ul,
    .mx_ReplyChain_wrapper ol,
    .mx_ReplyChain_wrapper li,
    .mx_ReplyChain_wrapper a,
    .mx_ReplyChain_wrapper h1,
    .mx_ReplyChain_wrapper h2,
    .mx_ReplyChain_wrapper h3,
    .mx_ReplyChain_wrapper h4,
    .mx_ReplyChain_wrapper h5,
    .mx_ReplyChain_wrapper h6,
    .mx_ReplyChain_wrapper span,
    .mx_ReplyChain_wrapper:not(:hover) .mx_ReplyTile .mx_EventTile_content .mx_EventTile_pre_container>pre,
    .mx_ReplyChain_wrapper:not(:hover) blockquote,
    .mx_ReplyTile>a,
    .mx_ReplyTile .mx_ReplyTile_sender,
    .mx_EventTile .mx_DisambiguatedProfile,
    .mx_ReplyTile .mx_EventTile_content,
    .mx_IRCLayout .mx_EventTile .mx_EventTile_line .mx_ReplyTile .mx_MTextBody,
    .mx_ReplyTile .mx_ReplyTile_sender .mx_DisambiguatedProfile {
      display: inline;
    }

    .mx_ReplyChain_wrapper br {
      display: none;
    }

    .mx_ReplyChain_wrapper blockquote,
    .mx_ReplyChain_wrapper p,
    .mx_ReplyChain_wrapper .mx_EventTile_content .markdown-body>ol,
    .mx_ReplyChain_wrapper .mx_EventTile_content .markdown-body>ul {
      margin-block-start: initial;
      margin-block-end: initial;
      margin-inline-start: initial;
      margin-inline-end: initial;
      padding-inline-start: initial;
      list-style-type: none;
    }

    /* a little space between the username and the text */
    .mx_ReplyChain_wrapper .mx_EventTile_body,
    .mx_ReplyChain_wrapper .mx_EventTile .mx_EventTile_body,
    /* a little space before the cite line */
    .mx_ReplyChain_wrapper {
      padding-left: 1em;
    }

    /* make pre code snippets flow in a single line */
    .mx_ReplyChain_wrapper:not(:hover) .mx_EventTile_content .markdown-body pre code,
    .mx_ReplyChain_wrapper:not(:hover) .mx_EventTile_content .markdown-body code {
      white-space: nowrap;
    }

    /* make markdown flow in a single line */
    .mx_ReplyChain_wrapper .mx_EventTile_content .markdown-body {
      white-space: nowrap !important; /* !important in original */
    }

    /* make non-markdown flow in a single line */
    .mx_ReplyChain_wrapper .mx_MTextBody {
      white-space: nowrap;
    }

    /* cut reply chain after first line */
    .mx_ReplyChain_wrapper {
      /* added padding of .mx_ReplyTile */
      max-height: calc(1em + 4px);
      overflow: hidden;
      margin-bottom: 0.5em;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    /* restore emoji height so it won't push over text */
    .mx_EventTile .mx_ReplyChain_wrapper .mx_Emoji {
      font-size: initial;
    }

    /* expand reply chain on hover */
    .mx_ReplyChain_wrapper:hover {
      max-height: initial;
    }

    /* reflow body on hover */
    .mx_ReplyChain_wrapper:hover .mx_EventTile_content .markdown-body {
      /* !important in original */
      white-space: initial !important;
    }

    .mx_ReplyChain_wrapper:hover .mx_MTextBody {
      white-space: initial;
    }

    /* adjust position of hovering reactions bar so doesn't flick that much when expanding threads */
    .mx_MessageActionBar,
    .mx_ThreadPanel .mx_EventTile[data-layout=group] .mx_MessageActionBar {
      bottom: -32px;
      top: initial;
    }
}
