/* =====================================================
   VISOR DE REVISTA CIENTIFICA (FLIPBOOK)
   Adaptado de Modulo-revista para autocargar el PDF
   guardado por el admin, sin selector de archivo.
===================================================== */

.rv-seccion {
    background: var(--navy-deep);
    color: white;
    padding: 60px 0 80px;
}

.rv-encabezado {
    text-align: center;
    margin-bottom: 30px;
}

.rv-encabezado h1 {
    font-size: clamp(1.6rem, 3vw, 2.2rem);
    margin: 0 0 6px;
}

.rv-encabezado p {
    opacity: .8;
    margin: 0;
}

.rv-estado {
    text-align: center;
    margin: 10px 0 20px;
    color: #cbd5e1;
    font-size: .95rem;
}

.rv-progreso {
    width: min(90vw, 500px);
    height: 8px;
    background: rgba(255, 255, 255, .15);
    border-radius: 20px;
    overflow: hidden;
    margin: 0 auto 30px;
}

.rv-barra-progreso {
    width: 0%;
    height: 100%;
    background: var(--gold-accent);
    transition: .3s;
}

/* ===============================
   LIBRO
=============================== */

.rv-libro {
    width: min(90vw, 1100px);
    height: min(62vw, 680px);
    min-height: 380px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    perspective: 2500px;
    margin: 0 auto;
    transition: .4s;
    cursor: grab;
}

.rv-libro:active {
    cursor: grabbing;
}

.rv-libro.rv-cambiando {
    opacity: .5;
    transform: scale(.98);
}

/* ===============================
   ANIMACION DE HOJA (flip 3D real)
=============================== */

.rv-libro.rv-animando {
    cursor: default;
}

.rv-flip {
    position: absolute;
    top: 0;
    width: 50%;
    height: 100%;
    z-index: 40;
    transform-style: preserve-3d;
    transform: rotateY(0deg);
    transition: transform .7s cubic-bezier(.45, .05, .35, 1);
    will-change: transform;
}

.rv-flip-der {
    right: 0;
}

.rv-flip-izq {
    left: 0;
}

.rv-flip-cara {
    position: absolute;
    inset: 0;
    background: white;
    overflow: hidden;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .45);
}

.rv-flip-cara img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.rv-flip-frente {
    z-index: 2;
}

.rv-flip-dorso {
    transform: rotateY(180deg);
    z-index: 1;
}

.rv-pagina {
    width: 50%;
    height: 100%;
    position: relative;
    overflow: hidden;
    background: white;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .45);
    transition: transform .6s ease, opacity .3s ease;
}

.rv-pagina img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.rv-izquierda {
    border-radius: 10px 0 0 10px;
}

.rv-derecha {
    border-radius: 0 10px 10px 0;
}

/* Lomo central */
.rv-libro::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 0;
    transform: translateX(-50%);
    height: 100%;
    width: 30px;
    background: linear-gradient(90deg, rgba(0, 0, 0, .45), transparent, rgba(0, 0, 0, .35));
    z-index: 10;
    pointer-events: none;
}

/* Sombra alrededor */
.rv-libro::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    box-shadow: inset 0 0 80px rgba(0, 0, 0, .25);
    border-radius: 14px;
}

.rv-mensaje-libro {
    text-align: center;
    font-size: 1.2rem;
    opacity: .7;
    padding: 0 20px;
}

/* Zoom de lectura para PC */
.rv-pagina {
    transform-origin: center center;
    will-change: transform;
    transition: transform .28s ease, opacity .3s ease, box-shadow .28s ease;
}

.rv-pagina.rv-zoom {
    box-shadow: 0 25px 80px rgba(0, 0, 0, .65);
    cursor: grab;
}

.rv-pagina.rv-zoom:active {
    cursor: grabbing;
}

.rv-libro.rv-zoom-activo {
    z-index: 30;
    overflow: visible;
}

.rv-libro.rv-zoom-activo .rv-pagina:not(.rv-zoom) {
    opacity: .82;
}

/* ===============================
   CONTROLES
=============================== */
.rv-controles {
    margin-top: 30px;
    text-align: center;
}

.rv-controles button,
.rv-zoom-controles button {
    padding: 11px 20px;
    margin: 5px;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    background: white;
    color: var(--navy-deep);
    font-weight: 700;
    transition: transform .2s, opacity .2s;
}

.rv-controles button:hover,
.rv-zoom-controles button:hover {
    transform: scale(1.04);
}

.rv-controles button:disabled,
.rv-zoom-controles button:disabled {
    opacity: .4;
    cursor: not-allowed;
    transform: none;
}

.rv-zoom-controles {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 14px;
}

.rv-zoom-indicador {
    display: inline-flex;
    min-width: 62px;
    justify-content: center;
    align-items: center;
    padding: 10px 14px;
    border-radius: 25px;
    background: rgba(255,255,255,.12);
    color: white;
    font-weight: 700;
}

.rv-volver {
    text-align: center;
    margin-bottom: 24px;
}
/* ==========================================
   REVISTA CIENTÍFICA - LISTADO
========================================== */


.revistas-grid {

    display:grid;

    grid-template-columns:
    repeat(auto-fill,minmax(160px,1fr));

    gap:20px;

}



.revista-card {

    display:flex;

    flex-direction:column;

    min-width:0;

}



/* PORTADA */

.revista-portada {

    width:100%;

    max-width:100%;

    min-width:0;

    aspect-ratio: 3 / 4;

    height:auto;

    max-height:220px;

    overflow:hidden;

    border-radius:14px;

    background:#eef2f7;

    margin-bottom:18px;

    display:flex;

    align-items:center;

    justify-content:center;

}



.revista-portada img {

    width:100%;

    height:100%;

    min-width:0;

    max-width:100%;

    object-fit:cover;

    display:block;

}



.sin-portada {

    color:#64748b;

    font-size:.9rem;

}



/* DATOS */

.revista-datos {

    color:var(--muted);

    font-size:.9rem;

    margin-top:8px;

}



.revista-descripcion {

    font-size:.95rem;

    line-height:1.5;

}



.revista-accion {

    margin-top:auto;

    padding-top:18px;

}
#rvLibro:fullscreen {
    width: 100vw;
    height: 100vh;
    max-width: none;
    background: #111827;
}

#rvLibro:fullscreen .rv-pagina {
    max-height: 94vh;
}

@media (max-width: 700px) {
    .rv-libro {
        width: 100%;
        max-width: 100%;
        height: 120vw;
    }

    .rv-pagina {
        width: 100%;
    }

    .rv-izquierda {
        display: none;
    }

    .rv-derecha {
        width: 100%;
    }

    .rv-libro {
        touch-action: pan-y;
    }

    /* Ocultar el lomo/dorsal central en mobile (solo se ve una pagina) */
    .rv-libro::before {
        display: none;
    }

    /* En mobile se mantiene el gesto táctil. */
    .rv-controles {
        display: none;
    }

    .rv-zoom-controles {
        display: none;
    }

    /* La hoja animada ocupa todo el ancho, ya que en mobile
       solo se muestra una pagina por vez */
    .rv-flip {
        width: 100%;
        left: 0;
        right: 0;
    }
}

@media (max-width: 480px) {
    .revistas-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
    }

    .revista-portada {
        max-height: 160px;
    }
}

/* =====================================================
   LUPA LOCALIZADA - PC
   La revista queda al 100%; solo se muestra una ventana
   ampliada de la zona seleccionada con el mouse.
===================================================== */
.rv-lupa-activa {
    cursor: crosshair;
}

.rv-lupa-activa .rv-pagina {
    transform: none !important;
    opacity: 1 !important;
}

.rv-lupa-activa .rv-pagina img {
    pointer-events: none;
    user-select: none;
}

.rv-lupa-ventana {
    position: absolute;
    width: min(360px, 30vw);
    height: min(270px, 23vw);
    min-width: 260px;
    min-height: 195px;
    transform: translate(-50%, -50%);
    z-index: 200;
    border: 5px solid white;
    border-radius: 14px;
    background-repeat: no-repeat;
    background-color: white;
    box-shadow: 0 18px 55px rgba(0,0,0,.65), 0 0 0 2px rgba(0,0,0,.25);
    pointer-events: none;
    overflow: hidden;
}

.rv-lupa-ventana::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 9px;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.65), inset 0 0 35px rgba(0,0,0,.18);
    pointer-events: none;
}

.rv-zoom-indicador {
    font-variant-numeric: tabular-nums;
}

.rv-controles-secundarios {
    margin-top: 10px;
}

#rvLupa.activo {
    box-shadow: 0 0 0 3px rgba(255,255,255,.25);
}

@media (max-width: 700px), (pointer: coarse) {
    .rv-lupa-ventana { display: none !important; }
    #rvLupa { display: none; }
}

@media (min-width: 701px) and (pointer: fine) {
    .rv-libro.rv-lupa-activa .rv-pagina {
        cursor: crosshair;
    }
}

.rv-libro:fullscreen {
    width: 100vw;
    height: 100vh;
    background: var(--navy-deep);
    padding: 30px;
    box-sizing: border-box;
}

.rv-libro:fullscreen .rv-pagina {
    max-height: calc(100vh - 60px);
}
