/* ==UserStyle==
@name           Compact++
@namespace      https://grzesiek11.stary.pc.pl
@version        1.8.0
@description    Makes Discord's Compact mode more like IRC (and thus better)
@author         Grzesiek11 <grzesiek11@stary.pc.pl> (https://grzesiek11.stary.pc.pl)
@preprocessor   less
@license        MIT
@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 "Hide tags" 0
@var            checkbox hide-icons "Hide icons" 0
@var            checkbox minimize-replies "Minimize replies" 0
@var            text header-width "Header width" 160px
@var            text header-margin-left "Header margin left" 10px
@var            text header-margin-right "Header margin right" 5px
@var            text message-margin-right "Message margin right" 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") {

:root {
    /* Message header width */
    --compactpp-header-width: @header-width;
    /* Message header left margin */
    --compactpp-header-margin-left: @header-margin-left;
    /* Message header right margin */
    --compactpp-header-margin-right: @header-margin-right;
    /* Message container right margin */
    --compactpp-message-margin-right: @message-margin-right;
    /* Message 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_c19a55.wrapper_c19a55 {
    padding-left: 0;
    padding-right: var(--compactpp-message-margin-right) !important;
}

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

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

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

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

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

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

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

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

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

/* Message markup quote line */
.compact_c19a55 .blockquoteContainer__75297 .blockquoteDivider__75297 {
    flex-shrink: 0;
}

/* Message header container */
.compact_c19a55 .header_c19a55,
/* Message header container with gradient (more specific selector) */
.zalgo_c19a55.gradient_c19a55.compact_c19a55 .header_c19a55,
/* 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_c19a55.withDisplayNameStyles_c19a55.withDisplayNameStyles_c19a55 .header_c19a55 {
    margin-left: var(--compactpp-header-margin-left);
    position: absolute;
    display: flex;
    width: var(--compactpp-header-width);
    align-items: center;
}

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

/* Hidden message timestamp */
.compact_c19a55 .timestampVisibleOnHover_c19a55 {
    opacity: unset;
}

/* Message avatar */
.compact_c19a55 .avatar_c19a55 {
    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_c19a55 .headerText_c19a55 {
    display: flex;
    align-items: center;
    margin-left: 5px;
    margin-right: 0;
    min-width: 0;
    order: 2;
}

& when (@hide-tags = 1) {
    /* Message tag */
    .compact_c19a55 .botTag_c19a55,
    /* System message tag */
    .compact_c19a55 .systemTag__44492,
    /* AutoMod notice tag */
    .compact_c19a55 .systemTag_df2817,
    /* Message clan tag */
    .compact_c19a55 .clanTagChiplet_c19a55 {
        display: none;
    }
}

& when (@hide-tags = 0) {
    /* Message tag */
    .compact_c19a55 .botTag_c19a55,
    /* System message tag */
    .compact_c19a55 .systemTag__44492,
    /* AutoMod notice tag */
    .compact_c19a55 .systemTag_df2817,
    /* Message clan tag */
    .compact_c19a55 .clanTagChiplet_c19a55 {
        margin-left: 0;
        margin-right: 5px;
    }

    /* Message tag */
    .compact_c19a55 .botTag_c19a55 {
        position: static;
    }

    /* Message clan tag */
    .compact_c19a55 .clanTagChiplet_c19a55 {
        white-space: nowrap;
    }
}

/* Message username */
.compact_c19a55 .headerText_c19a55 .username_c19a55 {
    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;
}

/* Message username on hover */
.mouse-mode .compact_c19a55 .headerText_c19a55 .username_c19a55:hover,
/* AutoMod message username container on hover */
.mouse-mode .compact__44492.usernameContainer__44492 > :nth-child(2):hover,
/* AutoMod notice username container on hover */
.mouse-mode .compact_df2817.usernameContainer_df2817 > :nth-child(2):hover,
/* Vencord UserMessagesPronouns plugin: Message pronouns on hover */
.mouse-mode .compact_c19a55 .headerText_c19a55 .timestamp_c19a55: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);
}

/* Role and new member icon container */
.compact_c19a55 .headerText_c19a55 :has(.newMemberBadge_f80704), .compact_c19a55 .headerText_c19a55 :has(.roleIcon_c19a55) {
    order: 1;
}

& when (@hide-icons = 1) {
    /* Role icon */
    .compact_c19a55 .roleIcon_c19a55,
    /* New member icon */
    .compact_c19a55 .newMemberBadge_f80704 {
        display: none;
    }
}

& when (@hide-icons = 0) {
    /* Role icon */
    .compact_c19a55 .roleIcon_c19a55,
    /* New member icon */
    .compact_c19a55 .newMemberBadge_f80704 {
        margin-right: 5px;
        margin-left: 0;
    }
}

/* Message tag in username container (like the Remix tag) */
.compact_c19a55 .headerText_c19a55 .botTag_c19a55 {
    order: 0;
}

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

/* Silent message icon */
.compact_c19a55 .badge__6ba43 when (@hide-icons = 1) {
    display: none;
}

/* Silent message icon */
.compact_c19a55 .badge__6ba43 when (@hide-icons = 0) {
    position: static;
}

/* Message content */
.compact_c19a55 .contents_c19a55 .messageContent_c19a55 {
    display: block;
}

/* Message content */
.compact_c19a55 .contents_c19a55 .messageContent_c19a55,
/* Message embed container */
.compact_c19a55 > .container_b7e1cb,
/* AutoMod referenced message container */
.compact__44492.messageContent__44492,
/* AutoMod referenced message footer */
.compact__44492.footerContainer__44492,
/* Edit input */
.compact_c19a55 .channelTextArea__5126c,
/* Edit actions */
.compact_c19a55 .operations_bab751,
/* AutoMod notice embed */
.embedCard_df2817.compact_df2817 {
    margin-left: calc(var(--compactpp-header-width) + var(--compactpp-header-margin-left) + var(--compactpp-header-margin-right));
}

/* Message content of message with empty embed container */
.compact_c19a55:has(> .container_b7e1cb:empty) .contents_c19a55 .messageContent_c19a55 {
    /* 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 blocked message notice container */
.blockedNoticeContainer_b7ab2c.compact_b7ab2c {
    margin-left: 0;
}

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

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

/* System message content */
.compact_c19a55.systemMessage__5126c > .contents_c19a55 > .messageContent_c19a55,
/* Blocked message drawer */
.compact_c19a55 .blockedSystemMessage__7a70a {
    margin-left: calc(var(--compactpp-header-width) + var(--compactpp-header-margin-left) - var(--compactpp-avatar-size));
}

/* System message icon */
.compact__235ca .iconContainer__235ca {
    margin-right: var(--compactpp-header-margin-right);
    width: var(--compactpp-avatar-size);
    height: var(--compactpp-avatar-size);
    align-items: center;
    padding-top: 0;
}

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

/* Non-AutoMod system message container */
.compact__235ca.container__235ca:not(.mainContainer__44492) {
    align-items: center;
}

/* AutoMod message container */
.compact__44492.mainContainer__44492,
/* AutoMod notice */
.compact_df2817.mainContainer_df2817 {
    margin-left: 0;
}

/* AutoMod message header */
.compact__44492.usernameContainer__44492,
/* AutoMod notice header */
.compact_df2817.usernameContainer_df2817 {
    margin-left: var(--compactpp-header-margin-left) !important;
}

/* AutoMod message timestamp */
.compact__44492.mainContainer__44492 .timestamp_c19a55,
/* AutoMod notice timestamp */
.compact_df2817.mainContainer_df2817 .timestamp_c19a55 {
    flex-shrink: 0;
}

/* AutoMod message username container */
.compact__44492.usernameContainer__44492 > :nth-child(2),
/* AutoMod notice username container */
.compact_df2817.usernameContainer_df2817 > :nth-child(2) {
    margin-left: 5px;
    overflow: hidden;
}

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

/* AutoMod message username */
.compact_c19a55 .username__44492,
/* AutoMod notice username */
.compact_c19a55 .username_df2817 {
    font-weight: 500;
    margin-right: 0;
    text-overflow: ellipsis;
    overflow: hidden;
}

/* AutoMod message tag */
.compact__44492.usernameContainer__44492 > :nth-child(2) > * > :nth-child(1),
/* AutoMod notice tag */
.compact_df2817.usernameContainer_df2817 > :nth-child(2) > * > :nth-child(1) {
    order: 1;
}

/* AutoMod message action */
.compact__44492.usernameContainer__44492 > :nth-child(2) > * > :nth-child(3) {
    display: none !important;
}

/* AutoMod message header flex container */
.compact_c19a55 .spanCorrection__44492,
/* AutoMod notice header flex container */
.compact_c19a55 .spanCorrection_df2817 {
    flex-wrap: unset;
}

/* AutoMod message content */
.compact_c19a55 .contents_c19a55 .messageContent_c19a55:has(> div > .compact__44492.mainContainer__44492),
/* AutoMod notice content */
.compact_c19a55 .contents_c19a55 .messageContent_c19a55:has(> div > .compact_df2817.mainContainer_df2817) {
    margin-left: 0;
}

/* AutoMod referenced message container */
.compact__44492.messageContent__44492 {
    padding-left: 0;
}

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

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

/* AutoMod notice content container */
.compact_df2817.content_df2817 {
    align-items: unset;
}

/* AutoMod notice embed */
.compact_df2817.embedCard_df2817 {
    margin-top: 0;
    margin-bottom: 0;
}

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

/* Vencord UserMessagesPronouns plugin: Reply pronouns */
.compact_c19a55 .repliedMessage_c19a55 .timestamp_c19a55 {
    margin-left: 0;
}

& when (@minimize-replies = 1) {
    /* Reply username */
    .compact_c19a55 .repliedMessage_c19a55 .username_c19a55,
    /* Reply preview */
    .compact_c19a55 .repliedTextPreview_c19a55,
    /* Reply icon */
    .compact_c19a55 .repliedTextContentIcon_da8b30 {
        opacity: 0;
        transition: 0.2s;
    }

    /* Reply username on message hover */
    .compact_c19a55.message__5126c:hover .repliedTextPreview_c19a55,
    /* Reply preview on message hover */
    .compact_c19a55.message__5126c:hover .repliedMessage_c19a55 .username_c19a55,
    /* Reply icon on message hover */
    .compact_c19a55.message__5126c:hover .repliedTextContentIcon_da8b30 {
        opacity: 1;
    }
}

/* Message thread link line next to the message content */
.compact_c19a55.hasThread_c19a55 .contents_c19a55::before {
    display: none;
}

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

/* Message thread embed */
.compact_c19a55 .container__9271d {
    margin-top: 0;
}

/* Edit input */
.compact_c19a55 .channelTextArea__5126c {
    width: unset;
}

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

/* Vencord UserMessagesPronouns plugin: Message pronouns */
.compact_c19a55 .headerText_c19a55 .timestamp_c19a55 {
    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_c19a55 .headerText_c19a55 .timestamp_c19a55:hover {
    width: unset;
}

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

}
