:root {
    --white: #FFF;
    --antique-white: #FFF0DE;
    --amber-gold: #FFC107;
    --graphite: #303030;
    --light-carbon-black: #222222;
    --carbon-black: #1F1F1F;
    --toolbar-height: 60px;
    --toolbar-border: rgba(255, 255, 255, 0.12);
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
}

body {
    font-family: Arial, Helvetica, sans-serif;
    color: var(--white);
    background: var(--light-carbon-black);
    overflow: hidden;
}

button,
a {
    font: inherit;
}

button {
    appearance: none;
}

/* Viewer */
.document-viewer {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;
    background: var(--light-carbon-black);
    overflow: hidden;
}

/* Toolbar */
.document-viewer__toolbar {
    position: relative;
    z-index: 100;
    display: grid;
    flex: 0 0 var(--toolbar-height);
    grid-template-columns: minmax(120px, 1fr) auto minmax(120px, 1fr);
    align-items: center;
    height: var(--toolbar-height);
    padding: 0 12px;
    background: var(--graphite);
    border-bottom: 1px solid var(--toolbar-border);
}

.document-viewer__toolbar-section {
    display: flex;
    align-items: center;
    gap: 4px;
}

.document-viewer__toolbar-section--center {
    justify-content: center;
}

.document-viewer__toolbar-section--right {
    justify-content: flex-end;
}

.document-viewer__filename {
    max-width: 300px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.document-viewer__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    color: var(--white);
    background: transparent;
    border: 0;
    border-radius: 4px;
    transition:
        background-color 0.15s ease,
        opacity 0.15s ease;
    cursor: pointer;
}

.document-viewer__button:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.10);
}

.document-viewer__button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.document-viewer__button-icon {
    width: 20px;
    height: 20px;
    pointer-events: none;
}

.document-viewer__zoom {
    min-width: 58px;
    padding: 5px 8px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    background: var(--carbon-black);
    border-radius: 3px;
    user-select: none;
}

.document-viewer__separator {
    width: 1px;
    height: 24px;
    margin: 0 6px;
    background: var(--toolbar-border);
}

/* Viewport */
.document-viewer__viewport {
    position: relative;
    flex: 1;
    min-width: 0;
    min-height: 0;
    background: var(--light-carbon-black);
    overflow: auto;
    scrollbar-gutter: stable;
    overscroll-behavior: contain;
    touch-action: pan-x pan-y;
}

.document-viewer__canvas {
    position: relative;
    min-width: 100%;
    min-height: 100%;
}

/* Navigation */
.document-viewer__nav {
    position: absolute;
    z-index: 90;
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    padding: 0;
    color: var(--white);
    background: rgba(20, 20, 20, 0.62);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 50%;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.30);
    transform: translateY(-50%);
    transition:
        background-color 0.15s ease,
        transform 0.15s ease,
        opacity 0.15s ease;
    cursor: pointer;
    user-select: none;
}

.document-viewer__nav:hover:not(:disabled) {
    background: rgba(10, 10, 10, 0.82);
    transform:
        translateY(-50%)
        scale(1.06);
}

.document-viewer__nav:active:not(:disabled) {
    transform: translateY(-50%) scale(0.94);
}

.document-viewer__nav:disabled {
    opacity: 0.18;
    cursor: not-allowed;
    pointer-events: none;
}

.document-viewer__nav-icon {
    width: 28px;
    height: 28px;
    pointer-events: none;
}

/* Stage */
.document-viewer__book-stage {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: top left;
    will-change: transform;
}

/* Book */
.document-viewer__book {
    position: relative;
    margin: 0;
    box-shadow: 
        0 6px 16px rgba(0, 0, 0, 0.22), 
        0 18px 36px rgba(0, 0, 0, 0.16);
}

/* Page */
.document-viewer__page {
    position: relative;
    background: var(--antique-white);
    overflow: hidden;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.document-viewer__page-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
}

/* Lomo */
.document-viewer__spine {
    position: absolute;
    top: 0;
    left: 50%;
    z-index: 30;
    width: 34px;
    height: 100%;
    background: linear-gradient( to right,
        rgba(0, 0, 0, 0) 0%,
        rgba(0, 0, 0, 0.025) 20%,
        rgba(0, 0, 0, 0.08) 38%,
        rgba(0, 0, 0, 0.16) 49%,
        rgba(0, 0, 0, 0.16) 51%,
        rgba(0, 0, 0, 0.08) 62%,
        rgba(0, 0, 0, 0.025) 80%,
        rgba(0, 0, 0, 0) 100%
    );
    transform: translateX(-50%);
    pointer-events: none;
}

.document-viewer__button:focus-visible,
.document-viewer__viewport:focus-visible,
.document-viewer__nav:focus-visible {
    outline: 3px solid var(--amber-gold);
    outline-offset: 3px;
}

/* Page Flip */
.stf__parent,
.stf__wrapper,
.stf__block {
    overflow: hidden !important;
}

/* Mobile */
@media (max-width: 768px) {

    .document-viewer__book,
    .document-viewer__page,
    .document-viewer__page-image {
        touch-action: none;
    }
    
    .document-viewer__toolbar {
        grid-template-columns: minmax(60px, auto) 1fr auto;
        padding: 0 6px;
    }

    .document-viewer__filename {
        max-width: 90px;
        font-size: 11px;
    }

    .document-viewer__button {
        width: 34px;
        height: 34px;
    }

    .document-viewer__zoom {
        min-width: 50px;
    }

    .document-viewer__spine {
        display: none;
    }

    .document-viewer__nav {
        width: 40px;
        height: 40px;
    }

    .document-viewer__nav-icon {
        width: 24px;
        height: 24px;
    }

}