/* ========================================
   RASTI - Book Viewer Modal
   ======================================== */

/* Modal Overlay */
.book-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.book-modal.active {
    opacity: 1;
    visibility: visible;
}

/* Modal Content */
.book-modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    padding: 2rem;
    max-width: 95vw;
    max-height: 95vh;
}

/* Close Button */
.book-modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 1.75rem;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.book-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* Flipbook Container */
.flipbook-container {
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    overflow: visible;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.flipbook {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

/* Center when showing cover only */
.flipbook-container.cover-mode {
    transform: translateX(0);
    box-shadow: none;
}

/* Center when showing backcover only */
.flipbook-container.backcover-mode {
    transform: translateX(0);
    box-shadow: none;
}

/* Normal position when book is open (two pages) */
.flipbook-container.open-mode {
    transform: translateX(0);
}

/* Page Flip Styles */
.flipbook-container .stf__parent {
    background: transparent !important;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Center the cover by shifting left (cover is on right side) */
.flipbook-container.cover-mode .stf__parent {
    transform: translateX(-25%);
}

/* Center the backcover by shifting right (backcover is on left side) */
.flipbook-container.backcover-mode .stf__parent {
    transform: translateX(25%);
}

/* Remove all shadows and backgrounds in cover/backcover mode */
.flipbook-container.cover-mode .stf__wrapper,
.flipbook-container.backcover-mode .stf__wrapper {
    box-shadow: none !important;
    background: transparent !important;
}

.flipbook-container .stf__wrapper {
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.3);
}

/* Individual Pages */
.book-page {
    background-color: #f8f7f5;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.book-page img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Fill container, crop if needed */
    display: block;
}

.book-page-text {
    position: absolute;
    left: 8%;
    top: 5%;
    width: 84%;
    height: 35%;
    z-index: 2;
    font-family: var(--font-sans);
    color: #1f2a44;
    font-size: clamp(12px, 1.6vw, 18px);
    line-height: 1.25;
    text-align: left;
    white-space: pre-wrap;
    overflow: hidden;
    user-select: text;
    cursor: default;
}

.book-page-text[contenteditable="true"] {
    outline: none;
}

.book-page-text.book-page-title {
    font-family: var(--font-display);
    text-align: center;
    font-size: clamp(16px, 2.4vw, 30px);
    line-height: 1.1;
}

/* Book Controls */
.book-controls {
    display: flex;
    align-items: center;
    gap: 2rem;
    background: rgba(255, 255, 255, 0.15);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    backdrop-filter: blur(10px);
}

.book-controls button {
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1.25rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.book-controls button:hover:not(:disabled) {
    background: var(--primary);
    color: white;
}

.book-controls button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.page-indicator {
    color: white;
    font-size: 0.95rem;
    font-weight: 500;
    min-width: 80px;
    text-align: center;
}

/* Book Title in Modal */
.book-modal-title {
    color: white;
    font-family: var(--font-display);
    font-size: 1.5rem;
    text-align: center;
    margin-bottom: -0.5rem;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

/* Responsive */
@media (max-width: 768px) {
    .book-modal-content {
        padding: 0.75rem;
        gap: 1rem;
        justify-content: center;
    }

    .book-modal-title {
        font-size: 1.1rem;
        padding: 0 2rem;
        line-height: 1.3;
    }

    .flipbook-container {
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    }

    .book-controls {
        gap: 0.75rem;
        padding: 0.5rem 1rem;
    }

    .book-controls button {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
    }

    .page-indicator {
        font-size: 0.85rem;
        min-width: 60px;
    }

    .book-modal-close {
        top: 5px;
        right: 10px;
        width: 36px;
        height: 36px;
        font-size: 1.5rem;
        background: rgba(0, 0, 0, 0.4);
        z-index: 10;
    }
}

@media (max-width: 480px) {
    .book-modal-content {
        padding: 0.5rem;
        gap: 0.75rem;
    }

    .book-modal-title {
        font-size: 1rem;
        margin-bottom: 0;
    }

    .book-controls {
        gap: 0.5rem;
        padding: 0.4rem 0.75rem;
    }

    .book-controls button {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }

    .page-indicator {
        font-size: 0.8rem;
        min-width: 50px;
    }

    .book-modal-close {
        top: 8px;
        right: 8px;
        width: 32px;
        height: 32px;
        font-size: 1.25rem;
    }

    /* In portrait mode (mobile), no horizontal shift needed - pages are centered */
    .flipbook-container.cover-mode .stf__parent,
    .flipbook-container.backcover-mode .stf__parent {
        transform: translateX(0);
    }
}

/* Removed drag hint - cleaner interface */
