* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;

    font-family: "Gill Sans", "Gill Sans MT", Calibri, "Trebuchet MS",
        sans-serif;
}

.hidden {
    display: none !important;
}

html,
body {
    height: 100%;
    width: 100%;

    overflow: hidden;
}

header,
footer {
    background-color: #333;
    color: white;
    padding: 10px;

    z-index: 10;

    display: flex;
    justify-content: center;
    align-items: center;
}

a {
    color: white;
    text-decoration: none;
}

body {
    display: grid;
    grid-template-rows: 40px calc(100% - 80px) 40px;
}

main {
    display: grid;
    grid-template-rows: 40px calc(100% - 40px);

    /* padding: 10px; */

    /* gap: 5px; */
    height: 100%;
    /* width: 100%; */

    /* center the input, details, controls, and viewer */
    align-items: center;
    justify-items: center;

    /* display: grid; */
    /* grid-template-rows: 20px calc(100% - 140px); */
}

.ui {
    display: flex;
    flex-direction: column;
    gap: 5px;

    z-index: 10;

    width: 100%;

    background-color: #3336;

    /* center the input, details, and controls */
    align-items: center;
    justify-items: center;
    padding: 5px;
}

.input {
    display: flex;
    gap: 5px;
}

.controls {
    display: flex;
    gap: 5px;
}

.controls button {
    padding: 5px;
    border: none;
    border-radius: 5px;
    background-color: #333;
    color: white;
    cursor: pointer;
}

.controls button:disabled {
    opacity: 0.25;
    cursor: not-allowed;
}

.details {
    height: 20px;

    color: white;
}

.details span {
    margin-right: 10px;
}

.viewer {
    text-align: center;

    user-select: none;

    display: flex;
    flex-direction: column;
}

/* viewer fit height */
.viewer.fit {
    height: 100%;
    width: 100%;
    padding: 0;
    justify-content: center;
}

.viewer.fit .page {
    max-width: 100%;
    max-height: calc(100% - 2px);

    height: 100%;
    /* width: 100%; */
    display: block;
    height: auto;
    object-fit: contain;
}

/* viewer fit width */
.viewer.width {
    overflow-y: scroll !important;

    width: 100% !important;
    height: 100% !important;
}

.viewer.width .page {
    max-width: 100% !important;
    max-height: unset !important;

    width: 100vw !important;
    height: unset !important;
}

.bookDetails {
    position: absolute;
    z-index: 100;

    right: -190px;
    top: 40px;
    bottom: 39px;

    padding: 10px;
    width: 200px;

    background-color: rgba(0, 0, 0);
    color: white;

    display: flex;
    flex-direction: column;
    gap: 5px;

    transition: right 100ms ease-in-out;
}

.bookDetails:hover {
    right: 0;

    transition: right 200ms ease-in-out;
}

.bookDetails .detail {
    display: flex;
    flex-direction: column;
}

.bookDetails .detail .detailName {
    font-weight: bold;
}

.bookDetails .detail .detailValue {
    padding-left: 2em;
}

/* DROPZONE */

#dropzone {
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;

    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);

    z-index: 100;

    color: #fff;
    font-size: 3em;

    visibility: hidden;
}

#dropzone p {
    pointer-events: none;
}

/* ZOOM */

.zoom {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;

    z-index: 1000;

    background-color: rgba(0, 0, 0, 0.5);
}

.page.zoom {
    max-width: none !important;
    max-height: none !important;

    width: auto;
    height: auto;

    cursor: zoom-out;
}

.zoom img {
    max-width: 100%;
    max-height: 100%;

    position: absolute;
    top: 50%;
    left: 50%;

    transform: translate(-50%, -50%);
}

/* NIGHT MODE */
body.night {
    background-color: #000000;
    color: white;

    header,
    footer {
        background-color: #000000;
        color: white;

        border-top: 1px solid #333;
    }

    .ui {
        border-top: 1px solid #333;
        border-bottom: 1px solid #333;
    }

    .viewer {
        /* filter: contrast(1.3); */
        /* filter: invert(1) contrast(1.5) brightness(1.5) sepia(0.8) saturate(0.8) hue-rotate(180deg); */
        mix-blend-mode: lighten;

        /* filter: invert(0%) brightness(91%) contrast(81%); */
    }

    .bookDetails {
        background-color: #171717;
        color: white;

        border: 1px solid #333;
        border-right: none;
    }
}



/* touch zones */
.touch-zones {
    height: 100vh;
    width: 100vw;
    position: fixed;
    z-index: 1;

    pointer-events: none;
}


.touch-zones > div {
    /* contains two smaller zones, ie #touchLeft and #touchLeftMinor */
    height: 100%;
    width: 25%;
    max-width: 150px;
    
    position: absolute;
    top: 0;

    display: grid;
    grid-template-rows: 20% 80%;

    pointer-events: auto;
}


.touch-zones .right {
    right: 0;
}

.touchZone {
    height: 100%;
    width: 100%;
    background-color: #000;
    opacity: 0;
    transition: opacity 100ms ease-in-out;
}

.touchZone:hover
{
    opacity: 0.25;
}


#touchLeft
{
    background-color: #f00;
}
#touchLeftMinor
{
    background-color: #f66;
}

#touchRight
{
    background-color: #00f;
}
#touchRightMinor
{
    background-color: #66f;
}





/* Mobile */

@media (max-width: 768px) {
    .bookDetails {
        display: none;
    }

    .ui button
    {
        display: none;
    }

    .ui span
    {
        display: none;
    }

    .touchZone:hover
    {
        opacity: 0;
    }

    main:not(:has(.page))
    {
        .ui
        {
            font-size: 0;
            height: 30px;
            width: 100%;
        }
    
        .ui::before
        {
            content: "Double-tap to load a book";
            text-align: center;
    
            font-size: 15px;
            color: white;
        }
    }
}