/* ==UserStyle==
@name           Compact++
@namespace      https://grzesiek11.stary.pc.pl
@version        1.9.5
@description    Discord theme that makes Compact mode more like IRC (and thus better).
@author         Grzesiek11 <grzesiek11@stary.pc.pl> (https://grzesiek11.stary.pc.pl/en)
@preprocessor   less
@license        BSD-2-Clause-Patent
@homepageURL    https://git.stary.pc.pl/Grzesiek11/compactpp
@supportURL     https://git.stary.pc.pl/Grzesiek11/compactpp/issues
@updateURL      https://grzesiek11.stary.pc.pl/files/builds/compactpp/latest/compactpp.user.css
@var            checkbox hide-tags-usercss "Hide tags" 0
@var            checkbox hide-icons-usercss "Hide icons" 0
@var            checkbox minimize-replies-usercss "Minimize replies" 0
@var            text header-width "Header width" 160px
@var            text header-margin-left "Header left margin" 10px
@var            text header-margin-right "Header right margin" 5px
@var            text message-margin-right "Message right margin" 15px
@var            text avatar-size "Avatar size" 1.25rem
@var            text reply-link-line-offset "Reply link line offset" 30px
@var            text pronoundb-pronouns-width "UserMessagesPronouns pronouns width" 45px
==/UserStyle== */

@-moz-document domain("discord.com") {

@legacy: true;
@hide-tags: boolean(@hide-tags-usercss = 1);
@hide-icons: boolean(@hide-icons-usercss = 1);
@minimize-replies: boolean(@minimize-replies-usercss = 1);

:root {
    & when not (@legacy) {
        /* Hide tags */
        --compactpp-hide-tags: @hide-tags;
        /* Hide icons */
        --compactpp-hide-icons: @hide-icons;
        /* Minimize replies */
        --compactpp-minimize-replies: @minimize-replies;
    }
    /* Header width */
    --compactpp-header-width: @header-width;
    /* Header left margin */
    --compactpp-header-margin-left: @header-margin-left;
    /* Header right margin */
    --compactpp-header-margin-right: @header-margin-right;
    /* Message right margin */
    --compactpp-message-margin-right: @message-margin-right;
    /* Avatar size */
    --compactpp-avatar-size: @avatar-size;
    /* Reply link line offset */
    --compactpp-reply-link-line-offset: @reply-link-line-offset;
    /* UserMessagesPronouns pronouns width */
    --compactpp-pronoundb-pronouns-width: @pronoundb-pronouns-width;
}

/* Message container */
.compact_2i8Bfm.wrapper_2i8Bfm {
    padding-left: 0;
    padding-right: var(--compactpp-message-margin-right) !important;
}

/* Message content container */
.compact_2i8Bfm .contents_2i8Bfm {
    margin-left: 0;
    padding-left: 0;
    text-indent: 0;
}

/* Message markup first header 1 */
.compact_2i8Bfm .markup_ku1OHH h1:first-child,
/* Message markup first header 2 */
.compact_2i8Bfm .markup_ku1OHH h2:first-child,
/* Message markup first header 3 */
.compact_2i8Bfm .markup_ku1OHH h3:first-child {
    margin-top: 0;
}

/* Message markup last header 1 */
.compact_2i8Bfm .markup_ku1OHH h1:last-child,
/* Message markup last header 2 */
.compact_2i8Bfm .markup_ku1OHH h2:last-child,
/* Message markup last header 3 */
.compact_2i8Bfm .markup_ku1OHH h3:last-child {
    margin-bottom: 0;
}

/* Message markup first unordered list */
.compact_2i8Bfm .markup_ku1OHH ul:first-child,
/* Message markup first ordered list */
.compact_2i8Bfm .markup_ku1OHH ol:first-child {
    margin-top: 0;
}

/* Message markup list last element */
.compact_2i8Bfm .markup_ku1OHH li:last-child {
    margin-bottom: 0;
}

/* Message markup unordered list */
.compact_2i8Bfm .markup_ku1OHH ul,
/* Message markup ordered list */
.compact_2i8Bfm .markup_ku1OHH ol {
    margin-bottom: 4px;
}

/* Message markup last unordered list */
.compact_2i8Bfm .markup_ku1OHH ul:last-child,
/* Message markup last ordered list */
.compact_2i8Bfm .markup_ku1OHH ol:last-child {
    margin-bottom: 0px;
}

/* Message markup code block */
.compact_2i8Bfm .markup_ku1OHH pre {
    max-width: unset;
}

/* Message markup quote container */
.compact_2i8Bfm .markup_ku1OHH blockquote {
    padding-right: 0;
    max-width: unset;
    min-width: 0;
}

/* Message markup quote line */
.compact_2i8Bfm .blockquoteContainer_ku1OHH .blockquoteDivider_ku1OHH {
    flex-shrink: 0;
}

/* Message header container */
.compact_2i8Bfm .header_2i8Bfm,
/* Message header container with gradient (more specific selector) */
.zalgo_2i8Bfm.gradient_2i8Bfm.compact_2i8Bfm .header_2i8Bfm,
/* Message header container with special font in DMs (more specific selector) */
/* Seriously, this class is only applied in DMs/GCs. Why?? Also yes this *is* the required specificity. */
.withDisplayNameStyles_2i8Bfm.withDisplayNameStyles_2i8Bfm.withDisplayNameStyles_2i8Bfm .header_2i8Bfm {
    margin-left: var(--compactpp-header-margin-left);
    position: absolute;
    display: flex;
    width: var(--compactpp-header-width);
    align-items: center;
}

/* Message timestamp */
.compact_2i8Bfm .header_2i8Bfm .timestamp_2i8Bfm {
    flex-grow: 1;
    margin-right: 0;
    text-align: left;
    white-space: nowrap;
    width: unset;
}

/* Hidden message timestamp */
.compact_2i8Bfm .timestampVisibleOnHover_2i8Bfm {
    opacity: unset;
}

/* Message avatar */
.compact_2i8Bfm .avatar_2i8Bfm {
    position: static;
    width: var(--compactpp-avatar-size);
    height: var(--compactpp-avatar-size);
    margin-left: 5px;
    margin-right: 0;
    z-index: auto;
    order: 1;
}

/* Message username container */
.compact_2i8Bfm .headerText_2i8Bfm {
    display: flex;
    align-items: center;
    margin-left: 5px;
    margin-right: 0;
    min-width: 0;
    order: 2;
}

/* Message tag */
.compact_2i8Bfm .botTag_2i8Bfm,
/* System message tag */
.compact_2i8Bfm .systemTag_q-l2Gj,
/* AutoMod notice tag */
.compact_2i8Bfm .systemTag_bbJCi7,
/* Message clan tag */
.compact_2i8Bfm .clanTagChiplet_2i8Bfm {
    margin-left: 0;
    margin-right: 5px;
}

/* Message tag */
.compact_2i8Bfm .botTag_2i8Bfm {
    position: static;
}

/* Message clan tag */
.compact_2i8Bfm .clanTagChiplet_2i8Bfm {
    white-space: nowrap;
}

& when (@legacy) and (@hide-tags) {
    /* Message tag */
    .compact_2i8Bfm .botTag_2i8Bfm,
    /* System message tag */
    .compact_2i8Bfm .systemTag_q-l2Gj,
    /* AutoMod notice tag */
    .compact_2i8Bfm .systemTag_bbJCi7,
    /* Message clan tag */
    .compact_2i8Bfm .clanTagChiplet_2i8Bfm {
        display: none;
    }
}

& when not (@legacy) {
    @container style(--compactpp-hide-tags: true) {
        /* Message tag */
        .compact_2i8Bfm .botTag_2i8Bfm,
        /* System message tag */
        .compact_2i8Bfm .systemTag_q-l2Gj,
        /* AutoMod notice tag */
        .compact_2i8Bfm .systemTag_bbJCi7,
        /* Message clan tag */
        .compact_2i8Bfm .clanTagChiplet_2i8Bfm {
            display: none;
        }
    }
}

/* Message username */
.compact_2i8Bfm .headerText_2i8Bfm .username_2i8Bfm {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    /* Gradient glow is absolute, we want it relative to the username */
    position: relative;
    flex-shrink: 1;
    z-index: 1;
    order: 2;
}

/* AutoMod message username container */
.compact_q-l2Gj.usernameContainer_q-l2Gj > :nth-child(2),
/* AutoMod notice username container */
.compact_bbJCi7.usernameContainer_bbJCi7 > :nth-child(2) {
    overflow: hidden;
    margin-left: 5px;
}

/* Message username on hover */
.mouse-mode .compact_2i8Bfm .headerText_2i8Bfm .username_2i8Bfm:hover,
/* AutoMod message username container on hover */
.mouse-mode .compact_q-l2Gj.usernameContainer_q-l2Gj > :nth-child(2):hover,
/* AutoMod notice username container on hover */
.mouse-mode .compact_bbJCi7.usernameContainer_bbJCi7 > :nth-child(2):hover,
/* Vencord UserMessagesPronouns plugin: Message pronouns on hover */
.mouse-mode .compact_2i8Bfm .headerText_2i8Bfm .timestamp_2i8Bfm:hover {
    /* Show full username */
    overflow: visible;
    /* Not background-color to override gradient */
    background: var(--background-secondary-alt);
    outline: 3px solid var(--background-secondary-alt);
    border-radius: 3px;
    /* Disable gradient, as it's in conflict with the full username popup */
    -webkit-text-fill-color: unset;
    color: var(--custom-gradient-color-1, var(--text-strong));
}

/* Role and new member icon container */
.compact_2i8Bfm .headerText_2i8Bfm :has(.newMemberBadge_P4-UkH), .compact_2i8Bfm .headerText_2i8Bfm :has(.roleIcon_2i8Bfm) {
    order: 1;
}

/* Role icon */
.compact_2i8Bfm .roleIcon_2i8Bfm,
/* New member icon */
.compact_2i8Bfm .newMemberBadge_P4-UkH {
    margin-right: 5px;
    margin-left: 0;
}

& when (@legacy) and (@hide-icons) {
    /* Role icon */
    .compact_2i8Bfm .roleIcon_2i8Bfm,
    /* New member icon */
    .compact_2i8Bfm .newMemberBadge_P4-UkH {
        display: none;
    }
}

& when not (@legacy) {
    @container style(--compactpp-hide-icons: true) {
        /* Role icon */
        .compact_2i8Bfm .roleIcon_2i8Bfm,
        /* New member icon */
        .compact_2i8Bfm .newMemberBadge_P4-UkH {
            display: none;
        }
    }
}

/* Message tag in username container (like the Remix tag) */
.compact_2i8Bfm .headerText_2i8Bfm .botTag_2i8Bfm {
    order: 0;
}

/* Silent message icon container */
.compact_2i8Bfm .badgesContainer_2i8Bfm {
    margin-right: 0;
    margin-left: 5px;
}

/* Silent message icon */
.compact_2i8Bfm .badge__6ba43 {
    position: static;
}

& when (@legacy) and (@hide-icons) {
    /* Silent message icon container */
    .compact_2i8Bfm .badgesContainer_2i8Bfm {
        display: none;
    }
}

& when not (@legacy) {
    @container style(--compactpp-hide-icons: true) {
        /* Silent message icon container */
        .compact_2i8Bfm .badgesContainer_2i8Bfm {
            display: none;
        }
    }
}

/* Message content */
.compact_2i8Bfm .contents_2i8Bfm .messageContent_2i8Bfm {
    display: block;
    overflow: visible;
}

/* Message content */
.compact_2i8Bfm .contents_2i8Bfm .messageContent_2i8Bfm,
/* Message embed container */
.compact_2i8Bfm > .container_YUQhib,
/* AutoMod referenced message container */
.compact_bbJCi7.messageContent_bbJCi7,
/* AutoMod referenced message footer */
.compact_bbJCi7.footerContainer_bbJCi7,
/* Edit input */
.compact_2i8Bfm .channelTextArea_SY_P2T,
/* Edit actions */
.compact_2i8Bfm .operations_h_zE4S,
/* AutoMod message content */
.compact_q-l2Gj.content_q-l2Gj > :nth-child(2) {
    margin-left: calc(var(--compactpp-header-width) + var(--compactpp-header-margin-left) + var(--compactpp-header-margin-right));
}

/* AutoMod message container */
.compact_q-l2Gj.content_q-l2Gj {
    display: block;
}

/* Message content of message with empty embed container */
.compact_2i8Bfm:has(> .container_YUQhib:empty) .contents_2i8Bfm .messageContent_2i8Bfm {
    /* Make the content have at least 1 line of height, in case the client
     * renders a message with no content and no embeds */
    /* This has happened before with the 2023-09_soundmoji experiment. If a
     * client without the experiment enabled received a message with only a
     * soundmoji, it got rendered without content. */
    min-height: 1lh;
}

/* AutoMod notice content */
.compact_bbJCi7.content_bbJCi7 > :nth-child(2) {
    line-height: var(--chat-markup-line-height);
}

/* AutoMod blocked message notice container */
.messageContainer_CKGXbh.compact_CKGXbh {
    margin-left: 0;
}

/* AutoMod blocked message accessories container */
.ephemeralAccessories_CKGXbh.compact_CKGXbh {
    margin-left: 0;
}

/* System message container */
.compact_bLMKT5 {
    margin-left: 0;
}

/* System message content */
.compact_2i8Bfm.systemMessage_SY_P2T > .contents_2i8Bfm > .messageContent_2i8Bfm,
/* Blocked message drawer */
.compact_2i8Bfm .blockedSystemMessage__7a70a {
    margin-left: calc(var(--compactpp-header-width) + var(--compactpp-header-margin-left) - var(--compactpp-avatar-size));
}

/* System message icon */
.compact_2i8Bfm .iconContainer_bLMKT5.iconContainer_bLMKT5 {
    margin-right: var(--compactpp-header-margin-right);
    width: var(--compactpp-avatar-size);
    height: var(--compactpp-avatar-size);
    align-items: center;
    padding-top: 0;
    /* Attributes copied from Compact mode rule as the group leave message has Cozy mode classes */
    position: relative;
    inset-inline-end: auto;
}

/* Send welcome sticker button */
.compact_2i8Bfm .welcomeCTA_f5d1e2,
/* Poll closed embed */
.compact_2i8Bfm .container_f69538 {
    margin-left: calc(var(--compactpp-avatar-size) + var(--compactpp-header-margin-right));
}

/* Non-AutoMod system message container */
.compact_bLMKT5.container_bLMKT5:not(.mainContainer_bbJCi7, .mainContainer_q-l2Gj) {
    align-items: center;
}

/* AutoMod message main container */
.compact_q-l2Gj.mainContainer_q-l2Gj,
/* AutoMod notice main container */
.compact_bbJCi7.mainContainer_bbJCi7 {
    margin-left: 0;
    padding-top: 0;
    padding-bottom: 0;
}

/* AutoMod message header */
.compact_q-l2Gj.usernameContainer_q-l2Gj,
/* AutoMod notice header */
.compact_bbJCi7.usernameContainer_bbJCi7 {
    margin-left: var(--compactpp-header-margin-left) !important;
}

/* AutoMod message timestamp */
.compact_q-l2Gj.mainContainer_q-l2Gj .timestamp_2i8Bfm,
/* AutoMod notice timestamp */
.compact_bbJCi7.mainContainer_bbJCi7 .timestamp_2i8Bfm {
    flex-shrink: 0;
}

/* AutoMod message username container on hover */
.mouse-mode.full-motion .compact_q-l2Gj.usernameContainer_q-l2Gj > :nth-child(2):hover {
    z-index: 2;
}

/* AutoMod message username */
.compact_2i8Bfm .username_q-l2Gj,
/* AutoMod notice username */
.compact_2i8Bfm .username_bbJCi7 {
    font-weight: 500;
    margin-right: 0;
    text-overflow: ellipsis;
    overflow: hidden;
    order: 1;
    line-height: var(--chat-markup-line-height);
}

/* AutoMod notice action */
.compact_bbJCi7.usernameContainer_bbJCi7 > :nth-child(2) > * > :nth-child(3) {
    display: none !important;
}

/* AutoMod message header flex container */
.compact_2i8Bfm .spanCorrection_q-l2Gj,
/* AutoMod notice header flex container */
.compact_2i8Bfm .spanCorrection_bbJCi7 {
    flex-wrap: unset;
    align-items: center;
}

/* AutoMod message outer container */
.compact_2i8Bfm .contents_2i8Bfm .messageContent_2i8Bfm:has(> div > .compact_q-l2Gj.mainContainer_q-l2Gj),
/* AutoMod notice outer container */
.compact_2i8Bfm .contents_2i8Bfm .messageContent_2i8Bfm:has(> div > .compact_bbJCi7.mainContainer_bbJCi7) {
    margin-left: 0;
}

/* AutoMod referenced message container */
.compact_bbJCi7.messageContent_bbJCi7 {
    padding-left: 0;
}

/* AutoMod referenced message */
.compact_2i8Bfm .messageContainer__44c9a {
    margin-left: 0;
}

/* AutoMod referenced message content */
.compact_2i8Bfm .messageContainer__44c9a .messageContent_2i8Bfm {
    margin-left: calc(var(--compactpp-header-width) + var(--compactpp-header-margin-right));
}

/* AutoMod referenced message avatar */
.compact__44c9a .avatar_2i8Bfm,
/* AutoMod referenced message username with disabled avatars */
.compact__44c9a .headerText_2i8Bfm:not(.avatar_2i8Bfm + *) {
    margin-left: auto;
}

/* AutoMod notice content container */
.compact_bbJCi7.content_bbJCi7 {
    line-height: 1;
    align-items: unset;
}

/* AutoMod notice embed */
.compact_bbJCi7.embedCard_bbJCi7 {
    margin-top: 0;
    margin-bottom: 0;
}

/* Message reply container */
.compact_2i8Bfm .repliedMessage_2i8Bfm {
    margin-left: calc(var(--compactpp-header-margin-left) + var(--compactpp-reply-link-line-offset));
}

/* Vencord UserMessagesPronouns plugin: Reply pronouns */
.compact_2i8Bfm .repliedMessage_2i8Bfm .timestamp_2i8Bfm {
    margin-left: 0;
}

& when (@legacy) and (@minimize-replies) {
    /* Reply username */
    .compact_2i8Bfm .repliedMessage_2i8Bfm .username_2i8Bfm,
    /* Reply preview */
    .compact_2i8Bfm .repliedTextPreview_2i8Bfm,
    /* Reply icon */
    .compact_2i8Bfm .repliedTextContentIcon_da8b30 {
        opacity: 0;
        transition: 0.2s;
    }

    /* Reply username on message hover */
    .compact_2i8Bfm.message_SY_P2T:hover .repliedTextPreview_2i8Bfm,
    /* Reply preview on message hover */
    .compact_2i8Bfm.message_SY_P2T:hover .repliedMessage_2i8Bfm .username_2i8Bfm,
    /* Reply icon on message hover */
    .compact_2i8Bfm.message_SY_P2T:hover .repliedTextContentIcon_da8b30 {
        opacity: 1;
    }
}

& when not (@legacy) {
    @container style(--compactpp-minimize-replies: true) {
        /* Reply username */
        .compact_2i8Bfm .repliedMessage_2i8Bfm .username_2i8Bfm,
        /* Reply preview */
        .compact_2i8Bfm .repliedTextPreview_2i8Bfm {
        /* Reply icon */
        /* TODO: Not sure what that was, but it doesn't work anymore - figure it out or remove */
        /*.compact_2i8Bfm .repliedTextContentIcon_da8b30 {*/
            opacity: 0;
            transition: 0.2s;
        }

        /* Reply username on message hover */
        .compact_2i8Bfm.message_SY_P2T:hover .repliedTextPreview_2i8Bfm,
        /* Reply preview on message hover */
        .compact_2i8Bfm.message_SY_P2T:hover .repliedMessage_2i8Bfm .username_2i8Bfm,
        /* Reply icon on message hover */
        .compact_2i8Bfm.message_SY_P2T:hover .repliedTextContentIcon_da8b30 {
            opacity: 1;
        }
    }
}

/* Message thread link line next to the message content */
.compact_2i8Bfm.hasThread_2i8Bfm .contents_2i8Bfm::before {
    display: none;
}

/* Message thread link line next to the message embed container */
.compact_2i8Bfm .spine_g2fiji {
    display: none;
}

/* Message thread embed */
.compact_2i8Bfm .container_g2fiji {
    margin-top: 0;
}

/* Edit input */
.compact_2i8Bfm .channelTextArea_SY_P2T {
    width: unset;
}

/* Vencord MessageLatency plugin: Latency indicator */
.compact_2i8Bfm .headerText_2i8Bfm > svg {
    flex-shrink: 0;
    margin-right: 5px !important;
}

/* Vencord UserMessagesPronouns plugin: Message pronouns */
.compact_2i8Bfm .headerText_2i8Bfm .timestamp_2i8Bfm {
    width: var(--compactpp-pronoundb-pronouns-width);
    max-width: fit-content;
    flex-grow: 1;
    flex-shrink: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    order: 1;
    margin-left: -2px;
    margin-right: 4px;
}

/* Vencord UserMessagesPronouns plugin: Message pronouns on hover */
.compact_2i8Bfm .headerText_2i8Bfm .timestamp_2i8Bfm:hover {
    width: unset;
}

/* Vencord PlatformIndicators plugin: Message platform indicator */
.compact_2i8Bfm .vc-platform-indicator {
    margin-left: 0 !important;
    position: static !important;
    margin-right: 5px;
}

}
