/* La Cripta - 3D Bookshelf Styling */

.cripta-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem 5rem;
}

.cripta-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 4rem;
}

.cripta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 4rem 2rem;
    perspective: 1000px;
    /* Enable 3D space */
}

/* 3D Book Item */
.cripta-book-item {
    position: relative;
    width: 200px;
    height: 300px;
    margin: 0 auto;
    transform-style: preserve-3d;
    transition: transform 0.4s ease, box-shadow 0.4s ease;
    cursor: pointer;
    box-shadow: 10px 20px 30px rgba(0, 0, 0, 0.5);
    border-radius: 4px 12px 12px 4px;
}

.cripta-book-item:hover {
    transform: translateY(-10px) rotateY(-5deg) rotateX(5deg);
    box-shadow: 15px 25px 40px rgba(0, 0, 0, 0.7);
}

/* Base Cover */
.cripta-book-cover {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 2px 10px 10px 2px;
    background-color: var(--color-bg-alt);
    background-size: cover;
    background-position: center;
    transform: translateZ(10px);
    z-index: 2;
    overflow: hidden;
}

/* Spine effect */
.cripta-book-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 20px;
    height: 100%;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.2) 0%, rgba(0, 0, 0, 0.5) 100%);
    border-radius: 4px 0 0 4px;
    transform: rotateY(-90deg) translateZ(10px);
    transform-origin: left;
}

/* Pages effect (right side) */
.cripta-book-item::after {
    content: '';
    position: absolute;
    top: 4px;
    right: -10px;
    width: 20px;
    height: calc(100% - 8px);
    background: #f4edd4;
    background-image: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0, 0, 0, 0.05) 3px);
    border-radius: 0 4px 4px 0;
    transform: rotateY(90deg) translateZ(calc(100% - 10px));
    transform-origin: right;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
}

/* Overlay for styling missing covers */
.cripta-book-fallback {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a1a1a, #0a0a0a);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    text-align: center;
    border: 1px solid var(--color-divine-gold);
}

.cripta-book-fallback h4 {
    color: var(--color-divine-gold);
    font-family: var(--font-headings);
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.cripta-book-fallback p {
    color: var(--color-silver);
    font-size: 0.8rem;
    font-style: italic;
}

/* Modal */
.cripta-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.cripta-modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.cripta-modal-content {
    background: #fdfaf6;
    /* Light parchment theme */
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    border: 1px solid rgba(212, 175, 55, 0.5);
    border-radius: 8px;
    overflow-y: auto;
    position: relative;
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.cripta-modal-overlay.open .cripta-modal-content {
    transform: translateY(0);
}

.close-modal-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    color: #333333;
    font-size: 2rem;
    cursor: pointer;
    z-index: 10;
    transition: color 0.2s;
}

.close-modal-btn:hover {
    color: var(--color-divine-gold);
}

.modal-body {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 3rem;
    padding: 3rem;
}

.modal-cover-container {
    box-shadow: 10px 20px 30px rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    overflow: hidden;
    height: max-content;
}

.modal-cover {
    width: 100%;
    height: auto;
    display: block;
}

.modal-tag {
    display: inline-block;
    padding: 0.2rem 0.8rem;
    border: 1px solid var(--color-divine-gold);
    color: var(--color-divine-gold);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1rem;
    border-radius: 50px;
}

.modal-title {
    font-family: var(--font-headings);
    font-size: 2.2rem;
    color: #1a1a1a;
    margin-bottom: 0.5rem;
    line-height: 1.2;
}

.modal-author {
    color: #4a4a4a;
    font-family: var(--font-primary);
    font-size: 1.2rem;
    font-style: italic;
    margin-bottom: 1.5rem;
}

.separator-line {
    height: 1px;
    background: linear-gradient(90deg, var(--color-divine-gold) 0%, transparent 100%);
    margin-bottom: 1.5rem;
    opacity: 0.6;
}

.modal-desc {
    color: #333333;
    line-height: 1.8;
    font-size: 1rem;
    opacity: 0.9;
}

#modalLink {
    background: #1a1a1a;
    color: var(--color-divine-gold);
    border: 1px solid var(--color-divine-gold);
}

#modalLink:hover {
    background: var(--color-divine-gold);
    color: #1a1a1a;
}

@media (max-width: 768px) {
    .modal-body {
        grid-template-columns: 1fr;
        padding: 2rem;
        gap: 2rem;
    }

    .modal-cover-container {
        max-width: 250px;
        margin: 0 auto;
    }

    .cripta-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 3rem 1rem;
    }

    .cripta-book-item {
        width: 160px;
        height: 240px;
    }
}

/* ===== Botón Flotante: Libros Ocultos ===== */
.libros-ocultos-fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 900;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.85rem 1.4rem;
    background: linear-gradient(135deg, #1a1a2e 0%, #2d1b4e 100%);
    color: var(--color-divine-gold, #d4af37);
    border: 1px solid rgba(212, 175, 55, 0.5);
    border-radius: 50px;
    font-family: var(--font-heading, 'Cinzel', serif);
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    cursor: pointer;
    box-shadow:
        0 4px 20px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(212, 175, 55, 0.15);
    transition: all 0.3s ease;
    animation: fabPulse 3s ease-in-out infinite;
}

.libros-ocultos-fab:hover {
    background: linear-gradient(135deg, #2d1b4e 0%, #4a2a7a 100%);
    border-color: var(--color-divine-gold, #d4af37);
    box-shadow:
        0 8px 30px rgba(0, 0, 0, 0.5),
        0 0 20px rgba(212, 175, 55, 0.2);
    transform: translateY(-3px);
    animation: none;
}

.libros-ocultos-fab:active {
    transform: translateY(-1px);
}

@keyframes fabPulse {

    0%,
    100% {
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(212, 175, 55, 0.15);
    }

    50% {
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), 0 0 12px rgba(212, 175, 55, 0.3);
    }
}

@media (max-width: 768px) {
    .libros-ocultos-fab span {
        display: none;
    }

    .libros-ocultos-fab {
        padding: 1rem;
        border-radius: 50%;
        font-size: 1.2rem;
        bottom: 1.5rem;
        right: 1.5rem;
    }
}