/* =====================================================
   BOOK DETAIL PAGE STYLESHEET - ENHANCED
   WITH: Reading Progress Bar & PDF Export
===================================================== */

/* =====================================================
   CSS VARIABLES
===================================================== */

:root {
    --primary-dark: rgba(8, 12, 22, 0.75);
    --primary-darker: rgba(5, 8, 18, 0.96);
    --primary-darkest: rgba(18, 24, 38, 0.88);
    --accent-color: #d9cfff;
    --accent-light: #e8d8ff;
    --text-primary: #cfd5e6;
    --text-secondary: #2d2417;
    --text-tertiary: #3d3427;
    --border-light: rgba(190, 210, 255, 0.12);
    --border-medium: rgba(190, 210, 255, 0.28);
    --border-heavy: rgba(190, 210, 255, 0.35);
    --parchment-light: rgba(239, 228, 201, 0.96);
    --parchment-mid: rgba(227, 216, 189, 0.96);
    --parchment-accent: rgba(139, 90, 43, 0.4);
    --parchment-dark: rgba(139, 90, 43, 0.6);
    --shadow-light: rgba(0, 0, 0, 0.15);
    --shadow-medium: rgba(0, 0, 0, 0.2);
    --shadow-heavy: rgba(0, 0, 0, 0.6);
    --glow-blue: rgba(180, 220, 255, 0.5);
}

/* =====================================================
   READING PROGRESS
===================================================== */

.reading-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-color), #9fb4ff);
    width: 0%;
    transition: width 0.2s ease;
    z-index: 200;
    will-change: width;
}

/* =====================================================
   TOPBAR
===================================================== */

.topbar {
    background: var(--primary-dark);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-light);
    padding: 14px 16px;
    transition: all 0.3s ease;
    will-change: transform;
}

body.fullscreen-parchment .topbar {
    opacity: 0;
    pointer-events: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 5;
}

.topbar-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.brand img {
    width: 56px;
    height: 56px;
    object-fit: contain;
    filter: drop-shadow(0 0 12px rgba(120, 200, 255, 0.45));
    flex-shrink: 0;
}

.brand h1 {
    font-family: 'Cinzel', serif;
    font-size: clamp(1.2rem, 4vw, 2rem);
    letter-spacing: 2px;
    color: var(--accent-color);
    margin: 0;
    white-space: nowrap;
}

.brand p {
    color: var(--text-primary);
    margin: 4px 0 0 0;
    font-size: 0.75rem;
    white-space: nowrap;
}

.topbar-nav {
    display: none;
    flex-wrap: wrap;
    gap: 0;
}

.topbar-nav a {
    text-decoration: none;
    color: white;
    padding: 8px 12px;
    transition: 0.25s ease;
    border-right: 1px solid var(--border-light);
    font-family: 'Cinzel', serif;
    letter-spacing: 0.5px;
    font-size: 0.9rem;
}

.topbar-nav a:last-child {
    border-right: none;
}

.topbar-nav a:hover {
    color: var(--accent-color);
    text-shadow: 0 0 8px var(--glow-blue);
    border-color: rgba(180, 220, 255, 0.5);
}

.mobile-menu-toggle {
    position: relative;
    height: 42px;
    padding: 0 12px;
    border-radius: 8px;
    border: 1px solid var(--border-light);
    background: var(--primary-darkest);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-family: 'EB Garamond', serif;
    font-size: 1rem;
    transition: all 0.25s ease;
    min-width: 44px;
}

.mobile-menu-toggle:hover {
    background: rgba(8, 12, 22, 0.85);
    border-color: rgba(180, 220, 255, 0.8);
}

@media (min-width: 769px) {
    .topbar {
        padding: 14px 28px;
    }

    .topbar-inner {
        gap: 30px;
    }

    .brand {
        gap: 18px;
    }

    .brand img {
        width: 72px;
        height: 72px;
    }

    .brand h1 {
        font-size: 2rem;
        letter-spacing: 3px;
    }

    .brand p {
        font-size: 0.9rem;
    }

    .topbar-nav {
        display: flex;
    }

    .topbar-nav a {
        padding: 8px 14px;
        font-size: 0.95rem;
    }

    .mobile-menu-toggle {
        display: none;
    }
}

.topbar-nav.mobile-open {
    display: flex !important;
    flex-direction: column;
    gap: 0;
    padding: 12px;
    background: var(--primary-darker);
    border-radius: 8px;
    margin-top: 8px;
    border: 1px solid var(--border-light);
    position: absolute;
    top: 100%;
    right: 16px;
    left: 16px;
    z-index: 1000;
    box-shadow: 0 4px 12px var(--shadow-heavy);
}

.topbar-nav.mobile-open a {
    border-right: none;
    padding: 12px;
    border-bottom: 1px solid var(--border-light);
}

.topbar-nav.mobile-open a:last-child {
    border-bottom: none;
}

/* =====================================================
   BREADCRUMB
===================================================== */

.book-breadcrumb {
    margin: 8px 5% 16px 5%;
    padding: 0;
    color: var(--text-primary);
    font-size: clamp(0.75rem, 2vw, 0.95rem);
    animation: fadeIn 0.6s ease-out;
    transition: all 0.3s ease;
    overflow-x: auto;
    white-space: nowrap;
}

body.fullscreen-parchment .book-breadcrumb {
    opacity: 0;
    pointer-events: none;
    position: fixed;
    z-index: 5;
}

.book-breadcrumb a {
    color: var(--accent-color);
    text-decoration: none;
    transition: all 0.2s ease;
}

.book-breadcrumb a:hover {
    text-shadow: 0 0 8px rgba(203, 185, 255, 0.6);
}

/* =====================================================
   LAYOUT
===================================================== */

.book-layout {
    width: 90%;
    max-width: 1400px;
    margin: 0 auto 40px auto;
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    align-items: start;
    transition: all 0.3s ease;
}

@media (min-width: 1024px) {
    .book-layout {
        grid-template-columns: 280px 1fr;
        gap: 30px;
    }
}

body.fullscreen-parchment .book-layout {
    width: 100%;
    max-width: 100%;
    margin: 0;
    grid-template-columns: 1fr;
    gap: 0;
    padding: 0;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    height: 100vh;
    z-index: 100;
}

/* =====================================================
   SIDEBAR
===================================================== */

.book-sidebar {
    padding: 20px;
    background: var(--primary-darkest);
    border: 1px solid var(--border-medium);
    border-radius: 12px;
    box-shadow: 0 4px 12px var(--shadow-light);
    animation: slideInLeft 0.6s ease-out;
    transition: all 0.3s ease;
    will-change: transform;
}

@media (min-width: 1024px) {
    .book-sidebar {
        position: sticky;
        top: 24px;
        max-height: calc(100vh - 48px);
        overflow-y: auto;
        padding: 24px;
        border-radius: 18px;
    }
}

body.fullscreen-parchment .book-sidebar {
    opacity: 0;
    pointer-events: none;
    position: absolute;
    z-index: 5;
}

.book-sidebar h3 {
    font-family: 'Cinzel', serif;
    color: var(--accent-color);
    margin: 0 0 12px 0;
    font-size: clamp(0.95rem, 3vw, 1.05rem);
}

.details-list,
.subjects-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.details-list li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.85rem;
    color: var(--text-primary);
}

.details-list li:last-child {
    border-bottom: none;
}

.detail-label {
    color: var(--text-primary);
    font-weight: 500;
}

.subjects-list li {
    padding: 8px 0;
}

.subjects-list a {
    color: var(--accent-color);
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 0.85rem;
}

.subjects-list a:hover {
    color: var(--accent-light);
    text-shadow: 0 0 8px rgba(203, 185, 255, 0.6);
}

.sidebar-actions {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-light);
}

.sidebar-actions h3 {
    font-size: 0.95rem;
    margin-bottom: 12px;
}

.action-button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    background: rgba(8, 12, 22, 0.5);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 8px;
    font-family: 'EB Garamond', serif;
    text-decoration: none;
    justify-content: center;
}

.action-button:last-child {
    margin-bottom: 0;
}

.action-button:hover {
    background: rgba(8, 12, 22, 0.75);
    border-color: var(--accent-color);
    color: var(--accent-color);
    box-shadow: 0 0 8px rgba(180, 220, 255, 0.3);
}

.action-button svg {
    width: 16px;
    height: 16px;
    stroke-width: 2;
}

/* =====================================================
   FULLSCREEN CONTAINER
===================================================== */

.fullscreen-scroll-container {
    position: relative;
}

body.fullscreen-parchment .fullscreen-scroll-container {
    position: fixed;
    top: 40px;
    left: 0;
    right: 0;
    bottom: 40px;
    overflow-y: scroll;
    overflow-x: hidden;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 40px;
    z-index: 100;
}

body.fullscreen-parchment .fullscreen-scroll-container::-webkit-scrollbar {
    width: 16px;
}

body.fullscreen-parchment .fullscreen-scroll-container::-webkit-scrollbar-track {
    background: transparent;
}

body.fullscreen-parchment .fullscreen-scroll-container::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(180, 140, 80, 1), rgba(139, 90, 43, 1));
    border-radius: 8px;
}

/* =====================================================
   BOOK PAGE
===================================================== */

.book-pages-container {
    width: 100%;
    position: relative;
    transition: all 0.3s ease;
}

body.fullscreen-parchment .book-pages-container {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.book-page {
    background: 
        linear-gradient(135deg, var(--parchment-light), var(--parchment-mid)),
        repeating-linear-gradient(90deg, transparent, transparent 2px, rgba(210, 180, 140, 0.03) 2px, rgba(210, 180, 140, 0.03) 4px),
        repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(210, 180, 140, 0.02) 2px, rgba(210, 180, 140, 0.02) 4px);
    color: var(--text-secondary);
    padding: clamp(20px, 5vw, 60px);
    border-radius: 2px;
    box-shadow: 0 10px 40px var(--shadow-heavy), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(139, 90, 43, 0.4);
    line-height: 1.8;
    font-size: clamp(0.95rem, 2vw, 1.05rem);
    font-weight: 500;
    position: relative;
    min-height: 600px;
    overflow: visible;
    transition: all 0.5s ease;
    display: block;
    will-change: opacity;
}

body.fullscreen-parchment .book-page {
    position: relative;
    width: calc(90vw - 40px);
    max-width: calc(900px - 80px);
    height: auto;
    min-height: auto;
    padding: 40px;
    margin: 20px auto;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
}

.book-page.hidden {
    display: none;
}

.book-page::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(ellipse at 20% 50%, rgba(255, 255, 255, 0.08), transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(139, 69, 19, 0.05), transparent 50%);
    pointer-events: none;
}

.book-page > * {
    position: relative;
    z-index: 1;
}

.book-header-integrated {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px double rgba(139, 90, 43, 0.3);
}

.book-title {
    font-family: 'Cinzel', serif;
    font-size: clamp(1.6rem, 6vw, 2.4rem);
    color: #1a1410;
    margin-bottom: 8px;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.3);
}

.book-author {
    font-family: 'EB Garamond', serif;
    font-size: clamp(0.95rem, 3vw, 1.15rem);
    color: var(--text-tertiary);
    font-style: italic;
    letter-spacing: 1px;
    font-weight: 400;
    margin: 0;
}

.book-page-number {
    position: absolute;
    top: 20px;
    left: 20px;
    font-family: 'EB Garamond', serif;
    font-size: 0.8rem;
    color: var(--parchment-dark);
    font-style: italic;
}

.book-page p {
    margin-bottom: clamp(16px, 4vw, 28px);
    text-align: justify;
    color: var(--text-secondary);
    text-indent: 1.5em;
}

.book-page p:first-of-type {
    text-indent: 0;
}

.book-page > p:first-of-type::first-letter {
    font-family: 'Cinzel', serif;
    font-size: clamp(2rem, 8vw, 2.8rem);
    color: #1a1410;
    font-weight: bold;
    margin-right: 3px;
    line-height: 1.2;
}

/* =====================================================
   PAGE BUFFER
===================================================== */

.book-page-buffer {
    height: 60px;
    margin-bottom: 30px;
    border-bottom: 2px solid rgba(139, 90, 43, 0.2);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 15px;
}

.book-page-buffer::after {
    content: '❖';
    color: var(--parchment-accent);
    font-size: 1rem;
    letter-spacing: 2px;
}

/* =====================================================
   PAGE CONTROLS - HEADER
===================================================== */

.book-page-controls-header {
    position: absolute;
    top: 140px;
    left: -32px;
    right: -32px;
    display: flex;
    justify-content: space-between;
    gap: 0;
    z-index: 10;
    pointer-events: auto;
}

#book-page-1 .book-page-controls-header {
    left: -52px;
    right: -52px;
}

#book-page-2 .book-page-controls-header,
#book-page-3 .book-page-controls-header {
    top: 90px;
    left: 5px;
    right: 5px;
}

body.fullscreen-parchment .book-page-controls-header {
    position: fixed;
    top: 50%;
    left: 45px;
    right: 45px;
    transform: translateY(-50%);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 103;
    pointer-events: auto;
}

body.fullscreen-parchment #book-page-1 .book-page-controls-header,
body.fullscreen-parchment #book-page-2 .book-page-controls-header,
body.fullscreen-parchment #book-page-3 .book-page-controls-header {
    position: fixed;
    top: 50%;
    left: 45px;
    right: 45px;
    transform: translateY(-50%);
}

.page-btn-small {
    width: 44px;
    height: 44px;
    padding: 0;
    background: var(--primary-darkest);
    border: 1.5px solid var(--border-heavy);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
    box-shadow: 0 2px 8px var(--shadow-medium);
    will-change: transform;
    min-width: 44px;
    min-height: 44px;
}

.page-btn-small:hover:not(:disabled) {
    background: rgba(8, 12, 22, 0.85);
    border-color: rgba(180, 220, 255, 0.8);
    color: var(--accent-color);
    box-shadow: 0 0 12px var(--glow-blue), 0 4px 12px var(--shadow-medium);
    transform: scale(1.1);
}

.page-btn-small:active:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 0 8px var(--glow-blue), 0 2px 6px var(--shadow-light);
}

.page-btn-small:disabled {
    opacity: 0.2;
    cursor: not-allowed;
}

body.fullscreen-parchment .page-btn-small {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    font-size: 1.5rem;
    background: rgba(18, 24, 38, 0.95);
    border: 2px solid rgba(180, 220, 255, 0.6);
    color: var(--accent-color);
    box-shadow: 0 0 20px var(--glow-blue), 0 4px 16px rgba(0, 0, 0, 0.4);
}

body.fullscreen-parchment .page-btn-small:hover:not(:disabled) {
    background: rgba(8, 12, 22, 0.95);
    border-color: rgba(220, 240, 255, 0.9);
    color: var(--accent-light);
    box-shadow: 0 0 30px rgba(180, 220, 255, 0.8), 0 6px 20px rgba(0, 0, 0, 0.5);
    transform: scale(1.15);
}

/* =====================================================
   FULLSCREEN TOGGLE
===================================================== */

.fullscreen-toggle {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    padding: 0;
    background: var(--primary-darkest);
    border: 1.5px solid var(--border-heavy);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    z-index: 20;
    min-width: 40px;
    min-height: 40px;
}

.fullscreen-toggle:hover {
    background: rgba(8, 12, 22, 0.85);
    border-color: rgba(180, 220, 255, 0.8);
    color: var(--accent-color);
    box-shadow: 0 0 10px var(--glow-blue);
    transform: scale(1.1);
}

.fullscreen-toggle:active {
    transform: scale(1.05);
}

body.fullscreen-parchment .fullscreen-toggle {
    position: fixed;
    top: 24px;
    right: 24px;
}

/* =====================================================
   FULLSCREEN EXIT
===================================================== */

.fullscreen-exit {
    position: fixed;
    top: 24px;
    left: 24px;
    width: 40px;
    height: 40px;
    padding: 0;
    background: var(--primary-darkest);
    border: 1.5px solid var(--border-heavy);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 1.3rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: none;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    z-index: 101;
    min-width: 44px;
    min-height: 44px;
}

body.fullscreen-parchment .fullscreen-exit {
    display: flex;
}

.fullscreen-exit:hover {
    background: rgba(8, 12, 22, 0.85);
    border-color: rgba(180, 220, 255, 0.8);
    color: var(--accent-color);
    box-shadow: 0 0 10px var(--glow-blue);
    transform: scale(1.1);
}

/* =====================================================
   FULLSCREEN OVERLAY
===================================================== */

.fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        linear-gradient(135deg, rgba(5, 8, 18, 0.6), rgba(15, 12, 25, 0.7)),
        url('arcanaeumimage.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    z-index: 99;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

body.fullscreen-parchment .fullscreen-overlay {
    opacity: 1;
    pointer-events: auto;
}

/* =====================================================
   PAGE CONTROLS - BOTTOM
===================================================== */

.book-page-controls-bottom {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: clamp(12px, 3vw, 20px);
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
    flex-wrap: wrap;
    animation: slideUp 0.6s ease-out;
}

body.fullscreen-parchment .book-page-controls-bottom {
    opacity: 0;
    pointer-events: none;
}

.page-btn-large {
    padding: clamp(10px, 2vw, 12px) clamp(14px, 3vw, 20px);
    background: var(--primary-darkest);
    border: 2px solid var(--border-medium);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: 'EB Garamond', serif;
    font-size: clamp(0.85rem, 2vw, 0.95rem);
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
    min-width: 100px;
    min-height: 44px;
    box-shadow: 0 2px 8px var(--shadow-light);
}

.page-btn-large:hover:not(:disabled) {
    background: rgba(8, 12, 22, 0.75);
    border-color: rgba(180, 220, 255, 0.8);
    color: var(--accent-color);
    box-shadow: 0 0 12px var(--glow-blue), 0 4px 12px var(--shadow-light);
    transform: translateY(-2px);
}

.page-btn-large:active:not(:disabled) {
    transform: translateY(0);
}

.page-btn-large:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-counter-bottom {
    color: var(--text-primary);
    font-size: clamp(0.85rem, 2vw, 0.95rem);
    font-family: 'EB Garamond', serif;
    font-weight: 500;
    text-align: center;
}

body.fullscreen-parchment .book-page-controls-bottom .page-counter-bottom {
    opacity: 1 !important;
    pointer-events: auto !important;
    position: fixed !important;
    bottom: 24px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    background: var(--primary-darkest) !important;
    border: 1.5px solid var(--border-heavy) !important;
    border-radius: 8px !important;
    padding: 8px 16px !important;
    z-index: 102 !important;
    display: block !important;
    margin: 0 !important;
}

/* =====================================================
   RELATED WORKS
===================================================== */

.related-section {
    width: 90%;
    max-width: 1400px;
    margin: 40px auto;
    padding: clamp(20px, 5vw, 40px);
    border-top: 1px solid var(--border-light);
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(18, 24, 38, 0.4), rgba(8, 12, 22, 0.3));
    backdrop-filter: blur(8px);
    animation: slideUp 0.6s ease-out 0.2s both;
}

body.fullscreen-parchment .related-section {
    opacity: 0;
    pointer-events: none;
    position: absolute;
    z-index: 5;
}

.related-section h2 {
    font-family: 'Cinzel', serif;
    color: var(--accent-color);
    font-size: clamp(1.4rem, 5vw, 1.8rem);
    margin: 0 0 20px 0;
}

.related-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

@media (min-width: 768px) {
    .related-grid {
        grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
        gap: 20px;
    }
}

.related-card {
    padding: clamp(16px, 4vw, 24px);
    background: var(--primary-darkest);
    border: 1px solid var(--border-medium);
    border-radius: 8px;
    transition: all 0.25s ease;
    animation: fadeIn 0.6s ease-out;
}

.related-card:hover {
    background: rgba(8, 12, 22, 0.75);
    border-color: rgba(210, 220, 255, 0.45);
    box-shadow: 0 0 12px rgba(180, 220, 255, 0.18), 0 8px 20px var(--shadow-light);
    transform: translateY(-3px);
}

.related-card h3 {
    font-family: 'Cinzel', serif;
    color: var(--accent-color);
    font-size: clamp(1rem, 3vw, 1.2rem);
    margin: 0 0 8px 0;
}

.related-meta {
    color: #9fb4ff;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.related-card p {
    color: var(--text-primary);
    font-size: clamp(0.8rem, 2vw, 0.9rem);
    line-height: 1.5;
    margin-bottom: 8px;
}

.related-link {
    display: inline-block;
    color: var(--accent-color);
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.related-link:hover {
    color: var(--accent-light);
    text-shadow: 0 0 8px rgba(203, 185, 255, 0.6);
}

/* =====================================================
   NAVIGATION
===================================================== */

.book-navigation {
    width: 90%;
    max-width: 1400px;
    margin: 30px auto 0;
    display: flex;
    justify-content: center;
    gap: clamp(12px, 3vw, 12px);
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
    flex-wrap: wrap;
    animation: slideUp 0.6s ease-out 0.3s both;
}

body.fullscreen-parchment .book-navigation {
    opacity: 0;
    pointer-events: none;
    position: absolute;
    z-index: 5;
}

.nav-btn {
    flex: 1;
    min-width: 120px;
    padding: clamp(10px, 2vw, 12px) clamp(14px, 3vw, 20px);
    background: var(--primary-darkest);
    border: 1px solid var(--border-medium);
    border-radius: 8px;
    color: var(--text-primary);
    text-decoration: none;
    text-align: center;
    transition: all 0.2s ease;
    font-family: 'EB Garamond', serif;
    font-size: clamp(0.85rem, 2vw, 0.95rem);
    box-shadow: 0 2px 8px var(--shadow-light);
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-btn:hover {
    background: rgba(8, 12, 22, 0.75);
    border-color: rgba(180, 220, 255, 0.5);
    color: var(--accent-color);
    box-shadow: 0 0 12px var(--glow-blue), 0 4px 12px var(--shadow-light);
    transform: translateY(-2px);
}

.nav-btn:active {
    transform: translateY(0);
}

/* =====================================================
   CONTENT
===================================================== */

.content {
    max-width: 100%;
    margin: 0;
    padding: 0 0 40px 0;
    background:
        linear-gradient(rgba(5, 8, 18, 0.65), rgba(5, 8, 18, 0.75)),
        url('arcanaeumimage.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    transition: all 0.3s ease;
}

body.fullscreen-parchment .content {
    overflow: hidden;
}

/* =====================================================
   ANIMATIONS
===================================================== */

@keyframes fadeIn {
    from { opacity: 0.95; }
    to { opacity: 1; }
}

@keyframes slideInLeft {
    from { opacity: 0.95; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slideUp {
    from { opacity: 0.95; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =====================================================
   ACCESSIBILITY
===================================================== */

@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
    }
}

#fullscreen-page-counter {
    position: fixed !important;
    bottom: 24px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    background: var(--primary-darkest) !important;
    border: 1.5px solid var(--border-heavy) !important;
    border-radius: 8px !important;
    padding: 8px 16px !important;
    z-index: 102 !important;
    font-size: 1rem !important;
    color: var(--text-primary) !important;
    font-family: 'EB Garamond', serif !important;
    font-weight: 500 !important;
    text-align: center !important;
    pointer-events: none !important;
}


/* ==========================================
   MOBILE BOOK INFO DRAWER
========================================== */
.mobile-book-filter-toggle{
    display:none;
}

@media (max-width:1023px){

    .book-layout{
        display:flex;
        flex-direction:column;
    }

    .mobile-book-filter-toggle{
        display:flex;
        align-items:center;
        justify-content:center;
        gap:8px;
        width:100%;
        padding:12px;
        margin-bottom:12px;
        background:var(--primary-darkest);
        border:1px solid var(--border-medium);
        border-radius:8px;
        color:var(--text-primary);
        font-family:'Cinzel', serif;
        cursor:pointer;
    }

    .book-sidebar{
        display:block;
        order:2;
        overflow:hidden;
        max-height:0;
        opacity:0;
        margin:0;
        padding-top:0;
        padding-bottom:0;
        transition:max-height .35s ease, opacity .25s ease;
    }

    .book-sidebar.mobile-open{
        max-height:1200px;
        opacity:1;
        margin-bottom:16px;
        padding-top:20px;
        padding-bottom:20px;
    }

    .fullscreen-scroll-container{
        order:3;
    }
}


/* ==========================================
   MOBILE IMMERSIVE READING MODE
========================================== */
@media (max-width:1023px){

    /* Hide navigation arrows on page */
    .book-page-controls-header{
        display:none !important;
    }

    /* Hide large bottom controls */
    .book-page-controls-bottom{
        display:none !important;
    }

    /* Smaller fullscreen button */
    .fullscreen-toggle{
        width:32px;
        height:32px;
        min-width:32px;
        min-height:32px;
        font-size:.85rem;
        opacity:.75;
    }

    /* Cleaner page number */
    .book-page-number{
        top:auto;
        left:50%;
        bottom:12px;
        transform:translateX(-50%);
        background:rgba(0,0,0,.12);
        padding:4px 10px;
        border-radius:20px;
        font-size:.75rem;
    }

    /* Reading page gets a little more room */
    .book-page{
        padding:20px 18px 48px 18px;
    }

    /* Subtle cue that page is tappable */
    .book-page::after{
        content:'Tap sides or swipe to turn page';
        position:absolute;
        bottom:10px;
        right:14px;
        font-size:.65rem;
        opacity:.35;
        pointer-events:none;
    }
}


/* ==========================================
   PHASE 1 + 2 DESKTOP READER
========================================== */

.two-page-toggle{
    display:none;
}

@media (min-width:1024px){

    .two-page-toggle{
        display:block;
        margin:14px auto;
        padding:10px 18px;
        border-radius:8px;
        border:1px solid rgba(190,210,255,.28);
        background:rgba(18,24,38,.9);
        color:#cfd5e6;
        cursor:pointer;
    }

    /* Uniform arrow placement */
    .book-page-controls-header,
    #book-page-1 .book-page-controls-header,
    #book-page-2 .book-page-controls-header,
    #book-page-3 .book-page-controls-header{
        top:50%;
        left:-70px;
        right:-70px;
        transform:translateY(-50%);
    }

    .page-btn-small{
        opacity:.75;
        transition:all .25s ease;
    }

    .page-btn-small:hover{
        opacity:1;
    }

    /* Two-page spread */
    body.two-page-mode .book-pages-container{
        display:flex;
        gap:20px;
        justify-content:center;
        align-items:flex-start;
    }

    body.two-page-mode .book-page{
        width:48%;
        min-height:700px;
    }
}

/* Page transitions */
.book-page{
    transition:opacity .22s ease, transform .22s ease;
}

.book-page.fade-out{
    opacity:0;
    transform:translateX(-15px);
}

.book-page.fade-in{
    opacity:1;
    transform:translateX(0);
}


/* ==========================================
   READER REFINEMENT PROTOTYPE
========================================== */

@media (min-width:1024px){

    /* Fixed arrow positions for all pages and modes */
    .book-pages-container{
        position:relative;
    }

    .book-page-controls-header,
    #book-page-1 .book-page-controls-header,
    #book-page-2 .book-page-controls-header,
    #book-page-3 .book-page-controls-header{
        position:fixed;
        top:50%;
        left:calc(50% - 520px);
        right:calc(50% - 520px);
        transform:translateY(-50%);
        z-index:50;
        pointer-events:none;
    }

    .book-page-controls-header .page-btn-small{
        pointer-events:auto;
    }

    body.two-page-mode .book-page-controls-header,
    body.two-page-mode #book-page-1 .book-page-controls-header,
    body.two-page-mode #book-page-2 .book-page-controls-header,
    body.two-page-mode #book-page-3 .book-page-controls-header{
        left:calc(50% - 700px);
        right:calc(50% - 700px);
    }

    /* Open-book look */
    body.two-page-mode .book-pages-container{
        display:flex;
        justify-content:center;
        align-items:flex-start;
        gap:0;
    }

    body.two-page-mode .book-page{
        width:46%;
        border-radius:0;
    }

    body.two-page-mode .book-page:first-child{
        box-shadow: inset -8px 0 18px rgba(0,0,0,.12);
    }

    body.two-page-mode .book-page:last-child{
        box-shadow: inset 8px 0 18px rgba(0,0,0,.12);
    }
}

/* Replace page-refresh feeling with subtle parchment pulse */
.book-page{
    transition:filter .12s ease, opacity .12s ease;
}

.book-page.page-turning{
    filter:brightness(.97);
}


/* ==========================================
   DESKTOP PAGE CURL + STABLE ARROWS
========================================== */

@media (min-width:1024px){

    /* restore arrows closer to original position */
    .book-pages-container{
        position:relative;
    }

    .book-page-controls-header,
    #book-page-1 .book-page-controls-header,
    #book-page-2 .book-page-controls-header,
    #book-page-3 .book-page-controls-header{
        position:absolute !important;
        top:50% !important;
        left:-28px !important;
        right:-28px !important;
        transform:translateY(-50%) !important;
    }

    body.two-page-mode .book-page-controls-header,
    body.two-page-mode #book-page-1 .book-page-controls-header,
    body.two-page-mode #book-page-2 .book-page-controls-header,
    body.two-page-mode #book-page-3 .book-page-controls-header{
        left:-32px !important;
        right:-32px !important;
    }

    .page-btn-small{
        opacity:.88;
    }

    /* remove previous movement feel */
    .book-page,
    .book-page.fade-in,
    .book-page.fade-out{
        transform:none !important;
        filter:none;
        transition:none;
    }

    .page-curl-overlay{
        position:fixed;
        top:0;
        right:0;
        width:50vw;
        height:100vh;
        pointer-events:none;
        z-index:120;
        opacity:0;
        transform-origin:right center;
        background:
            linear-gradient(
                270deg,
                rgba(255,255,255,.25) 0%,
                rgba(255,255,255,.08) 30%,
                rgba(0,0,0,.08) 70%,
                transparent 100%
            );
    }

    .page-curl-overlay.curl-active{
        animation: pageCurlDesktop 220ms ease-out;
    }

    @keyframes pageCurlDesktop{
        0%{
            opacity:0;
            transform:perspective(1200px) rotateY(0deg);
        }
        30%{
            opacity:1;
            transform:perspective(1200px) rotateY(-18deg);
        }
        100%{
            opacity:0;
            transform:perspective(1200px) rotateY(-45deg);
        }
    }
}

@media (max-width:1023px){
    .page-curl-overlay{
        display:none;
    }
}


/* ==========================================
   DESKTOP UNIFORM ARROW LAYOUT
   Fullscreen intentionally unchanged
========================================== */

@media (min-width:1024px){

    /* Single universal rule for all normal desktop pages */
    body:not(.fullscreen-parchment) .book-page-controls-header,
    body:not(.fullscreen-parchment) #book-page-1 .book-page-controls-header,
    body:not(.fullscreen-parchment) #book-page-2 .book-page-controls-header,
    body:not(.fullscreen-parchment) #book-page-3 .book-page-controls-header{
        position:absolute !important;
        top:50% !important;
        left:-30px !important;
        right:-30px !important;
        transform:translateY(-50%) !important;

        display:flex !important;
        justify-content:space-between !important;
        align-items:center !important;

        z-index:25;
        pointer-events:none;
    }

    body:not(.fullscreen-parchment) .book-page-controls-header .page-btn-small{
        pointer-events:auto;
        width:48px;
        height:48px;
        min-width:48px;
        min-height:48px;
        opacity:.9;
    }

    /* Remove any desktop page-turn animation experiments */
    body:not(.fullscreen-parchment) .book-page,
    body:not(.fullscreen-parchment) .book-page.fade-in,
    body:not(.fullscreen-parchment) .book-page.fade-out,
    body:not(.fullscreen-parchment) .book-page.page-turning{
        transform:none !important;
        transition:none !important;
        animation:none !important;
        filter:none !important;
    }
}

/* Disable page curl prototype */
.page-curl-overlay{
    display:none !important;
}

/* ==========================================
   HYBRID READER MODES
========================================== */

.view-mode-bar{
    width:90%;
    max-width:1400px;
    margin:18px auto;
    display:flex;
    gap:10px;
    flex-wrap:wrap;
}

.view-mode-btn{
    padding:10px 14px;
    border-radius:8px;
    border:1px solid rgba(190,210,255,.28);
    background:rgba(18,24,38,.9);
    color:#cfd5e6;
    cursor:pointer;
}

.view-mode-btn.active{
    border-color:#d9cfff;
}

@media(max-width:1023px){
    .desktop-only{display:none;}
}

/* Scroll mode = default */
body.mode-scroll .book-page.hidden{
    display:block !important;
}

body.mode-scroll .book-page-controls-header,
body.mode-scroll .book-page-controls-bottom{
    display:none !important;
}

body.mode-scroll .book-pages-container{
    display:block !important;
}

body.mode-scroll .book-page{
    margin-bottom:24px;
}

/* Reader mode */
body.mode-reader .book-page-controls-header,
body.mode-reader .book-page-controls-bottom{
    display:none !important;
}

/* Spread mode */
@media(min-width:1024px){
    body.mode-spread .book-pages-container{
        display:flex;
        flex-wrap:wrap;
        gap:20px;
        justify-content:center;
    }

    body.mode-spread .book-page{
        width:46%;
    }

    body.mode-spread .book-page.hidden{
        display:block !important;
    }

    body.mode-spread .book-page-controls-header,
    body.mode-spread .book-page-controls-bottom{
        display:none !important;
    }
}


/* ==========================================
   SCROLL / READER / SPREAD PROTOTYPE
========================================== */

/*
Prototype intent:

Scroll View:
- one continuous document container
- no page controls

Reading Mode:
- single page reader
- tap/click left-right navigation

Two Page Spread:
- desktop only
- no visible arrows
*/


/* =====================================================
   READER V2 REBUILD
===================================================== */

/* Default = Scroll View */
body.mode-scroll .book-page.hidden{
    display:block !important;
}
body.mode-scroll .book-page-controls-header,
body.mode-scroll .book-page-controls-bottom,
body.mode-scroll .two-page-toggle,
body.mode-scroll .book-page-number{
    display:none !important;
}
body.mode-scroll .book-page{
    min-height:auto;
    margin-bottom:0;
    border-bottom:0;
    box-shadow:none;
}
body.mode-scroll .book-page-buffer{
    display:none;
}
body.mode-scroll .book-pages-container{
    background:
        linear-gradient(135deg, var(--parchment-light), var(--parchment-mid));
    border:1px solid rgba(139,90,43,.4);
    box-shadow:0 10px 40px rgba(0,0,0,.4);
}
body.mode-scroll .book-page{
    background:transparent;
    border:none;
}

/* Reader mode */
body.mode-reader .book-page-controls-header,
body.mode-reader .book-page-controls-bottom{
    display:none !important;
}

/* Spread mode */
@media (min-width:1024px){
 body.mode-spread .book-pages-container{
   display:flex;
   gap:0;
   justify-content:center;
 }
 body.mode-spread .book-page{
   width:48%;
 }
 body.mode-spread .book-page.hidden{
   display:none !important;
 }
}

/* Click zones */
.reader-click-left,
.reader-click-right{
 position:absolute;
 top:0;
 bottom:0;
 width:25%;
 z-index:30;
 cursor:pointer;
}
.reader-click-left{left:0;}
.reader-click-right{right:0;}
body.mode-scroll .reader-click-left,
body.mode-scroll .reader-click-right{
 display:none;
}

/* ===== READER V3 REBUILD ===== */
.scroll-reader{
 display:none;
 background:linear-gradient(135deg,var(--parchment-light),var(--parchment-mid));
 color:var(--text-secondary);
 padding:40px;
 border:1px solid rgba(139,90,43,.4);
 box-shadow:0 10px 40px rgba(0,0,0,.4);
 line-height:1.9;
}
.scroll-reader p{margin-bottom:24px;text-indent:1.5em;}
.mode-scroll .scroll-reader{display:block;}
.mode-scroll .book-page{display:none !important;}
.mode-scroll .book-page-controls-bottom{display:none !important;}

.mode-reader .scroll-reader,
.mode-spread .scroll-reader{display:none;}

.mode-reader .book-page-controls-header,
.mode-reader .page-btn-small,
.mode-reader .book-page-controls-bottom{display:none !important;}

.reader-click-left,.reader-click-right{
 display:none;
}
.mode-reader .reader-click-left,
.mode-reader .reader-click-right,
.mode-spread .reader-click-left,
.mode-spread .reader-click-right{
 display:block;
 position:absolute;
 top:0;bottom:0;
 width:30%;
 z-index:40;
}
.mode-reader .reader-click-left,.mode-spread .reader-click-left{left:0;}
.mode-reader .reader-click-right,.mode-spread .reader-click-right{right:0;}

.mode-spread .book-page-controls-header,
.mode-spread .book-page-controls-bottom,
.mode-spread .page-btn-small{display:none !important;}

@media(min-width:1024px){
 .mode-spread #book-page-1,
 .mode-spread #book-page-2{display:block !important;width:48%;}
 .mode-spread .book-pages-container{display:flex;gap:20px;}
}

.book-page-controls-header,
.page-btn-small{display:none !important;}


/* ===== READER V4 CLEANUP ===== */

/* Scroll view becomes the only visible reader */
body.mode-scroll .book-page,
body.mode-scroll .fullscreen-toggle,
body.mode-scroll .book-page-number,
body.mode-scroll .book-page-buffer{
    display:none !important;
}

body.mode-scroll .scroll-reader{
    display:block !important;
    background:
      linear-gradient(135deg,var(--parchment-light),var(--parchment-mid));
    color:var(--text-secondary);
    padding:clamp(20px,5vw,60px);
    border:1px solid rgba(139,90,43,.4);
    box-shadow:0 10px 40px rgba(0,0,0,.6);
    font-size:clamp(0.95rem,2vw,1.05rem);
    line-height:1.8;
    font-weight:500;
}

body.mode-scroll .scroll-reader p{
    text-indent:1.5em;
    margin-bottom:clamp(16px,4vw,28px);
    text-align:justify;
}

body.mode-scroll .scroll-reader > p:first-of-type{
    text-indent:0;
}

body.mode-scroll .scroll-reader > p:first-of-type::first-letter{
    float:left;
    font-family:'Cinzel', serif;
    font-size:2.6rem;
    font-weight:bold;
    line-height:.75;
    margin:0 4px 0 0;
    color:#1a1410;
}

body.mode-scroll .book-pages-container{
    display:block !important;
}

/* Hide legacy controls in reader/spread */
.mode-reader .page-btn-small,
.mode-reader .book-page-controls-header,
.mode-spread .page-btn-small,
.mode-spread .book-page-controls-header{
    display:none !important;
}


/* ===== READER V5 ===== */

/* TRUE scroll mode: only scroll reader visible */
body.mode-scroll .scroll-reader{
    display:block !important;
}

body.mode-scroll .book-page,
body.mode-scroll .book-page.hidden,
body.mode-scroll .reader-click-left,
body.mode-scroll .reader-click-right{
    display:none !important;
}

/* Global fullscreen button styling */
#globalFullscreenBtn{
    margin-left:auto;
}

/* Scroll reader gets fullscreen support */
body.fullscreen-parchment.mode-scroll .scroll-reader{
    max-width:900px;
    margin:40px auto;
    box-shadow:0 30px 80px rgba(0,0,0,.8);
}

/* Keep reader mode untouched */
body.mode-reader .scroll-reader,
body.mode-spread .scroll-reader{
    display:none !important;
}


/* ==========================================
   READER V6
========================================== */

/* Remove legacy center toggle entirely */
.two-page-toggle{
    display:none !important;
}

/* Desktop uses top fullscreen button only */
@media (min-width:1024px){
    .fullscreen-toggle{
        display:none !important;
    }
}

/* Fullscreen follows active mode */
body.fullscreen-parchment.mode-scroll .scroll-reader{
    display:block !important;
    width:min(1000px,92vw);
    margin:20px auto;
}

body.fullscreen-parchment.mode-scroll .book-page{
    display:none !important;
}

body.fullscreen-parchment.mode-reader .scroll-reader,
body.fullscreen-parchment.mode-spread .scroll-reader{
    display:none !important;
}

/* Cleaner fullscreen reading space */
body.fullscreen-parchment .related-section,
body.fullscreen-parchment .book-navigation,
body.fullscreen-parchment footer,
body.fullscreen-parchment .book-sidebar,
body.fullscreen-parchment .book-breadcrumb,
body.fullscreen-parchment .mobile-book-filter-toggle{
    display:none !important;
}

body.fullscreen-parchment .view-mode-bar{
    position:fixed;
    top:10px;
    left:50%;
    transform:translateX(-50%);
    z-index:150;
}

/* Reader mode click navigation preserved */
body.mode-reader .reader-click-left,
body.mode-reader .reader-click-right,
body.mode-spread .reader-click-left,
body.mode-spread .reader-click-right{
    display:block !important;
}


/* ==========================================
   V6.1 SCROLL VIEW CLEANUP
========================================== */

.scroll-book-header{
    text-align:center;
    margin-bottom:30px;
    padding-bottom:20px;
    border-bottom:2px double rgba(139,90,43,.3);
}

.scroll-reader .book-author{
    text-indent:0 !important;
}

.scroll-reader .book-author::first-letter{
    font-size:inherit !important;
    font-family:inherit !important;
    font-weight:inherit !important;
    color:inherit !important;
}

.scroll-reader .book-author + p::first-letter{
    font-family:'Cinzel', serif;
    font-size:clamp(2rem, 8vw, 2.8rem);
    color:#1a1410;
    font-weight:bold;
    margin-right:3px;
    line-height:1.2;
}


/* ==========================================
   STEP 2 REFINEMENTS
========================================== */

.scroll-reader .book-author + p{
    text-indent:0 !important;
    margin-top:0 !important;
    line-height:1.8 !important;
}

.scroll-reader .book-author + p::first-letter{
    float:left;
    font-family:'Cinzel', serif;
    font-size:2.6rem;
    color:#1a1410;
    font-weight:bold;
    line-height:.75;
    margin:0 4px 0 0;
    padding:0;
}

/* Prevent fullscreen mode bar from overlapping the exit X */
body.fullscreen-parchment .view-mode-bar{
    padding-left:80px;
}

.view-mode-btn[data-mode="spread"]{
    display:none !important;
}

/* ==========================================
   FULLSCREEN SCROLL CLEANUP
========================================== */

body.fullscreen-parchment.mode-scroll .book-pages-container{
    background:transparent !important;
    border:none !important;
    box-shadow:none !important;
    padding:0 !important;
}

body.fullscreen-parchment.mode-scroll .scroll-reader{
    width:min(1000px,92vw);
    margin:8px auto !important;
    border:1px solid rgba(139,90,43,.4);
    box-shadow:0 30px 80px rgba(0,0,0,.8);
}

body.fullscreen-parchment.mode-scroll .fullscreen-scroll-container{
    padding-top:8px !important;
    padding-bottom:8px !important;
}

@media (max-width:1023px){

    body.fullscreen-parchment.mode-scroll .scroll-reader{
        margin-top:90px !important;
    }

    body.fullscreen-parchment.mode-reader .book-page{
        margin-top:90px !important;
    }

}