
/* =========================================
   ESTILOS GENERALES
========================================= */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    padding: 25px 10px;
    font-family: Georgia, "Times New Roman", serif;
    background: radial-gradient(ellipse, #25251f, #121410);
    color: #fff6e7;
}

.encabezado {
    text-align: center;
    margin-bottom: 30px;
}

.encabezado h1 {
    font-size: clamp(26px, 4vw, 42px);
    margin-bottom: 8px;
}

.encabezado p,
.ayuda {
    color: #c2cfda;
    font-family: Arial, sans-serif;
    font-size: 13px;
}

/* =========================================
   ESCENARIO Y LIBRO
========================================= */

.escenario {
    display: flex;
    justify-content: center;
    padding: 10px;
    perspective: 2200px;
}

.libro {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: min(940px, 96vw);
    height: clamp(380px, 55vw, 570px);
    background: #5a3924;
    border-radius: 5px 12px 12px 5px;
    box-shadow: 0 25px 35px #0008, 0 9px 0 #3c2719;
    transform-style: preserve-3d;
}

/* =========================================
   PÁGINAS
========================================= */

.pagina {
    position: relative;
    min-width: 0;
    height: 100%;
    overflow: hidden;
    color: #382a1d;
    background: #fffaf0;
    padding: clamp(14px, 2.5vw, 30px);
}

.izquierda {
    border-radius: 5px 0 0 5px;
    box-shadow: inset -15px 0 20px -18px #49321e;
}

.derecha {
    border-radius: 0 8px 8px 0;
    box-shadow: inset 15px 0 20px -18px #49321e;
}

/* =========================================
   CONTENIDO INTERIOR
========================================= */

.contenido {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    overflow: hidden;
}

.contenido h2 {
    color: #704a29;
    text-align: center;
    font-size: clamp(18px, 2.5vw, 28px);
    font-weight: normal;
    margin: 5px 0;
}

/* IMÁGENES */

.contenido img {
    display: block;
    width: 100%;
    max-width: 100%;
    height: clamp(110px, 20vw, 220px);
    flex-shrink: 0;
    object-fit: contain;
    background: #f1e4cd;
    border: 4px solid white;
    outline: 1px solid #d7c4a6;
    box-shadow: 0 5px 12px #0002;
}

.contenido p {
    width: 100%;
    margin: 0;
    font-size: clamp(12px, 1.5vw, 16px);
    line-height: 1.65;
    text-align: justify;
    overflow-y: auto;
}

.numero-pagina {
    align-self: flex-end;
    color: #9e8767;
    font-size: 11px;
    flex-shrink: 0;
}

.pie-foto {
    color: #8b7457;
    font-size: 11px;
    font-style: italic;
    text-align: center;
    flex-shrink: 0;
}

/* =========================================
   PORTADA
========================================= */

.portada {
    justify-content: center;
    text-align: center;
    border: 5px double #b18c56;
    background: linear-gradient(135deg, #f8edda, #e5c99b);
    padding: 18px;
}

.portada h2 {
    font-size: clamp(23px, 3vw, 40px);
    letter-spacing: 3px;
}

.portada p {
    text-align: center;
    font-style: italic;
}

.portada img {
    height: 170px;
    max-width: 100%;
}

/* =========================================
   LOMO CENTRAL
========================================= */

.lomo {
    position: absolute;
    z-index: 12;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 12px;
    transform: translateX(-50%);
    background: linear-gradient(
        90deg,
        #51331e,
        #d0ad77,
        #80552f,
        #422817
    );
    box-shadow: 0 0 9px #0005;
    pointer-events: none;
}

/* =========================================
   HOJA QUE GIRA
========================================= */

.hoja {
    display: none;
    position: absolute;
    z-index: 10;
    top: 0;
    left: 50%;
    width: 50%;
    height: 100%;
    transform-style: preserve-3d;
    transform-origin: left center;
}

.cara {
    position: absolute;
    inset: 0;
    overflow: hidden;
    padding: clamp(14px, 2.5vw, 30px);
    color: #382a1d;
    background: #fffaf0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.frontal {
    border-radius: 0 8px 8px 0;
}

.trasera {
    transform: rotateY(180deg);
    border-radius: 8px 0 0 8px;
}

/* ANIMACIONES */

.girando-adelante {
    animation: girarAdelante 0.9s ease-in-out forwards;
}

.girando-atras {
    animation: girarAtras 0.9s ease-in-out forwards;
}

@keyframes girarAdelante {
    from {
        transform: rotateY(0deg);
    }

    to {
        transform: rotateY(-180deg);
    }
}

@keyframes girarAtras {
    from {
        transform: rotateY(0deg);
    }

    to {
        transform: rotateY(180deg);
    }
}

/* =========================================
   CONTROLES
========================================= */

.controles {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 30px;
}

button {
    padding: 12px 18px;
    color: #fff5e3;
    background: linear-gradient(#a98451, #70502e);
    border: 1px solid #d0b17e;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
}

button:hover:not(:disabled) {
    filter: brightness(1.2);
}

button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#contador {
    font: 13px Arial, sans-serif;
    color: #eee0c9;
}

.ayuda {
    text-align: center;
    margin-top: 20px;
}

/* =========================================
   ADAPTACIÓN A CELULARES
========================================= */

@media (max-width: 600px) {
    .libro {
        width: 96vw;
        height: 430px;
    }

    .pagina,
    .cara {
        padding: 12px;
    }

    .contenido {
        gap: 10px;
    }

    .contenido img {
        height: 120px;
    }

    .contenido p {
        font-size: 12px;
        line-height: 1.5;
    }

    .contenido h2 {
        font-size: 17px;
    }

    .controles {
        gap: 8px;
    }

    button {
        padding: 10px;
        font-size: 12px;
    }
}
