/* PDF Flipbook – styly. Barvy lze přepsat CSS proměnnými na elementu .pfb */
.pfb {
    --pfb-bg: #2a2d33;
    --pfb-bg-toolbar: #1f2126;
    --pfb-fg: #e9ebee;
    --pfb-accent: #ffffff;
    --pfb-page-bg: #ffffff;
    --pfb-radius: 10px;

    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    box-sizing: border-box;
    background: var(--pfb-bg);
    color: var(--pfb-fg);
    font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    border-radius: var(--pfb-radius);
    overflow: hidden;
    outline: none;
    -webkit-user-select: none;
    user-select: none;
}
.pfb *, .pfb *::before, .pfb *::after { box-sizing: border-box; }
.pfb:focus-visible { box-shadow: 0 0 0 3px rgba(120, 170, 255, .6); }

.pfb:fullscreen { border-radius: 0; width: 100vw; height: 100vh; }
.pfb:-webkit-full-screen { border-radius: 0; width: 100vw; height: 100vh; }

/* ---------- scéna ---------- */
.pfb-stage {
    position: relative;
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 260px;
    padding: 28px 56px;
    overflow: hidden;
}
.pfb--single .pfb-stage { padding: 16px 44px; }

/* zoom a posun; bez will-change, aby prohlížeč obsah po přiblížení překreslil ostře */
.pfb-zoom { position: relative; flex: 0 0 auto; }
.pfb-zoom.is-animated { transition: transform .25s ease-out; }

.pfb-book {
    position: relative;
    perspective: 4200px;
    transition: transform .7s cubic-bezier(.645, .045, .355, 1);
    touch-action: pan-y pinch-zoom;
    cursor: pointer;
}
.pfb:not(.pfb--ready) .pfb-book { display: none; }

/* při 1× jde svisle posouvat web, roztažení prsty zpracuje flipbook; při přiblížení všechna gesta */
.pfb--can-zoom .pfb-stage,
.pfb--can-zoom .pfb-zoom,
.pfb--can-zoom .pfb-book { touch-action: pan-y; }
.pfb--zoomed .pfb-stage,
.pfb--zoomed .pfb-zoom,
.pfb--zoomed .pfb-book { touch-action: none; cursor: grab; }
.pfb--panning .pfb-stage,
.pfb--panning .pfb-zoom,
.pfb--panning .pfb-book { cursor: grabbing; }

.pfb-slot,
.pfb-face {
    position: absolute;
    top: 0;
    height: 100%;
    overflow: hidden;
    background: var(--pfb-page-bg);
}
.pfb-slot { width: 50%; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); }
.pfb-left { left: 0; }
.pfb-right { left: 50%; }
.pfb--single .pfb-left { display: none; }
.pfb--single .pfb-right { left: 0; width: 100%; }
.pfb-slot.is-empty { background: transparent; box-shadow: none; }

.pfb-slot img,
.pfb-face img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

/* stín ve hřbetu */
.pfb--double .pfb-slot:not(.is-empty)::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 12%;
    pointer-events: none;
    z-index: 2;
}
.pfb--double .pfb-left::after { right: 0; background: linear-gradient(to left, rgba(0,0,0,.18), rgba(0,0,0,0)); }
.pfb--double .pfb-right::after { left: 0; background: linear-gradient(to right, rgba(0,0,0,.18), rgba(0,0,0,0)); }

.pfb-shade {
    position: absolute;
    inset: 0;
    background: #000;
    opacity: 0;
    pointer-events: none;
    z-index: 3;
}

/* placeholder při načítání stránky */
.is-loading::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 28px;
    height: 28px;
    margin: -14px 0 0 -14px;
    border: 3px solid rgba(0, 0, 0, .12);
    border-top-color: rgba(0, 0, 0, .45);
    border-radius: 50%;
    animation: pfb-spin .8s linear infinite;
    z-index: 1;
}

/* ---------- otáčená stránka ---------- */
.pfb-flipper {
    position: absolute;
    top: 0;
    height: 100%;
    width: 50%;
    transform-style: preserve-3d;
    z-index: 10;
    pointer-events: none;
}
.pfb-flipper-fwd { left: 50%; transform-origin: left center; }
.pfb-flipper-back { left: 0; transform-origin: right center; }
.pfb-flipper-single { left: 0; width: 100%; transform-origin: left center; }

.pfb-face {
    left: 0;
    width: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    box-shadow: 0 0 25px rgba(0, 0, 0, .25);
}
.pfb-face-back { transform: rotateY(180deg); }
.pfb-face.is-empty { background: var(--pfb-page-bg); }

/* ---------- boční šipky ---------- */
.pfb-side {
    position: absolute;
    top: 50%;
    z-index: 20;
    width: 44px;
    height: 64px;
    margin-top: -32px;
    border: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--pfb-fg);
    opacity: .7;
    cursor: pointer;
    transition: opacity .2s, transform .2s;
}
.pfb-side svg { width: 32px; height: 32px; }
.pfb-side:hover { opacity: 1; }
.pfb-side-prev { left: 6px; }
.pfb-side-next { right: 6px; }
.pfb-side-prev:hover { transform: translateX(-2px); }
.pfb-side-next:hover { transform: translateX(2px); }
.pfb--zoomed .pfb-side { background: rgba(31, 33, 38, .65); border-radius: 8px; }
.pfb-side:disabled { opacity: 0; pointer-events: none; }
/* při přiblížení je šipka nad stránkou: rychlé klepání na konci katalogu nesmí propadnout jako dvojklik */
.pfb--zoomed .pfb-side:disabled { pointer-events: auto; cursor: default; }
.pfb--single .pfb-side { width: 36px; }
.pfb:not(.pfb--ready) .pfb-side { display: none; }

/* ---------- stav (načítání / chyba) ---------- */
.pfb-status {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--pfb-fg);
    opacity: .85;
}
.pfb-status[hidden] { display: none; }
.pfb-status-text { max-width: 560px; padding: 0 20px; text-align: center; }
.pfb-status-detail { margin-top: 8px; font-size: 13px; opacity: .75; word-break: break-word; -webkit-user-select: text; user-select: text; }
.pfb-spinner {
    width: 26px;
    height: 26px;
    border: 3px solid rgba(255, 255, 255, .2);
    border-top-color: var(--pfb-accent);
    border-radius: 50%;
    animation: pfb-spin .8s linear infinite;
}
@keyframes pfb-spin { to { transform: rotate(360deg); } }

/* ---------- lišta ---------- */
.pfb-toolbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 10px;
    background: var(--pfb-bg-toolbar);
}
.pfb-group { display: flex; align-items: center; gap: 2px; }
.pfb-toolbar::before { content: ""; flex: 1 1 0; } /* vycentrování hlavní skupiny */
.pfb-group-extra { flex: 1 1 0; justify-content: flex-end; }
.pfb:not(.pfb--ready) .pfb-group { visibility: hidden; }

.pfb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 6px;
    padding: 0;
    background: transparent;
    color: var(--pfb-fg);
    cursor: pointer;
    text-decoration: none;
    transition: background .15s;
}
.pfb-btn:hover { background: rgba(255, 255, 255, .1); color: var(--pfb-accent); }
.pfb-btn:disabled { opacity: .3; cursor: default; background: transparent; }

.pfb-counter { display: inline-flex; align-items: center; gap: 6px; padding: 0 8px; white-space: nowrap; }
.pfb-input {
    min-width: 3ch;
    height: 28px;
    padding: 0 4px;
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 5px;
    background: rgba(255, 255, 255, .06);
    color: var(--pfb-fg)!important;
    font: inherit;
    text-align: center;
}
.pfb-input:focus { outline: none; border-color: rgba(255, 255, 255, .5); }
.pfb-total { opacity: .7; }

/* úzký katalog – rozhoduje šířka katalogu, ne okna (třídu nastavuje flipbook.js) */
.pfb--compact .pfb-btn-first,
.pfb--compact .pfb-btn-last { display: none; }
.pfb--compact .pfb-toolbar { gap: 4px; padding: 6px 4px; }
.pfb--compact .pfb-toolbar::before { display: none; }
.pfb--compact .pfb-group { flex: 0 1 auto; min-width: 0; }
.pfb--compact .pfb-btn { flex: 0 1 36px; min-width: 24px; }
.pfb--compact .pfb-group { gap: 0; }
.pfb--compact .pfb-counter { padding: 0 2px; }

@media (prefers-reduced-motion: reduce) {
    .pfb-book, .pfb-zoom.is-animated { transition: none; }
}
