/* =====================================================================
   Maqueteo Flipbook — estilos
   ===================================================================== */

/* ---------- Portada 3D (lo que se ve en la página) ---------- */
.mqf-ebook-wrap {
    display: flex;
    width: 100%;
    margin: 16px 0;
}

.mqf-ebook {
    display: inline-block;
    cursor: pointer;
    text-align: center;
    perspective: 2000px;
    -webkit-perspective: 2000px;
    outline: none;
    user-select: none;
}

.mqf-book-3d {
    position: relative;
    width: var(--mqf-w, 300px);
    height: var(--mqf-h, 420px);
    margin: 0 auto;
    transform-style: preserve-3d;
    transform: rotateY(-24deg) rotateX(2deg);
    transition: transform .6s cubic-bezier(.2, .8, .2, 1);
    will-change: transform;
}

.mqf-ebook:hover .mqf-book-3d,
.mqf-ebook:focus .mqf-book-3d {
    transform: rotateY(-7deg) rotateX(1deg) translateY(-6px);
}

/* Cara frontal (la portada) */
.mqf-book-cover {
    position: absolute;
    inset: 0;
    border-radius: 3px 6px 6px 3px;
    overflow: hidden;
    background: #2b2b2b;
    box-shadow:
        0 1px 1px rgba(0, 0, 0, .15),
        0 18px 34px rgba(0, 0, 0, .38);
    transform: translateZ(2px);
    backface-visibility: hidden;
}

.mqf-cover-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Render de la portada desde el PDF (cuando no hay imagen "cover") */
.mqf-cover-pdf {
    background-color: #1d1d1d;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: opacity .4s ease;
}
.mqf-cover-pdf:not(.loaded)::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 50% 45%, rgba(255,255,255,.08), transparent 60%);
}
.mqf-cover-pdf:not(.loaded) {
    background-image: linear-gradient(135deg, #3a3a3a 0%, #232323 100%);
    animation: mqf-pulse 1.4s ease-in-out infinite;
}
@keyframes mqf-pulse { 0%,100% { opacity: .85; } 50% { opacity: 1; } }

/* Lomo izquierdo (la doblez del libro) */
.mqf-book-spine {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 16px;
    z-index: 3;
    pointer-events: none;
    background: linear-gradient(
        90deg,
        rgba(0, 0, 0, .45) 0%,
        rgba(0, 0, 0, .12) 28%,
        rgba(255, 255, 255, .14) 48%,
        rgba(0, 0, 0, .10) 54%,
        rgba(0, 0, 0, 0) 100%
    );
}

/* Brillo que cruza al pasar el cursor */
.mqf-book-shine {
    position: absolute;
    inset: 0;
    z-index: 4;
    pointer-events: none;
    opacity: 0;
    background: linear-gradient(
        105deg,
        transparent 32%,
        rgba(255, 255, 255, .28) 46%,
        rgba(255, 255, 255, .05) 56%,
        transparent 64%
    );
    transition: opacity .5s ease;
}
.mqf-ebook:hover .mqf-book-shine,
.mqf-ebook:focus .mqf-book-shine { opacity: 1; }

/* Grosor / hojas del lado derecho (da la sensación de libro físico) */
.mqf-book-pages {
    position: absolute;
    top: 3px;
    bottom: 3px;
    left: 100%;
    width: var(--mqf-thick, 26px);
    transform-origin: left center;
    transform: rotateY(-90deg);
    background: repeating-linear-gradient(
        to right,
        #fbf9f3 0px,
        #fbf9f3 1px,
        #ded8c9 2px,
        #fbf9f3 3px
    );
    border-radius: 0 2px 2px 0;
    box-shadow: inset 0 0 8px rgba(0, 0, 0, .12);
}

.mqf-ebook-title {
    margin-top: 16px;
    font-weight: 700;
    font-size: 15px;
    color: inherit;
    letter-spacing: .2px;
}

/* ---------- Modal / visor ---------- */
.mqf-modal {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(38, 38, 38, .94);
    opacity: 0;
    transition: opacity .35s ease;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}
.mqf-modal.mqf-open { opacity: 1; }

.mqf-modal-close {
    position: absolute;
    top: 18px;
    right: 22px;
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #fff;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    z-index: 6;
    transition: background .2s ease, transform .2s ease;
}
.mqf-modal-close:hover { background: rgba(255, 255, 255, .15); transform: rotate(90deg); }

/* Área donde se monta el flipbook */
.mqf-stage {
    position: relative;
    width: 92%;
    height: 88%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.mqf-flip { margin: 0 auto; touch-action: pan-y; }

/* Sombra bajo el libro abierto */
.mqf-flip .stf__parent { filter: drop-shadow(0 20px 40px rgba(0, 0, 0, .45)); }

/* ---------- Animación de carga ---------- */
.mqf-loader {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    transition: opacity .4s ease;
    z-index: 5;
}
.mqf-loader.mqf-hide { opacity: 0; pointer-events: none; }

.mqf-spinner {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
}
.mqf-spinner::after {
    content: '';
    width: 26px;
    height: 26px;
    border: 3px solid #2bb3d6;
    border-top-color: transparent;
    border-radius: 50%;
    animation: mqf-spin .8s linear infinite;
}
@keyframes mqf-spin { to { transform: rotate(360deg); } }

.mqf-loader-text {
    background: #fff;
    color: #444;
    font-size: 14px;
    font-weight: 500;
    padding: 8px 18px;
    border-radius: 7px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, .18);
    white-space: nowrap;
}

/* ---------- Flechas de navegación ---------- */
.mqf-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 46px;
    height: 76px;
    border: 0;
    background: transparent;
    color: rgba(255, 255, 255, .85);
    font-size: 44px;
    line-height: 1;
    cursor: pointer;
    z-index: 6;
    transition: color .2s ease, transform .2s ease;
}
.mqf-nav:hover { color: #fff; }
.mqf-nav-prev { left: 6px; }
.mqf-nav-prev:hover { transform: translateY(-50%) translateX(-3px); }
.mqf-nav-next { right: 6px; }
.mqf-nav-next:hover { transform: translateY(-50%) translateX(3px); }

/* ---------- Barra inferior ---------- */
.mqf-toolbar {
    position: absolute;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
    background: rgba(0, 0, 0, .45);
    border-radius: 30px;
    z-index: 6;
    opacity: 0;
    transition: opacity .4s ease;
}
.mqf-toolbar.mqf-show { opacity: 1; }

.mqf-counter {
    color: #fff;
    font-size: 13px;
    padding: 0 12px;
    min-width: 64px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.mqf-tool-btn {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #fff;
    font-size: 17px;
    cursor: pointer;
    transition: background .2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
.mqf-tool-btn:hover { background: rgba(255, 255, 255, .18); }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
    .mqf-nav { font-size: 34px; width: 36px; }
    .mqf-stage { width: 96%; height: 84%; }
    .mqf-toolbar { bottom: 12px; }
}

/* ---------- Zoom / desplazamiento y páginas (v1.1) ---------- */
.mqf-stage { overflow: hidden; }
.mqf-viewport {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    touch-action: none;
}
.mqf-zoom { will-change: transform; transform-origin: center center; }

/* páginas (incluye portada/contraportada rígidas y la hoja en blanco de relleno) */
.mqf-page { background: #fff; }
.mqf-page img { display: block; width: 100%; height: 100%; object-fit: fill; }
.mqf-blank { background: #fff; }

/* controles de zoom en la barra */
.mqf-tb-sep { width: 1px; height: 20px; background: rgba(255,255,255,.22); margin: 0 4px; }
.mqf-zoom-lvl {
    color: #fff; font-size: 12px; min-width: 46px; text-align: center;
    cursor: pointer; font-variant-numeric: tabular-nums; user-select: none;
}
.mqf-tool-btn svg { pointer-events: none; }
.mqf-tool-btn[disabled] { opacity: .35; cursor: default; }

@media (max-width: 640px) {
    .mqf-tb-sep { margin: 0 2px; }
    .mqf-zoom-lvl { min-width: 40px; font-size: 11px; }
}
