/* ABOUTME: Self-hosted page-flip catalog viewer ([wsllc_flipbook], or [flipbook_catalog] with a
   ABOUTME: local copy). Markup from wsllc_flipbook_html(), behaviour in js/wsllc-flipbook.js. */

.wsllc-fb {
    --fb-accent: #ca511d;
    --fb-fg: #2b2b2b;
    --fb-muted: #6b6b6b;
    --fb-line: #e4e1de;
    --fb-desk: #f3f1ee;
    --fb-ratio: 0.7727;            /* one page, width / height; JS sets the real value */
    --fb-flip: 650ms;
    position: relative;
    margin: 24px 0;
    scroll-margin-top: 100px;     /* clear The7's floating header when a #catalog-pN link jumps here */
    border: 1px solid var(--fb-line);
    border-radius: 8px;
    background: var(--fb-desk);
    color: var(--fb-fg);
    outline: none;
}
.wsllc-fb *, .wsllc-fb *::before, .wsllc-fb *::after { box-sizing: border-box; }

/* ---- GSL catalog: green plaster desk (images/flipbook-gsl-green.webp) instead of the grey ---- */
.wsllc-fb--gsl-catalog {
    --fb-desk: #16291e;
    border-color: #0f1f16;
    background: #16291e url("../images/flipbook-gsl-green.webp") center / 1200px auto repeat;
}
.wsllc-fb--gsl-catalog .wsllc-fb__page.has-img,
.wsllc-fb--gsl-catalog .wsllc-fb__face { box-shadow: 0 8px 26px rgba(0, 0, 0, .45); }
.wsllc-fb--gsl-catalog .wsllc-fb__goto label { color: #fff; }
.wsllc-fb--gsl-catalog .wsllc-fb__goto-field { color: rgba(255, 255, 255, .72); }
.wsllc-fb--gsl-catalog .wsllc-fb__nav { border-color: transparent !important; }
.wsllc-fb--gsl-catalog .wsllc-fb__page.is-loading::before { border-color: rgba(255, 255, 255, .25); border-top-color: #fff; }

/* ---- bar ---- */
.wsllc-fb__bar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 12px 10px 18px;
    border-bottom: 1px solid var(--fb-line);
    background: #fff;
    border-radius: 8px 8px 0 0;
}
.wsllc-fb .wsllc-fb__title { margin: 0 !important; padding: 0 !important; font-size: 16px !important; line-height: 1.3 !important; font-weight: 600 !important; }
.wsllc-fb__tools { display: flex; gap: 4px; }
.wsllc-fb .wsllc-fb__btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; min-width: 0 !important; margin: 0 !important; padding: 0 !important;
    border: 1px solid transparent !important; border-radius: 6px !important;
    background: transparent !important; color: var(--fb-fg) !important;
    box-shadow: none !important; cursor: pointer;
}
.wsllc-fb .wsllc-fb__btn:hover,
.wsllc-fb .wsllc-fb__btn[aria-expanded="true"] { background: var(--fb-desk) !important; border-color: var(--fb-line) !important; }
.wsllc-fb .wsllc-fb__btn:focus-visible { outline: 2px solid var(--fb-accent); outline-offset: 1px; }
.wsllc-fb .wsllc-fb__mute { display: none; }
.wsllc-fb .is-muted .wsllc-fb__mute { display: inline; }
.wsllc-fb .is-muted .wsllc-fb__wave { display: none; }
.wsllc-fb svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---- stage + book ---- */
.wsllc-fb__stage {
    position: relative;
    display: flex; align-items: center; justify-content: center;
    padding: 22px 56px;
    user-select: none;
    touch-action: pan-y;
}
.wsllc-fb__book {
    position: relative;
    display: flex;
    width: 100%;
    max-width: calc(var(--fb-max-h, 78vh) * var(--fb-ratio) * 2);
    aspect-ratio: calc(var(--fb-ratio) * 2);
    perspective: 2600px;
}
.wsllc-fb.is-single .wsllc-fb__book {
    max-width: calc(var(--fb-max-h, 78vh) * var(--fb-ratio));
    aspect-ratio: var(--fb-ratio);
}
.wsllc-fb__page {
    position: relative;
    flex: 1 1 50%;
    overflow: hidden;
    background: transparent;
}
.wsllc-fb.is-single .wsllc-fb__page.is-left { display: none; }
.wsllc-fb__page.has-img { background: #fff; box-shadow: 0 6px 18px rgba(0, 0, 0, .14); cursor: zoom-in; }
.wsllc-fb__page img,
.wsllc-fb__leaf img {
    position: absolute; inset: 0;
    display: block;
    width: 100% !important; height: 100% !important; max-width: none !important;
    object-fit: contain;
    pointer-events: none;
}
/* the fold: a soft shadow on each page's inner edge */
.wsllc-fb:not(.is-single) .wsllc-fb__page.is-left.has-img::after,
.wsllc-fb:not(.is-single) .wsllc-fb__page.is-right.has-img::after {
    content: ""; position: absolute; top: 0; bottom: 0; width: 7%; pointer-events: none;
}
.wsllc-fb:not(.is-single) .wsllc-fb__page.is-left.has-img::after { right: 0; background: linear-gradient(to left, rgba(0,0,0,.16), transparent); }
.wsllc-fb:not(.is-single) .wsllc-fb__page.is-right.has-img::after { left: 0; background: linear-gradient(to right, rgba(0,0,0,.16), transparent); }
.wsllc-fb__page.is-loading::before {
    content: ""; position: absolute; top: 50%; left: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px;
    border: 2px solid var(--fb-line); border-top-color: var(--fb-accent); border-radius: 50%;
    animation: wsllc-fb-spin .8s linear infinite;
}
@keyframes wsllc-fb-spin { to { transform: rotate(360deg); } }

/* the turning leaf: absolutely over one half of the book, rotating on the spine */
.wsllc-fb__leaf {
    position: absolute; top: 0; bottom: 0; width: 50%;
    transform-style: preserve-3d;
    transition: transform var(--fb-flip) cubic-bezier(.45, .05, .35, 1);
    z-index: 3;
    pointer-events: none;
}
.wsllc-fb__leaf.is-fwd { left: 50%; transform-origin: left center; }
.wsllc-fb__leaf.is-back { left: 0; transform-origin: right center; }
.wsllc-fb__leaf.is-fwd.is-turned { transform: rotateY(-180deg); }
.wsllc-fb__leaf.is-back.is-turned { transform: rotateY(180deg); }
.wsllc-fb__face {
    position: absolute; inset: 0;
    backface-visibility: hidden; -webkit-backface-visibility: hidden;
    background: #fff;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .14);
}
.wsllc-fb__face.is-blank { background: transparent; box-shadow: none; }
.wsllc-fb__face.is-under { transform: rotateY(180deg); }
.wsllc-fb__face::after { content: ""; position: absolute; inset: 0; opacity: 0; transition: opacity var(--fb-flip) ease; pointer-events: none; }
.wsllc-fb__leaf.is-fwd .wsllc-fb__face:not(.is-under)::after { background: linear-gradient(to left, rgba(0,0,0,.25), transparent 60%); }
.wsllc-fb__leaf.is-back .wsllc-fb__face:not(.is-under)::after { background: linear-gradient(to right, rgba(0,0,0,.25), transparent 60%); }
.wsllc-fb__leaf.is-turned .wsllc-fb__face::after { opacity: 1; }

/* single-page mode: a quick slide instead of a turn */
.wsllc-fb.is-single .wsllc-fb__page.is-right img { transition: opacity .25s ease, transform .25s ease; }
.wsllc-fb.is-single .wsllc-fb__page.is-right.is-out-next img { opacity: 0; transform: translateX(-24px); }
.wsllc-fb.is-single .wsllc-fb__page.is-right.is-out-prev img { opacity: 0; transform: translateX(24px); }

/* ---- side arrows ---- */
.wsllc-fb .wsllc-fb__nav {
    position: absolute; top: 50%; z-index: 4;
    display: flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; margin: -22px 0 0 !important; padding: 0 !important;
    border: 1px solid var(--fb-line) !important; border-radius: 50% !important;
    background: #fff !important; color: var(--fb-fg) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .08) !important; cursor: pointer;
    transition: opacity .2s, border-color .2s, color .2s;
}
.wsllc-fb .wsllc-fb__nav:hover { border-color: var(--fb-accent) !important; color: var(--fb-accent) !important; }
.wsllc-fb .wsllc-fb__nav:focus-visible { outline: 2px solid var(--fb-accent); outline-offset: 2px; }
.wsllc-fb .wsllc-fb__nav[disabled] { opacity: 0; pointer-events: none; }
.wsllc-fb__nav.is-prev { left: 6px; }
.wsllc-fb__nav.is-next { right: 6px; }

/* ---- footer: slider + page box ---- */
.wsllc-fb__foot {
    display: flex; align-items: center; gap: 16px;
    padding: 10px 18px 14px;
}
.wsllc-fb .wsllc-fb__range {
    flex: 1 1 auto; min-width: 0; width: auto !important; height: 20px !important; margin: 0 !important; padding: 0 !important;
    border: 0 !important; background: none !important; box-shadow: none !important;
    -webkit-appearance: auto; appearance: auto; accent-color: var(--fb-accent);
}
.wsllc-fb__goto { margin: 0 !important; flex: 0 0 auto; }
.wsllc-fb__goto label { display: flex; align-items: center; gap: 12px; margin: 0 !important; font-size: 14px; font-weight: 600; white-space: nowrap; color: var(--fb-fg); }
.wsllc-fb__goto-field { font-weight: 400; color: var(--fb-muted); }
.wsllc-fb .wsllc-fb__goto input {
    width: 64px !important; height: 34px !important; margin: 0 0 0 6px !important; padding: 0 8px !important;
    border: 1px solid var(--fb-line) !important; border-radius: 6px !important; background: #fff !important;
    font-size: 14px !important; color: var(--fb-fg) !important;
}

/* ---- thumbnails ---- */
.wsllc-fb__thumbs {
    /* full height: the grid grows with the page and scrolls with it, no inner scroll bar */
    padding: 16px 18px 20px;
    scroll-margin-top: 100px;
    border-top: 1px solid var(--fb-line);
    background: #fff;
    border-radius: 0 0 8px 8px;
}
.wsllc-fb__thumbs[hidden] { display: none; }
.wsllc-fb__thumb-list {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 16px 12px;
    margin: 0 !important; padding: 0 !important; list-style: none !important;
}
.wsllc-fb__thumb-list li { margin: 0 !important; padding: 0 !important; list-style: none !important; }
.wsllc-fb .wsllc-fb__thumb {
    display: block; width: 100%; margin: 0 !important; padding: 0 !important;
    border: 0 !important; background: none !important; box-shadow: none !important;
    cursor: pointer; text-align: center; color: var(--fb-muted) !important; font-size: 12px !important; line-height: 1.6 !important;
}
.wsllc-fb__thumb img {
    display: block; width: 100% !important; max-width: none !important; height: auto !important; aspect-ratio: var(--fb-ratio);
    object-fit: contain;   /* whole page, never cropped */
    border: 2px solid transparent; border-radius: 3px; background: var(--fb-desk);
    box-shadow: 0 1px 4px rgba(0, 0, 0, .12);
}
.wsllc-fb__thumb:hover img { border-color: var(--fb-line); }
.wsllc-fb__thumb.is-current img { border-color: var(--fb-accent); }
.wsllc-fb__thumb.is-current { color: var(--fb-accent) !important; font-weight: 600; }

/* ---- zoom overlay (moved under <body> by the script, so it carries its own button styles) ---- */
.wsllc-fb__zoom .wsllc-fb__btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; min-width: 0 !important; margin: 0 !important; padding: 0 !important;
    border: 0 !important; border-radius: 6px !important;
    background: transparent !important; color: #fff !important; box-shadow: none !important; cursor: pointer;
}
.wsllc-fb__zoom .wsllc-fb__btn:hover { background: rgba(255, 255, 255, .12) !important; }
.wsllc-fb__zoom .wsllc-fb__btn[disabled] { opacity: .3; pointer-events: none; }
.wsllc-fb__zoom .wsllc-fb__btn:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }
.wsllc-fb__zoom svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.wsllc-fb__zoom {
    position: fixed; inset: 0; z-index: 2147483000;   /* above TranslatePress's flag (9999999) */
    display: flex; flex-direction: column;
    background: rgba(20, 20, 20, .94);
}
.wsllc-fb__zoom[hidden] { display: none; }
.wsllc-fb__zoom-bar {
    display: flex; align-items: center; justify-content: flex-end; gap: 6px;
    padding: 10px 14px; color: #fff; font-size: 14px;
}
.wsllc-fb__zoom-bar [data-fb-zoom-label] { margin-right: auto; padding-left: 6px; font-weight: 600; }
.wsllc-fb__zoom-scroll { flex: 1 1 auto; overflow: auto; -webkit-overflow-scrolling: touch; text-align: center; padding: 0 12px 24px; cursor: zoom-out; }
.wsllc-fb__zoom-scroll img { display: inline-block; width: min(100%, 1100px); max-width: none !important; height: auto; background: #fff; cursor: zoom-out; }
.wsllc-fb__zoom-scroll.is-full img { width: 1870px; cursor: zoom-out; }
html.wsllc-fb-noscroll { overflow: hidden; }

/* ---- full screen ---- */
.wsllc-fb:fullscreen { display: flex; flex-direction: column; margin: 0; border: 0; border-radius: 0; overflow: auto; }
.wsllc-fb:fullscreen .wsllc-fb__stage { flex: 1 1 auto; --fb-max-h: calc(100vh - 150px); }
.wsllc-fb:fullscreen .wsllc-fb__bar { border-radius: 0; }
.wsllc-fb:fullscreen .wsllc-fb__book { --fb-max-h: calc(100vh - 150px); }

@media (max-width: 767px) {
    .wsllc-fb__stage { padding: 14px 10px 8px; }
    .wsllc-fb .wsllc-fb__nav { width: 38px; height: 38px; margin-top: -19px !important; background: rgba(255, 255, 255, .92) !important; }
    .wsllc-fb__nav.is-prev { left: 4px; }
    .wsllc-fb__nav.is-next { right: 4px; }
    .wsllc-fb__foot { flex-wrap: wrap; gap: 8px 12px; padding: 8px 12px 12px; }
    .wsllc-fb__range { flex-basis: 100%; order: 2; }
    .wsllc-fb__goto { flex: 1 1 100%; }
    .wsllc-fb__goto label { justify-content: space-between; }
    .wsllc-fb .wsllc-fb__title { font-size: 15px !important; }
}
@media (prefers-reduced-motion: reduce) {
    .wsllc-fb { --fb-flip: 1ms; }
    .wsllc-fb.is-single .wsllc-fb__page.is-right img { transition: none; }
}
