/* ===== GLOBAL RESET & SCROLL SNAP ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html {
    height: 100%;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
}
body {
    width: 100%; min-height: 100%;
    font-family: 'Cormorant Garamond', serif;
    background: #0a0502; color: #f5e6c8;
    overflow-x: hidden;
}
.snap-page {
    position: relative; width: 100vw; height: 100vh;
    scroll-snap-align: start; overflow: hidden;
    display: flex; align-items: center; justify-content: center;
}

/* ===== PROGRESS BAR & PAGE INDICATOR ===== */
.progress-container {
    position: fixed; top: 0; left: 0; width: 100%; height: 3px;
    background: rgba(10, 5, 2, 0.3); z-index: 10000;
}
.progress-bar {
    height: 100%;
    background: linear-gradient(to right, #ff8c00, #d4af37);
    width: 0%; transition: width 0.3s ease;
}
.page-indicator {
    position: fixed; top: 15px; left: 30px;
    font-family: 'Playfair Display', serif; font-size: 0.9rem;
    color: #f5e6c8; z-index: 10000;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
    letter-spacing: 0.1em;
    background: rgba(10, 5, 2, 0.7);
    padding: 8px 15px; border-radius: 3px;
    border: 1px solid rgba(212, 175, 55, 0.3);
}

/* ===== LOADING SCREEN ===== */
.loading-screen {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: #0a0502; z-index: 9999;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    opacity: 1; transition: opacity 1s ease;
}
.loading-screen.loaded { opacity: 0; pointer-events: none; }
.loading-title {
    font-family: 'Great Vibes', cursive;
    font-size: clamp(3rem, 6vw, 5rem); color: #f5e6c8;
    text-shadow: 0 0 30px rgba(255, 69, 0, 0.4), 0 2px 4px rgba(0,0,0,0.8);
    margin-bottom: 40px; opacity: 0;
    animation: loadingFadeIn 1s ease 0.5s forwards;
}
.loading-subtitle {
    font-family: 'Cormorant Garamond', serif; font-style: italic;
    font-size: 1.1rem; color: #e8d4a8; letter-spacing: 0.15em;
    opacity: 0; animation: loadingFadeIn 1s ease 1s forwards;
}
.loading-divider {
    width: 0; height: 1px;
    background: linear-gradient(to right, transparent, rgba(255, 140, 0, 0.6), transparent);
    margin: 30px 0; animation: loadingDivider 1.5s ease 1.5s forwards;
}
@keyframes loadingFadeIn { to { opacity: 1; } }
@keyframes loadingDivider { to { width: 200px; } }

/* ===== SHADOW BRIDGES ===== */
.shadow-bridge-top, .shadow-bridge-bottom {
    position: absolute; left: 0; width: 100%; height: 180px;
    z-index: 4; pointer-events: none;
}
.shadow-bridge-top {
    top: 0;
    background: linear-gradient(to bottom, #0a0502 0%, transparent 100%);
}
.shadow-bridge-bottom {
    bottom: 0;
    background: linear-gradient(to top, #0a0502 0%, transparent 100%);
}

/* =========================================
   ARCHIVIST TAB STYLES (With Pulse Animation)
   ========================================= */
@keyframes pulseTab {
    0% { transform: translateY(-50%) scale(1); box-shadow: 2px 2px 8px rgba(0,0,0,0.4); }
    50% { transform: translateY(-50%) scale(1.08); box-shadow: 0 0 15px rgba(139, 0, 0, 0.8); }
    100% { transform: translateY(-50%) scale(1); box-shadow: 2px 2px 8px rgba(0,0,0,0.4); }
}
.archivist-tab-btn {
    position: absolute; left: 0; top: 50%; transform: translateY(-50%);
    background-color: #8b0000; color: #f5e6c8; border: none;
    padding: 16px 10px; border-radius: 0 6px 6px 0;
    cursor: pointer; z-index: 100;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.4);
    transition: background-color 0.3s ease;
    animation: pulseTab 3s infinite ease-in-out; 
}
.archivist-tab-btn:hover {
    background-color: #a00000; animation: none;
    transform: translateY(-50%) scale(1.05);
}
.tab-icon { font-size: 1.3rem; display: block; }

.archivist-panel {
    position: absolute; top: 0; left: -400px; width: 320px; height: 100%;
    background-color: #4a0404; color: #f5e6c8; z-index: 101;
    padding: 50px 30px 30px 30px; box-shadow: 5px 0 20px rgba(0,0,0,0.6);
    transition: left 0.5s cubic-bezier(0.25, 1, 0.5, 1); overflow-y: auto;
}
.archivist-panel.open { left: 0; }
.close-panel-btn {
    position: absolute; top: 15px; right: 20px;
    background: none; border: none; color: #f5e6c8;
    font-size: 2rem; cursor: pointer; line-height: 1;
    transition: color 0.3s ease;
}
.close-panel-btn:hover { color: #d4af37; }
.panel-content { padding-top: 20px; }
.panel-title {
    font-family: 'Playfair Display', serif; font-size: 1.3rem;
    color: #f5e6c8; margin-bottom: 8px; line-height: 1.3;
}
.panel-subtitle {
    font-family: 'Cormorant Garamond', serif; font-style: italic;
    font-size: 1.05rem; color: #d4af37; margin-bottom: 25px;
    border-bottom: 1px solid rgba(212, 175, 55, 0.3); padding-bottom: 12px;
}
.panel-details p {
    font-family: 'Cormorant Garamond', serif; font-size: 1rem;
    line-height: 1.5; margin-bottom: 12px; color: #e8d4a8;
}
.panel-details em { color: #d4af37; font-style: italic; }

/* =========================================
   CITATION POP-UPS (CLICKABLE TOOLTIPS)
   ========================================= */
.citation-pop {
    color: #ff8c00; font-style: italic; cursor: pointer;
    border-bottom: 1px dotted rgba(255, 140, 0, 0.5);
    transition: color 0.3s ease, border-color 0.3s ease; position: relative;
}
.citation-pop:hover { color: #ffa500; border-bottom-color: #ffa500; }
.citation-pop.active { color: #ffa500; border-bottom-color: #ffa500; font-weight: 600; }

#citation-tooltip {
    position: fixed; bottom: 40px; left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(10, 5, 2, 0.95); color: #f5e6c8;
    padding: 15px 25px; border: 1px solid #d4af37; border-radius: 4px;
    font-family: 'Cormorant Garamond', serif; font-size: 1.05rem;
    font-style: italic; max-width: 600px; width: 90%; text-align: center;
    opacity: 0; visibility: hidden;
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
    z-index: 10000; box-shadow: 0 5px 20px rgba(0,0,0,0.7);
    pointer-events: none; line-height: 1.5;
}
#citation-tooltip.visible {
    opacity: 1; visibility: visible;
    transform: translateX(-50%) translateY(0); pointer-events: auto;
}

/* =========================================
   NAVIGATION BUTTONS
   ========================================= */
.navigation-container {
    position: absolute; bottom: 40px; left: 50%;
    transform: translateX(-50%); z-index: 10;
    display: flex; gap: 20px; opacity: 0;
    transition: opacity 1s ease 2.5s;
}
/* Note: You will change .page-s5-1 to your actual last page class */
.page-s5-8.in-view .navigation-container { opacity: 1; } 

.nav-btn {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 25px; background: rgba(10, 5, 2, 0.8);
    border: 2px solid #d4af37; color: #f5e6c8; text-decoration: none;
    font-family: 'Playfair Display', serif; font-size: 1rem;
    letter-spacing: 0.1em; text-transform: uppercase; border-radius: 4px;
    transition: all 0.3s ease;
}
.nav-btn:hover { background: rgba(212, 175, 55, 0.9); color: #0a0502; }
.btn-arrow { width: 20px; height: 20px; }

/* =========================================
   MOBILE RESPONSIVENESS
   ========================================= */
@media (max-width: 768px) {
    #citation-tooltip { bottom: 20px; font-size: 0.95rem; padding: 12px 20px; }
    .archivist-panel { width: 100%; left: -100%; }
    .navigation-container {
        bottom: 30px; flex-direction: column; width: 80%;
    }
    .nav-btn { justify-content: center; width: 100%; }
}
/* =========================================
   PAGE 1: DANTE'S LETTER TO FLORENTINE FRIEND
   ========================================= */
.page-s5-1 {
    display: flex;
    align-items: flex-end; /* Pushes content to the bottom */
    justify-content: center;
    background-color: #1a0f0a;
}
.page-s5-1-bg {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-image: url('images/section-5-florence.jpg');
    background-size: cover;
    background-position: center;
    z-index: 1;
    transform: scale(1.05);
    transition: transform 2s cubic-bezier(0.25, 1, 0.5, 1);
}
.page-s5-1.in-view .page-s5-1-bg {
    transform: scale(1);
}

/* Text Box - Lower Position */
.florence-letter-box {
    position: relative;
    z-index: 4;
    width: 70%;
    max-width: 1100px;
    margin-bottom: 8%;
    padding: 40px 50px;
    /* Light parchment background for readability */
    background-color: rgba(245, 230, 200, 0.85);
    border-radius: 4px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.4);

    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Entrance Animation */
.page-s5-1.in-view .florence-letter-box {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 1.2s ease 1s, transform 1.2s cubic-bezier(0.25, 1, 0.5, 1) 1s;
}

/* Quote Text Styling */
.florence-letter-quote {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.35rem;
    line-height: 1.7;
    color: #1a0f0a; /* Dark text for light background */
    text-align: justify;
    font-style: italic;
    font-weight: 600;
    margin-bottom: 20px;
}
.florence-letter-quote:last-child {
    margin-bottom: 0;
}

/* Decorative Drop Cap */
.florence-letter-box .drop-cap {
    font-family: 'Great Vibes', cursive;
    font-size: 3.5rem;
    color: #8b0000;
    float: left;
    line-height: 0.8;
    margin-right: 8px;
    margin-top: 5px;
}

/* Citation Styling */
.florence-letter-citation {
    font-family: 'Playfair Display', serif;
    font-size: 1rem;
    color: #5a0a0a;
    line-height: 1.6;
    margin-top: 25px;
    padding-top: 15px;
    border-top: 1px solid rgba(139, 0, 0, 0.2);
}
.florence-letter-citation .author {
    font-weight: 700;
    color: #8b0000;
    display: block;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.florence-letter-citation em {
    font-style: italic;
}

/* Mobile Responsiveness for Page 1 */
@media (max-width: 768px) {
    .page-s5-1 {
        align-items: center;
    }
    .florence-letter-box {
        width: 90%;
        max-width: 90%;
        margin-bottom: 0;
        padding: 30px 25px;
        background-color: rgba(245, 230, 200, 0.95);
        max-height: 75vh; /* Limit height to 75% of viewport */
        overflow-y: auto; /* Enable vertical scrollbar */
        overflow-x: hidden; /* Hide horizontal scrollbar */
    }
    .florence-letter-quote {
        font-size: 1.1rem;
        line-height: 1.5;
    }
    .florence-letter-box .drop-cap {
        font-size: 2.5rem;
    }
    .florence-letter-citation {
        font-size: 0.9rem;
    }
    .page-s5-1-bg {
        background-position: center center;
    }
}
/* =========================================
   PAGE 2: DANTE'S EXILE & BAPTISTERY
   ========================================= */
.page-s5-2 {
    display: flex;
    align-items: center;
    justify-content: flex-end; /* Pushes content to the right */
    background-color: #1a0f0a;
}
.page-s5-2-bg {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-image: url('images/section-5-florence-temple.jpg');
    background-size: cover;
    background-position: center left; /* Focuses on the Baptistery on the left */
    z-index: 1;
    transform: scale(1.05);
    transition: transform 2s cubic-bezier(0.25, 1, 0.5, 1);
}
.page-s5-2.in-view .page-s5-2-bg {
    transform: scale(1);
}

/* Glassmorphic Text Box - Right Side */
.baptistery-text-box {
    position: relative;
    z-index: 4;
    width: 45%;
    max-width: 700px;
    margin-right: 5%;
    padding: 40px 50px;
    
    /* GLASSMORPHISM EFFECT */
    background: rgba(10, 5, 2, 0.7);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    
    /* Light-catching glass edges */
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-top: 1px solid rgba(255, 255, 255, 0.25);
    border-left: 1px solid rgba(255, 255, 255, 0.25);
    
    /* Floating shadow + inner depth */
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5),
                inset 0 0 20px rgba(0, 0, 0, 0.15);
    
    border-radius: 12px;

    /* Constrain height and enable internal scrolling */
    max-height: 85vh;
    overflow-y: auto;
    overflow-x: hidden;

    opacity: 0;
    transform: translateX(50px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Entrance Animation */
.page-s5-2.in-view .baptistery-text-box {
    opacity: 1;
    transform: translateX(0);
    transition: opacity 1.2s ease 1s, transform 1.2s cubic-bezier(0.25, 1, 0.5, 1) 1s;
}

/* Hover effect */
.baptistery-text-box:hover {
    background: rgba(10, 5, 2, 0.75);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6),
                inset 0 0 25px rgba(0, 0, 0, 0.2);
    transform: translateX(-5px);
}

/* Text Styling */
.baptistery-text {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.4rem;
    line-height: 1.5;
    color: #ffffff;
    text-align: justify;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.7),
                 0 0 1px rgba(0, 0, 0, 0.5);
    margin-bottom: 20px;
}
.baptistery-text:last-child {
    margin-bottom: 0;
}
.baptistery-text em {
    font-style: italic;
    color: #d4af37;
}

/* =========================================
   CUSTOM GOLDEN SCROLLBAR FOR BAPTISTERY BOX
   ========================================= */
/* Webkit browsers (Chrome, Safari, Edge) */
.baptistery-text-box::-webkit-scrollbar {
    width: 8px;
}
.baptistery-text-box::-webkit-scrollbar-track {
    background: rgba(10, 5, 2, 0.3);
    border-radius: 4px;
}
.baptistery-text-box::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, #d4af37, #8b0000); /* Gold to deep red */
    border-radius: 4px;
    border: 1px solid rgba(10, 5, 2, 0.5);
}
.baptistery-text-box::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(to bottom, #f5e6c8, #d4af37); /* Lighter gold on hover */
}

/* Firefox */
.baptistery-text-box {
    scrollbar-width: thin;
    scrollbar-color: #d4af37 rgba(10, 5, 2, 0.3);
}

/* Mobile Responsiveness for Page 2 */
@media (max-width: 768px) {
    .page-s5-2 {
        align-items: center;
        justify-content: center;
    }
    .baptistery-text-box {
        width: 90%;
        max-width: 90%;
        margin-right: 0;
        padding: 30px 25px;
        backdrop-filter: blur(12px) saturate(180%);
        -webkit-backdrop-filter: blur(12px) saturate(180%);
        background: rgba(10, 5, 2, 0.8);
        max-height: 80vh;
    }
    .baptistery-text {
        font-size: 1.15rem;
        line-height: 1.5;
    }
    .page-s5-2-bg {
        background-position: center center;
    }
}
/* =========================================
   PAGE 3: DANTE'S RETURN & BAPTISTERY
   ========================================= */
.page-s5-3 {
    display: flex;
    align-items: center;
    justify-content: flex-start; /* Pushes content to the left */
    background-color: #1a0f0a;
}
.page-s5-3-bg {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-image: url('images/section-5-jesus.jpg');
    background-size: cover;
    background-position: center right; /* Focuses on the dome on the right */
    z-index: 1;
    transform: scale(1.05);
    transition: transform 2s cubic-bezier(0.25, 1, 0.5, 1);
}
.page-s5-3.in-view .page-s5-3-bg {
    transform: scale(1);
}

/* Ornate Text Box - Left Side (Parchment Style) */
.jesus-poem-box {
    position: relative;
    z-index: 4;
    width: 40%;
    max-width: 500px;
    margin-left: 2%;
    padding: 50px 60px;
    /* Light parchment background with red/gold borders */
    background-color: #f5e6c8;
    border: 8px solid #8b0000;
    outline: 3px solid #d4af37;
    outline-offset: -12px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.6);

    opacity: 0;
    transform: translateX(-50px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Entrance Animation */
.page-s5-3.in-view .jesus-poem-box {
    opacity: 1;
    transform: translateX(0);
    transition: opacity 1.2s ease 1s, transform 1.2s cubic-bezier(0.25, 1, 0.5, 1) 1s;
}

/* Poem Text Styling */
.jesus-poem-text {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.4rem;
    line-height: 1.6;
    color: #1a0f0a; /* Dark text for light background */
    text-align: center;
    font-style: italic;
    font-weight: 600;
    margin-bottom: 15px;
}
.jesus-poem-text:last-of-type {
    margin-bottom: 25px;
}

/* Decorative Drop Cap */
.jesus-poem-box .drop-cap {
    font-family: 'Great Vibes', cursive;
    font-size: 3.5rem;
    color: #8b0000;
    float: center;
    line-height: 0.8;
    margin-right: 8px;
    margin-top: 5px;
}

/* Citation Styling */
.jesus-poem-citation {
    font-family: 'Playfair Display', serif;
    font-size: 1rem;
    color: #5a0a0a;
    line-height: 1.5;
    border-top: 1px solid rgba(139, 0, 0, 0.2);
    padding-top: 15px;
}
.jesus-poem-citation .author {
    font-weight: 700;
    color: #8b0000;
    display: block;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.jesus-poem-citation em {
    font-style: italic;
}

/* Mobile Responsiveness for Page 3 */
@media (max-width: 768px) {
    .page-s5-3 {
        justify-content: center;
    }
    .jesus-poem-box {
        width: 90%;
        max-width: 90%;
        margin-left: 0;
        padding: 30px 25px;
        border-width: 6px;
        outline-width: 2px;
        outline-offset: -10px;
    }
    .jesus-poem-text {
        font-size: 1.1rem;
        line-height: 1.5;
    }
    .jesus-poem-box .drop-cap {
        font-size: 2.5rem;
    }
    .jesus-poem-citation {
        font-size: 0.9rem;
    }
    .page-s5-3-bg {
        background-position: center center;
    }
}
/* =========================================
   PAGE 4: CACCIAGUIDA IN PARADISE (DORÉ)
   ========================================= */
.page-s5-4 {
    display: flex;
    align-items: flex-start; /* Pushes content to the top */
    justify-content: flex-end; /* Pushes content to the right */
    background-color: #1a0f0a;
}
.page-s5-4-bg {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-image: url('images/section-5-paradise.jpg');
    background-size: cover;
    background-position: center;
    z-index: 1;
    transform: scale(1.05);
    transition: transform 2s cubic-bezier(0.25, 1, 0.5, 1);
}
.page-s5-4.in-view .page-s5-4-bg {
    transform: scale(1);
}

/* Glassmorphic Text Box - Upper Right */
.paradise-desc-box {
    position: relative;
    z-index: 4;
    width: 40%;
    max-width: 420px;
    margin-right: 40%;
    margin-top: 35%; /* Distance from the top of the screen */
    padding: 35px 40px;
    
    /* GLASSMORPHISM EFFECT */
    background: rgba(10, 5, 2, 0.65);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    
    /* Light-catching glass edges */
    border: 1px solid rgba(212, 175, 55, 0.25);
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    border-left: 1px solid rgba(255, 255, 255, 0.2);
    
    /* Floating shadow + inner depth */
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5),
                inset 0 0 20px rgba(0, 0, 0, 0.15);
    
    border-radius: 12px;

    opacity: 0;
    transform: translateX(30px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Entrance Animation */
.page-s5-4.in-view .paradise-desc-box {
    opacity: 1;
    transform: translateX(0);
    transition: opacity 1.2s ease 1s, transform 1.2s cubic-bezier(0.25, 1, 0.5, 1) 1s;
}

/* Hover effect */
.paradise-desc-box:hover {
    background: rgba(10, 5, 2, 0.72);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6),
                inset 0 0 25px rgba(0, 0, 0, 0.2);
    transform: translateX(-5px);
}

/* Text Styling */
.paradise-text {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.2rem;
    line-height: 1.2;
    color: #ffffff;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.7),
                 0 0 1px rgba(0, 0, 0, 0.5);
    margin: 0;
    text-align: justify;
}

/* Mobile Responsiveness for Page 4 */
@media (max-width: 768px) {
    .page-s5-4 {
        align-items: center;
        justify-content: center;
    }
    .paradise-desc-box {
        width: 90%;
        max-width: 90%;
        margin-right: 0;
        margin-top: 105%;
        padding: 30px 25px;
        backdrop-filter: blur(12px) saturate(180%);
        -webkit-backdrop-filter: blur(12px) saturate(180%);
        background: rgba(10, 5, 2, 0.75);
    }
    .paradise-text {
        font-size: 1.15rem;
        text-align: center;
    }
    .page-s5-4-bg {
        background-position: center center;
    }
}
/* =========================================
   PAGE 5: TOPAZ POEM (PARADISO XV)
   ========================================= */
.page-s5-5 {
    display: flex;
    align-items: center;
    justify-content: flex-start; /* Pushes content to the left */
    background-color: #1a0f0a;
}
.page-s5-5-bg {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-image: url('images/section-5-topaz.jpg');
    background-size: cover;
    background-position: center;
    z-index: 1;
    transform: scale(1.05);
    transition: transform 2s cubic-bezier(0.25, 1, 0.5, 1);
}
.page-s5-5.in-view .page-s5-5-bg {
    transform: scale(1);
}

/* Glassmorphic Text Box - Left Side */
.topaz-poem-box {
    position: relative;
    z-index: 4;
    width: 45%;
    max-width: 450px;
    margin-left: 5%;
    padding: 45px 50px;
    
    /* GLASSMORPHISM EFFECT */
    background: rgba(10, 5, 2, 0.7);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    
    /* Light-catching glass edges */
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-top: 1px solid rgba(255, 255, 255, 0.25);
    border-left: 1px solid rgba(255, 255, 255, 0.25);
    
    /* Floating shadow + inner depth */
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5),
                inset 0 0 20px rgba(0, 0, 0, 0.15);
    
    border-radius: 12px;

    opacity: 0;
    transform: translateX(-50px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Entrance Animation */
.page-s5-5.in-view .topaz-poem-box {
    opacity: 1;
    transform: translateX(0);
    transition: opacity 1.2s ease 1s, transform 1.2s cubic-bezier(0.25, 1, 0.5, 1) 1s;
}

/* Hover effect */
.topaz-poem-box:hover {
    background: rgba(10, 5, 2, 0.75);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6),
                inset 0 0 25px rgba(0, 0, 0, 0.2);
    transform: translateX(5px);
}

/* Poem Text Styling */
.topaz-poem-box .poem-content {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.4rem;
    line-height: 1.6;
    color: #ffffff;
    text-align: center;
    font-style: italic;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.7),
                 0 0 1px rgba(0, 0, 0, 0.5);
}

/* Stanza Spacing */
.topaz-poem-box .poem-stanza {
    margin-bottom: 20px;
}
.topaz-poem-box .poem-stanza:last-child {
    margin-bottom: 0;
}

/* Decorative Drop Cap */
.topaz-poem-box .drop-cap {
    font-family: 'Great Vibes', cursive;
    font-size: 3.5rem;
    color: #d4af37;
    float: left;
    line-height: 0.8;
    margin-right: 8px;
    margin-top: 5px;
}

/* Tiny Book Icon (Citation Trigger) */
.topaz-poem-box .poem-citation-icon {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 1.3rem;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: color 0.3s ease, transform 0.2s ease;
    z-index: 5;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}
.topaz-poem-box .poem-citation-icon:hover {
    color: #ffffff;
    transform: scale(1.2);
}

/* Mobile Responsiveness for Page 5 */
@media (max-width: 768px) {
    .page-s5-5 {
        justify-content: center;
    }
    .topaz-poem-box {
        width: 90%;
        max-width: 90%;
        margin-left: 0;
        padding: 35px 25px;
        backdrop-filter: blur(12px) saturate(180%);
        -webkit-backdrop-filter: blur(12px) saturate(180%);
        background: rgba(10, 5, 2, 0.8);
    }
    .topaz-poem-box .poem-content {
        font-size: 1.15rem;
        line-height: 1.5;
    }
    .topaz-poem-box .poem-stanza {
        margin-bottom: 15px;
    }
    .topaz-poem-box .drop-cap {
        font-size: 2.5rem;
    }
    .page-s5-5-bg {
        background-position: center center;
    }
}
/* =========================================
   AI DISCLOSURE TEXT BOX (Page 5, Section 5)
   ========================================= */
.ai-disclosure-box-s5-5 {
    position: absolute;
    bottom: 30px;
    right: 30px;
    z-index: 5;
    padding: 12px 20px;
    background: rgba(10, 5, 2, 0.85);
    border: 1px solid rgba(212, 175, 55, 0.4);
    border-radius: 4px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.page-s5-5.in-view .ai-disclosure-box-s5-5 {
    opacity: 0.7;
    transform: translateY(0);
    transition: opacity 1s ease 2s, transform 1s ease 2s;
}

.ai-disclosure-box-s5-5:hover {
    opacity: 1 !important;
}

.ai-disclosure-text-s5-5 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 0.85rem;
    color: #e8d4a8;
    text-align: right;
    line-height: 1.4;
    margin: 0;
    font-style: italic;
    letter-spacing: 0.05em;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .ai-disclosure-box-s5-5 {
        bottom: 20px;
        right: 20px;
        padding: 10px 15px;
    }
    .ai-disclosure-text-s5-5 {
        font-size: 0.75rem;
    }
}
/* =========================================
   PAGE 6: CACCIAGUIDA'S PROPHECY (ARMY)
   ========================================= */
.page-s5-6 {
    display: flex;
    align-items: center;
    justify-content: center; /* Centers the box */
    background-color: #1a0f0a;
}
.page-s5-6-bg {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-image: url('images/section-5-army.jpg');
    background-size: cover;
    background-position: center;
    z-index: 1;
    transform: scale(1.05);
    transition: transform 2s cubic-bezier(0.25, 1, 0.5, 1);
}
.page-s5-6.in-view .page-s5-6-bg {
    transform: scale(1);
}

/* Centered Ornate Text Box (Parchment Style) */
.army-poem-box {
    position: relative;
    z-index: 4;
    width: 40%;
    max-width: 480px;
    padding: 50px 60px;
    margin-left: 150px;
    /* Light parchment background with red/gold borders */
    outline-offset: -12px;

    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Entrance Animation */
.page-s5-6.in-view .army-poem-box {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 1.2s ease 1s, transform 1.2s cubic-bezier(0.25, 1, 0.5, 1) 1s;
}

/* Poem Text Styling */
.army-poem-box .poem-content {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.4rem;
    line-height: 1.2;
    color: #1a0f0a; /* Dark text for light background */
    text-align: center;
    font-weight: 600;
    font-style: italic;
}

/* Stanza Spacing */
.army-poem-box .poem-stanza {
    margin-bottom: 18px;
}
.army-poem-box .poem-stanza:last-child {
    margin-bottom: 0;
}

/* Decorative Drop Cap */
.army-poem-box .drop-cap {
    font-family: 'Great Vibes', cursive;
    font-size: 3.5rem;
    color: #8b0000;
    float: left;
    line-height: 0.8;
    margin-right: 8px;
    margin-top: 5px;
}

/* Tiny Book Icon (Citation Trigger) */
.army-poem-box .poem-citation-icon {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 1.3rem;
    color: rgba(139, 0, 0, 0.6); /* Darker red to match parchment */
    cursor: pointer;
    transition: color 0.3s ease, transform 0.2s ease;
    z-index: 5;
}
.army-poem-box .poem-citation-icon:hover {
    color: #8b0000;
    transform: scale(1.2);
}

/* Mobile Responsiveness for Page 6 */
@media (max-width: 768px) {
    .army-poem-box {
        width: 150%;
        padding: 55px 0;
        margin-right: 5px;
        margin-left: 19%;
        border-width: 6px;
        outline-width: 2px;
        outline-offset: -10px;
    }
    .army-poem-box .poem-content {
        font-size: 1.1rem;
    }
    .army-poem-box .poem-stanza {
        margin-bottom: 12px;
    }
    .army-poem-box .drop-cap {
        font-size: 2.5rem;
        margin-right: -10%;
    }
    .page-s5-6-bg {
        background-position: center center;
    }
}
/* =========================================
   PAGE 7: LETTER TO CAN GRANDE DELLA SCALA
   ========================================= */
.page-s5-7 {
    display: flex;
    align-items: center;
    justify-content: flex-end; /* Pushes content to the right */
    background-color: #1a0f0a;
}
.page-s5-7-bg {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-image: url('images/section-5-dante-sunset.jpg');
    background-size: cover;
    background-position: center left; /* Focuses on the left side of the image */
    z-index: 1;
    transform: scale(1.05);
    transition: transform 2s cubic-bezier(0.25, 1, 0.5, 1);
}
.page-s5-7.in-view .page-s5-7-bg {
    transform: scale(1);
}

/* Ornate Text Box - Right Side (Parchment Style) */
.can-grande-letter-box {
    position: relative;
    z-index: 4;
    width: 45%;
    max-width: 700px;
    margin-right: 5%;
    padding: 50px 60px;
    /* Light parchment background with red/gold borders */
    background-color: #f5e6c8;
    border: 8px solid #8b0000;
    outline: 3px solid #d4af37;
    outline-offset: -12px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.6);

    /* Constrain height and enable internal scrolling if needed */
    max-height: 85vh;
    overflow-y: auto;
    overflow-x: hidden;

    opacity: 0;
    transform: translateX(50px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Entrance Animation */
.page-s5-7.in-view .can-grande-letter-box {
    opacity: 1;
    transform: translateX(0);
    transition: opacity 1.2s ease 1s, transform 1.2s cubic-bezier(0.25, 1, 0.5, 1) 1s;
}

/* Letter Text Styling */
.can-grande-letter-text {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.4rem;
    line-height: 1.7;
    color: #1a0f0a; /* Dark text for light background */
    text-align: justify;
    font-style: italic;
    font-weight: 600;
    margin-bottom: 20px;
}
.can-grande-letter-text em {
    font-style: italic;
    color: #8b0000; /* Red emphasis for key terms */
}

/* Decorative Drop Cap */
.can-grande-letter-box .drop-cap {
    font-family: 'Great Vibes', cursive;
    font-size: 3.5rem;
    color: #8b0000;
    float: left;
    line-height: 0.8;
    margin-right: 8px;
    margin-top: 5px;
}

/* Citation Styling */
.can-grande-letter-citation {
    font-family: 'Playfair Display', serif;
    font-size: 1rem;
    color: #8b0000; /* Red citation to match the presentation */
    line-height: 1.6;
    border-top: 1px solid rgba(139, 0, 0, 0.2);
    padding-top: 15px;
    text-align: center;
}
.can-grande-letter-citation .author {
    font-weight: 700;
    display: block;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.can-grande-letter-citation em {
    font-style: italic;
}

/* =========================================
   CUSTOM GOLDEN SCROLLBAR FOR LETTER BOX
   ========================================= */
/* Webkit browsers (Chrome, Safari, Edge) */
.can-grande-letter-box::-webkit-scrollbar {
    width: 8px;
}
.can-grande-letter-box::-webkit-scrollbar-track {
    background: rgba(139, 0, 0, 0.1); /* Subtle red-tinted track */
    border-radius: 4px;
}
.can-grande-letter-box::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, #d4af37, #8b0000); /* Gold to deep red */
    border-radius: 4px;
    border: 1px solid rgba(245, 230, 200, 0.5);
}
.can-grande-letter-box::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(to bottom, #f5e6c8, #d4af37); /* Lighter gold on hover */
}

/* Firefox */
.can-grande-letter-box {
    scrollbar-width: thin;
    scrollbar-color: #d4af37 rgba(139, 0, 0, 0.1);
}

/* Mobile Responsiveness for Page 7 */
@media (max-width: 768px) {
    .page-s5-7 {
        justify-content: center;
    }
    .can-grande-letter-box {
        width: 90%;
        max-width: 90%;
        margin-right: 0;
        padding: 30px 25px;
        border-width: 6px;
        outline-width: 2px;
        outline-offset: -10px;
        max-height: 80vh;
    }
    .can-grande-letter-text {
        font-size: 1.1rem;
        line-height: 1.5;
    }
    .can-grande-letter-box .drop-cap {
        font-size: 2.5rem;
    }
    .can-grande-letter-citation {
        font-size: 0.9rem;
    }
    .page-s5-7-bg {
        background-position: center center;
    }
}
/* =========================================
   PAGE 8: GUIDO DA MONTEFELTRO (ZONA DANTESCĂ)
   ========================================= */
.page-s5-8 {
    display: flex;
    align-items: center;
    justify-content: flex-start; /* Pushes box to the left */
    background-color: #1a0f0a;
}
.page-s5-8-bg {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-image: url('images/section-5-zona-dantesca.jpg');
    background-size: cover;
    background-position: center;
    z-index: 1;
    transform: scale(1.05);
    transition: transform 2s cubic-bezier(0.25, 1, 0.5, 1);
}
.page-s5-8.in-view .page-s5-8-bg {
    transform: scale(1);
}

/* Left-Aligned Parchment Text Box */
.dantesca-text-box {
    position: relative;
    z-index: 4;
    width: 40%;
    max-width: 450px;
    margin-left: 8%;
    padding: 30px 35px 30px 50px;
    /* Light parchment background with red/gold borders */
    background-color: #f5e6c8;
    border: 8px solid #8b0000;
    outline: 3px solid #d4af37;
    outline-offset: -12px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.6);

    opacity: 0;
    transform: translateX(-50px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}
/* Tiny Book Icon (Citation Trigger) for Parchment Boxes */
.dantesca-text-box .poem-citation-icon {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 1.3rem;
    color: rgba(139, 0, 0, 0.6); /* Darker red to match parchment */
    cursor: pointer;
    transition: color 0.3s ease, transform 0.2s ease;
    z-index: 5;
}
.dantesca-text-box .poem-citation-icon:hover {
    color: #8b0000;
    transform: scale(1.2);
}
/* Entrance Animation */
.page-s5-8.in-view .dantesca-text-box {
    opacity: 1;
    transform: translateX(0);
    transition: opacity 1.2s ease 1s, transform 1.2s cubic-bezier(0.25, 1, 0.5, 1) 1s;
}

/* Text Styling */
.dantesca-text {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.4rem;
    line-height: 1.4;
    color: #1a0f0a; /* Dark text for light background */
    text-align: left; /* Left-aligned for natural manuscript flow */
    font-style: italic;
    font-weight: 600;
    margin: 0;
}

/* Decorative Drop Cap */
.dantesca-text-box .drop-cap {
    font-family: 'Great Vibes', cursive;
    font-size: 3.5rem;
    color: #8b0000;
    float: left;
    line-height: 0.8;
    margin-right: 8px;
    margin-top: 5px;
}

/* Mobile Responsiveness for Page 8 - WITH SCROLLING */
@media (max-width: 768px) {
    .dantesca-text-box {
        width: 90%;
        max-width: 90%;
        margin-left: 5%;
        margin-bottom: 29%;
        padding: 30px 25px 25px 25px;
        border-width: 6px;
        outline-width: 2px;
        outline-offset: -10px;
        
        /* NEW: Limit height and enable scrolling */
        max-height: 65vh; /* Reduced to leave room for buttons */
        overflow-y: auto; /* Enable vertical scrollbar */
        overflow-x: hidden;
    }
    
    .dantesca-text {
        font-size: 1.1rem;
        line-height: 1.5;
    }
    
    .dantesca-text-box .drop-cap {
        font-size: 2.5rem;
    }
    
    .page-s5-8-bg {
        background-position: center center;
    }
    
    /* =========================================
       GOLDEN SCROLLBAR FOR MOBILE
       ========================================= */
    /* Webkit browsers (Chrome, Safari, Edge) */
    .dantesca-text-box::-webkit-scrollbar {
        width: 6px;
    }
    
    .dantesca-text-box::-webkit-scrollbar-track {
        background: rgba(139, 0, 0, 0.1);
        border-radius: 3px;
    }
    
    .dantesca-text-box::-webkit-scrollbar-thumb {
        background: linear-gradient(to bottom, #d4af37, #8b0000);
        border-radius: 3px;
        border: 1px solid rgba(245, 230, 200, 0.5);
    }
    
    .dantesca-text-box::-webkit-scrollbar-thumb:hover {
        background: linear-gradient(to bottom, #f5e6c8, #d4af37);
    }
    
    /* Firefox */
    .dantesca-text-box {
        scrollbar-width: thin;
        scrollbar-color: #d4af37 rgba(139, 0, 0, 0.1);
    }
}