/** Global styles **/

/* Base */

:root {
    --background: #ebe9e8;
    --background-secondary: #ffffff;
    --background-accent: #d9d9d9;
    --primary: #5B442D;
    --secondary: #6e5133;
    --text-secondary: #FFFFFF;
    --action-color: #5c462e;
    --accent-color: #6c6c6c;
    --accent-action-color: #919191;

    --highlight: var(--secondary);
    --text-highlight: var(--text-secondary);

    --main-content-width: 1250px;

    color-scheme: light; /* remove if darktheme added */

    font-family: "Poppins", sans-serif;
    font-weight: 400;
    font-style: normal;

    background-color: var(--background);
}

:placeholder-shown {
    text-overflow: ellipsis;
}

.anchor {
    color: lightgray;
    font-weight: bold;
    margin-inline: .35em;
}

.anchor:hover, 
:is(:hover, :focus, :focus-visible, :focus-within) > .anchor {
    color: darkgray;
}


body > main {
    a {
        color: var(--secondary);
    }

    a:is(:hover, :focus, :focus-within, :focus-visible) {
        text-decoration: underline;
    }

    a:active {
        color: var(--action-color);
    }
}

/* ::selection {
    background-color: var(--secondary);
    color: var(--text-secondary);
} */

body > main {
    display: grid;
    grid-template-columns: 0 1fr minmax(0, var(--main-content-width)) 1fr;
    min-height: 100dvh;
    transition: all 350ms ease-in-out;

    &:has(> #selector-sidebar #sidebar-content[open]) {
        grid-template-columns: 300px 2rem 1fr 3rem;
    }
}

body.has-sidebar > main {
    grid-template-columns: 2.5rem 1fr minmax(0, var(--main-content-width)) 1fr;
}

#main-content {
    grid-column: 3;
    background: var(--background-secondary);
    padding: 20px 25px;
}

/* magic number */
@media screen and (max-width: 1147px) {
    html:has(#sidebar-content[open]),
    body:has(#sidebar-content[open]) {
        overflow: hidden;
        max-height: 100dvh;
    }

    body > main#content {
        grid-template-columns: 0 1fr 0;

        #main-content {
            grid-column: 2;
        }
    }

    body.has-sidebar > main#content:has(#sidebar-content[open]) {
        grid-template-columns: min(300px, calc(100dvw - 2rem)) 1fr 0;
        width: calc(100% + min(300px, 100dvw - 2rem));
        margin-left: calc(min(300px, 100dvw - 2rem) * -1);
        translate: min(300px, calc(100dvw - 2rem));
        transition: translate 350ms ease-in-out;
    }

    #selector-sidebar {
        display: none;
    }
}

/* day vote selector sidebar */

#selector-sidebar {
    /* sidebar controls */

    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: scroll;
    background-color: #d9d9d9;
    border-inline-end: 1px solid white;
    
    &:has(#sidebar-content[open]) {
        display: flex;
        justify-content: start;

        /* magic number */
        @media screen and (max-width: 1147px) {
            max-height: calc(100dvh - 120px);
            box-shadow: inset -3px 0px 3px 0px darkgray;
        }

        #sidebar-toggle {
            display: flex;
            align-items: center;
            justify-content: space-between;
            width: 100%;
            padding: .5rem .75rem;
            border-bottom: 1px solid white;
        
            .open {
                display: none;
            }
        }
    }

    &:has(#sidebar-content:not([open])) {
        padding-top: 1rem;

        #sidebar-toggle {
            @media screen and (min-width: 1000px) {
                text-orientation: mixed;
                writing-mode: sideways-lr;
                flex-grow: 1;
                text-align: end;
            }

            .close {
                display: none;
            }
        }
    }

    #sidebar-content {
        position: static;
        background: transparent;
        border: none;
    }

    #sidebar-toggle {
        /* button reset */
        appearance: none;
        background: transparent;
        border: none;

        /* styles */
        text-transform: uppercase;
        font-weight: 600;
        color: var(--accent-color);
        cursor: pointer;
    
        > span:first-child {
            padding-inline-end: .5rem;
        }
    }

    /* sidebar content */

    .back {
        margin: 0;
        font-weight: bold;
        display: flex;
        align-items: center;
        color: var(--accent-color);

        i.fa-solid {
            font-size: 1rem;
        }
    }

    .top-control {
        width: 100%;
        padding: .75rem;
        border-bottom: 1px solid white;
    
    
        h2 {
            margin: .75rem 0 .25rem
        }
    }

    .sidebar-filters {
        display: flex;
        align-items: center;
        justify-content: space-between;
    
        width: 100%;
        padding: .25rem .75rem;
        border-block-end: 1px solid white;
    
        font-size: .9rem;
        color: var(--accent-color);
        font-weight: 600;
    }

    .votes {
        display: flex;
        flex-direction: column;
        gap: .5rem;
        width: 100%;
        padding: .75rem .5rem;
    }
}

article#szavazas > h1 {
    font-weight: bold;

    &::before {
        content: "Szavazás ";
        color: var(--accent-color);
    }
}

#mobile-sidebar-toggle {
    display: none;
}

@media screen and (max-width: 1000px) {
    header#header:has(+ main#content > #selector-sidebar) #mobile-sidebar-toggle {
        display: block;
        cursor: pointer;

        button {
            background: none;
            border: none;
            color: inherit;
        }
    }
}


/* pretty-table Styles */

:has(> table.pretty-table) {
    overflow-x: auto;
}

table.pretty-table {
    width: 100%;
    border-collapse: collapse;

    > tr > th, 
    > tr > td, 
    > * > tr > th, 
    > * > tr > td {
       padding: 10px;
    }

    thead {
        font-weight: 600;
    }
    
    tbody tr:hover, 
    tbody tr:focus {
        background: #dfdfdf !important;
    }
    
    th, 
    td {
        border: 2px solid #fff;
    }
    
    > * > tr > th {
        background: var(--primary);
        color: #fff;
    }
    
    tbody tr:nth-child(even) {
        background: #f5f5f5;
    }
    
    tbody tr:nth-child(odd) {
        background: #e9edef;
    }
}

/* sortable table styles */
table.sortable {
    thead {
        tr {
            user-select: none;

            th {
                cursor: pointer; 
                white-space: nowrap;
            }
        }
    }

    .sort-icon {
        margin-left: 0.25rem; 
        font-size: 0.85em; 
        color: #888;
    }
}

/* tabs */

.tab-controls {
    position: relative;
    max-width: 100%;
    padding-inline-start: .5rem;
    padding-block-end: 2px;
    flex-grow: 1;
    
    .tab-controls-tabs {
        display: flex;
        gap: 1.5rem;
        overflow-x: scroll;
        scrollbar-width: none;

        &::after {
            display: block;
            content: '';
            min-width: 2rem;
            position: sticky;
            right: -1px;
            bottom: 0;
            background: linear-gradient(to right, transparent, white);
        }
    }

    &::before {
        content: '';
        position: absolute;
        width: 100%;
        bottom: 3px;
        left: 0;
        height: 2px;
        background: #d9d6d3;
        right: 0;
        z-index: 1;
    }


    .tab-control {
        position: relative;
        background: none;
        border: none;
        padding: 8px 0px;
        cursor: pointer;

        &.active {
            margin-bottom: 4px;

            &::after {
                content: '';
                position: absolute;
                height: 3px;
                bottom: 0px;
                left: 0;
                right: 0;
                background: black;
                margin-bottom: -4px;
                z-index: 2;
            }
        }
    }
}

.pagefind-metadata {
    visibility: hidden;
    position: absolute;
    z-index: -10;
}

/* temp */
.search-dashboard {
    max-width: 100%;
}

@media screen and (max-width: 1000px) {
    .search-dashboard {
        max-width: 100dvw;
    }
}