/* ==========================================================================
   BIBLIOTECA DIGITAL
   Requiere base.css cargado antes.
   ========================================================================== */

/* ---------- Contenedor (igual que noticias) ---------- */
.bib-wrapper {
    max-width: 1080px;
    width: 100%;
    margin: 0 auto;
    padding: 48px 24px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

/* ---------- Botón de volver (igual que noticias) ---------- */
.bib-back {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 28px;
}

/* ---------- Introducción (igual que noticias) ---------- */
.bib-intro {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-muted);
    margin-bottom: 16px;
}


/* ---------- Estantería ---------- */
.bib-estanteria {
    --escala: 1;
    margin-bottom: 44px;
}

.bib-fila {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 3px;
    padding: 56px 14px 0;          /* espacio para que el libro se levante sin cortarse */
    overflow-x: auto;
}

.bib-tabla {
    height: 14px;
    margin: 0 -8px;
    border-radius: 4px;
    background: var(--border-color);
    box-shadow: 0 10px 18px -10px rgba(0, 0, 0, 0.45);
}

/* ---------- Lomo del libro ---------- */
.bib-libro {
    flex: 0 0 auto;
    width: calc(var(--ancho) * var(--escala));
    height: calc(var(--alto) * var(--escala));
    margin: 0;
    padding: 10px 0;
    border: 0;
    border-radius: 2px 2px 0 0;
    background: var(--fondo);
    color: var(--texto);
    font: inherit;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    box-shadow:
        inset 2px 0 0 rgba(255, 255, 255, 0.14),
        inset -2px 0 0 rgba(0, 0, 0, 0.2);
    transition:
        transform 380ms cubic-bezier(0.2, 0.8, 0.2, 1),
        box-shadow 380ms ease;
    -webkit-tap-highlight-color: transparent;
}

.bib-libro:hover,
.bib-libro:focus-visible,
.bib-libro.is-elevado {
    transform: translateY(-14px);
    box-shadow:
        inset 2px 0 0 rgba(255, 255, 255, 0.14),
        inset -2px 0 0 rgba(0, 0, 0, 0.2),
        0 16px 18px -8px rgba(0, 0, 0, 0.45);
}

.bib-libro:focus-visible {
    outline: 2px solid var(--accent-hover);
    outline-offset: 3px;
}

.bib-lomo-titulo {
    display: block;
    writing-mode: vertical-rl;
    max-height: calc(var(--alto) * var(--escala) - 24px);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-family: 'Archivo', Arial, sans-serif;
    font-weight: 700;
    font-size: 11px;
    line-height: 1;
    letter-spacing: 0.3px;
}

/* ---------- Portada centrada ---------- */
.bib-velo {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 300ms ease;
    z-index: 900;
}

.bib-velo.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.bib-portada {
    position: fixed;
    left: 50%;
    top: 50%;
    width: min(240px, 62vw);
    aspect-ratio: 2 / 3;
    transform: translate(-50%, -50%) scale(0.85);
    opacity: 0;
    pointer-events: none;
    transition:
        opacity 300ms ease,
        transform 420ms cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 901;
}

.bib-portada.is-visible {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.bib-portada.is-pinned {
    pointer-events: auto;
    cursor: pointer;
}

.bib-portada-cubierta {
    position: relative;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    padding: 22px 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    background: var(--fondo);
    color: var(--texto);
    border-radius: 4px 8px 8px 4px;
    box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.6);
}

/* Marco interior de la portada */
.bib-portada-cubierta::before {
    content: "";
    position: absolute;
    inset: 10px;
    border: 1px solid currentColor;
    opacity: 0.35;
    border-radius: 2px;
    pointer-events: none;
}

/* Sombra del lomo a la izquierda */
.bib-portada-cubierta::after {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 10px;
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.3), transparent);
    pointer-events: none;
}

.bib-portada-anio {
    font-size: 0.75rem;
    letter-spacing: 2px;
    opacity: 0.7;
}

.bib-portada-titulo {
    font-family: 'Archivo', Arial, sans-serif;
    font-weight: 900;
    font-size: 1.5rem;
    line-height: 1.1;
    text-transform: uppercase;
    margin: 0 0 10px;
    overflow-wrap: anywhere;
}

.bib-portada-autor {
    margin: 0;
    font-size: 0.9rem;
    opacity: 0.85;
}

.bib-cerrar {
    position: absolute;
    top: -44px;
    right: 0;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: var(--card-bg);
    color: var(--text-main);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    display: none;
}

.bib-portada.is-pinned .bib-cerrar {
    display: block;
}

.bib-pista {
    position: absolute;
    top: calc(100% + 14px);
    left: 0;
    right: 0;
    margin: 0;
    text-align: center;
    font-size: 0.8rem;
    color: #fff;
    display: none;
}

.bib-portada.is-pinned .bib-pista {
    display: block;
}

/* ---------- Footer (igual que noticias) ---------- */
.bib-footer {
    margin-top: 48px;
    padding: 24px 0;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.85rem;
    color: var(--footer-text);
}

/* ---------- Tamaños en pantallas pequeñas ---------- */
@media (max-width: 720px) {
    .bib-estanteria {
        --escala: 0.7;
    }
}

@media (max-width: 480px) {
    .bib-estanteria {
        --escala: 0.5;
    }
}

/* ---------- Movimiento reducido ---------- */
@media (prefers-reduced-motion: reduce) {
    .bib-libro,
    .bib-velo,
    .bib-portada {
        transition: none;
    }
}


/* ---------- Fuente y enlace de lectura ---------- */
.bib-portada-fuente {
    margin: 6px 0 0;
    font-size: 0.75rem;
    opacity: 0.7;
}

.bib-leer {
    display: inline-block;
    margin-top: 14px;
    font-size: 0.85rem;
    font-weight: 700;
    color: inherit;
    text-decoration: none;
    border-bottom: 1px solid currentColor;
}

.bib-portada:not(.is-pinned) .bib-leer {
    display: none;
}