/* ==UserStyle==
@name           GitLab
@namespace      git.mfocko.xyz/mfocko/usercss
@updateURL      https://git.mfocko.xyz/mfocko/usercss/raw/branch/main/gitlab.user.css
@version        1.9.6
@description    Switch monospace font and allow to disable diff highlight.
@author         mfocko <me@mfocko.xyz>
@preprocessor   stylus
@var select monospace-font "Font" [
    "custom*",
    "Berkeley Mono Variable",
    "Cascadia Code NF",
    "Comic Code Ligatures",
    "Fira Code",
    "Hack",
    "IBM Plex Mono",
    "Iosevka Term",
    "Iosevka Term Slab",
    "Iosevka Comfy",
    "Pragmasevka",
    "JetBrains Mono",
    "JuliaMono",
    "MonoLisa Variable",
    "PragmataPro Liga",
    "PragmataPro Mono Liga",
    "Rec Mono Linear",
    "Roboto Mono",
    "SF Mono",
    "Source Code Pro",
    "Victor Mono",
]
@var text custom-font "Custom font" "monospace"
@var text font-features "Font feature settings" "'calt' on, 'liga' on, 'dlig' on"
@var text custom-font-weight "Custom font weight" "400"

@var checkbox diff-highlight "Show diff highlighting" 1
@var checkbox all-the-way "Render everything in monospace font" 0
==/UserStyle== */

if monospace-font=="custom"
    monospace-font=custom-font

@-moz-document domain("gitlab.com"),
domain("gitlab.fi.muni.cz"),
domain("git.kpi.fei.tuke.sk"),
regexp("https://gitlab\\.([^.]*)\\.redhat\\.com/.*"),
domain("gitlab.haskell.org"),
domain("gitlab.gnome.org"),
domain("gitlab.freedesktop.org"),
domain("invent.kde.org"),
domain("salsa.debian.org"),
domain("gitlab.mfocko.xyz") {
    pre,
    code,
    kbd,
    samp,
    tt,
    .text-monospace,
    .gl-markdown .monospace,
    .gl-compact-markdown .monospace,
    .search-token-target-branch .value,
    .help-form .form-group .form-control,
    .help-form .form-group .search form,
    .search .help-form .form-group form,
    .file-content.code pre,
    .file-content.code pre code,
    .file-content.code .line-numbers a,
    .job-log,
    .md-suggestion-diff,
    .md code,
    .monospace,
    .commit-sha,
    .gfm-commit,
    .gfm-commit_range,
    .ref-name,
    .pipeline-number,
    .git-revision-dropdown .dropdown-content li:not(.dropdown-menu-empty-item) a,
    textarea.js-gfm-input,
    .diff-table.code,
    table.code,
    .commit-message-container,
    .file-editor .file-title,
    .mr-state-widget .label-branch,
    .discussion-reply-holder .reply-placeholder-text-field,
    .git-clone-holder .form-control,
    .git-clone-holder .search form,
    .search .git-clone-holder form,
    .prometheus-svg-container > svg .deploy-info-text-link,
    .tui-editor-defaultUI .te-md-container .CodeMirror *,
    .project-mirror-settings .known-hosts,
    .gl-font-monospace,
    table.code .line_content :not(pre), .job-log :not(pre),
    .ref-container, .commit-sha-container,
    * [style *=" monospace"] {
        font-family: monospace-font !important;
        font-feature-settings: font-features;
        font-variant-ligatures: contextual;
        
        if custom-font-weight != "400" {
            font-weight: custom-font-weight !important;
        }
    }
    
    :root {
        --font-family-monospace: monospace-font !important;
        font-feature-settings: font-features;
        font-variant-ligatures: contextual;
    }

    .code.white .line_holder .diff-line-num.new,
    .code.white .line_holder .line-coverage.new,
    .code.white .line_holder .line-codequality.new,
    .code.white .line_holder .line_content.new,
    .code.white .line_holder .diff-line-num.new-nomappinginraw,
    .code.white .line_holder .line-coverage.new-nomappinginraw,
    .code.white .line_holder .line-codequality.new-nomappinginraw,
    .code.white .line_holder .line_content.new-nomappinginraw,

    .code.white .line_holder .diff-line-num.old,
    .code.white .line_holder .line-coverage.old,
    .code.white .line_holder .line-codequality.old,
    .code.white .line_holder .line_content.old,
    .code.white .line_holder .diff-line-num.old-nomappinginraw,
    .code.white .line_holder .line-coverage.old-nomappinginraw,
    .code.white .line_holder .line-codequality.old-nomappinginraw,
    .code.white .line_holder .line_content.old-nomappinginraw,
    
    .code.dark .line_holder .diff-line-num.new,
    .code.dark .line_holder .line-coverage.new,
    .code.dark .line_holder .line-codequality.new,
    .code.dark .line_holder .line_content.new,
    .code.dark .line_holder .diff-line-num.new-nomappinginraw,
    .code.dark .line_holder .line-coverage.new-nomappinginraw,
    .code.dark .line_holder .line-codequality.new-nomappinginraw,
    .code.dark .line_holder .line_content.new-nomappinginraw,
    
    .code.dark .line_holder .diff-line-num.old,
    .code.dark .line_holder .line-coverage.old,
    .code.dark .line_holder .line-codequality.old,
    .code.dark .line_holder .line_content.old,
    .code.dark .line_holder .diff-line-num.old-nomappinginraw,
    .code.dark .line_holder .line-coverage.old-nomappinginraw,
    .code.dark .line_holder .line-codequality.old-nomappinginraw,
    .code.dark .line_holder .line_content.old-nomappinginraw,

    .code.solarized-light .line_holder .diff-line-num.new,
    .code.solarized-light .line_holder .line-coverage.new,
    .code.solarized-light .line_holder .line-codequality.new,
    .code.solarized-light .line_holder .line_content.new,
    .code.solarized-light .line_holder .diff-line-num.new-nomappinginraw,
    .code.solarized-light .line_holder .line-coverage.new-nomappinginraw,
    .code.solarized-light .line_holder .line-codequality.new-nomappinginraw,
    .code.solarized-light .line_holder .line_content.new-nomappinginraw,
    
    .code.solarized-light .line_holder .diff-line-num.old,
    .code.solarized-light .line_holder .line-coverage.old,
    .code.solarized-light .line_holder .line-codequality.old,
    .code.solarized-light .line_holder .line_content.old,
    .code.solarized-light .line_holder .diff-line-num.old-nomappinginraw,
    .code.solarized-light .line_holder .line-coverage.old-nomappinginraw,
    .code.solarized-light .line_holder .line-codequality.old-nomappinginraw,
    .code.solarized-light .line_holder .line_content.old-nomappinginraw,
 
    .code.solarized-dark .line_holder .diff-line-num.new,
    .code.solarized-dark .line_holder .line-coverage.new,
    .code.solarized-dark .line_holder .line-codequality.new,
    .code.solarized-dark .line_holder .line_content.new,
    .code.solarized-dark .line_holder .diff-line-num.new-nomappinginraw,
    .code.solarized-dark .line_holder .line-coverage.new-nomappinginraw,
    .code.solarized-dark .line_holder .line-codequality.new-nomappinginraw,
    .code.solarized-dark .line_holder .line_content.new-nomappinginraw,
    
    .code.solarized-dark .line_holder .diff-line-num.old,
    .code.solarized-dark .line_holder .line-coverage.old,
    .code.solarized-dark .line_holder .line-codequality.old,
    .code.solarized-dark .line_holder .line_content.old,
    .code.solarized-dark .line_holder .diff-line-num.old-nomappinginraw,
    .code.solarized-dark .line_holder .line-coverage.old-nomappinginraw,
    .code.solarized-dark .line_holder .line-codequality.old-nomappinginraw,
    .code.solarized-dark .line_holder .line_content.old-nomappinginraw,
 
    .code.monokai .line_holder .diff-line-num.new,
    .code.monokai .line_holder .line-coverage.new,
    .code.monokai .line_holder .line-codequality.new,
    .code.monokai .line_holder .line_content.new,
    .code.monokai .line_holder .diff-line-num.new-nomappinginraw,
    .code.monokai .line_holder .line-coverage.new-nomappinginraw,
    .code.monokai .line_holder .line-codequality.new-nomappinginraw,
    .code.monokai .line_holder .line_content.new-nomappinginraw,
    
    .code.monokai .line_holder .diff-line-num.old,
    .code.monokai .line_holder .line-coverage.old,
    .code.monokai .line_holder .line-codequality.old,
    .code.monokai .line_holder .line_content.old,
    .code.monokai .line_holder .diff-line-num.old-nomappinginraw,
    .code.monokai .line_holder .line-coverage.old-nomappinginraw,
    .code.monokai .line_holder .line-codequality.old-nomappinginraw,
    .code.monokai .line_holder .line_content.old-nomappinginraw {
        if !diff-highlight {
            background: none !important;
        }
    }
    
    if all-the-way {
        * {
            font-family: monospace-font !important;
            font-feature-settings: font-features;
        }
    }
}