
/*************************************************
 * Barrelectic
 * © 2026 All rights reserved
 * 
 * pdf-viewer.css
 * 
**************************************************/

:root {
    --panel:          rgba(20, 20, 20, 0.78);
    --text:           #f3f3f3;
    --muted:          rgba(255,255,255,0.62);
    --shadow-book:    0 18px 50px rgba(0,0,0,0.45);
    --shadow-page:    0 8px 24px rgba(0,0,0,0.22);
    --thumb-w:        220px;
    --transition-dur: 340ms;
}

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

html, body {
    height: 100%;
    overflow: hidden;
    font-family: Arial, sans-serif;
    color: var(--text);
}

body {
    background:
        radial-gradient(circle at center, rgba(255,255,255,0.03) 0 1px, transparent 1px),
        radial-gradient(circle at center, rgba(255,255,255,0.02) 0 1px, transparent 1px),
        linear-gradient(180deg, #2d2d2d 0%, #1f1f1f 100%);
    background-size: 10px 10px, 14px 14px, cover;
    background-position: 0 0, 5px 5px, center;
}

.viewer-shell {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.viewer-title {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 10px auto;
    max-width: calc(100vw - 40px);
    padding: 8px 18px;
    border-radius: 999px;
    background: var(--panel);
    backdrop-filter: blur(10px);
    box-shadow: 0 12px 30px rgba(0,0,0,0.32);
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    z-index: 40;
}

#thumb-sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--thumb-w);
    height: 100%;
    z-index: 60;
    background: rgba(12,12,12,0.94);
    backdrop-filter: blur(14px);
    display: flex;
    flex-direction: column;
    transform: translateX(calc(-1 * var(--thumb-w)));
    transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
    box-shadow: 4px 0 28px rgba(0,0,0,0.55);
}

#thumb-sidebar.open { 
    transform: translateX(0); 
}

.thumb-header {
    padding: 18px 14px 12px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    border-bottom: 1px solid rgba(255,255,255,0.07);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.thumb-close { 
    cursor: pointer; 
    opacity: 0.55; 
    font-size: 17px; 
    transition: opacity 0.15s; 
}

.thumb-close:hover { 
    opacity: 1; 
}

#thumb-list {
    overflow-y: auto;
    flex: 1;
    padding: 10px 8px 24px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.14) transparent;
}

.thumb-item {
    cursor: pointer;
    border-radius: 5px;
    overflow: hidden;
    border: 2px solid transparent;
    transition: border-color 0.14s, transform 0.14s;
    position: relative;
    background: rgba(255,255,255,0.04);
    flex-shrink: 0;
}

.thumb-item:hover  { 
    transform: scale(1.025); 
    border-color: rgba(255,255,255,0.22); 
}
.thumb-item.active { 
    border-color: rgba(255,255,255,0.75); 
}

.thumb-item canvas { 
    display: block; 
    width: 100%; 
    height: auto; }

.thumb-label {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 3px 0;
    font-size: 10px;
    text-align: center;
    color: rgba(255,255,255,0.65);
    background: rgba(0,0,0,0.42);
}

#pdf-container {
    flex: 1;
    position: relative;
    perspective: 1800px;
    overflow: hidden;
    min-height: 0;
}

.pdf-slot {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2px 0;
    will-change: transform, opacity;
}

.pdf-slot.idle-hidden { 
    opacity: 0; 
    pointer-events: none; 
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(26%)  rotateY(-7deg); }
    to   { opacity: 1; transform: translateX(0)    rotateY(0deg);  }
}
@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-26%) rotateY(7deg);  }
    to   { opacity: 1; transform: translateX(0)    rotateY(0deg);  }
}
@keyframes slideOutLeft {
    from { opacity: 1; transform: translateX(0)    rotateY(0deg);  }
    to   { opacity: 0; transform: translateX(-16%) rotateY(4deg);  }
}
@keyframes slideOutRight {
    from { opacity: 1; transform: translateX(0)    rotateY(0deg);  }
    to   { opacity: 0; transform: translateX(16%)  rotateY(-4deg); }
}

.pdf-slot.anim-in-right  { animation: slideInRight  var(--transition-dur)  cubic-bezier(0.22,1,0.36,1) forwards; }
.pdf-slot.anim-in-left   { animation: slideInLeft   var(--transition-dur)  cubic-bezier(0.22,1,0.36,1) forwards; }
.pdf-slot.anim-out-left  { animation: slideOutLeft  calc(var(--transition-dur) * .72) ease-in forwards; pointer-events: none; }
.pdf-slot.anim-out-right { animation: slideOutRight calc(var(--transition-dur) * .72) ease-in forwards; pointer-events: none; }

.book-stage {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%; height: 100%;
    transform-style: preserve-3d;
}

.pdf-spread {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    max-width: 100%;
    max-height: 100%;
    filter: drop-shadow(var(--shadow-book));
    transform-origin: center center;
    transition: transform 0.16s ease;
    user-select: none;
}

.pdf-spread.zoomed   { 
    cursor: grab; 
}

.pdf-spread.dragging { 
    cursor: grabbing; 
}

.pdf-page {
    background: #fff;
    overflow: hidden;
    box-shadow: var(--shadow-page);
    position: relative;
    z-index: 20;
}

.pdf-page canvas { 
    display: block; 
}

.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 36px; height: 36px;
    z-index: 50;
    cursor: pointer;
    user-select: none;
    opacity: 0.75;
    background: transparent;
    transition: opacity 0.18s, transform 0.18s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-arrow:hover { 
    opacity: 1; 
    transform: translateY(-50%) scale(1.12);
}

.nav-arrow::before {
    content: '';
    display: block;
    width: 12px; height: 12px;
    border-top: 2.5px solid rgba(255,255,255,0.92);
    border-right: 2.5px solid rgba(255,255,255,0.92);
}

.arrow-prev::before { 
    transform: rotate(-135deg) translate(-1px, 1px); 
}
.arrow-next::before { 
    transform: rotate(45deg)   translate(-1px, 1px); 
}

.nav-jump {
    position: fixed;
    width: 32px; height: 32px;
    z-index: 9999;
    cursor: pointer;
    user-select: none;
    opacity: 0.55;
    background: transparent;
    transition: opacity 0.18s, transform 0.18s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-jump:hover { 
    opacity: 0.95; 
    transform: scale(1.12);
}

.nav-jump::before, .nav-jump::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 8px; height: 8px;
    border-top: 2px solid rgba(255,255,255,0.85);
    border-right: 2px solid rgba(255,255,255,0.85);
}

.jump-start::before { 
    left: 2px;  
    transform: translateY(-50%) rotate(-135deg); 
}

.jump-start::after { 
    left: 10px; 
    transform: translateY(-50%) rotate(-135deg); 
}

.jump-end::before { 
    left: 2px;  
    transform: translateY(-50%) rotate(45deg);   
}

.jump-end::after { 
    left: 10px; 
    transform: translateY(-50%) rotate(45deg);
}

.viewer-toolbar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    margin: 10px auto;
    padding: 8px 12px;
    border-radius: 999px;
    background: var(--panel);
    backdrop-filter: blur(10px);
    box-shadow: 0 12px 30px rgba(0,0,0,0.32);
    z-index: 55;
}

.viewer-button {
    border: none;
    min-width: 36px; height: 36px;
    border-radius: 999px;
    padding: 0 10px;
    background: rgba(255,255,255,0.08);
    color: var(--text);
    cursor: pointer;
    font-size: 15px;
    transition: background 0.14s, transform 0.14s, opacity 0.14s;
    white-space: nowrap;
}

.viewer-button:hover { 
    background: rgba(255,255,255,0.16); 
    transform: translateY(-1px); 
}

.viewer-button:disabled { 
    opacity: 0.32; cursor: not-allowed; transform: none; 
}

.viewer-button.active { 
    background: rgba(255,255,255,0.22); 
}

.viewer-sep {
    width: 1px; height: 20px;
    background: rgba(255,255,255,0.11);
    margin: 0 2px;
    flex-shrink: 0;
}

.viewer-status {
    min-width: 110px;
    text-align: center;
    font-size: 13px;
    color: var(--muted);
    padding: 0 4px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.14s;
}
.viewer-status:hover { 
    background: rgba(255,255,255,0.07); 
}

#page-input {
    display: none;
    width: 52px;
    text-align: center;
    background: rgba(255,255,255,0.11);
    border: 1px solid rgba(255,255,255,0.26);
    border-radius: 6px;
    color: #fff;
    font-size: 13px;
    padding: 3px 6px;
    outline: none;
}
#page-input:focus { 
    border-color: rgba(255,255,255,0.58); 
}

#zoom-label {
    font-size: 12px;
    color: var(--muted);
    min-width: 36px;
    text-align: center;
}

.click-zone {
    position: absolute;
    top: 0; bottom: 0;
    z-index: 25;
    cursor: pointer;
    user-select: none;
}

#shortcuts-panel {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.52);
    backdrop-filter: blur(6px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}
#shortcuts-panel.open { 
    opacity: 1; 
    pointer-events: auto; 
}

.shortcuts-box {
    background: rgba(18,18,18,0.97);
    border: 1px solid rgba(255,255,255,0.09);
    border-radius: 14px;
    padding: 26px 30px;
    max-width: 400px;
    width: 90vw;
    box-shadow: 0 24px 60px rgba(0,0,0,0.65);
}

.shortcuts-box h2 {
    font-size: 14px;
    font-weight: 700;
    color: rgba(255,255,255,0.9);
    margin-bottom: 16px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.shortcut-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255,255,255,0.055);
    font-size: 13px;
    color: var(--muted);
}
.shortcut-row:last-child { 
    border-bottom: none; 
}

.shortcut-keys { 
    display: flex; 
    gap: 4px; 
}

kbd {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 5px;
    background: rgba(255,255,255,0.09);
    border: 1px solid rgba(255,255,255,0.17);
    font-size: 11px;
    font-family: monospace;
    color: #fff;
}

#nav-spinner {
    position: fixed;
    inset: 0;
    z-index: 35;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
}
#nav-spinner.visible { 
    opacity: 1; 
}

.nav-spinner-ring {
    width: 44px; height: 44px;
    border-radius: 50%;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: rgba(255,255,255,0.8);
    animation: spin 0.7s linear infinite;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.5));
}

@keyframes spin { to { transform: rotate(360deg); } }

#loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(20,20,20,0.92);
    backdrop-filter: blur(6px);
    transition: opacity 0.4s;
}
#loading-overlay.hidden { 
    opacity: 0; 
    pointer-events: none; 
}

.spinner {
    width: 40px; height: 40px;
    border: 3px solid rgba(255,255,255,0.12);
    border-top-color: rgba(255,255,255,0.8);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
    margin-bottom: 14px;
}
.loading-text { 
    color: rgba(255,255,255,0.52); 
    font-size: 13px; 
}

#key-toast {
    position: fixed;
    bottom: 74px;
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    z-index: 70;
    padding: 5px 14px;
    border-radius: 999px;
    background: rgba(255,255,255,0.11);
    backdrop-filter: blur(8px);
    color: #fff;
    font-size: 12px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.18s, transform 0.18s;
    white-space: nowrap;
}
#key-toast.show { 
    opacity: 1; 
    transform: translateX(-50%) translateY(0); 
}

#logo {
    position: fixed;
    bottom: 18px;
    right: 18px;
    z-index: 55;
    display: block;
    line-height: 0;
}

#logo-img {
    height: 75px;
    width: auto;
    opacity: 0.80;
    transition: opacity 0.18s;
    display: block;
}

#logo:hover #logo-img { 
    opacity: 1; 
}

.shortcuts-button { 
    display: none; 
}

.action-popup {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.52);
    backdrop-filter: blur(6px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}
.action-popup.open { 
    opacity: 1; pointer-events: auto; 
}

.action-box {
    background: rgba(18,18,18,0.97);
    border: 1px solid rgba(255,255,255,0.09);
    border-radius: 14px;
    padding: 24px 28px;
    width: 420px;
    max-width: 90vw;
    box-shadow: 0 24px 60px rgba(0,0,0,0.65);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.action-box h2 {
    font-size: 13px;
    font-weight: 700;
    color: rgba(255,255,255,0.9);
    margin-bottom: 6px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    text-align: center;
}

.action-btn {
    border: none;
    border-radius: 8px;
    padding: 12px 16px;
    background: rgba(255,255,255,0.08);
    color: var(--text);
    cursor: pointer;
    font-size: 14px;
    transition: background 0.14s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.action-btn:hover { 
    background: rgba(255,255,255,0.15); 
}

.action-btn-icon { 
    font-size: 18px; 
}

.action-cancel {
    margin-top: 4px;
    border: none;
    background: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 13px;
    text-align: center;
    padding: 6px;
    transition: color 0.14s;
}
.action-cancel:hover { color: #fff; }

.action-spinner {
    display: none;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
    padding: 4px 0;
}

.page-checkbox-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 8px;
}

.page-checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    white-space: nowrap;
    font-size: 13px;
    color: var(--muted);
}

.page-checkbox-label input[type="checkbox"] {
    width: 15px;
    height: 15px;
    cursor: pointer;
    accent-color: rgba(255,255,255,0.8);
    flex-shrink: 0;
}

.textLayer {
    position: absolute;
    inset: 0;
    overflow: hidden;
    line-height: 1;
    text-size-adjust: none;
    forced-color-adjust: none;
    transform-origin: 0 0;
    z-index: 35;
    pointer-events: auto;
    user-select: text;
    -webkit-user-select: text;
}

.textLayer span,
.textLayer br {
    color: transparent;
    position: absolute;
    white-space: pre;
    cursor: text !important;
    transform-origin: 0% 0%;
    pointer-events: auto;
    user-select: text;
    -webkit-user-select: text;
}

.textLayer ::selection {
    background: rgba(0, 0, 255, 0.25);
    color: transparent;
}

.textLayer .endOfContent {
    display: block;
    position: absolute;
    inset: 100% 0 0;
    z-index: -1;
    cursor: default;
    user-select: none;
}

#search-bar {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 65;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 999px;
    background: var(--panel);
    backdrop-filter: blur(10px);
    box-shadow: 0 12px 30px rgba(0,0,0,0.32);
}

#search-input {
    display: none;
    background: rgba(255,255,255,0.11);
    border: 1px solid rgba(255,255,255,0.26);
    border-radius: 999px;
    color: #fff;
    font-size: 13px;
    padding: 4px 12px;
    outline: none;
    width: 200px;
}
#search-input:focus { 
    border-color: rgba(255,255,255,0.58); 
}

#search-input::placeholder { 
    color: rgba(255,255,255,0.35); 
}

#search-count {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    display: none;
    min-width: 60px;
    text-align: center;
}

#search-prev-btn, #search-next-btn, #search-close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

#search-prev-btn, #search-next-btn, #search-close-btn { 
    display: none;
}

.textLayer .highlight {
    background: rgba(255, 200, 0, 0.45);
    border-radius: 2px;
    color: transparent;
    cursor: text;
}

.textLayer .highlight.selected {
    background: rgba(255, 120, 0, 0.70);
}

@media (max-width: 900px) {
    .pdf-slot { 
        padding: 8px 0; 
    }
    .viewer-toolbar { 
        gap: 3px; 
        padding: 6px 8px; 
    }

    .viewer-button { 
        min-width: 32px; 
        height: 32px; 
        font-size: 14px; 
        padding: 0 8px; 
    }

    .viewer-status { 
        min-width: 80px; 
        font-size: 12px; 
    }

    .viewer-title { 
        font-size: 13px; 
    }

    #zoom-label { 
        display: none; 
    }

    #search-input { 
        width: 130px; 
    }

    #logo { 
        display: none; 
    }
}