/* ==========================================================================
   ARTTECHES.COM — 3D INTERACTIVE DIGITAL BOOK READER (FLAGSHIP 2026 EDITION)
   Imam Razi Islamic & Digital Institute — Production CSS Systems
   ========================================================================== */

/* 1. READER MAIN MODAL OVERLAY & CONTAINER */
#readerModal3D {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: #0b0f19;
    color: #f8fafc;
    flex-direction: column;
    overflow: hidden;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    user-select: none;
    -webkit-user-select: none;
    transition: background-color 0.3s ease;
}

#readerModal3D.dark-mode {
    background: #07090e;
}

#readerModal3D.light-mode {
    background: #e2e8f0;
    color: #0f172a;
}

/* Fullscreen Mode Override */
#readerModal3D.is-fullscreen {
    width: 100vw !important;
    height: 100vh !important;
}

/* 2. READER HEADER TOOLBAR */
.reader-3d-header {
    background: linear-gradient(135deg, #022c22 0%, #064e3b 60%, #0f172a 100%);
    padding: 10px 20px;
    height: 64px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    z-index: 100;
    flex-shrink: 0;
}

.reader-3d-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.reader-3d-logo-icon {
    background: rgba(255, 106, 0, 0.2);
    border: 1px solid #ff6a00;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ff6a00;
    font-size: 18px;
    box-shadow: 0 2px 8px rgba(255, 106, 0, 0.25);
}

.reader-3d-brand-text {
    display: flex;
    flex-direction: column;
}

.reader-3d-institute {
    font-size: 9px;
    font-weight: 900;
    letter-spacing: 1.2px;
    color: #34d399;
    text-transform: uppercase;
}

.reader-3d-title {
    font-size: 15px;
    font-weight: 800;
    color: #ffffff;
    margin: 1px 0 0;
    max-width: 380px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 3. TOOLBAR CONTROLS */
.reader-3d-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
}

.reader-3d-group {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    padding: 3px;
    gap: 2px;
}

.reader-3d-btn {
    background: transparent;
    color: #cbd5e1;
    border: none;
    height: 32px;
    padding: 0 10px;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.18s ease;
}

.reader-3d-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
}

.reader-3d-btn:active {
    transform: scale(0.96);
}

.reader-3d-btn.primary {
    background: #ff6a00;
    color: #ffffff;
    box-shadow: 0 2px 10px rgba(255, 106, 0, 0.35);
}

.reader-3d-btn.primary:hover {
    background: #e05d00;
}

/* Spread Counter Badge */
.reader-3d-counter {
    background: rgba(15, 23, 42, 0.6);
    color: #f1f5f9;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.3px;
    min-width: 110px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.reader-3d-counter span {
    color: #ff6a00;
}

/* 4. 3D BOOK STAGE & VIEWPORT */
.reader-3d-stage {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    perspective: 2200px;
    -webkit-perspective: 2200px;
    padding: 20px;
}

/* Background Table Texture / Ambient Shadow */
.reader-3d-stage::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, rgba(15, 23, 42, 0.4) 0%, rgba(5, 8, 15, 0.95) 85%);
    pointer-events: none;
    z-index: 1;
}

#readerModal3D.light-mode .reader-3d-stage::before {
    background: radial-gradient(circle at center, rgba(255, 255, 255, 0.8) 0%, rgba(203, 213, 225, 0.95) 85%);
}

/* 3D Book Container */
.book-wrapper-3d {
    position: relative;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transform-style: preserve-3d;
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.6), 0 10px 20px rgba(0, 0, 0, 0.4);
    border-radius: 8px;
}

/* PageFlip Container Integration */
.stpageflip-container {
    margin: 0 auto;
    background: transparent !important;
}

.page-flip-page {
    background-color: #fdfbf7;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    position: relative;
}

/* Center Spine Shadow Overlay */
.book-spine-shadow {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 60px;
    transform: translateX(-50%);
    background: linear-gradient(90deg, 
        rgba(0, 0, 0, 0.22) 0%, 
        rgba(0, 0, 0, 0.08) 25%, 
        rgba(0, 0, 0, 0.02) 48%, 
        rgba(0, 0, 0, 0.08) 75%, 
        rgba(0, 0, 0, 0.22) 100%
    );
    pointer-events: none;
    z-index: 50;
}

/* Outer Book Paper Thickness Borders */
.book-edge-shadow-left {
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 0;
    width: 14px;
    background: linear-gradient(90deg, rgba(0,0,0,0.15) 0%, rgba(0,0,0,0) 100%);
    border-left: 3px double rgba(160, 140, 110, 0.4);
    pointer-events: none;
    z-index: 45;
}

.book-edge-shadow-right {
    position: absolute;
    top: 4px;
    bottom: 4px;
    right: 0;
    width: 14px;
    background: linear-gradient(270deg, rgba(0,0,0,0.15) 0%, rgba(0,0,0,0) 100%);
    border-right: 3px double rgba(160, 140, 110, 0.4);
    pointer-events: none;
    z-index: 45;
}

/* 5. HARDBOUND BOOK COVER STYLING */
.book-cover-page {
    background: linear-gradient(135deg, #022c22 0%, #064e3b 50%, #022c22 100%) !important;
    border: 4px solid #d97706;
    border-radius: 6px 12px 12px 6px;
    box-shadow: inset 0 0 40px rgba(0,0,0,0.6), 0 10px 30px rgba(0,0,0,0.5);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 32px 28px;
    position: relative;
    box-sizing: border-box;
}

.book-cover-back {
    background: linear-gradient(135deg, #022c22 0%, #064e3b 100%) !important;
    border: 4px solid #d97706;
    border-radius: 12px 6px 6px 12px;
}

.cover-header {
    text-align: center;
    border-bottom: 2px solid rgba(217, 119, 6, 0.4);
    padding-bottom: 16px;
}

.cover-badge {
    display: inline-block;
    background: rgba(255, 106, 0, 0.2);
    color: #ff6a00;
    border: 1px solid #ff6a00;
    font-size: 10px;
    font-weight: 900;
    padding: 4px 12px;
    border-radius: 20px;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.cover-title {
    font-size: 22px;
    font-weight: 900;
    color: #ffffff;
    line-height: 1.35;
    margin: 8px 0;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.cover-author {
    font-size: 13px;
    color: #34d399;
    font-weight: 700;
}

.cover-body-motif {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
    color: #d97706;
}

.cover-emblem {
    font-size: 64px;
    opacity: 0.9;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.4));
}

.cover-prompt {
    background: linear-gradient(135deg, #ff6a00, #e05d00);
    color: #ffffff;
    border-radius: 30px;
    padding: 12px 24px;
    font-size: 13px;
    font-weight: 900;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 15px rgba(255, 106, 0, 0.4);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.cover-prompt:hover {
    transform: scale(1.05);
}

.cover-footer {
    text-align: center;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.65);
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    padding-top: 12px;
}

/* 6. PDF PAGE CANVAS WRAPPER */
.pdf-page-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fdfbf7;
    position: relative;
    box-sizing: border-box;
}

.pdf-page-canvas {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
    display: block;
}

.page-num-footer {
    position: absolute;
    bottom: 8px;
    font-size: 11px;
    font-weight: 800;
    color: #94a3b8;
}

.page-num-footer.left { left: 16px; }
.page-num-footer.right { right: 16px; }

/* 7. LOADING & ERROR OVERLAYS */
.reader-3d-loading, .reader-3d-error {
    position: absolute;
    inset: 0;
    z-index: 80;
    background: rgba(11, 15, 25, 0.94);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 30px;
    text-align: center;
}

.reader-spinner {
    width: 54px;
    height: 54px;
    border: 4px solid rgba(255, 106, 0, 0.2);
    border-top-color: #ff6a00;
    border-radius: 50%;
    animation: readerSpin 0.9s infinite linear;
}

@keyframes readerSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.reader-loading-text {
    font-size: 18px;
    font-weight: 800;
    color: #ffffff;
}

.reader-loading-sub {
    font-size: 13px;
    color: #94a3b8;
}

/* 8. RESPONSIVE BREAKPOINTS */
@media (max-width: 900px) {
    .reader-3d-header {
        padding: 8px 12px;
    }
    .reader-3d-title {
        max-width: 180px;
        font-size: 13px;
    }
    .reader-3d-institute {
        font-size: 8px;
    }
    .reader-3d-counter {
        min-width: 85px;
        font-size: 11px;
        padding: 4px 8px;
    }
    .reader-3d-btn {
        padding: 0 7px;
        font-size: 12px;
    }
}
