/* ============================================================
   Por Pharma — Catalog Flipbook v3
   StPageFlip + PDF.js — big responsive viewer, real page flip
   ============================================================ */

/* ── Shell (outer wrapper) ─────────────────────────────────── */
.fb-shell {
    background: #0d0f18;
    border-radius: 16px;
    overflow: hidden;
    box-shadow:
        0 2px 4px rgba(0,0,0,.4),
        0 20px 60px rgba(0,0,0,.65);
    outline: none;
    position: relative;
}

/* ── Toolbar ───────────────────────────────────────────────── */
.fb-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(255,255,255,.035);
    border-bottom: 1px solid rgba(255,255,255,.07);
    position: relative;
    z-index: 10;
}
.fb-toolbar-center {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
}
.fb-toolbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

/* Toolbar buttons */
.fb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    border: none;
    background: rgba(255,255,255,.06);
    color: #b0bac5;
    cursor: pointer;
    transition: background .18s, color .18s, transform .1s;
    flex-shrink: 0;
}
.fb-btn:hover { background: rgba(255,255,255,.13); color: #fff; }
.fb-btn:active { transform: scale(.92); }
.fb-btn:disabled { opacity: .28; cursor: not-allowed; transform: none !important; }
.fb-btn svg { width: 18px; height: 18px; }

/* Page indicator */
.fb-indicator {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    color: #94a3b8;
    white-space: nowrap;
    letter-spacing: .01em;
    min-width: 90px;
    text-align: center;
    user-select: none;
}

/* Download button */
.fb-btn-dl {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 38px;
    padding: 0 14px;
    border-radius: 8px;
    border: none;
    background: rgba(59,130,246,.18);
    color: #7dd3fc;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background .18s, color .18s;
    white-space: nowrap;
}
.fb-btn-dl:hover { background: rgba(59,130,246,.32); color: #bae6fd; }
.fb-btn-dl svg { width: 15px; height: 15px; flex-shrink: 0; }
.fb-dl-txt { display: none; }
@media (min-width: 540px) { .fb-dl-txt { display: inline; } }

/* ── Stage (canvas area) ───────────────────────────────────── */
.fb-stage {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 580px;
    height: clamp(580px, 85vh, 1100px);
    overflow: hidden;
    background: radial-gradient(ellipse at 50% 60%, #131625 0%, #0d0f18 100%);
}

/* Fullscreen: stage fills shell */
.fb-shell:fullscreen .fb-stage,
.fb-shell:-webkit-full-screen .fb-stage {
    height: calc(100vh - 60px); /* minus toolbar */
    min-height: 0;
}

/* ── Book container (StPageFlip mounts here) ───────────────── */
.fb-book {
    position: relative;
    margin: 0 auto;
    /* Shadow beneath the book */
    filter: drop-shadow(0 24px 40px rgba(0,0,0,.8)) drop-shadow(0 4px 12px rgba(0,0,0,.5));
}

/* StPageFlip page elements */
.fb-page {
    background: #fff;
    overflow: hidden;
    /* Exact page size set by JS */
}
.fb-page canvas {
    display: block;
    width: 100%;
    height: 100%;
    /* 'auto' = browser's best quality algorithm — best for PDF text/vectors */
    image-rendering: auto;
    /* Retina: canvas internal res is already 2×; CSS stretches it at display size */
}

/* ── Loading overlay ───────────────────────────────────────── */
.fb-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: #0d0f18;
    z-index: 30;
    transition: opacity .35s;
}
.fb-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(255,255,255,.07);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: fb-spin .85s linear infinite;
}
@keyframes fb-spin { to { transform: rotate(360deg); } }
.fb-loading-txt {
    color: #64748b;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
}

/* ── Error state ───────────────────────────────────────────── */
.fb-error {
    display: none;
    position: absolute;
    inset: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 32px;
    text-align: center;
    color: #f87171;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    background: #0d0f18;
    z-index: 30;
}
.fb-error svg { width: 44px; height: 44px; opacity: .5; }

/* ── Swipe hint ────────────────────────────────────────────── */
.fb-swipe-hint {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
    color: rgba(255,255,255,.25);
    font-size: 11px;
    font-family: 'Inter', sans-serif;
    pointer-events: none;
    white-space: nowrap;
    z-index: 5;
    transition: opacity .5s;
}
.fb-swipe-hint svg { width: 13px; height: 13px; }
.fb-hint-hidden { opacity: 0 !important; }

/* Hide swipe hint on desktop */
@media (min-width: 768px) { .fb-swipe-hint { display: none; } }

/* ── Overlay nav arrows (left / right of book) ────────────── */
.fb-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    width: clamp(40px, 5vw, 56px);
    height: clamp(64px, 10vw, 96px);
    border: none;
    border-radius: 10px;
    background: rgba(10, 12, 24, 0.72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    color: rgba(255,255,255,.75);
    cursor: pointer;
    transition: background .18s, color .18s, transform .15s, opacity .2s;
    outline: none;
}
.fb-nav-btn:hover {
    background: rgba(10, 12, 24, 0.92);
    color: #fff;
}
.fb-nav-btn:focus-visible {
    outline: 2px solid rgba(99,179,237,.7);
    outline-offset: 2px;
}
.fb-nav-btn:active { transform: translateY(-50%) scale(.94); }
.fb-nav-btn:disabled {
    opacity: 0;
    pointer-events: none;
}
.fb-nav-btn svg { width: clamp(18px, 2.5vw, 26px); height: clamp(18px, 2.5vw, 26px); }

.fb-nav-prev { left:  clamp(8px, 1.5vw, 20px); }
.fb-nav-next { right: clamp(8px, 1.5vw, 20px); }

/* RTL: keep physical nav direction (catalog is LTR) */
[dir="rtl"] .fb-nav-prev { left:  clamp(8px, 1.5vw, 20px); right: auto; }
[dir="rtl"] .fb-nav-next { right: clamp(8px, 1.5vw, 20px); left:  auto; }

/* Mobile: smaller, slightly more inset */
@media (max-width: 767px) {
    .fb-nav-btn {
        width: 36px;
        height: 56px;
        border-radius: 8px;
        background: rgba(10,12,24,.6);
    }
    .fb-nav-prev { left:  4px; }
    .fb-nav-next { right: 4px; }
}
/* StPageFlip injects its own canvas into the DOM beside #fb-book */
/* Give it a nice perspective shadow */
.stf__parent {
    perspective: 2400px !important;
}
.stf__block {
    border-radius: 2px;
    overflow: hidden;
}

/* ── Fullscreen ────────────────────────────────────────────── */
.fb-shell:fullscreen,
.fb-shell:-webkit-full-screen {
    border-radius: 0;
    display: flex;
    flex-direction: column;
}
.fb-shell:fullscreen .fb-toolbar,
.fb-shell:-webkit-full-screen .fb-toolbar {
    flex-shrink: 0;
}

/* ── RTL — shell and book stay LTR ────────────────────────── */
[dir="rtl"] .fb-shell { direction: ltr; }
[dir="rtl"] .fb-toolbar {
    direction: rtl;
    flex-direction: row-reverse;
}
[dir="rtl"] .fb-toolbar-left  { flex-direction: row-reverse; }
[dir="rtl"] .fb-toolbar-right { flex-direction: row-reverse; }

/* ── Responsive ────────────────────────────────────────── */

/* Tablet: single-page, taller stage */
@media (min-width: 768px) and (max-width: 1023px) {
    .fb-stage {
        min-height: 500px;
        height: clamp(500px, 80vh, 900px);
    }
}

/* Mobile landscape + portrait */
@media (max-width: 767px) {
    .fb-stage {
        min-height: 380px;
        height: clamp(380px, 74vh, 660px);
        height: clamp(380px, 74dvh, 660px);
    }
    .fb-toolbar { padding: 8px 12px; }
    .fb-btn { width: 34px; height: 34px; }
    .fb-btn svg { width: 16px; height: 16px; }
    .fb-indicator { min-width: 60px; font-size: 12px; }
}
@media (max-width: 479px) {
    .fb-stage {
        min-height: 300px;
        height: clamp(300px, 72vh, 540px);
        height: clamp(300px, 72dvh, 540px);
    }
}
