/* ============================================
   EBOOKS.CSS — CS Archive Library
   Final Version with Realistic Wood Shelf
   ============================================ */

:root {
    --bg-primary: #0b0b12;
    --bg-secondary: #11111c;
    --bg-shelf: #2b1d14;
    --bg-shelf-dark: #1e140e;
    --bg-wood-light: #5d4037;
    --bg-wood-mid: #4e342e;
    --bg-wood-dark: #3e2723;
    --wood-highlight: #6d4c41;
    --wood-shadow: #1a120c;
    --gold: #d4a04c;
    --gold-light: #e8c07a;
    --gold-dark: #a07830;
    --warm-white: #f0e8dc;
    --text-muted: #b0a898;
    --text-dim: #7a7060;
    --font-serif: 'Playfair Display', 'Noto Serif Bengali', serif;
    --font-sans: 'Inter', 'Noto Serif Bengali', sans-serif;
    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.5);
    --shadow-medium: 0 8px 40px rgba(0, 0, 0, 0.6);
    --shadow-heavy: 0 20px 80px rgba(0, 0, 0, 0.8);
    --transition-smooth: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --transition-bounce: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    background-color: var(--bg-primary);
    color: var(--warm-white);
    font-family: var(--font-sans);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

/* Subtle noise texture overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.03'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 99999; /* সর্বোচ্চ, কিন্তু body::before সাধারণত ব্যাকগ্রাউন্ড */
    opacity: 0.5;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--bg-wood-light);
    border-radius: 4px;
    border: 1px solid rgba(212, 160, 76, 0.2);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--gold-dark);
}

/* ==================== HERO / FEATURED SECTION ==================== */
.hero {
    padding: 80px 40px 40px;
    text-align: center;
    position: relative;
    overflow: hidden;
}
.hero::before {
    content: '';
    position: absolute;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    width: 70%;
    height: 60%;
    background: radial-gradient(ellipse at center, rgba(212, 160, 76, 0.08) 0%, transparent 70%);
    pointer-events: none;
}

.hero-badge {
    display: inline-block;
    padding: 8px 20px;
    border: 1px solid rgba(212, 160, 76, 0.3);
    border-radius: 30px;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--gold-light);
    margin-bottom: 24px;
    background: rgba(212, 160, 76, 0.05);
}

.hero-title {
    font-family: var(--font-serif);
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    font-weight: 900;
    line-height: 1.15;
    color: var(--warm-white);
    margin-bottom: 16px;
    letter-spacing: -0.02em;
    position: relative;
}
.hero-title .highlight {
    background: linear-gradient(135deg, var(--gold-light), var(--gold), var(--gold-dark));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-style: italic;
}

.hero-subtitle {
    font-size: 1.1rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto 32px;
    font-weight: 300;
    line-height: 1.8;
}

.hero-stats {
    display: flex;
    justify-content: center;
    gap: 48px;
    flex-wrap: wrap;
}
.hero-stat {
    text-align: center;
}
.hero-stat-number {
    font-family: var(--font-serif);
    font-size: 2rem;
    font-weight: 700;
    color: var(--gold);
    display: block;
}
.hero-stat-label {
    font-size: 0.75rem;
    color: var(--text-dim);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    font-weight: 500;
}

/* ==================== SHELF CONTAINER ==================== */
.library-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 40px 80px;
    position: relative;
}

.shelf-section {
    margin-bottom: 60px;
    position: relative;
}
.shelf-section:last-child {
    margin-bottom: 20px;
}

.shelf-heading {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}
.shelf-heading-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, rgba(212, 160, 76, 0.4), transparent);
}
.shelf-heading-text {
    font-family: var(--font-serif);
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--gold-light);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    white-space: nowrap;
}
.shelf-heading-line.right {
    background: linear-gradient(to left, rgba(212, 160, 76, 0.4), transparent);
}

/* =========================================================
   NATURAL WOOD SHELF — FINAL VERSION
   ========================================================= */

.shelf {
    position: relative;
    background:
        linear-gradient(180deg, #5a3b28 0%, #513522 19%, #563824 39%, #4c301f 60%, #523522 80%, #442a1b 100%),
        repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.06) 0px, rgba(0, 0, 0, 0.06) 3px, transparent 3px, transparent 7px),
        repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.02) 0px, rgba(255, 255, 255, 0.02) 1px, transparent 1px, transparent 4px);

    border-radius: 16px;
    padding: 16px 12px 12px;
    box-shadow:
        inset 0 0 45px rgba(65, 34, 12, 0.28),
        inset 0 1px 0 rgba(255, 230, 190, 0.20),
        0 18px 38px rgba(0, 0, 0, 0.34),
        var(--shadow-medium);
    border: 1px solid rgba(212, 160, 76, 0.15);
    overflow: hidden;
    transition: var(--transition-smooth);
}

.shelf::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(212, 160, 76, 0.4), transparent);
    z-index: 1;
    pointer-events: none;
}

.shelf::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        92deg,
        transparent,
        transparent 45px,
        rgba(255, 255, 255, 0.02) 45px,
        rgba(255, 255, 255, 0.02) 46px,
        transparent 46px
    );
    pointer-events: none;
    border-radius: 16px;
    z-index: 1;
}

.shelf-books {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    position: relative;
    z-index: 3;
    flex-wrap: wrap;
    padding-bottom: 12px;
    min-height: 160px;
}

.shelf-bottom {
    height: 14px;
    background: linear-gradient(to bottom, #6d4c41 0%, #5d4037 20%, #4e342e 50%, #3e2723 80%, #1e140e 100%);
    border-radius: 4px;
    position: relative;
    z-index: 3;
    box-shadow:
        0 6px 14px rgba(0, 0, 0, 0.6),
        inset 0 2px 4px rgba(255, 255, 255, 0.15),
        inset 0 -2px 4px rgba(0, 0, 0, 0.4);
    margin-top: -4px;
}

.shelf-bottom::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 0;
    right: 0;
    height: 10px;
    background: var(--bg-shelf-dark);
    border-radius: 0 0 8px 8px;
    opacity: 0.7;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.5);
}

/* ==================== BOOK SPINE ==================== */
.book-spine {
    cursor: pointer;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    border-radius: 4px 6px 6px 4px;
    padding: 16px 10px;
    transition: var(--transition-bounce);
    transform-origin: bottom center;
    box-shadow:
        -4px 2px 12px rgba(0, 0, 0, 0.5),
        inset 2px 0 4px rgba(255, 255, 255, 0.08);
    user-select: none;
    min-width: 44px;
    border-left: 2px solid rgba(255, 255, 255, 0.25);
    border-right: 2px solid rgba(0, 0, 0, 0.5);
    z-index: 5;
}
.book-spine:hover {
    transform: translateY(-12px) rotate(-2deg) scale(1.04);
    box-shadow:
        -8px 8px 24px rgba(0, 0, 0, 0.7),
        0 0 30px rgba(212, 160, 76, 0.25),
        inset 2px 0 4px rgba(255, 255, 255, 0.15);
    z-index: 20;
}
.book-spine:active {
    transform: translateY(-4px) scale(0.98);
    transition-duration: 0.1s;
}

.book-spine-title {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-family: var(--font-serif);
    font-size: 0.85rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    max-height: 160px;
}
.book-spine-author {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.65);
    writing-mode: vertical-rl;
    text-orientation: mixed;
    letter-spacing: 0.05em;
    white-space: nowrap;
}
/* Decorative lines on spine */
.book-spine::before {
    content: '';
    position: absolute;
    top: 12%;
    left: 25%;
    right: 25%;
    height: 2px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 1px;
}
.book-spine::after {
    content: '';
    position: absolute;
    bottom: 15%;
    left: 30%;
    right: 30%;
    height: 3px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}
/* Ribbon marker */
.book-spine .ribbon {
    position: absolute;
    bottom: -6px;
    right: 8px;
    width: 4px;
    height: 18px;
    background: var(--gold-dark);
    border-radius: 0 0 3px 3px;
    opacity: 0.7;
}

/* ==================== BOOK SIZES (Enlarged) ==================== */
.book-height-1 { height: 190px; width: 52px; }
.book-height-2 { height: 215px; width: 58px; }
.book-height-3 { height: 165px; width: 45px; }
.book-height-4 { height: 235px; width: 64px; }
.book-height-5 { height: 205px; width: 56px; }
.book-height-6 { height: 180px; width: 50px; }

/* ==================== BOOK COLORS (স্পষ্ট ও আলাদা) ==================== */
.book-color-1 { background: linear-gradient(to right, #a03c3c, #7a2626, #5f1e1e); }
.book-color-2 { background: linear-gradient(to right, #3a5f8a, #25466b, #1a3450); }
.book-color-3 { background: linear-gradient(to right, #4a7a46, #325a30, #244322); }
.book-color-4 { background: linear-gradient(to right, #8a5e3a, #6b4527, #50331d); }
.book-color-5 { background: linear-gradient(to right, #5a4a8a, #423265, #302547); }
.book-color-6 { background: linear-gradient(to right, #8a3d70, #672952, #4a1d3c); }
.book-color-7 { background: linear-gradient(to right, #3a8a82, #28645e, #1c4a46); }
.book-color-8 { background: linear-gradient(to right, #a06e3a, #7c5227, #5c3d1d); }
.book-color-9 { background: linear-gradient(to right, #704c4c, #543838, #3f2828); }
.book-color-10 { background: linear-gradient(to right, #3a4a8a, #263567, #1c284c); }

/* ==================== READING MODAL ==================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 99999; /* ✅ সর্বোচ্চ z-index, header-এর উপরে */
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.4s ease;
}
.modal-overlay.active {
    display: flex;
    opacity: 1;
}
.modal-overlay.closing {
    opacity: 0;
}

.modal-container {
    background: var(--bg-secondary);
    border-radius: 20px;
    width: min(95vw, 1100px);
    height: min(90vh, 800px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-heavy);
    border: 1px solid rgba(212, 160, 76, 0.25);
    transform: scale(0.9) translateY(30px);
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}
.modal-overlay.active .modal-container {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: linear-gradient(to bottom, rgba(212, 160, 76, 0.08), transparent);
    border-bottom: 1px solid rgba(212, 160, 76, 0.15);
    flex-shrink: 0;
}
.modal-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}
.modal-header-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--gold-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}
.modal-header-text {
    min-width: 0;
}
.modal-header-title {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--warm-white);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.modal-header-author {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.modal-close-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid rgba(212, 160, 76, 0.3);
    background: rgba(212, 160, 76, 0.1);
    color: var(--gold-light);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}
.modal-close-btn:hover {
    background: rgba(212, 160, 76, 0.25);
    border-color: var(--gold);
    transform: rotate(90deg) scale(1.05);
    box-shadow: 0 0 20px rgba(212, 160, 76, 0.2);
}

.modal-body {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #000;
    min-height: 0;
}

.pdf-viewer-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a1a1a;
}

.pdf-viewer-container canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
    margin: auto;
}

.pdf-protection-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    background: transparent;
    pointer-events: auto;
    cursor: default;
}

.loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    z-index: 4;
    pointer-events: none;
    transition: opacity 0.4s ease;
}
.loading-spinner.hidden {
    opacity: 0;
}
.spinner-ring {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(212, 160, 76, 0.2);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.loading-spinner p {
    color: var(--text-muted);
    font-size: 0.85rem;
    letter-spacing: 0.1em;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 24px;
    border-top: 1px solid rgba(212, 160, 76, 0.15);
    background: rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}
.modal-footer-text {
    font-size: 0.7rem;
    color: var(--text-dim);
    letter-spacing: 0.05em;
}
.modal-footer-badge {
    font-size: 0.65rem;
    padding: 4px 12px;
    border-radius: 20px;
    background: rgba(212, 160, 76, 0.15);
    color: var(--gold-light);
    letter-spacing: 0.08em;
    border: 1px solid rgba(212, 160, 76, 0.2);
}

/* ==================== DECORATIVE FLOATING PARTICLES ==================== */
.particle {
    position: fixed;
    border-radius: 50%;
    background: rgba(212, 160, 76, 0.3);
    pointer-events: none;
    z-index: 1;
    animation: floatParticle 20s ease-in-out infinite;
}
@keyframes floatParticle {
    0%, 100% {
        transform: translateY(0) translateX(0);
        opacity: 0.1;
    }
    25% {
        transform: translateY(-40px) translateX(20px);
        opacity: 0.4;
    }
    50% {
        transform: translateY(-80px) translateX(-10px);
        opacity: 0.2;
    }
    75% {
        transform: translateY(-30px) translateX(-30px);
        opacity: 0.35;
    }
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
    .hero {
        padding: 60px 16px 30px;
    }
    .hero-title {
        font-size: 2rem;
    }
    .hero-subtitle {
        font-size: 0.9rem;
        padding: 0 12px;
    }
    .hero-stats {
        gap: 20px;
    }
    .hero-stat-number {
        font-size: 1.4rem;
    }
    .library-container {
        padding: 10px 12px 40px;
    }
    .shelf {
        padding: 12px 10px 8px;
    }
    .shelf-books {
        gap: 6px;
        min-height: 120px;
        padding-bottom: 8px;
    }
    /* Adjust book sizes for mobile (still larger than original) */
    .book-height-1 { height: 150px; width: 40px; }
    .book-height-2 { height: 170px; width: 45px; }
    .book-height-3 { height: 130px; width: 35px; }
    .book-height-4 { height: 190px; width: 50px; }
    .book-height-5 { height: 160px; width: 44px; }
    .book-height-6 { height: 140px; width: 38px; }
    .book-spine-title {
        font-size: 0.7rem;
        max-height: 100px;
    }
    .book-spine-author {
        font-size: 0.55rem;
    }
    .book-spine {
        padding: 8px 6px;
        border-radius: 3px 4px 4px 3px;
    }
    .modal-container {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
    }
    .modal-header {
        padding: 12px 16px;
    }
    .modal-header-title {
        font-size: 0.95rem;
    }
    .modal-footer {
        padding: 8px 16px;
        flex-direction: column;
        gap: 4px;
    }
    .shelf-heading-text {
        font-size: 1rem;
        letter-spacing: 0.05em;
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: 1.6rem;
    }
    .hero-badge {
        font-size: 0.6rem;
        padding: 6px 14px;
    }
    .shelf-books {
        gap: 4px;
    }
    /* Even smaller book sizes for very small screens */
    .book-height-1 { height: 120px; width: 32px; }
    .book-height-2 { height: 140px; width: 36px; }
    .book-height-3 { height: 100px; width: 28px; }
    .book-height-4 { height: 150px; width: 40px; }
    .book-height-5 { height: 130px; width: 34px; }
    .book-height-6 { height: 110px; width: 30px; }
    .book-spine-title { font-size: 0.6rem; max-height: 70px; }
    .book-spine-author { font-size: 0.5rem; }
}