#site-header {
    display: grid;
}

#site-header-marks {
    display: flex;
    height: 100%;
    width: 100%;
    justify-content: start;
}

#site-header-marks a {
    display: flex;
    height: 100%;

    // Note that the wordmark's underline is drawn here, and is not a part of the SVG file.
    border-bottom: 3px solid var(--8);
    box-sizing: border-box;
}

#site-header-wordmark {
    width: 100%;
    @media (prefers-color-scheme: dark) {
        filter: invert(1);
    }
}

.searchButton {
    position: absolute;
    right: var(--space);
    top: 50%;
    transform: translate(0, -50%);
    background: none;
    cursor: pointer;
    padding: var(--space);
    width: calc(var(--space) * 4);
    z-index: 6;
    border-left: 1px solid var(--blue-1);
    @media (prefers-color-scheme: dark) {
        border-left: 1px solid var(--blue-7);
    }
}

#site-header-search-icon {
    grid-row: pagestart;
    position: absolute;
    top: calc(var(--space) * 1.5);
    right: var(--space);
    color: var(--0);
    @media (prefers-color-scheme: dark) {
        color: var(--8);
    }
}

#site-header-search-bar {
    padding: var(--space);
    height: 100%;
    font-size: calc(var(--space) * 2);
    border-bottom: 3px solid var(--8);
    width: 100%;
}

#site-header-search-bar::placeholder {
    color: var(--blue-1);
    font-weight: bold;
    font-family: 'Libre Caslon';
    @media (prefers-color-scheme: dark) {
        color: var(--blue-7);
    }
}

#site-header-search-bar:focus::placeholder {
    color: var(--blue-4);
}

#site-header-search-bar:hover {
    box-shadow: inset 0 0 6px 1px var(--blue-6), 0 0 3px .1px var(--blue-7);
    border-top: 2px solid var(--blue-6);
}

#site-header-search-bar:focus {
    outline: 3px solid var(--blue-6);
    background-color: var(--0);
    background-image: linear-gradient(90deg, var(--0), var(--blue-1) 80%);
    border-top: 2px solid var(--blue-7);
    box-shadow: none;
    @media (prefers-color-scheme: dark) {
        outline: 3px solid var(--blue-4);
        background-color: var(--8);
        background-image: none;
    }
}

#site-header-search-bar:focus:hover {
    box-shadow: inset 0 0 6px 1px var(--blue-5);
}

.site-header-user {
    position: relative;
    margin-left: auto;
}

.site-header-user button {
    display: block;
    height: calc(100% - 3px);
    text-wrap: nowrap;
    padding-left: var(--space);
    padding-right: var(--space);
    border-bottom: 3px solid var(--8);
    color: var(--8);
}

.site-header-user button:hover {
    box-shadow: inset 0 0 3px 3px var(--blue-5);
}

.site-header-user:focus-within button {
    background-image: none;
    background-color: var(--blue-4);
    box-shadow: 0 0 2px .5px var(--blue-7);
    @media (prefers-color-scheme: dark) {
        box-shadow: 0 0 2px .5px var(--0);
        background-color: var(--blue-3);
    }
        
}

#site-header-user-links ul > .mw-list-item a {
    color: var(--blue-7);
}

.color-scheme-toggle {
    padding: var(--space);
    width: calc(var(--space) * 3);

    filter: saturate(0%) brightness(0) contrast(10);

    @media (prefers-color-scheme: dark) {
        filter: saturate(0%) brightness(1) contrast(10);
    }
}

@media (min-width: 1201px) {

    #site-header {
        grid-column: navstart / -2;
        grid-row: topstart;
        grid-template-columns: subgrid;
        grid-template-rows: subgrid;
        margin-top: var(--space);
    }

    #site-header-search form {
        height: 100%;
    }

    #site-header-marks {
        grid-column: 1;
        grid-row: 1;
        align-items: flex-start;
    }


    #site-header-marks {
        grid-row: 1;
    }

    #site-header-search, #site-header-search-bar {
        grid-column: pagestart / menugap;
        width: 100%;
        position: relative;
    }

    .site-header-user {
        grid-column: menustart / pageend;
    }

    #site-header-container {
        grid-column: pagestart;
        display: flex;
        gap: calc(var(--space) * 2);
    }

}

@media (max-width: 1200px) {

    #site-header {
        grid-column: 1;
        grid-row: topstart / -1;
        grid-template-columns:
            [marks] 1fr
            [toggle] auto
            [menu] auto
        ;
        grid-template-rows: 3em auto;
        row-gap: var(--space);
        column-gap: var(--space);
        margin: var(--space);
    }


    #site-header-container {
        grid-row: 2;
        grid-column: 1 / -1;
    }

    .site-header-user {
        grid-column: 3;
        grid-row: 1;
    }

    #color-scheme-toggle {
        grid-column: 2;
    }

    #site-header-search {
        position: sticky;
        align-self: flex-start;
        top: var(--space);
        z-index: 6;
    }

    #site-header-search {
        top: var(--space);
        grid-row: 2;
    }

}