* {
    box-sizing: border-box;
    font-family: var(--font), sans-serif;
}

:root {
    --nav-w: 200px;
    --font: "Commissioner";
    --corners: 2px;
    --panel-opacity: 100;
    --panel-blur: 0px;
    --wallpaper: url("");
    --wallpaper-fit: cover;
    --wallpaper-repeat: no-repeat;
    --wallpaper-blur: 0px;
    --wallpaper-opacity: 1.0;
    --wallpaper-brightness: 1.0;
}

*::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}
*::-webkit-scrollbar-track {
    background: none;
    border-radius: var(--corners);
    border-right: 1px solid transparent;
    background-clip: padding-box;
}
*::-webkit-scrollbar-thumb {
    background-color: var(--accent);
    border-radius: var(--corners);
    border-right: 1px solid transparent;
    background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover {
    cursor: grab;
}
*::-webkit-scrollbar-thumb:active {
    cursor: grabbing;
}
*::-webkit-scrollbar-corner {
    background: transparent;
}

.spacer {height: 100%; width: 100%;}
.flex-break {flex-basis: 100%;}

i.ti {font-size: 1.2em; margin-top: 0.1em;}

.logo-icon {
    aspect-ratio: 1/1;
    height: 1em;
    background-color: currentColor;
    -webkit-mask: url('/assets/logo.svg') no-repeat center / contain;
    mask: url('/assets/logo.svg') no-repeat center / contain;
}

body {
    background-color: var(--bg-2);
    background-position: center;
    transition: background 0.15s ease;
    color: var(--textb);
    display: flex;
    flex-direction: column;
    margin: 0;
    height: 100vh;
    width: 100vw;
    font-family: var(--font);
    font-size: 0.8rem;
    overflow: hidden;

    &:before {
        content: "";
        position: absolute;
        top: 0; 
        left: 0;
        width: 100vw; 
        height: 100vh;
        background-image: var(--wallpaper);
        background-size: var(--wallpaper-fit);
        background-repeat: var(--wallpaper-repeat);
        background-position: center;
        filter: blur(var(--wallpaper-blur)) brightness(var(--wallpaper-brightness));
        opacity: var(--wallpaper-opacity);
        z-index: -1;
    }

    /* GENERAL/STANDARDIZED ELEM STYLES */
    button {
        background: none;
        border: none;
        color: var(--textm);
        display: flex;
        justify-content: center;
        align-items: center;
        border-radius: var(--corners);
        transition: background 0.15s ease;

        &:hover {
            cursor: pointer;
            background: var(--btn-highlight);
        }

        /* all except for ones inside inputs bc those are slightly off */
        &:not(.cinput button):has(> i.ti:only-child) {
            aspect-ratio: 1/1;
        }
    }

    label:not(:has(input[type="radio"])) {
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    hr {
        background: var(--border-sep);
        border: none;
        height: 1px;
        width: calc(100% - 1rem);
    }

    /* globally fix annoying icons off center */
    span:has(>i.ti) {
        display: flex;
        align-items: center;
        >i.ti {
            margin-top: 0.1em;
        }
    }
    /* END standardized */

    /* MULTI-USE ELEMENT STYLES */
    .cinput {
        display: flex;
        border: 1px solid var(--border-m);
        border-radius: var(--corners);
        transition: border 0.15s ease;
        height: calc(2rem - 8px);

        input {
            background: none;
            border: none;
            color: var(--textb);
            width: 100%;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            padding-left: 4px;
            font-size: 0.95em;

            &:focus {
                border: none;
                outline: none;
            }
        }

        button {
            height: 100%;
        }

        /* shift focus highlight from input element to custom wrapper */
        &:has(input:focus) {
            border-color: var(--accent);
        }
    }

    .modal-container {
        height: 100vh;
        width: 100vw;
        backdrop-filter: brightness(100%) blur(0px);
        position: absolute;
        top: 0;
        left: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        pointer-events: none;
        transition: all 0.15s ease;
        z-index: 100;

        .modal-window {
            background: color-mix(in srgb, var(--bg) calc(var(--panel-opacity) * 1%), transparent);
            backdrop-filter: blur(var(--panel-blur));
            padding: 0.5rem;
            border: 1px solid var(--border-sep);
            border-radius: var(--corners);
            position: relative;
            min-width: 100px;
            min-height: 50px;
            max-width: 50rem;
            max-height: 80vw;
            opacity: 0;
            transform: scale(0.2);
            transition: all 0.15s ease;
            display: flex;
            flex-direction: column;
            gap: 0.5rem;

            >header {
                width: 100%;
                height: 2rem;
                display: flex;
                white-space: nowrap;
                align-items: center;
                gap: 2rem;
                
                h2 {
                    margin: 0;
                }
            }

            main {
                display: flex;
                flex-direction: column;
                gap: 0.5rem;
            }
        }

        &.modal-open {
            backdrop-filter: brightness(60%) blur(2px);
            pointer-events: all;

            .modal-window {
                opacity: 1;
                transform: scale(1);
            }
        }
    }

    #notificationsContainer {
        height: auto;
        display: flex;
        justify-content: flex-end;
        gap: 0.5rem;
        flex-direction: column-reverse;
        width: 20rem;
        position: fixed;
        bottom: 0;
        right: 0;
        padding: 1rem;
        pointer-events: none;
        z-index: 200;
    }
    .notification {
        background: var(--bg);
        border: 1px solid var(--border-m);
        border-radius: var(--corners);
        display: flex;
        flex-direction: column;
        overflow: hidden;
        box-shadow: 0 0 4px #000;
        --nhcol: var(--accent);
        --ndecayt: 3s;
        transform: translateX(calc(100% + 2rem));
        transition: transform 0.3s ease;
        pointer-events: all;

        header {
            width: 100%;
            white-space: nowrap;
            height: 2rem;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 4rem;
            margin-top: 2px;
            position: relative;
            padding: 8px;
            padding-left: 2.5em;
            padding-right: 2px;
            position: relative;

            &:before {
                font-family: 'tabler-icons';
                content: "\eac5";
                font-size: 1.2em;
                margin-top: 0.1em;
                position: absolute;
                left: 8px;
                color: var(--nhcol);
            }

            &:after {
                content: "";
                display: block;
                width: 100%;
                background: var(--nhcol);
                height: 2px;
                position: absolute;
                top: -2px;
                left: 0;
                transform-origin: left;
                transition: width var(--ndecayt) linear;
            }
        }

        >div {
            height: 100%;
            width: 100%;
            padding: 8px;

            span {
                color: var(--textm);
                text-wrap: wrap;
                height: 100%;
                width: 100%;

                a {
                    color: var(--accent);
                    text-decoration: none;

                    &:hover {
                        cursor: pointer;
                        text-decoration: underline;
                    }
                }
            }
        }

        &.n-success {--nhcol: var(--success);
            header:before {content: "\ea67";}}
        &.n-warning {--nhcol: var(--warning);
            header:before {content: "\ea06";}}
        &.n-error {--nhcol: var(--danger);
            header:before {content: "\f80e";}}

        &.displayed {
            transform: translateX(0);

            header:after {
                width: 0%;
            }
        }
        &.gettingRemoved header:after {display: none;}
    }

    /* END multi-use stuff */

    >header {
        display: flex;
        align-items: center;
        width: 100%;
        height: 2rem;
        padding: 4px;
        gap: 4px;
        z-index: 899;

        button {
            border: none;
            background: none;
            border-radius: var(--corners);
            color: var(--textb);
            font-size: 0.8rem;
            display: flex;
            white-space: nowrap;
            flex-shrink: 0;

            &:hover {
                cursor: pointer;
                background: var(--btn-highlight);
            }

            kbd {
                color: var(--textm);
            }
        }

        #versionSpan {
            color: var(--textm);
            margin-right: 1rem;
        }
    }
    
    .header-dropdown {
        position: relative;
        display: flex;

        &:focus-within > div {
            opacity: 1;
            pointer-events: all;
        }

        &:focus-within >button {
            background: var(--btn-highlight);
        }

        >div {
            position: absolute;
            top: 100%;
            background: var(--bg);
            border: 1px solid var(--border-sep);
            border-radius: var(--corners);
            opacity: 0;
            pointer-events: none;
            transition: all 0.15s ease;
            transition-delay: 0.1s;
            box-shadow: 0 0 4px #000;
            z-index: 7;

            button {
                height: 1.4rem;
                width: 100%;
                display: flex;
                gap: 2em;
                justify-content: space-between;
                white-space: nowrap;
            }

            /* sub-dropdowns */
            .header-dropdown {
                >button:after {
                    font-family: 'tabler-icons';
                    content: "\ea61";
                    font-size: 1.2em;
                    margin-top: 0.1em;
                }
                div {
                    top: 0;
                    left: 100%;
                }
            }
        }
    }

    #midsect {
        width: 100%;
        height: calc(100% - 2rem);
        display: flex;
        padding: 0.25rem;
        padding-top: 0;

        >nav, #findandreplace {
            border: 1px solid var(--border-sep);
            border-radius: var(--corners);
        }

        nav {
            width: var(--nav-w);
            background: color-mix(in srgb, var(--bg-2) calc(var(--panel-opacity) * 1%), transparent); /* for panel opacity */
            backdrop-filter: blur(var(--panel-blur));
            display: flex;
            flex-direction: column;
            flex-shrink: 0;
            position: relative;
            z-index: 1;

            #navnoteslistarea {
                overflow-y: scroll;
                height: 100%;
                width: 100%;
            }

            .no-notes {
                color: var(--textm);
                height: auto;
                display: block;
                min-width: 100%;
                max-width: 100%;
                text-align: center;
                overflow-wrap: break-word;
                hyphens: auto;
                padding: 4px 8px;
            }

            .object-name {
                width: 100%;
                white-space: nowrap;
                text-overflow: ellipsis;
                overflow: hidden;

                &:focus {
                    outline: 1px solid var(--accent);
                }
            }

            header {
                width: 100%;
                height: 2rem;
                flex-shrink: 0;
                display: flex;
                align-items: center;
                white-space: nowrap;
                padding: 0 2px;
                padding-left: 8px;
                font-weight: 500;

                button {

                    &:hover {
                        cursor: pointer;
                        background: var(--btn-highlight);
                    }
                }
            }

            .item {
                display: flex;
                align-items: center;
                white-space: nowrap;
                height: 1.8rem;
                padding: 0 0.5rem;
                font-weight: 300;
                position: relative;
                width: 100%;
                border-radius: var(--corners);

                &:hover {
                    cursor: pointer;
                    background: var(--btn-highlight);
                }

                &.current {
                    background: var(--accentm) !important;
                }
            }

            section {

                header {
                    height: 1.8rem;
                    padding: 0 3px;
                    padding-right: 0.5rem;
                    font-weight: 300;
                    background: none;

                    .expanded-indic {
                        color: var(--textm);
                        margin-top: 2px;
                        margin-right: 4px;
                    }
                }

                .itemlist {
                    overflow-y: scroll;
                    height: 0;

                    >*:not(.navsearchresult):not(.no-notes) {
                        padding-left: calc(0.8rem + 8px) !important;
                    }

                    /* automatically display when no items present */
                    &:has(.item) {
                        .no-notes {
                            display: none;
                        }
                    }
                    .item {padding-right: 0 !important;}
                    .item, .navsearchresult {
                        display: flex;
                        align-items: center;
                        white-space: nowrap;
                        height: 1.8rem;
                        padding: 0 4px;
                        font-weight: 300;
                        position: relative;

                        /* child line */
                        &.item:before {
                            content: "";
                            display: block;
                            position: absolute;
                            top: 0;
                            left: calc(0.4rem + 4px);
                            height: 100%;
                            width: 1px;
                            background: var(--border-sep);
                            transition: background 0.15s ease;
                        }

                        /* darken for better visibility/contrast */
                        &:hover:before {
                            background: var(--bg-2);
                        }

                        /* lil unsaved dot */
                        &.unsaved:after {
                            content: "";
                            display: block;
                            height: 5px;
                            width: 5px;
                            border-radius: 50%;
                            background: var(--unsaved);
                            position: absolute;
                            left: calc(0.4rem + 4px - 6px);
                            border: 4px solid var(--bg-2);
                            transition: border 0.15s ease;
                        }

                        /* not using a mask for this one gng */
                        &.unsaved:hover:after {
                            border-color: var(--btn-highlight);
                        }
                    }

                    .navsearchresult span {
                        width: 100%;
                        overflow: hidden;
                        white-space: nowrap;
                        text-overflow: ellipsis;
                    }
                }

                header, .itemlist .item, .navsearchresult {
                    border-radius: var(--corners);
                    transition: background 0.15s ease;

                    &:hover {
                        cursor: pointer;
                        background: var(--btn-highlight);
                    }

                    &:has(>button:hover) {
                        background: none;
                        &:before {background: var(--border-sep);}
                        &:after {border-color: var(--bg-2) !important;}
                    }
                }

                &.expanded {
                    header .expanded-indic {
                        transform: rotate(90deg);
                    }

                    .itemlist {
                        height: auto;
                    }
                }
            }

            section#navsearch {
                display: none;

                header {
                    background: transparent; cursor: default;
                    height: calc(2rem - 8px);
                    padding: 0 8px;
                }
                .cinput {
                    height: 100%; width: 100%;
                }
                #navsearchresults {
                    height: auto;
                    max-height: 5.4rem;
                    overflow-y: scroll;

                    .navsearchresult {
                        padding: 0 8px;
                    }

                    >span {
                        width: 100%;
                        text-align: center;
                        color: var(--textm);
                    }
                }

                &.shown {
                    display: block;
                }
            }
        }

        #navresize {
            border: 1px solid transparent;
            width: 4px;
            border-radius: var(--corners);
            transition: background 0.1s, filter 0.2s;
            position: relative;
            flex-shrink: 0;
            z-index: 99;

            &:after {
                font-family: 'tabler-icons';
                content: "\eb1d";
                display: block;
                opacity: 0;
                color: var(--bg);
                background: var(--accent);
                border-radius: var(--corners);
                aspect-ratio: 1/1;
                z-index: 99;
                position: absolute;
                top: 50%;
                left: 50%;
                transform: translate(-50%, -50%) rotate(90deg);
                font-size: 1.2rem;
                box-shadow: 0 0 10px var(--accent);
                transition: opacity 0.1s ease;
                pointer-events: none;
            }

            &:hover, &.inuse {
                transition-delay: 0.5s;
                cursor: col-resize;
                background: var(--accent);
                filter: drop-shadow(0 0 16px var(--accent));

                &:after {
                    transition-delay: 0.5s;
                    opacity: 1;
                }
            }
        }

        main.editor {
            display: flex;
            flex-direction: column;
            gap: 0.25rem;
            width: 100%;
            max-width: auto;
            overflow: visible;
            position: relative;
            min-width: 0;

            #workspace {
                display: flex;
                flex-direction: column;
                flex-grow: 1;
                min-height: 0;
                gap: 0.25rem;
                overflow: visible;

                #editorWrapper {
                    height: 100%;
                    width: 100%;
                    background: none;
                    border: none;
                    color: var(--textb);
                    font-family: inherit;
                    display: none;
                    overflow: hidden;

                    &:focus {
                        outline: none;
                        border: none;
                    }

                    &:empty:before {
                        content: attr(data-placeholder);
                        color: var(--textm);
                        pointer-events: none;
                    }
                }

                #noNoteOpenOverlay {
                    height: 100%;
                    width: 100%;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    flex-direction: column;
                    color: var(--textm);
                    padding: 2rem;
                    text-align: center;
                    gap: 2rem;
                    background-color: color-mix(in srgb, var(--bg) calc(var(--panel-opacity) * 1%), transparent);
                    background-image: radial-gradient(circle at center, var(--bg) 0, transparent 100%), radial-gradient(circle at center, var(--bg-3) 1px, transparent 0);
                    background-size: 100% 100%, 1rem 1rem;
                    background-repeat: round;
                    border: 1px solid var(--border-sep);
                    border-radius: var(--corners);

                    .logo-icon {
                        color: var(--btn-highlight);
                        font-size: 20rem;
                    }
                }

                &.noteopen {
                    #editorWrapper {display: flex;}
                    #noNoteOpenOverlay {display: none;}
                }

                #wordCounter {
                    display: none;
                    flex-direction: column;
                    background: var(--bg);
                    padding: 0.5rem;
                    border: 1px solid var(--border-m);
                    border-radius: var(--corners);
                    position: absolute;
                    bottom: 0.5rem;
                    right: 0.5rem;
                    gap: 0.25rem;

                    &.open {display: flex;}

                    header {
                        display: flex;
                        align-items: center;
                        gap: 2rem;
                        width: 100%;
                        justify-content: space-between;

                        button {
                            padding: 0.25rem;
                        }
                    }

                    >span {
                        display: flex;
                        width: 100%;
                        justify-content: space-between;
                        gap: 1rem;
                    }
                }
            }

            #findandreplace {
                height: 4rem;
                background: var(--bg-2);
                padding: 4px;
                width: 100%;
                display: flex;
                gap: 4px;

                >div {
                    height: 100%;
                    display: flex;
                    flex-direction: column;
                    gap: 4px;

                    >div {
                        height: 50%;
                        display: flex;
                        align-items: center;

                        >button {
                            height: 100%;
                        }
                    }

                    &:first-child {
                        flex-grow: 1;
                    }
                }

                .cinput {
                    height: 100%;
                    width: 100%;
                }
            }
        }
    }

    &:has(#text-area:focus) {
        background: var(--bg-2);
    }
}

#ctxmenu {
    position: absolute;
    top: 0; left: 0;
    z-index: 999;
    background: var(--bg);
    border: 1px solid var(--border-sep);
    border-radius: var(--corners);
    display: none;
    flex-direction: column;

    &.shown {display: flex;}

    button {
        width: 100%;
        height: 1.6rem;
        background: none;
        border: none;
        border-radius: var(--corners);
        color: var(--textm);
        display: flex;
        align-items: center;
        gap: 0.5rem;
        white-space: nowrap;
        color: var(--textb);
        justify-content: flex-start;

        i, kbd {
            opacity: 60%;
        }

        kbd {
            margin-left: auto;
        }

        &:hover {
            cursor: pointer;
            background: var(--btn-highlight);
        }

        &.danger {
            color: var(--danger);
        }
    }
}


#modal-settings {
    .modal-window {
        padding-bottom: 0;
        padding-right: 0;
        height: 80vh;
        max-height: 35rem;
        width: 80vw;
        max-width: 50rem;
        display: flex;

        >header {
            padding-right: 0.5em;
        }

        main {
            display: flex;
            flex-direction: row;
            height: calc(100% - 2.5rem); /* fts */
            width: 100%;

            nav {
                border-right: 1px solid var(--border-sep);
                padding-right: 8px;
                display: flex;
                flex-direction: column;
                padding-bottom: 8px;
                width: 16rem;
                max-width: 12rem;
                flex-grow: 0;
                flex-shrink: 0;

                #settingsPageButtons {
                    overflow-y: scroll;
                }

                .cinput {
                    width: 100%;
                }

                >div {
                    width: 100%;
                    margin-top: 8px;

                    button {
                        width: 100%;
                        display: flex;
                        align-items: center;
                        justify-content: flex-start;
                        gap: 8px;
                        height: 1.5rem;
                        white-space: nowrap;

                        span {
                            white-space: nowrap;
                            text-overflow: ellipsis;
                            overflow: hidden;
                        }

                        i.ti {
                            margin-top: 0.2em;
                        }

                        &.current {
                            color: var(--textb);
                            background: var(--accentm);
                        }

                        &.danger {
                            color: var(--danger);
                            background: color-mix(in srgb, var(--danger) 20%, transparent);

                            &.current {
                                background: var(--accentm);
                                color: var(--textb);
                            }
                        }
                    }
                }
            }

            #settings-pages {
                padding: 0.5rem 0;
                width: 100%;
                padding-right: 0.5rem;
                overflow-y: scroll;

                /* individual page */
                >div {
                    display: none;
                    height: 100%;
                    width: 100%;

                    &.page-current {
                        display: block;
                    }
                }

                @keyframes labelFlash {
                    0% {background: transparent;}
                    25% {background: var(--accentm);}
                    50% {background: transparent;}
                    75% {background: var(--accentm);}
                    100% {background: transparent;}
                }

                section {
                    display: flex;
                    flex-direction: column;
                    gap: 0.5rem;

                    &:not(:first-child) {
                        margin-top: 1rem;
                    }

                    &:last-child {
                        padding-bottom: 1rem;
                    }

                    h2 {
                        width: 100%;
                        height: 2em;
                        border-bottom: 1px solid var(--border-sep);
                        margin: 0;
                        margin-bottom: 0.5rem;
                        display: flex;
                        gap: 0.25rem;

                        span {
                            width: 100%;
                        }

                        button {
                            flex-grow: 0;
                            white-space: nowrap;
                            height: 2rem;
                            background: var(--bg-3);

                            &:hover {
                                background: var(--btn-highlight);
                            }
                        }
                    }
                    
                    h3 {
                        border-bottom: 1px solid var(--border-sep);
                        height: 1.5rem;
                        margin: 0;
                        margin-top: 0.25rem;
                        width: 100%;
                    }

                    .label-description {
                        margin-top: 0.25rem;
                        color: var(--textm);
                        font-size: 0.9em;
                    }


                    .storageDisplay {
                        background: var(--bg-2);
                        padding: 1rem;
                        border-radius: var(--corners);
                        display: flex;
                        gap: 1rem;

                        >div {
                            width: 100%;
                            display: flex;
                            flex-direction: column;

                            &:has(.piChart) {
                                align-items: center;
                            }

                            .buttons {
                                margin-top: auto;
                                display: flex;
                                width: 100%;
                                justify-content: center;
                                gap: 0.5rem;

                                button {
                                    background: var(--bg-3);
                                    padding: 0.5rem 0.75rem;

                                    &[disabled] {
                                        opacity: 0.6;
                                        cursor: not-allowed;
                                    }

                                    &:hover:not([disabled]) {
                                        background: var(--btn-highlight);
                                    }
                                }
                            }

                            .info {
                                line-height: 0.75rem;
                                >span {
                                    display: flex;
                                    justify-content: space-between;
                                }
                            }
                        }

                        .piChart {
                            --donut: 40%;
                            height: 10rem;
                            width: 10rem;
                            border-radius: 50%;
                            mask: radial-gradient(transparent var(--donut), black var(--donut))
                        }

                        ul {
                            margin-top: 1rem;
                            list-style: none;
                            padding-left: 1.5em;
                            display: flex;
                            flex-direction: column;
                            gap: 0.5rem;
                            width: 100%;
                            padding: 0 10%;

                            >.size {
                                color: var(--textm);
                                text-align: center;
                            }

                            li {
                                position: relative;
                                display: flex;
                                justify-content: space-between;
                                width: 100%;
                                gap: 1rem;
                                white-space: nowrap;
                                padding-left: 1.5em;

                                .size {
                                    color: var(--textm);
                                }
                            }

                            li::before {
                                content: "";
                                display: block;
                                height: 1em;
                                width: 1em;
                                border-radius: 50%;
                                background: var(--bullet-color);
                                position: absolute;
                                left: 0;
                                top: 0.25em;
                            }
                        }
                    }
                }
            }
        }
    }
}

#modal-deleteconfirmation {

    #deleteconfirmationBtn {
        color: var(--danger);
    }
    main>div {
        width: 100%;
        display: flex;
        gap: 0.25rem;

        button {
            padding: 0.25rem;
            width: 100%;
        }
    }
}

/* NAV DRAGGIN STUFF, cant be bothered to scope it atp */
.treespacer {
    height: 4rem;
    width: 100%;
}

.node {
    &.item {
        border: solid transparent;
        border-width: 1px 0;
    }

    &:active {
        cursor: grabbing;
    }

    &.dragging {
        opacity: 0.5;
        outline: 1px dashed var(--border-sep);
    }

    &.drag-sort-below {
        border-bottom: 1px dashed var(--accent);
    }

    &.drag-sort-above {
        border-top: 1px dashed var(--accent);
    }

    &.drag-nest-inside {
        
        header {
            outline: 1px dashed var(--accent);
            outline-offset: -1px;
        }
    }
}

.drag-root-active {
    outline: 1px dashed var(--accent);
}