/* ============================================================
   JBuku Viewer — Editorial style, unified bottom controls
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Playfair+Display:wght@600&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body.jbuku-viewer-page {
    background: #1c1917;
    font-family: 'Inter', system-ui, sans-serif;
    overflow: hidden;
    height: 100dvh;
    width: 100vw;
}

#jbuku-app {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    width: 100vw;
}

/* ── TOP BAR ─────────────────────────────────────────────── */
.jbuku-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #111110;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    padding: 0 16px;
    height: 48px;
    flex-shrink: 0;
    z-index: 50;
}

.jbuku-title {
    font-family: 'Playfair Display', serif;
    font-size: 14px;
    font-weight: 600;
    color: #e7e5e4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
    letter-spacing: 0.01em;
}

.jbuku-topbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.jbuku-tb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: #a8a29e;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.jbuku-tb-btn:hover { background: rgba(255,255,255,0.08); color: #fafaf9; }
.jbuku-tb-btn svg { width: 18px; height: 18px; fill: currentColor; display: block; }

.jbuku-btn-download {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: 6px;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.12);
    color: #d6d3d1;
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    font-family: 'Inter', sans-serif;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
.jbuku-btn-download:hover { background: rgba(255,255,255,0.13); color: #fff; }
.jbuku-btn-download svg { width: 14px; height: 14px; fill: currentColor; flex-shrink: 0; }

/* ── STAGE ───────────────────────────────────────────────── */
.jbuku-stage {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    background: #1c1917;
    background-image: radial-gradient(ellipse at 50% 0%, rgba(120,100,80,0.07) 0%, transparent 70%);
}

#jbuku-flipbook {
    transform-origin: center center;
    transition: transform 0.2s ease;
    filter: drop-shadow(0 8px 40px rgba(0,0,0,0.8)) drop-shadow(0 2px 8px rgba(0,0,0,0.5));
}

/* ── Progress bar ────────────────────────────────────────── */
.jbuku-progress {
    position: absolute;
    bottom: 0; left: 0;
    width: 100%; height: 2px;
    background: rgba(255,255,255,0.05);
    pointer-events: none;
}
.jbuku-progress-bar {
    height: 100%;
    background: #c2a46a;
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 0 2px 2px 0;
}

/* ── BOTTOM BAR — unified controls ──────────────────────── */
.jbuku-bottombar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: #111110;
    border-top: 1px solid rgba(255,255,255,0.07);
    padding: 10px 16px;
    flex-shrink: 0;
}

/* Prev / Next buttons */
.jbuku-bar-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 16px;
    height: 40px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.10);
    background: rgba(255,255,255,0.06);
    color: #d6d3d1;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, transform 0.1s;
    white-space: nowrap;
    user-select: none;
}
.jbuku-bar-btn:hover {
    background: rgba(255,255,255,0.12);
    color: #fff;
}
.jbuku-bar-btn:active { transform: scale(0.96); }
.jbuku-bar-btn svg {
    width: 18px; height: 18px;
    fill: currentColor;
    flex-shrink: 0;
}

/* Zoom-only buttons (icon only, smaller) */
.jbuku-bar-icon {
    width: 40px;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Page counter pill */
.jbuku-page-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.09);
    border-radius: 20px;
    padding: 6px 16px;
    font-size: 13px;
    color: #a8a29e;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    min-width: 70px;
    justify-content: center;
}
.jbuku-page-pill strong { color: #e7e5e4; font-weight: 600; }

/* ── Loading ─────────────────────────────────────────────── */
.jbuku-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    color: #78716c;
    font-size: 13px;
    transition: opacity 0.3s;
    z-index: 10;
}
.jbuku-spinner {
    width: 30px; height: 30px;
    border: 2px solid rgba(255,255,255,0.07);
    border-top-color: #c2a46a;
    border-radius: 50%;
    animation: jbuku-spin 0.75s linear infinite;
}
@keyframes jbuku-spin { to { transform: rotate(360deg); } }

/* Page faces */
.jbuku-page { background: #fff; overflow: hidden; }
.jbuku-page img {
    width: 100%; height: 100%;
    object-fit: cover; display: block;
    pointer-events: none; -webkit-user-drag: none;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 580px) {
    .jbuku-title { font-size: 13px; }
    .jbuku-btn-download span { display: none; }

    .jbuku-bottombar { gap: 4px; padding: 8px 10px; }

    .jbuku-bar-btn { padding: 0 10px; height: 38px; font-size: 12px; gap: 4px; }
    .jbuku-bar-btn span { display: none; } /* hide text label on mobile */
    .jbuku-bar-btn svg { width: 20px; height: 20px; }
    .jbuku-bar-icon { width: 38px; }

    .jbuku-page-pill { padding: 5px 12px; font-size: 12px; min-width: 58px; }
}
