/* ==========================================================================
   JRTN Custom PDF Viewer — viewer.css v3.0
   Wiley Online Library EPDF Style
   Brand: #1e4b7a (Primary Blue), #172033 (Dark Ink), #637083 (Muted), #eff6ff
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. ROOT RESET
   -------------------------------------------------------------------------- */
html:has(body.jrtn-pdf-viewer-page),
body.jrtn-pdf-viewer-page {
    margin: 0;
    padding: 0;
    height: 100%;
}

body.jrtn-pdf-viewer-page {
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    font-family: "Noto Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #1e293b;
    color: #172033;
}

/* --------------------------------------------------------------------------
   2. TOP TOOLBAR
   -------------------------------------------------------------------------- */
.jrtn-pv-toolbar {
    flex-shrink: 0;
    height: 52px;
    background: linear-gradient(135deg, #1e4b7a 0%, #163a5d 100%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 16px;
    z-index: 200;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

/* Mobile Burger Button */
.jrtn-pv-burger-btn {
    display: none; /* hidden on desktop */
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.28);
    border-radius: 6px;
    color: #fff;
    padding: 6px 10px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease;
}
.jrtn-pv-burger-btn:hover {
    background: rgba(255,255,255,0.25);
}

.jrtn-pv-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: rgba(255,255,255,0.88) !important;
    text-decoration: none !important;
    font-size: 0.82rem;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
    transition: color 0.15s ease;
}
.jrtn-pv-back:hover { color: #fff !important; }
.jrtn-pv-back .fa { font-size: 0.75rem; }

.jrtn-pv-toolbar-title {
    flex: 1;
    font-size: 0.83rem;
    font-weight: 600;
    color: rgba(255,255,255,0.90);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    padding: 0 10px;
}

/* Toolbar Controls & Page Navigation */
.jrtn-pv-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.jrtn-pv-page-nav,
.jrtn-pv-zoom-nav {
    display: flex;
    align-items: center;
    background: rgba(0,0,0,0.25);
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 6px;
    padding: 2px 4px;
    gap: 4px;
}

.jrtn-pv-ctrl-btn {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.85);
    width: 26px;
    height: 26px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.75rem;
    transition: background 0.15s ease, color 0.15s ease;
}
.jrtn-pv-ctrl-btn:hover:not(:disabled) {
    background: rgba(255,255,255,0.2);
    color: #fff;
}
.jrtn-pv-ctrl-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.jrtn-pv-page-indicator,
.jrtn-pv-zoom-level {
    font-size: 0.76rem;
    font-weight: 600;
    color: #fff;
    padding: 0 6px;
    user-select: none;
    min-width: 35px;
    text-align: center;
}

.jrtn-pv-toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.30);
    border-radius: 6px;
    color: #fff !important;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none !important;
    white-space: nowrap;
    transition: background 0.15s ease;
}
.jrtn-pv-toolbar-btn:hover { background: rgba(255,255,255,0.25); }

/* --------------------------------------------------------------------------
   3. LAYOUT CONTAINER & BACKDROP
   -------------------------------------------------------------------------- */
.jrtn-pv-layout {
    flex: 1;
    display: flex;
    overflow: hidden;
    min-height: 0;
    position: relative;
}

.jrtn-pv-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    z-index: 800;
    opacity: 0;
    transition: opacity 0.25s ease;
}
.jrtn-pv-backdrop.is-active {
    display: block;
    opacity: 1;
}

/* --------------------------------------------------------------------------
   4. SIDEBAR (DESKTOP & MOBILE DRAWER)
   -------------------------------------------------------------------------- */
.jrtn-pv-sidebar {
    width: 350px;
    flex-shrink: 0;
    overflow-y: auto;
    background: #fff;
    border-right: 1px solid #cbd5e1;
    padding: 0;
    box-sizing: border-box;
}

.jrtn-pv-sidebar::-webkit-scrollbar       { width: 5px; }
.jrtn-pv-sidebar::-webkit-scrollbar-track { background: transparent; }
.jrtn-pv-sidebar::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* ── Journal Logo & Branding Header ── */
.jrtn-pv-journal-brand {
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.jrtn-pv-brand-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none !important;
    min-width: 0;
}

.jrtn-pv-logo-img {
    width: 44px;
    height: 44px;
    object-fit: contain;
    flex-shrink: 0;
    border-radius: 6px;
}

.jrtn-pv-brand-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.jrtn-pv-brand-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: #1e4b7a;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

.jrtn-pv-brand-sub {
    font-size: 0.68rem;
    font-weight: 600;
    color: #64748b;
    letter-spacing: 0.05em;
}

.jrtn-pv-drawer-close {
    display: none; /* only on mobile */
    background: transparent;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: #64748b;
    cursor: pointer;
    padding: 4px 8px;
}

/* ── Sections ── */
.jrtn-pv-section {
    padding: 16px 20px;
    border-bottom: 1px solid #f1f5f9;
}
.jrtn-pv-section:last-child {
    border-bottom: none;
}

.jrtn-pv-section-label {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    color: #94a3b8;
    margin-bottom: 10px;
}

/* ── Article Title ── */
.jrtn-pv-article-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.55;
    margin: 0;
}

/* ── Real-Time Metrics in Sidebar ── */
.jrtn-pv-section-metrics {
    padding: 10px 20px 14px;
    border-bottom: 1px solid #f1f5f9;
}

.jrtn-pv-metrics-bar {
    display: inline-flex;
    align-items: center;
    background: #1e4b7a;
    color: #ffffff;
    border-radius: 3px;
    padding: 6px 14px;
    gap: 16px 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    width: 100%;
    box-sizing: border-box;
    justify-content: flex-start;
}

.jrtn-pv-metric-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: transparent;
    border: none;
    border-radius: 3px;
    color: #ffffff;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    padding: 2px 4px;
    text-decoration: none;
    transition: all 0.15s ease;
    cursor: default;
}

.jrtn-pv-metric-badge:hover {
    background: rgba(255, 255, 255, 0.16);
}

.jrtn-pv-metric-badge:hover .jrtn-pv-metric-count {
    color: #f8d96b;
}

.jrtn-pv-metric-badge:hover .jrtn-pv-metric-icon {
    transform: scale(1.1);
}

.jrtn-pv-metric-icon {
    width: 17px;
    height: 17px;
    object-fit: contain;
    vertical-align: middle;
    display: inline-block;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.jrtn-pv-metric-label {
    font-size: 13px;
    font-weight: 500;
    color: #ffffff;
}

.jrtn-pv-metric-count {
    font-size: 13px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.01em;
    transition: color 0.15s ease;
}

/* ── Authors ── */
.jrtn-pv-authors {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.jrtn-pv-author-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.jrtn-pv-author-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #eff6ff;
    color: #1e4b7a;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 1px;
}

.jrtn-pv-author-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.jrtn-pv-author-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #1e4b7a;
}

.jrtn-pv-author-affil {
    font-size: 0.74rem;
    color: #64748b;
    line-height: 1.45;
    margin-top: 1px;
}
.jrtn-pv-author-affil .fa {
    font-size: 0.70rem;
    color: #94a3b8;
    margin-right: 4px;
}

.jrtn-pv-author-orcid {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.68rem;
    color: #a6ce39 !important;
    text-decoration: none !important;
    font-weight: 600;
    margin-top: 4px;
    margin-left: 42px;
}
.jrtn-pv-author-orcid:hover { text-decoration: underline !important; }

/* ── Publication Meta Grid ── */
.jrtn-pv-meta-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.jrtn-pv-meta-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.jrtn-pv-meta-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: #eff6ff;
    color: #1e4b7a;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    flex-shrink: 0;
}

.jrtn-pv-meta-content {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.jrtn-pv-meta-key {
    font-size: 0.68rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.jrtn-pv-meta-val {
    font-size: 0.82rem;
    color: #0f172a;
    font-weight: 500;
    line-height: 1.4;
}

.jrtn-pv-meta-doi {
    font-size: 0.78rem;
    color: #1e4b7a !important;
    text-decoration: underline !important;
    word-break: break-all;
    line-height: 1.4;
}

/* ── How to Cite Box ── */
.jrtn-pv-citation-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.jrtn-pv-citation-text {
    font-size: 0.78rem;
    line-height: 1.6;
    color: #334155;
    margin: 0;
    font-family: inherit;
    word-break: break-word;
}

.jrtn-pv-copy-btn {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    color: #1e4b7a;
    font-size: 0.74rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}
.jrtn-pv-copy-btn:hover {
    background: #eff6ff;
    border-color: #1e4b7a;
}
.jrtn-pv-copy-btn .fa {
    font-size: 0.72rem;
}

/* ── Abstract ── */
.jrtn-pv-abstract {
    font-size: 0.82rem;
    line-height: 1.75;
    color: #334155;
    max-height: 220px;
    overflow-y: auto;
    padding-right: 4px;
}
.jrtn-pv-abstract::-webkit-scrollbar       { width: 4px; }
.jrtn-pv-abstract::-webkit-scrollbar-track { background: transparent; }
.jrtn-pv-abstract::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }
.jrtn-pv-abstract p { margin: 0 0 0.5em; }
.jrtn-pv-abstract p:last-child { margin-bottom: 0; }

/* ── Keywords ── */
.jrtn-pv-keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.jrtn-pv-keyword {
    display: inline-block;
    background: #eff6ff;
    color: #1e4b7a;
    border: 1px solid #bfdbfe;
    border-radius: 20px;
    padding: 3px 12px;
    font-size: 0.72rem;
    font-weight: 500;
    line-height: 1.5;
}

/* ── Action Buttons ── */
.jrtn-pv-section-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 4px !important;
}

.jrtn-pv-btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 14px;
    background: #1e4b7a;
    color: #fff !important;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none !important;
    transition: background 0.15s ease;
    box-shadow: 0 2px 6px rgba(30,75,122,0.25);
}
.jrtn-pv-btn-primary:hover { background: #163a5d; }

.jrtn-pv-btn-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    background: #fff;
    color: #1e4b7a !important;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 500;
    text-decoration: none !important;
    transition: all 0.15s ease;
}
.jrtn-pv-btn-secondary:hover {
    border-color: #1e4b7a;
    background: #f8fafc;
}

/* --------------------------------------------------------------------------
   5. MAIN PDF SCROLL CONTAINER
   -------------------------------------------------------------------------- */
.jrtn-pv-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    background: #1e293b;
    position: relative;
}

.jrtn-pv-outdated {
    flex-shrink: 0;
    background: #fef3c7;
    border-bottom: 1px solid #fcd34d;
    padding: 10px 18px;
    font-size: 0.82rem;
    color: #92400e;
    display: flex;
    align-items: center;
    gap: 8px;
}
.jrtn-pv-outdated a { color: #92400e !important; font-weight: 600; }

.jrtn-pv-scroll-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    padding: 24px;
    box-sizing: border-box;
    touch-action: pan-x pan-y; /* Smooth 1-finger panning while allowing 2-finger zoom in JS */
    -webkit-overflow-scrolling: touch;
}

/* Custom Scrollbar */
.jrtn-pv-scroll-container::-webkit-scrollbar       { width: 8px; height: 8px; }
.jrtn-pv-scroll-container::-webkit-scrollbar-track { background: #0f172a; }
.jrtn-pv-scroll-container::-webkit-scrollbar-thumb { background: #475569; border-radius: 4px; }

/* Loading Spinner */
.jrtn-pv-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin: auto;
    color: #94a3b8;
    font-size: 0.9rem;
}

.jrtn-pv-spinner {
    width: 42px;
    height: 42px;
    border: 4px solid rgba(255,255,255,0.15);
    border-top-color: #38bdf8;
    border-radius: 50%;
    animation: jrtn-spin 0.8s linear infinite;
}

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

/* Error Box */
.jrtn-pv-error-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    margin: auto;
    background: #0f172a;
    border: 1px solid #334155;
    padding: 28px 36px;
    border-radius: 12px;
    color: #f87171;
    text-align: center;
}

/* PDF Pages Wrapper */
.jrtn-pv-pages-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    margin: 0 auto;
    width: max-content;
    min-width: 100%;
    transform-origin: top center;
    will-change: transform;
}

/* Bottom Spacer to ensure last page is fully visible and scrollable */
.jrtn-pv-bottom-spacer {
    height: 60px;
    width: 100%;
    flex-shrink: 0;
    pointer-events: none;
}

/* --------------------------------------------------------------------------
   6. PDF PAGE BOX, TEXT LAYER & ANNOTATION LAYER
   -------------------------------------------------------------------------- */
.jrtn-pv-page-box {
    position: relative;
    background: #fff;
    box-shadow: 0 6px 22px rgba(0,0,0,0.50);
    border-radius: 2px;
    overflow: hidden;
    user-select: text;
    -webkit-user-select: text;
}

.jrtn-pv-page-box canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
}

/* TEXT LAYER: Enables text selection, highlighting, copy-paste */
.textLayer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    opacity: 0.25;
    line-height: 1.0;
    pointer-events: auto;
    z-index: 2;
}

.textLayer > span {
    color: transparent;
    position: absolute;
    white-space: pre;
    cursor: text;
    transform-origin: 0% 0%;
}

.textLayer ::selection {
    background: rgba(30, 75, 122, 0.75);
    color: transparent;
}

.textLayer ::-moz-selection {
    background: rgba(30, 75, 122, 0.75);
    color: transparent;
}

/* ANNOTATION LAYER: Enables clickable hyperlinks, DOIs, web links */
.annotationLayer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 3;
}

.annotationLayer section {
    position: absolute;
    text-align: initial;
    pointer-events: auto;
    box-sizing: border-box;
}

.annotationLayer .linkAnnotation > a,
.annotationLayer a {
    position: absolute;
    font-size: 1em;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    background: transparent;
    transition: background 0.15s ease;
}

.annotationLayer .linkAnnotation > a:hover,
.annotationLayer a:hover {
    background: rgba(56, 189, 248, 0.25);
    outline: 1px solid rgba(56, 189, 248, 0.6);
}

/* --------------------------------------------------------------------------
   7. RESPONSIVE MOBILE & OFFCANVAS DRAWER
   -------------------------------------------------------------------------- */
@media (max-width: 890px) {
    .jrtn-pv-toolbar-title { display: none; }
    .jrtn-pv-page-nav { display: none; }
}

@media (max-width: 767px) {
    /* Show Burger Menu on Mobile */
    .jrtn-pv-burger-btn {
        display: inline-flex;
    }

    /* Transform Sidebar into an Off-canvas Drawer */
    .jrtn-pv-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 85%;
        max-width: 330px;
        height: 100vh;
        z-index: 900;
        border-right: 1px solid #cbd5e1;
        box-shadow: 4px 0 25px rgba(0, 0, 0, 0.5);
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: auto;
    }

    .jrtn-pv-sidebar.is-open {
        transform: translateX(0);
    }

    .jrtn-pv-drawer-close {
        display: block;
    }

    /* Main Area is Full Screen Height on Mobile (Dynamic Viewport 100dvh) */
    .jrtn-pv-main {
        height: calc(100vh - 52px);
        height: calc(100dvh - 52px);
        width: 100%;
    }

    .jrtn-pv-scroll-container {
        padding: 16px 8px 140px 8px !important;
        padding-bottom: max(140px, env(safe-area-inset-bottom) + 100px) !important;
        -webkit-overflow-scrolling: touch;
    }

    .jrtn-pv-pages-wrapper {
        gap: 16px;
    }

    .jrtn-pv-bottom-spacer {
        height: 120px;
    }

    .jrtn-pv-back-label {
        display: none;
    }
}

@media (max-width: 479px) {
    .jrtn-pv-toolbar { padding: 0 8px; gap: 6px; }
    .jrtn-pv-btn-text { display: none; }
    .jrtn-pv-toolbar-btn { padding: 6px 10px; }
    .jrtn-pv-burger-label { display: none; }
    .jrtn-pv-section { padding: 14px 16px; }
}

/* --------------------------------------------------------------------------
   8. CITATION & INTERNAL LINK NAVIGATION HIGHLIGHT EFFECT
   -------------------------------------------------------------------------- */
.jrtn-pv-citation-highlight {
    position: absolute;
    left: 8px;
    right: 8px;
    border-radius: 6px;
    background: rgba(254, 240, 138, 0.55);
    border-left: 6px solid #eab308;
    box-shadow: 0 0 18px rgba(234, 179, 8, 0.40);
    pointer-events: none;
    z-index: 10;
    animation: jrtn-highlight-flash 2.5s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes jrtn-highlight-flash {
    0% {
        opacity: 0;
        transform: scaleY(0.7);
        background: rgba(254, 240, 138, 0.85);
    }
    12% {
        opacity: 1;
        transform: scaleY(1);
        background: rgba(254, 240, 138, 0.75);
    }
    65% {
        opacity: 0.9;
        background: rgba(254, 240, 138, 0.50);
    }
    100% {
        opacity: 0;
        transform: scaleY(1);
        background: rgba(254, 240, 138, 0);
    }
}

.jrtn-span-highlighted {
    background-color: #fef08a !important;
    color: #854d0e !important;
    border-radius: 2px;
    box-shadow: 0 0 8px rgba(234, 179, 8, 0.6);
    transition: background-color 0.8s ease, color 0.8s ease;
}

