/* Digital Manuscript Design System */
:root {
    --bg-dark: #121212;
    --paper-white: #f5f5f5;
    --accent-orange: #ff5f1f;
    --text-primary: #e0e0e0;
    --control-bg: rgba(26, 26, 26, 0.85);
    --sharp-radius: 0px;
    --transition-smooth: cubic-bezier(0.23, 1, 0.32, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
}

#app-container {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* Keep centered but handle overflow if needed */
    position: relative;
    padding: 60px;
    /* Added internal padding for spacing on all edges */
}

/* Book Container */
.book-wrapper {
    position: relative;
    width: 90%;
    height: 60vh;
    /* Controlled height to ensure vertical space */
    max-height: 700px;
    /* Prevent being overly large on wide screens */
    display: flex;
    justify-content: center;
    align-items: center;
    perspective: 2000px;
    opacity: 0;
    transition: opacity 1s var(--transition-smooth);
    margin: 60px 0;
    /* Clear margin for top and bottom */
}

.book-wrapper.ready {
    opacity: 1;
}

#book {
    box-shadow: 0 50px 100px rgba(0, 0, 0, 0.5);
    background: #000;
}

/* Loading Overlay */
#loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    transition: opacity 0.5s var(--transition-smooth);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent-orange);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

#loader p {
    font-weight: 300;
    letter-spacing: 4px;
    text-transform: uppercase;
    font-size: 0.7rem;
    color: var(--accent-orange);
}

/* Overlay Controls */
#ui-overlay {
    position: absolute;
    bottom: 50px;
    /* Increased from 30px for more bottom space */
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 15px;
    padding: 10px 20px;
    background: var(--control-bg);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 1000;
    opacity: 0;
    animation: slideIn 0.8s var(--transition-smooth) forwards 0.5s;
}

@keyframes slideIn {
    from {
        transform: translate(-50%, 50px);
        opacity: 0;
    }

    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

.control-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s var(--transition-smooth);
    position: relative;
}

.control-btn:hover {
    color: var(--accent-orange);
    transform: translateY(-2px);
}

.control-btn svg {
    width: 22px;
    height: 22px;
}

/* Page Navigation Arrows */
.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
    height: 100px;
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: white;
    cursor: pointer;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.nav-arrow:hover {
    background: rgba(255, 255, 255, 0.1);
}

.nav-arrow.left {
    left: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-arrow.right {
    right: 0;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
}

/* Page Indicator */
#page-counter {
    font-size: 0.9rem;
    font-weight: 300;
    letter-spacing: 2px;
    color: var(--accent-orange);
    min-width: 60px;
    text-align: center;
    align-self: center;
}

/* Search Bar */
#search-input {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 5px 10px;
    outline: none;
    font-size: 0.8rem;
    width: 0;
    transition: width 0.4s var(--transition-smooth);
    opacity: 0;
}

#search-input.active {
    width: 150px;
    opacity: 1;
    margin-left: 10px;
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .book-wrapper {
        width: 95%;
        height: 70%;
    }

    #ui-overlay {
        width: 90%;
        justify-content: space-around;
        padding: 10px;
    }
}

/* Zoom Utility */
.zoomed {
    transform: scale(1.5);
    cursor: grab;
}