/* ═══════════════════════════════════════════════════════════════
   KissBooK Bibliotheque — Comic Reader Overlay
   Full-screen immersive reading experience
   Uses KissBooK Design System tokens
   ═══════════════════════════════════════════════════════════════ */

/* ══════════════════════════════════════════
   READER OVERLAY
   ══════════════════════════════════════════ */
.kbb-reader-overlay {
    position: fixed;
    inset: 0;
    z-index: 9997;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    flex-direction: column;
    color: #fff;
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    animation: kbbReaderIn 0.3s ease-out;
    user-select: none;
}

.kbb-reader-overlay *,
.kbb-reader-overlay *::before,
.kbb-reader-overlay *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

@keyframes kbbReaderIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ══════════════════════════════════════════
   READER HEADER
   ══════════════════════════════════════════ */
.kbb-reader-header {
    height: 50px;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
    z-index: 10;
    transition: transform 0.3s ease;
}

.kbb-reader-header.hidden {
    transform: translateY(-100%);
}

.kbb-reader-title {
    font-size: 14px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 50%;
}

.kbb-reader-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.kbb-reader-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.15s;
}

.kbb-reader-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.kbb-reader-close:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ff5555;
    border-color: rgba(239, 68, 68, 0.3);
}

.kbb-reader-page-info {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 600;
    min-width: 60px;
    text-align: center;
}

/* ══════════════════════════════════════════
   READER CONTENT
   ══════════════════════════════════════════ */
.kbb-reader-content {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
    min-height: 0;
}

.kbb-reader-page {
    max-width: 90vw;
    max-height: calc(100vh - 120px);
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    transition: opacity 0.3s ease, transform 0.3s ease;
    user-select: none;
    -webkit-user-drag: none;
}

.kbb-reader-page.fade-out {
    opacity: 0;
    transform: scale(0.98);
}

.kbb-reader-page.fade-in {
    opacity: 1;
    transform: scale(1);
}

/* Double-page spread */
.kbb-reader-spread {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: center;
}

.kbb-reader-spread .kbb-reader-page {
    max-width: 45vw;
}

/* ══════════════════════════════════════════
   NAVIGATION ARROWS
   ══════════════════════════════════════════ */
.kbb-reader-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.5);
    font-size: 22px;
    border: none;
    border-radius: 8px;
    transition: background 0.2s, color 0.2s;
    z-index: 5;
}

.kbb-reader-nav:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.kbb-reader-nav-prev {
    left: 12px;
}

.kbb-reader-nav-next {
    right: 12px;
}

.kbb-reader-nav:disabled {
    opacity: 0.2;
    cursor: default;
}

/* ══════════════════════════════════════════
   READER FOOTER
   ══════════════════════════════════════════ */
.kbb-reader-footer {
    height: 60px;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 16px;
    background: rgba(255, 255, 255, 0.05);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
    padding: 0 16px;
    transition: transform 0.3s ease;
}

.kbb-reader-footer.hidden {
    transform: translateY(100%);
}

/* ── Progress Bar ── */
.kbb-reader-progress {
    width: clamp(200px, 50vw, 600px);
    height: 4px;
    background: var(--kb-slate-700, #334155);
    border-radius: 2px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
}

.kbb-reader-progress:hover {
    height: 6px;
}

.kbb-reader-progress-fill {
    height: 100%;
    background: var(--kb-primary, #38bdf8);
    border-radius: 2px;
    transition: width 0.3s ease;
    min-width: 0;
}

/* ── Page Dots (small screens) ── */
.kbb-reader-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

.kbb-reader-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: all 0.2s;
}

.kbb-reader-dot.active {
    background: var(--kb-primary, #38bdf8);
    transform: scale(1.4);
}

/* ══════════════════════════════════════════
   READER LOADING STATE
   ══════════════════════════════════════════ */
.kbb-reader-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.8);
    z-index: 20;
}

.kbb-reader-loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--kb-primary, #38bdf8);
    border-radius: 50%;
    animation: kbbReaderSpin 0.8s linear infinite;
}

@keyframes kbbReaderSpin {
    to { transform: rotate(360deg); }
}

/* ══════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════ */
@media (max-width: 768px) {
    .kbb-reader-nav {
        width: 44px;
        height: 80px;
        font-size: 18px;
        border-radius: 6px;
    }

    .kbb-reader-nav-prev {
        left: 4px;
    }

    .kbb-reader-nav-next {
        right: 4px;
    }

    .kbb-reader-header {
        height: 44px;
        padding: 0 10px;
    }

    .kbb-reader-footer {
        height: 50px;
        gap: 10px;
    }

    .kbb-reader-page {
        max-width: 100vw;
        max-height: calc(100vh - 100px);
        border-radius: 0;
    }

    .kbb-reader-spread .kbb-reader-page {
        max-width: 90vw;
    }

    .kbb-reader-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }
}

@media (max-width: 480px) {
    .kbb-reader-title {
        display: none;
    }

    .kbb-reader-nav {
        width: 36px;
        opacity: 0.4;
    }
}
