/* ============================================================
   Flipbooks – Frontend Styles  v2.6.2
   • Edition archive  (.fb-archive)
   • Lightbox         (#fbv-lightbox)
   • Viewer           (.fb-viewer)
   ============================================================ */

/* ── Theme max-width override ─────────────────────────────── */
/* Breaks the archive out of narrow theme wrappers (e.g. .dp-page-content) */
.dp-page-content:has(.fb-archive) {
    max-width: 100% !important;
    width: 100% !important;
}

/* ── Reset ───────────────────────────────────────────────── */
.fb-archive *,
.fb-viewer *,
#fbv-lightbox * {
    box-sizing: border-box;
}

/* ============================================================
   EDITION ARCHIVE  — light theme
   ============================================================ */
.fb-archive {
    width: 100%;
    font-family: inherit; /* inherits the active theme's font */
    font-size: 15px;
}

/* Override theme paragraph margin inside the archive wrapper */
.dp-page-content p {
    margin-bottom: 5px !important;
}

/* ── Year filter pills + search bar (single row) ──────────── */
.fb-ar-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 16px 0;
    align-items: center;
}

/* Search pushed to the far right */
.fb-ar-search {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 7px;
    background: #f5f5f5;
    border: 1px solid #e8e8e8;
    border-radius: 999px;
    padding: 7px 16px;
    color: #c0c0c0;
    font-size: 12px;
    flex-shrink: 0;
}

.fb-search-input {
    background: none;
    border: none;
    outline: none;
    font-size: 12px;
    color: #555;
    font-family: inherit;
    width: 160px;
}

.fb-filter-pill {
    display: inline-flex;
    align-items: center;
    padding: 11px 28px;
    border-radius: 999px;
    border: 1px solid #ddd;
    background: transparent;
    color: #888;
    font-size: 15px;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    white-space: nowrap;
    line-height: 1;
}

.fb-filter-pill:hover {
    border-color: #aaa;
    color: #333;
}

.fb-filter-pill.is-active {
    background: #111;
    border-color: #111;
    color: #fff;
}

/* ── Two-column body ─────────────────────────────────────── */
.fb-ar-body {
    display: grid;
    --current-col: 40%; /* ← edit this % to resize the current-edition column */
    grid-template-columns: var(--current-col) 1fr;
    padding: 24px 0;
    gap: 0;
}

@media (max-width: 700px) {
    .fb-ar-body { grid-template-columns: 1fr; padding: 16px 0; }
    .fb-ar-current { border-right: none !important; border-bottom: 1px solid #eee; padding-right: 0 !important; padding-bottom: 20px; margin-bottom: 20px; }
    .fb-ar-past { padding-left: 0 !important; }
    .fb-grid { grid-template-columns: repeat(2, 1fr) !important; }
}

.fb-ar-current {
    padding-right: 28px;
    border-right: 1px solid #e8e8e8;
}

.fb-ar-past {
    padding-left: 28px;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* ── Section label ───────────────────────────────────────── */
.fb-ar-section-lbl {
    font-size: 15px !important;
    color: #999 !important;
    margin: 0 0 10px !important;
    font-weight: 600 !important;
}

/* ── Card label (title ABOVE card) ──────────────────────── */
.fb-card-label {
    font-size: 13px;
    color: #333;
    margin: 0 0 7px;
    line-height: 1.3;
    text-align: center;
}

/* ── Card ────────────────────────────────────────────────── */
.fb-card {
    position: relative;
    background: #fff;
    border: 1px solid #ebebeb;
    border-radius: 12px;
    padding: 10px;
    cursor: pointer;
    transition: border-color 0.15s;
}

.fb-card:hover {
    border-color: #ccc;
}

.fb-card-inner {
    display: flex;
    align-items: center;
    justify-content: center;
}

.fb-card-inner img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 6px;
}

.fb-no-cover {
    width: 100%;
    aspect-ratio: 3 / 4;
    background: #f0f0f0;
    border-radius: 6px;
    min-height: 160px;
}

/* ── Hover overlay ───────────────────────────────────────── */
.fb-card-hover {
    position: absolute;
    inset: 0;
    border-radius: 12px;
    background: rgba(0,0,0,0.62);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.fb-card:hover .fb-card-hover {
    opacity: 1;
    pointer-events: auto;
}

.fb-card-action {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.14);
    border: 1px solid rgba(255,255,255,0.28);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    transition: background 0.14s;
    padding: 0;
    flex-shrink: 0;
}

.fb-card-action:hover {
    background: rgba(255,255,255,0.28);
}

/* ── Previous editions grid (3 columns) ─────────────────── */
.fb-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px 10px;
    flex: 1;
}

@media (max-width: 900px) {
    .fb-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Card wrap: holds label + card */
.fb-card-wrap {
    display: flex;
    flex-direction: column;
}

/* ── Pagination ──────────────────────────────────────────── */
.fb-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding-top: 18px;
}

.fb-pg-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #666;
    transition: background 0.14s;
    padding: 0;
    flex-shrink: 0;
}

.fb-pg-btn:hover:not(:disabled) {
    background: #f0f0f0;
}

.fb-pg-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.fb-pg-num {
    font-size: 12px;
    color: #999;
    min-width: 40px;
    text-align: center;
}

/* ── Share modal (full-screen, blurred backdrop) ─────────── */
.fb-share-pop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.fb-share-pop.is-open {
    display: flex;
}

/* Centered dialog card */
.fb-share-dialog {
    background: #fff;
    border-radius: 22px;
    padding: 20px 20px 24px;
    width: 280px;
    box-shadow: 0 24px 72px rgba(0,0,0,0.28);
    animation: fb-share-in 0.22s cubic-bezier(0.34,1.56,0.64,1);
    position: relative;
}

@keyframes fb-share-in {
    from { transform: scale(0.88); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}

.fb-share-pop-head {
    text-align: center;
    margin-bottom: 20px;
    font-size: 15px;
    font-weight: 700;
    color: #111;
    padding: 0;
}

/* Prominent X close button — top-right corner */
.fb-share-pop-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #f0f0f0;
    border: none;
    cursor: pointer;
    color: #444;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.14s, color 0.14s;
}

.fb-share-pop-close:hover { background: #e0e0e0; color: #111; }

/* Icon-only grid: 3 columns, no text */
.fb-share-icons-row {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.fb-share-opt {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    transition: transform 0.14s;
}

.fb-share-opt:hover { transform: scale(1.1); }

.fb-sh-icon {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: box-shadow 0.14s;
}

.fb-share-opt:hover .fb-sh-icon {
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.fb-sh-icon--fb { background: #dbeafe; }
.fb-sh-icon--li { background: #e0edfa; }
.fb-sh-icon--em { background: #f0f0f0; }

/* ── Empty + Toast ───────────────────────────────────────── */
.fb-empty {
    color: #999 !important;
    font-style: italic !important;
}

.fb-toast {
    position: fixed !important;
    bottom: 28px !important;
    left: 50% !important;
    transform: translateX(-50%) translateY(20px) !important;
    background: rgba(20,20,20,0.92) !important;
    color: #fff !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    padding: 9px 20px !important;
    border-radius: 100px !important;
    opacity: 0 !important;
    transition: opacity 0.25s, transform 0.25s !important;
    pointer-events: none !important;
    z-index: 99999 !important;
}

.fb-toast.is-visible {
    opacity: 1 !important;
    transform: translateX(-50%) translateY(0) !important;
}

/* ============================================================
   LIGHTBOX
   ============================================================ */
#fbv-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99990;
    opacity: 0;
    transition: opacity 0.22s ease;
}

#fbv-lightbox.is-open {
    display: block;
}

/* Trigger fade-in on next frame after display:block */
#fbv-lightbox.is-visible {
    opacity: 1;
}

body.fbv-lb-open {
    overflow: hidden !important;
}

.fbv-lb-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

.fbv-lb-dialog {
    position: absolute;
    inset: 20px;
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: scale(0.97);
    transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

#fbv-lightbox.is-visible .fbv-lb-dialog {
    transform: scale(1);
}

@media (max-width: 600px) {
    .fbv-lb-dialog { inset: 0; border-radius: 0; }
}

/* ============================================================
   VIEWER  (shared by lightbox + standalone page)
   ============================================================ */

/* ─── Modern (default) ──────────────────────────────────── */
.fb-viewer {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: transparent;
    backdrop-filter: blur(32px);
    -webkit-backdrop-filter: blur(32px);
    color: #e8e8e8;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 13px;
    position: relative;
    overflow: hidden;
}

/* ── Floating close (replaces topbar for lightbox) ───────── */
.fbv-float-close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 30;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: rgba(30,30,30,0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.18);
    color: rgba(255,255,255,0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.18s, color 0.18s, transform 0.18s;
    padding: 0;
    flex-shrink: 0;
}

.fbv-float-close:hover {
    background: rgba(60,60,60,0.95);
    color: #fff;
    transform: scale(1.06);
}

/* Topbar */
.fbv-topbar {
    display: flex;
    align-items: center;
    height: 50px;
    padding: 0 12px;
    gap: 8px;
    background: rgba(20,20,20,0.72);
    backdrop-filter: blur(18px) saturate(1.4);
    -webkit-backdrop-filter: blur(18px) saturate(1.4);
    border-bottom: 1px solid rgba(255,255,255,0.07);
    flex-shrink: 0;
    position: relative;
    z-index: 2;
}

.fbv-topbar-center {
    flex: 1;
    display: flex;
    justify-content: center;
    overflow: hidden;
}

.fbv-title {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #ddd;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 480px;
}

.fbv-topbar-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.fbv-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #aaa;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 10px;
    border-radius: 8px;
    transition: color 0.18s, background 0.18s;
    flex-shrink: 0;
}

.fbv-back svg { flex-shrink: 0; }

.fbv-back:hover {
    color: #fff;
    background: rgba(255,255,255,0.07);
}

/* Buttons */
.fbv-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #bbb;
    transition: color 0.18s, background 0.18s;
    border-radius: 8px;
    padding: 8px;
    min-width: 38px;
    min-height: 38px;
}

.fbv-btn:hover { color: #fff; background: rgba(255,255,255,0.08); }

.fbv-lb-close {
    flex-shrink: 0;
}

/* Body */
.fbv-body {
    flex: 1;
    display: flex;
    overflow: hidden;
    min-height: 0;
}

/* Thumbnails panel */
.fbv-thumbs {
    width: 200px;
    flex-shrink: 0;
    overflow-y: auto;
    background: rgba(15,15,15,0.1);
    border-right: 1px solid rgba(255,255,255,0.06);
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}

.fbv-thumbs::-webkit-scrollbar { width: 4px; }
.fbv-thumbs::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

.fbv-thumbs-inner {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.fbv-thumb-item {
    cursor: pointer;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid transparent;
    transition: border-color 0.18s, opacity 0.18s;
    position: relative;
    opacity: 0.65;
    width: 168px;
    flex-shrink: 0;
}

.fbv-thumb-item:hover { opacity: 1; border-color: rgba(255,255,255,0.3); }
.fbv-thumb-item.is-active { opacity: 1; border-color: #fff; }

.fbv-thumb-canvas {
    display: block;
    width: 100% !important;
    height: auto !important;
}

.fbv-thumb-num {
    display: block;
    text-align: center;
    font-size: 10px;
    color: #888;
    padding: 3px 0 4px;
    background: rgba(0,0,0,0.5);
}

/* Main area */
.fbv-main {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 28px 20px;
    background: transparent;
    position: relative;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.12) transparent;
}

.fbv-main::-webkit-scrollbar { width: 6px; }
.fbv-main::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 4px; }

/* ── Side navigation arrows ──────────────────────────────── */
.fbv-side-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 15;
    width: 36px;
    height: 110px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.38);
    border: none;
    cursor: pointer;
    color: rgba(255,255,255,0.92);
    transition: background 0.2s, color 0.2s;
    padding: 0;
}

.fbv-side-btn:hover {
    background: rgba(0,0,0,0.60);
    color: #fff;
}

.fbv-side-prev {
    left: 0;
    border-radius: 0 10px 10px 0;
}

.fbv-side-next {
    right: 0;
    border-radius: 10px 0 0 10px;
}

/* ── turn.js book container ──────────────────────────────── */

/*
 * .fbv-turn-container wraps the turn.js book element.
 * Zoom is applied here via CSS transform so turn.js pixel
 * dimensions stay fixed and never need reinitialisation.
 */
.fbv-turn-container {
    display: inline-block;
    transform-origin: top center;
    /* smooth centering shift when moving between page 1 / spread / last page */
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    /* layered shadows around the full open spread */
    filter: drop-shadow(0 28px 72px rgba(0,0,0,0.85))
            drop-shadow(0 6px 18px rgba(0,0,0,0.55));
    /* prevent the unscaled layout footprint from pushing down the toolbar */
    overflow: visible;
    vertical-align: top;
}

/* The element turn.js is initialised on — explicit px size set by JS */
.fbv-turn-book {
    position: relative;
    background: transparent;
}

/* Individual page divs — JS sets position:relative + overflow:hidden */
.fbv-turn-page {
    background: #fff;
}

/* turn.js auto-inserts blank .hard pages at the start/end of the book
   (before page 1 and after the last page). Make them invisible. */
.fbv-turn-book .page.hard {
    background: transparent !important;
    box-shadow: none !important;
}

/* ── Text layer (for copy/paste) ─────────────────────────── */
.fbv-text-layer {
    position: absolute;
    top: 0;
    left: 0;
    overflow: hidden;
    line-height: 1;
    pointer-events: auto;
    user-select: text;
    -webkit-user-select: text;
}

.fbv-text-layer span,
.fbv-text-layer br {
    color: transparent;
    position: absolute;
    white-space: pre;
    cursor: text;
    transform-origin: 0% 0%;
    -webkit-text-stroke: 0px transparent;
}

.fbv-text-layer ::selection {
    background: rgba(60, 130, 246, 0.35);
    color: transparent;
}

/* Spinner */
.fbv-spinner {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(22,22,22,0.7);
    backdrop-filter: blur(4px);
}

.fbv-spinner span {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255,255,255,0.15);
    border-top-color: #fff;
    border-radius: 50%;
    animation: fbv-spin 0.7s linear infinite;
}

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

/* Error */
.fbv-error {
    color: #ff6b6b;
    text-align: center;
    padding: 40px 20px;
    font-size: 14px;
}

/* Toolbar */
.fbv-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    height: 54px;
    padding: 0 12px;
    background: rgba(20,20,20,0.42);
    backdrop-filter: blur(18px) saturate(1.4);
    -webkit-backdrop-filter: blur(18px) saturate(1.4);
    border-top: 1px solid rgba(255,255,255,0.07);
    flex-shrink: 0;
}

.fbv-toolbar-sep {
    width: 1px;
    height: 18px;
    background: rgba(255,255,255,0.1);
    margin: 0 6px;
    flex-shrink: 0;
}

.fbv-page-info {
    font-size: 12px;
    color: #aaa;
    min-width: 70px;
    text-align: center;
    flex-shrink: 0;
}

.fbv-zoom-label {
    font-size: 11px;
    color: #888;
    min-width: 36px;
    text-align: center;
    flex-shrink: 0;
}

/* ─── Classic override ──────────────────────────────────── */
.fb-ui-classic .fbv-topbar,
.fb-ui-classic .fbv-toolbar {
    background: #1e1e1e;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-color: #2e2e2e;
}

.fb-ui-classic .fbv-thumbs {
    background: #181818;
    border-color: #2a2a2a;
}

.fb-ui-classic .fbv-main {
    background: transparent;
}

/* ─── Standalone reader page ────────────────────────────── */
.fb-reader-standalone .fb-viewer--page {
    position: fixed;
    inset: 0;
    height: 100vh;
    z-index: 1;
}

/* ─── Mobile ─────────────────────────────────────────────── */
@media (max-width: 640px) {
    /* Hide thumbnail strip on mobile — single-page mode, no sidebar needed */
    .fbv-thumbs { display: none !important; }
    .fbv-title { font-size: 12px; }
    .fbv-toolbar { gap: 0; }
    .fbv-toolbar .fbv-btn { padding: 5px; }
    .fbv-toolbar-sep { margin: 0 3px; }
}
