/* ═══════════════════════════════════════════════════════════
   BOOK MODAL — DESKTOP
   ═══════════════════════════════════════════════════════════ */

.modal-backdrop.show {
    opacity: 0.95;
    background-color: #050505;
}

.modal-content-libro {
    box-shadow: none !important;
    background: transparent !important;
    border: none !important;
}

.modal.fade .modal-dialog {
    transition: transform 0.2s ease-out;
}

.modal.show .modal-dialog {
    transform: none;
}

/* Contenedor desktop */
.book-container {
    perspective: 2500px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100%;
    padding: 40px 20px;
}

.book-spread {
    position: relative;
    display: flex;
    width: 100%;
    max-width: 1400px;
    height: 820px;
    background: #fdfaf0;
    border-radius: 5px 20px 20px 5px;
    box-shadow:
        0 2px 4px rgba(0, 0, 0, .2),
        2px 0 5px rgba(0, 0, 0, .5),
        0 30px 50px rgba(0, 0, 0, .7);
    overflow: hidden;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Lomo del libro */
.book-spread::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 80px;
    transform: translateX(-50%) translateZ(0);
    background: linear-gradient(to right,
            transparent 0%,
            rgba(0, 0, 0, .2) 45%,
            rgba(0, 0, 0, .6) 50%,
            rgba(0, 0, 0, .2) 55%,
            transparent 100%);
    z-index: 20;
    pointer-events: none;
}

.page {
    flex: 1;
    padding: 40px 38px;
    position: relative;
    background-color: #fdfaf0;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 5;
    transform: translateZ(0);
    scrollbar-width: thin;
    scrollbar-color: #c8b99a transparent;
}

.page::-webkit-scrollbar {
    width: 4px;
}

.page::-webkit-scrollbar-thumb {
    background: #c8b99a;
    border-radius: 4px;
}

.page::-webkit-scrollbar-track {
    background: transparent;
}

.page-left {
    border-radius: 5px 0 0 5px;
    background: linear-gradient(to left, #e8e4d8 0%, #fdfaf0 8%);
    box-shadow: inset -20px 0 30px -15px rgba(0, 0, 0, .15);
}

.page-right {
    border-radius: 0 20px 20px 0;
    background: linear-gradient(to right, #e8e4d8 0%, #fdfaf0 8%);
    box-shadow: inset 20px 0 30px -15px rgba(0, 0, 0, .15);
}

.ornament {
    text-align: center;
    color: #8b7d6b;
    font-size: 28px;
    margin-bottom: 16px;
    opacity: 0.7;
}

.book-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    text-align: center;
    font-weight: 700;
    color: #2d2d2d;
    letter-spacing: -0.01em;
    margin-bottom: 16px;
}

.chapters-list {}

.section-title {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    color: #2d2d2d;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    margin-top: 12px;
    margin-bottom: 6px;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 6px;
}

.section-icon {
    font-size: 1rem !important;
    color: #8b7d6b;
}

.chapter-item {
    font-family: 'Crimson Pro', serif;
    color: #4a4a4a;
    font-size: 0.78rem;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 3px;
    line-height: 1.4;
}

.chapter-item span:first-child {
    flex: 1;
    padding-right: 8px;
}

.chapter-item span:last-child {
    font-weight: 600;
    white-space: nowrap;
    color: #8b7d6b;
}

.book-footer {
    background: transparent !important;
    padding-top: 12px;
    flex-shrink: 0;
}

.close-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background-color 0.25s ease, color 0.25s ease, transform 0.2s ease;
    font-family: 'Playfair Display', serif;
    border: 1px solid #8b7d6b;
    background: rgba(139, 125, 107, .05);
    color: #5a5a5a;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    font-size: 0.75rem;
    padding: 8px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-style: italic;
}

.close-btn:hover {
    background: #4a4a4a;
    color: #fdfaf0;
    border-color: #4a4a4a;
    transform: translateY(-2px);
}

.title-libro::after {
    background: none !important;
}

.footer-libro {
    background-color: transparent !important;
}

.footer-libro::before {
    background: none !important;
}

/* ═══════════════════════════════════════════════════════════
   BOOK MODAL — MOBILE  (< 992px)
   ═══════════════════════════════════════════════════════════ */

.book-mobile {
    display: flex;
    flex-direction: column;
    background: #fdfaf0;
    border-radius: 20px 20px 0 0;
    max-height: 92dvh;
    overflow: hidden;
    box-shadow: 0 -8px 40px rgba(0, 0, 0, .35);
    /* Textura sutil de papel */
    background-image:
        radial-gradient(ellipse at 20% 0%, rgba(200, 185, 154, .15) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 100%, rgba(200, 185, 154, .1) 0%, transparent 60%);
}

/* Header fijo */
.book-mobile-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px 14px;
    border-bottom: 1px solid rgba(139, 125, 107, .2);
    background: #fdfaf0;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 10;
}

.book-mobile-icon {
    font-size: 22px !important;
    color: #8b7d6b;
    opacity: .8;
    flex-shrink: 0;
}

.book-mobile-title {
    font-family: 'Playfair Display', serif;
    font-size: 1rem;
    font-weight: 700;
    color: #2d2d2d;
    margin: 0;
    flex: 1;
}

.book-mobile-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #8b7d6b;
    padding: 4px;
    display: flex;
    align-items: center;
    border-radius: 6px;
    transition: background .15s;
    flex-shrink: 0;
}

.book-mobile-close:hover {
    background: rgba(139, 125, 107, .1);
}

.book-mobile-close .material-symbols-outlined {
    font-size: 20px !important;
}

/* Body scrollable */
.book-mobile-body {
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    padding: 16px 20px;
    scrollbar-width: thin;
    scrollbar-color: #c8b99a transparent;
}

.book-mobile-body::-webkit-scrollbar {
    width: 3px;
}

.book-mobile-body::-webkit-scrollbar-thumb {
    background: #c8b99a;
    border-radius: 4px;
}

/* Item de introducción */
.mobile-intro-item {
    font-family: 'Crimson Pro', serif;
    font-size: 0.9rem;
    font-weight: 600;
    color: #4a4a4a;
    display: flex;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(139, 125, 107, .06);
    border-radius: 8px;
    margin-bottom: 16px;
    letter-spacing: 0.05em;
}

/* Sección acordeón */
.mobile-section {
    margin-bottom: 12px;
    border: 1px solid rgba(139, 125, 107, .2);
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
}

.mobile-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    background: rgba(139, 125, 107, .08);
    font-family: 'Playfair Display', serif;
    font-size: 0.72rem;
    font-weight: 700;
    color: #2d2d2d;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    cursor: pointer;
    user-select: none;
    transition: background .15s;
}

.mobile-section-header:hover {
    background: rgba(139, 125, 107, .14);
}

.mobile-section-header .material-symbols-outlined {
    font-size: 16px !important;
    color: #8b7d6b;
    flex-shrink: 0;
}

/* Flecha toggle */
.mobile-section-header::after {
    content: "expand_more";
    font-family: 'Material Symbols Outlined';
    font-size: 18px;
    color: #8b7d6b;
    margin-left: auto;
    transition: transform .25s ease;
    flex-shrink: 0;
}

.mobile-section.open .mobile-section-header::after {
    transform: rotate(180deg);
}

/* Capítulos colapsables */
.mobile-chapters {
    display: none;
    padding: 6px 0;
}

.mobile-section.open .mobile-chapters {
    display: block;
}

.mobile-chapter {
    font-family: 'Crimson Pro', serif;
    font-size: 0.82rem;
    color: #4a4a4a;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    padding: 7px 14px;
    border-bottom: 1px solid rgba(139, 125, 107, .08);
    line-height: 1.45;
    transition: background .12s;
}

.mobile-chapter:last-child {
    border-bottom: none;
}

.mobile-chapter:hover {
    background: rgba(139, 125, 107, .05);
}

.mobile-chapter span:first-child {
    flex: 1;
}

.mobile-chapter span:last-child {
    font-weight: 700;
    color: #8b7d6b;
    white-space: nowrap;
    font-size: 0.78rem;
}

/* Footer fijo */
.book-mobile-footer {
    padding: 12px 20px 20px;
    border-top: 1px solid rgba(139, 125, 107, .15);
    background: #fdfaf0;
    flex-shrink: 0;
}

/* Modal posicionado en la parte inferior en mobile */
@media (max-width: 991.98px) {
    .modal-dialog {
        margin: 0 !important;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        max-width: 100% !important;
        transform: translateY(100%) !important;
    }

    .modal.show .modal-dialog {
        transform: translateY(0) !important;
    }

    .modal.fade .modal-dialog {
        transition: transform 0.3s ease-out !important;
    }

    .modal-content-libro {
        border-radius: 20px 20px 0 0 !important;
    }
}

/* Reducir animaciones */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

.section-title::after {
    background: transparent !important;
}

.book-footer::before {
    background: transparent !important;
    padding-top: 12px;
    flex-shrink: 0;
}