/* ==UserStyle==
@name         GitHub Fixed Header
@version      1.3.1
@description  Add a pinned header on GitHub
@namespace    https://github.com/moosedookie
@author       moosedookie
@license      CC-BY-SA-4.0
@homepageURL  https://github.com/moosedookie/CustomCSS/blob/master/GitHubFixedHeader
@supportURL   https://github.com/moosedookie/CustomCSS/issues
@updateURL    https://moosedookie.github.io/CustomCSS/GitHubFixedHeader/githubfixedheader.user.css
@preprocessor default
==/UserStyle== */
/*       __  ___                          */
/*      /  |/  /___  ____  ________       */
/*     / /|_/ / __ \/ __ \/ ___/ _ \      */
/*    / /  / / /_/ / /_/ (__  )  __/      */
/*   /_/  /_/\____/\____/____/\___/  _    */
/*           / __ \____  ____  / /__(_)__ */
/*          / / / / __ \/ __ \/ //_/ / _ \*/
/*         / /_/ / /_/ / /_/ / ,< / /  __/*/
/*        /_____/\____/\____/_/|_/_/\___/ */
@-moz-document regexp("^https?://((gist|guides|help|raw|status|developer)\\.)?github\\.com/((?!generated_pages/preview).)*$") {

    /* AGENT_SHEET */
    :root {
        --height: 104px;
        --secondary-height: 40px;
    }

    body:not(.project-full-screen),
    /* .is-stuck = discussion sidebar & https://github.com/integrations > Category */
    body.logged-out:not(.f4),
    body.session-authentication {
        padding-top: var(--height) !important;
    }

    .pr-toolbar.is-stuck .diffbar {
        background: #ddd;
        border-left: 1px solid #ddd;
        border-right: 1px solid #ddd;
        padding: 8px;
    }

    .gh-header .gh-header-sticky.is-stuck+.gh-header-shadow {
        top: var(--height) !important;
    }

    /* Fix code block shift when sticky */
    .highlight[style*="overflow-x"] {
        overflow-x: unset !important;
    }

    /* Fix github.com/orgs/:org/people "Select all" sub-header */
    .table-list-header.table-list-header-next.js-sticky.is-stuck {
        height: calc(var(--height) + 50px);
    }

    /* Fix breaking floats */
    .file-header:before {
        clear: both;
    }

    /* Fixes other misalignment of headers */
    .diff-view .file-header {
        height: var(--secondary-height) !important;
    }

    .header-logged-out {
        height: var(--height) !important;
    }

    .is-stuck~#files .file-actions,
    .is-stuck~#files .file-info {
        position: relative;
    }

    /* make diff file header sticky under the toolbar & main header;
   * modified from Refined GitHub extension */
    @supports (position: sticky) {
        #files .file-header {
            position: sticky !important;
            position: -webkit-sticky !important;
            top: 110px !important;
            width: 100% !important;
            height: 40px !important;
            z-index: 6 !important;
        }

        #files .file-header.has-open-dropdown {
            z-index: 10 !important;
        }
    }

    /* user page bar now appears under fixed header */
    .user-profile-sticky-bar:after,
    div.discussion-sidebar,
    div.blog-aside {
        top: var(--height) !important;
    }

    #toc+#files .file-header {
        top: var(--height) !important;
    }

    /* move loading bar into view */
    .pjax-loader-bar,
    .pjax-loader-bar .progress {
        z-index: 1001 !important;
    }

    /* move anchors below fixed header */
    .accessibility-aid,
    a.anchor {
        padding-top: 55px !important;
        margin-top: -55px !important;
        pointer-events: none;
        /* anchors on help.github.com */
        min-width: 5px !important;
        display: inline-block !important;
    }

    a.anchor svg,
    /* spans used on help.github.com */
    a.anchor span {
        pointer-events: all !important;
        min-width: 20px !important;
    }

    /* make personal, blog, explore, etc match logged in height */
    .site-header {
        padding-top: 10px !important;
        padding-bottom: 10px !important;
    }

    /* page indicator on personal, open source, business & explore pages */
    .site-header-nav-main .nav-item:after {
        bottom: -10px !important;
    }

    /* .main-content? */
    #js-flash-container+.main-content {
        margin-top: 0 !important;
    }

    /* .header = logged-in */
    body.logged-in .header,
    /* .site-header = not-logged-in (removed 22 Aug 2017) */
    .site-header,
    /* .Header = (changed from .header) both logged in and not,
   * added on 22 Aug 2017
   */
    .Header,
    /* .Header => .Header-old (changed ~18 March 2019),
   * added .js-header-wrapper because it's the parent of .Header-old
   */
    .js-header-wrapper,
    .Header-old,
    /* #com #header = help.github.com */
    #com #header {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        z-index: 1000 !important;
    }

    /*
   * GitHub Notifications Dropdown userscript tweak
   * https://openuserjs.org/scripts/joeytwiddle/Github_Notifications_Dropdown
   */
    .notifications-dropdown,
    .Popover {
        z-index: 1001 !important;
    }

    /* Octotree side panel open - see #6 */
    .octotree-show .header .container,
    .octotree-show .Header .container {
        margin-left: auto !important;
    }
}

@-moz-document domain("gist.github.com") {

    /* gists don't have a secondary header */
    @supports (position: sticky) {
        #files .file-header {
            top: var(--height) !important;
        }
    }
}