/* =============================================================
   PDF Flipbook — Transparent background, optional shadow
   ============================================================= */

.pdf-flipbook-wrap {
    background: transparent;
    border-radius: 0;
    font-family: 'Georgia', serif;
    user-select: none;
    position: relative;
    z-index: 10;
    isolation: isolate;
    width: 100%;
    box-sizing: border-box;
}

/* On mobile, give the entire flipbook a solid background so Avada
   text/image sections behind it cannot bleed through */
@media (max-width: 640px) {
    .pdf-flipbook-wrap {
        background: #0d1b35;
        border-radius: 8px;
        overflow: hidden;
        padding-bottom: 4px;
    }
}

/* --- Stage --- */
.pfb-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 20px 20px;
    position: relative;
}

/* --- Book --- */
.pfb-book {
    display: flex;
    align-items: stretch;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    max-width: 100%;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3), 0 2px 6px rgba(0,0,0,0.18);
    transition: box-shadow 0.2s;
}

.pfb-no-shadow .pfb-book {
    box-shadow: none;
}

/* Spine */
.pfb-book::after {
    content: '';
    position: absolute;
    left: 50%; top: 0; bottom: 0;
    width: 6px;
    transform: translateX(-50%);
    background: linear-gradient(to right, rgba(0,0,0,0.22), transparent, rgba(0,0,0,0.22));
    pointer-events: none;
    z-index: 5;
}

.pfb-no-shadow .pfb-book::after,
.pfb-book.pfb-single::after {
    display: none;
}

/* --- Page canvases --- */
.pfb-page-canvas {
    display: block;
    background: #f5f0e8;
    max-width: 50%;
    flex: 1;
    /* Prevent browser from applying its own smoothing which blurs the canvas */
    image-rendering: -webkit-optimize-contrast; /* Safari */
    image-rendering: crisp-edges;               /* Firefox */
}

.pfb-book.pfb-single .pfb-page-canvas {
    max-width: 100%;
    width: 100% !important;
}

/* --- Loading overlay --- */
.pfb-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.45);
    color: #fff;
    gap: 12px;
    z-index: 10;
    border-radius: 4px;
}

.pfb-spinner {
    width: 36px; height: 36px;
    border: 3px solid rgba(255,255,255,0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: pfb-spin 0.8s linear infinite;
}

@keyframes pfb-spin { to { transform: rotate(360deg); } }

.pfb-overlay p {
    margin: 0;
    font-size: 14px;
    opacity: 0.8;
    font-family: sans-serif;
}

/* --- Controls bar --- */
.pfb-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 20px;
    background: transparent;
    flex-wrap: wrap;
}

/* --- Buttons --- */
.pfb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 22px;
    background: rgba(0,0,0,0.45);
    border: 1.5px solid rgba(255,255,255,0.35);
    border-radius: 6px;
    color: #fff;
    font-size: 13px;
    font-family: sans-serif;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.pfb-btn:hover {
    background: rgba(0,0,0,0.65);
    border-color: rgba(255,255,255,0.65);
}

.pfb-btn:active { background: rgba(0,0,0,0.75); }

.pfb-btn:disabled {
    opacity: 0.35;
    cursor: default;
    pointer-events: none;
}

.pfb-btn-next {
    background: rgba(10,30,70,0.7);
    border-color: rgba(255,255,255,0.5);
}

.pfb-btn-next:hover { background: rgba(10,30,70,0.9); }

/* --- Page counter --- */
.pfb-page-info {
    color: rgba(255,255,255,0.85);
    font-size: 13px;
    font-family: sans-serif;
    min-width: 130px;
    text-align: center;
    letter-spacing: 0.02em;
    text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

/* --- Dot indicators --- */
.pfb-dots {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 20px 18px;
    background: transparent;
    flex-wrap: wrap;
}

.pfb-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    cursor: pointer;
    border: none;
    padding: 0;
    transition: background 0.2s, transform 0.2s;
    flex-shrink: 0;
}

.pfb-dot:hover {
    background: rgba(255,255,255,0.6);
    transform: scale(1.2);
}

.pfb-dot.pfb-dot-active {
    background: rgba(255,255,255,0.9);
    width: 22px;
    border-radius: 4px;
}

/* =============================================================
   FULLSCREEN LIGHTBOX
   A fixed backdrop is injected into <body> so it sits above
   everything including Avada headers, sticky navs, etc.
   ============================================================= */

/* The backdrop/lightbox shell — appended to <body> by JS */
.pfb-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999999;           /* above Avada header (~100000) */
    background: #0d1b35;
    flex-direction: column;
    overflow: hidden;
    /* Animate in */
    opacity: 0;
    transition: opacity 0.2s ease;
}

.pfb-lightbox.pfb-lightbox-open {
    display: flex;
    opacity: 1;
}

/* Scrollable page area inside lightbox */
.pfb-lightbox-stage {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 20px 10px;
    -webkit-overflow-scrolling: touch;
}

/* Book inside lightbox */
.pfb-lightbox .pfb-lightbox-book {
    display: flex;
    align-items: stretch;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    max-width: 100%;
    max-height: 100%;
    box-shadow: 0 12px 40px rgba(0,0,0,0.6);
}

.pfb-lightbox .pfb-lightbox-book::after {
    content: '';
    position: absolute;
    left: 50%; top: 0; bottom: 0;
    width: 6px;
    transform: translateX(-50%);
    background: linear-gradient(to right, rgba(0,0,0,0.22), transparent, rgba(0,0,0,0.22));
    pointer-events: none;
    z-index: 5;
}

.pfb-lightbox .pfb-lightbox-book.pfb-single::after {
    display: none;
}

/* Controls inside lightbox */
.pfb-lightbox .pfb-lightbox-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background: #0d1b35;
    flex-wrap: wrap;
    flex-shrink: 0;
}

/* Dots inside lightbox */
.pfb-lightbox .pfb-lightbox-dots {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 20px 16px;
    background: #0d1b35;
    flex-wrap: wrap;
    flex-shrink: 0;
}

/* EXIT button accent */
.pfb-lightbox .pfb-btn-exit {
    background: rgba(180,30,30,0.5);
    border-color: rgba(255,100,100,0.5);
}

.pfb-lightbox .pfb-btn-exit:hover {
    background: rgba(180,30,30,0.8);
}

/* Prevent body scroll when lightbox open */
body.pfb-noscroll {
    overflow: hidden !important;
    /* keep layout stable on desktop where scrollbar was visible */
    padding-right: var(--pfb-scrollbar-w, 0px);
}

/* =============================================================
   MOBILE  (≤ 640px)
   ============================================================= */
@media (max-width: 640px) {

    .pfb-stage {
        padding: 12px 8px 8px;
        min-height: 0 !important;
        align-items: flex-start;
        background: #0d1b35;  /* solid bg blocks any bleed-through */
    }

    .pfb-controls {
        background: #0d1b35 !important;
    }

    .pfb-dots {
        background: #0d1b35 !important;
    }

    .pfb-book { width: 100%; }

    .pfb-page-canvas {
        max-width: 100%;
        width: 100% !important;
        height: auto !important;
    }

    /* Controls grid — row 1: PREV | counter | NEXT  row 2: FULL SCREEN */
    .pfb-controls {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        grid-template-rows: auto auto;
        gap: 8px;
        padding: 10px 12px 6px;
        align-items: center;
    }

    .pfb-btn-prev     { grid-column: 1; grid-row: 1; justify-self: stretch; padding: 10px 8px; font-size: 13px; }
    .pfb-page-info    { grid-column: 2; grid-row: 1; min-width: 0; font-size: 12px; padding: 0 6px; white-space: nowrap; }
    .pfb-btn-next     { grid-column: 3; grid-row: 1; justify-self: stretch; padding: 10px 8px; font-size: 13px; }
    .pfb-btn-fullscreen { grid-column: 1 / -1; grid-row: 2; justify-self: center; margin-left: 0; font-size: 13px; padding: 10px 28px; }

    .pfb-dots { padding: 4px 12px 14px; gap: 5px; }
    .pfb-dot  { width: 7px; height: 7px; }
    .pfb-dot.pfb-dot-active { width: 18px; }

    /* Lightbox controls on mobile */
    .pfb-lightbox .pfb-lightbox-controls {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        grid-template-rows: auto auto;
        gap: 8px;
        padding: 10px 12px 6px;
    }

    .pfb-lightbox .pfb-btn-prev      { grid-column: 1; grid-row: 1; justify-self: stretch; padding: 10px 8px; font-size: 13px; }
    .pfb-lightbox .pfb-lbinfo        { grid-column: 2; grid-row: 1; }
    .pfb-lightbox .pfb-btn-next      { grid-column: 3; grid-row: 1; justify-self: stretch; padding: 10px 8px; font-size: 13px; }
    .pfb-lightbox .pfb-btn-exit      { grid-column: 1 / -1; grid-row: 2; justify-self: center; padding: 10px 28px; font-size: 13px; }

    .pfb-lightbox .pfb-lightbox-dots { gap: 5px; padding: 4px 12px 14px; }
    .pfb-lightbox .pfb-lightbox-dots .pfb-dot { width: 7px; height: 7px; }
    .pfb-lightbox .pfb-lightbox-dots .pfb-dot.pfb-dot-active { width: 18px; }
}

/* =============================================================
   FLIP TRANSITION
   The pfb-flip-wrap gets a perspective container.
   pfb-flipping triggers a rotateY animation on the book inside.
   ============================================================= */

.pfb-flip-wrap {
    perspective: 1800px;
    perspective-origin: center center;
}

/* The book itself is the 3D element */
.pfb-flip-wrap .pfb-book,
.pfb-flip-wrap .pfb-lightbox-book {
    transform-style: preserve-3d;
    transition: transform 0.19s ease-in, opacity 0.19s ease-in;
    transform-origin: center center;
    will-change: transform, opacity;
}

/* Going forward (next): fold away to the left, then come back */
.pfb-flip-wrap.pfb-flipping.pfb-flip-next .pfb-book,
.pfb-flip-wrap.pfb-flipping.pfb-flip-next .pfb-lightbox-book {
    transform: rotateY(-12deg) scaleX(0.96);
    opacity: 0.7;
    transition: transform 0.19s ease-in, opacity 0.19s ease-in;
}

/* Going back (prev): fold away to the right */
.pfb-flip-wrap.pfb-flipping.pfb-flip-prev .pfb-book,
.pfb-flip-wrap.pfb-flipping.pfb-flip-prev .pfb-lightbox-book {
    transform: rotateY(12deg) scaleX(0.96);
    opacity: 0.7;
    transition: transform 0.19s ease-in, opacity 0.19s ease-in;
}

/* Return to normal after content swap */
.pfb-flip-wrap .pfb-book,
.pfb-flip-wrap .pfb-lightbox-book {
    transform: rotateY(0deg) scaleX(1);
    opacity: 1;
    transition: transform 0.19s ease-out, opacity 0.19s ease-out;
}
