:root {
    --background-color: #2d3131;
    --page-button-width: 35px;

    --dark-background-color: #12110D;
    --dark-overlay-color: #34343B;
    --dark-shadow-color: #333333;
    --dark-tile-color: #47474B;
}

* {
    box-sizing: border-box;
    font-family: Helvetica Neue,
    Helvetica,
    Arial,
    sans-serif;
}

html,
body {
    margin: 0;
    padding: 0;
    background: var(--dark-background-color);
    color: #f0f6fc;

    /* remove scroll bar for Reader */
    overflow-y: scroll;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* Internet Explorer 10+ */

    ::-webkit-scrollbar {
        display: none; /* Safari and Chrome */
    }
}

h2, p {
    text-align: center;
}

#wrapper {
    width: 70%;
    margin: auto;
}

/* The Close Button */
.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close:hover,
.close:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

.flexbox {
    display: flex;
}

#HomeNavBar {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    align-items: baseline;

    background-color: var(--dark-overlay-color);
    box-shadow: 0 0 10px #333333;
    padding: 10px;
    font-size: 24pt;


    div.nav-buttons {
        display: flex;
        font-size: 14pt;

        div {
            margin-inline: 10px;

            svg {
                height: 1em;
                padding-right: 5px;
                vertical-align: -10%;
            }
        }

        div:hover {
            cursor: pointer;
            color: #bbdefb;
        }
    }

    div.title {
        text-align: center;
    }

    div.nav-buttons-right {
        display: flex;
        margin: auto 0 0 auto;

        .help {
            padding-bottom: 2px;
        }

        a {
            display: flex;
            height: 1em;
            margin-inline: 10px;
            color: #f0f6fc;
            cursor: pointer;
            text-decoration: none;

            svg {
                height: 32px;
                transform: translateY(-0.4em);
            }
        }
    }
}

#HomeGrid {
    min-height: calc(100vh - 58px); /* screen height minus height of nav bar */
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);

    #GalleryContainer {
        grid-column: 2 / 3;
    }
}

#Gallery {
    display: flex;
    flex-wrap: wrap;
    margin: auto;
    width: 90%;

    .volume-item {
        background-color: var(--dark-tile-color);
        border: 2px solid lightslategray;
        box-shadow: 0 0 12px #444444;
        padding: 10px;
        margin: 5px;
        width: 280px;

        a, a:link, a:visited, a:hover, a:active a:any-link, & {
            /* remove styling on hyperlinks */
            color: inherit;
            text-decoration: inherit;
            font-weight: inherit;

            img {
                height: 364px;
                width: 256px;
                object-fit: fill;
            }

            button {
                height: 2em;

                &.download {
                    width: 65%;
                }

                &.delete {
                    width: 35%;
                }
            }
        }

        p[contenteditable="true"] {
            outline: 1px auto Highlight;
        }
    }
}

#Modal {
    position: fixed; /* Stay in place */
    z-index: 1; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgb(0, 0, 0); /* Fallback color */
    background-color: rgba(0, 0, 0, 0.6); /* Black w/ opacity */

    .modal-content {
        background-color: var(--background-color);
        margin: 100px auto; /* centered and offset from the top */
        padding: 20px;
        border: 2px solid #888;
        width: 65%; /* Could be more or less, depending on screen size */

        #storage-warning {
            position: relative;
            top: -2em;
            margin: -22px;
            padding: 5px;

            background-color: cadetblue;
            border: 2px solid #888;
            text-align: center;
        }

        .close-symbol {
            float: right;
            width: 12px;
            cursor: pointer;
            margin-inline: -5px;
        }

        .modal-title {
            font-size: 2rem;
            margin-block: 0.8em;
            text-align: center;
        }

        .modal-subtitle {
            font-size: 1.4rem;
            margin-block: 0.8em;
            text-align: center !important;
        }

        .help-content > p {
            text-align: left;
            white-space: pre-line;
            word-wrap: break-word;
        }

        .modal-note {
            font-size: 0.8em;
            margin: 20px;
            text-align: center;
        }

        a, a:link, a:visited, a:hover, a:active a:any-link {
            color: #bbdefb;
        }

        #drop-container {
            padding: 4rem;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            background: #3d4141;
            border: 1px dashed #fcfcfc;
            border-radius: 1rem;
            cursor: pointer;

            p {
                margin-block: 5px;
            }
        }

        input#file-upload {
            height: 0;
            visibility: hidden;
        }

        #UploadPreview {
            display: flex;
            flex-wrap: wrap;
            margin: auto;
            width: 90%;

            .preview-item {
                display: flex;
                flex-direction: column;
                justify-content: center;
                padding: 10px;
                margin: 5px;
                border: 2px solid lightslategray;

                img {
                    height: 273px;
                    width: 193px;
                    object-fit: fill;
                }
            }
        }
    }
}

#ReaderGrid {
    height: 100vh;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;

    #Reader {
        grid-column: 2 / 3;
        grid-row: 1 / 2;
        position: relative; /* essential for overflow: hidden to work correctly */
        overflow: hidden;
        padding: 10px;

        display: flex;
        flex-direction: row-reverse;
        align-items: center;
        justify-content: center;

        &:focus {
            outline: none;
        }

        .pagebar {
            height: 100%;
            width: var(--page-button-width);

            button {
                height: 100%;
                width: 100%;
                background-color: #222216;
                border: 0;
                box-shadow: 0 0 0 1px #222222;
                filter: brightness(125%);
                outline: 0;
                padding: 0;
                transition: 0.3s filter ease, 0.3s -webkit-filter ease;

                &:hover {
                    filter: brightness(150%);
                }
            }
        }

        .pagebar:last-of-type {
            transform: scale(-1, 1);
        }

        .reader-image {
            max-height: 100%;
            max-width: calc(50% - var(--page-button-width));

            -webkit-user-select: none;
            user-select: none;

            &:only-of-type {
                /* if only displaying a single page, make it full width */
                max-width: 100%;
            }
        }

        &.editable .reader-image {
            cursor: crosshair;
        }

        .new-ocr-block {
            position: fixed;
            cursor: crosshair;
            background-color: lightgray;
            outline: 1px solid darkgray;
            opacity: 50%;
            pointer-events: none;
        }

        .ocr-block {
            position: fixed;
            color: black;

            > p {
                background-color: white;
                display: table;
                margin: 0;
                opacity: 0;
                padding-inline: 2px;
                white-space: nowrap;
            }

            &:hover > p {
                opacity: 1
            }
        }

        &.editable .ocr-block {
            &:focus > p {
                opacity: 1
            }

            &[contenteditable="true"] {
                outline: 2px solid red;
            }

            &:not([contenteditable="true"]) {
                cursor: pointer;
                outline: 2px ridge darkgray;
                user-select: none;

                &:focus {
                    cursor: move;
                    outline: 2px solid red;
                    overflow: hidden;
                    resize: both;
                    z-index: 5;
                }
            }
        }

        #Magnifier {
            position: fixed;
            background-color: var(--background-color);
            border: 1px solid #000;
            cursor: none;
            z-index: 10;
        }

    }

    #HelpBanner {
        grid-column: 2 / 3;
        grid-row: 2 / 3;
        font-size: 15px;
        height: 30px;
        padding: 5px 20px;
        box-shadow: 0 0 2px #444444;
        overflow-x: scroll;
        scrollbar-width: none;
        white-space: nowrap;
    }
}

#SideBar {
    background-color: #303036;
    box-shadow: 0 0 5px #444444;

    grid-column: 1 / 2;
    grid-row: 1 / 3;
    padding: 5px;
    width: 40px;

    &.expanded {
        width: 140px;
        overflow-y: scroll;
        scrollbar-width: thin;
    }

    > svg {
        /* This SVG is the burger menu icon of the unexpanded SideBar */
        width: 30px;
        color: gray;
        cursor: pointer;
    }

    .sidebar-home-button-container {
        display: grid;
        grid-auto-flow: column;
        grid-auto-columns: 1fr;
        height: 30px;
        margin-block: 5px 15px;

        button {
            height: 100%;
            width: 100%;
            padding-inline: 0;

            svg {
                width: 1em;
                margin-right: 2px;
                vertical-align: -10%;
            }
        }

        > button > svg {
            transform: scale(-1, 0.75);
        }
    }

    .sidebar-header {
        text-align: center;
        margin: 25px 5px 15px;
    }

    .sidebar-input-container {
        font-size: 11pt;
        margin: 10px 5px;
    }

    .sidebar-input-container:has(input[type="checkbox"]) {
        display: grid;
        grid-template-columns: 1fr min-content;
        grid-column-gap: 10%;
    }

    .sidebar-input-container:has(input[type="number"]) > input {
        width: 100%;
    }
}

#NotificationContainer {
    position: absolute;
    max-height: calc(100% - 10px);
    width: 200px;
    top: 10px;
    right: 10px;
    overflow: hidden;

    .warning {
        border: 1px solid darkred;
        background-color: indianred;
        margin-block: 10px;

        .warning-top {
            font-size: 16px;
            margin: 5px;

            .warning-close {
                float: right;
                margin-top: -4px;
                width: 12px;
                cursor: pointer;
            }
        }

        .warning-content {
            font-size: 12px;
            margin-inline: 12px;
            text-align: left;
            white-space: pre-line;
            word-wrap: break-word;
        }
    }
}


/* Site is not intended for mobile devices. */
#MobileIncompatibility {
    visibility: hidden;
    margin-block: 25%;
    text-align: center;
}

@media only screen and (max-width: 720px) {

    #App, #NotificationContainer {
        height: 0;
        visibility: hidden;
    }

    #MobileIncompatibility {
        visibility: visible;
    }
}
