/**
 * flipbook-styles.css
 * Design épuré : fond transparent, livre au premier plan,
 * barre de contrôles légère. Palette : #2A3539.
 */

/* ── Variables ─────────────────────────────────────────────── */
.flipbook {
    --fb-text:        #2A3539;
    --fb-text-light:  #6b8088;
    --fb-text-xlight: #a8bbbf;
    --fb-accent-bg:   rgba(42, 53, 57, 0.07);
    --fb-ctrl-border: rgba(42, 53, 57, 0.10);
    --fb-transition:  160ms ease;
    --fb-font-ui:     system-ui, -apple-system, sans-serif;
}

/* ── Reset ─────────────────────────────────────────────────── */
.flipbook *, .flipbook *::before, .flipbook *::after {
    box-sizing: border-box; margin: 0; padding: 0;
}

.flipbook {
    background: transparent;
    font-family: var(--fb-font-ui);
    color: var(--fb-text);
    position: relative;
    min-height: 300px;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* ── Wrapper ────────────────────────────────────────────────── */
.fb-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 20px 0 16px;
}

.fb-wrapper.is-fullscreen,
:fullscreen .fb-wrapper,
:-webkit-full-screen .fb-wrapper {
    background: #f4f3f1;
    padding: 28px 24px 20px;
    height: 100vh;
    width: 100vw;
    justify-content: space-between;
}

/* ── Loader ─────────────────────────────────────────────────── */
.fb-loader {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.88);
    backdrop-filter: blur(3px);
    z-index: 100;
    border-radius: 10px;
    transition: opacity var(--fb-transition), visibility var(--fb-transition);
}

.fb-loader.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.fb-loader-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.fb-loader-text {
    font-size: 12px;
    color: var(--fb-text-light);
    letter-spacing: 0.03em;
}

.fb-spinner {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid rgba(42, 53, 57, 0.10);
    border-top-color: var(--fb-text);
    animation: fb-spin 0.8s linear infinite;
}

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

/* ── Scène ──────────────────────────────────────────────────── */
.fb-stage {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
}

.fb-book-container {
    width: 100%;                /* Occupe toute la largeur de .fb-stage */
    display: flex;
    justify-content: center;
    transition: transform 0.20s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform;
    /* Ombre portée douce sous le livre */
    filter: drop-shadow(0 6px 32px rgba(0,0,0,0.16)) drop-shadow(0 2px 6px rgba(0,0,0,0.08));
    animation: fb-fadein 0.35s ease both;
    animation-play-state: paused;
}

.fb-loader.is-hidden ~ .fb-stage .fb-book-container {
    animation-play-state: running;
}

@keyframes fb-fadein {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.fb-book { margin: 0 auto; }

/* ── Pages ──────────────────────────────────────────────────── */
.fb-page {
    background: #ffffff;
    overflow: hidden;
}

.fb-page-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.25s ease;
}

.fb-page-img[data-pending] { opacity: 0.45; }

/* ── Barre de contrôles ─────────────────────────────────────── */
.fb-controls {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 440px;
    height: 48px;
    padding: 0 4px;
}

.fb-controls-left,
.fb-controls-right {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

/* ── Boutons ────────────────────────────────────────────────── */
.fb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--fb-text-xlight);
    cursor: pointer;
    transition: background var(--fb-transition), color var(--fb-transition), transform 80ms ease;
}

.fb-btn svg { width: 17px; height: 17px; flex-shrink: 0; }
.fb-btn:hover { background: var(--fb-accent-bg); color: var(--fb-text); }
.fb-btn:active { transform: scale(0.90); }
.fb-btn:disabled { opacity: 0.18; pointer-events: none; }
.fb-btn:focus-visible { outline: 2px solid var(--fb-text); outline-offset: 2px; }
.fb-btn.is-active { color: var(--fb-text); background: var(--fb-accent-bg); }

.fb-btn-prev, .fb-btn-next { width: 40px; height: 40px; }
.fb-btn-prev svg, .fb-btn-next svg { width: 20px; height: 20px; }

/* ── Indicateur de page ─────────────────────────────────────── */
.fb-page-indicator {
    display: flex;
    align-items: center;
    gap: 2px;
    font-size: 13px;
    font-family: Georgia, 'Times New Roman', serif;
    color: var(--fb-text-light);
    padding: 0 10px;
    min-width: 78px;
    justify-content: center;
    letter-spacing: 0.01em;
}

.fb-page-current {
    color: var(--fb-text);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    border-radius: 4px;
    padding: 2px 5px;
    transition: background var(--fb-transition);
}

.fb-page-current:hover { background: var(--fb-accent-bg); }

.fb-page-current[contenteditable="true"] {
    background: var(--fb-accent-bg);
    outline: 1.5px solid var(--fb-text);
    min-width: 28px;
    text-align: center;
}

.fb-page-sep { opacity: 0.28; margin: 0 1px; }
.fb-page-total { font-variant-numeric: tabular-nums; }

/* ── Séparateur ─────────────────────────────────────────────── */
.fb-divider {
    width: 1px;
    height: 15px;
    background: var(--fb-ctrl-border);
    margin: 0 4px;
    flex-shrink: 0;
}

/* ── Erreurs ────────────────────────────────────────────────── */
.fb-error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 48px 32px;
    text-align: center;
    min-height: 240px;
}

.fb-error-icon  { font-size: 26px; opacity: 0.35; }
.fb-error-title { font-size: 14px; font-weight: 600; color: var(--fb-text); }

.fb-error-detail {
    font-size: 11px;
    color: var(--fb-text-light);
    max-width: 340px;
    word-break: break-all;
}

.fb-error-inline {
    padding: 10px 14px;
    background: rgba(200, 50, 50, 0.07);
    color: #b04040;
    border-left: 3px solid #c04040;
    border-radius: 4px;
    font-size: 13px;
    margin: 8px 0;
}

/* ── Mobile ─────────────────────────────────────────────────── */
@media (max-width: 767px) {
    .fb-wrapper { gap: 12px; padding: 12px 0 14px; }
    .fb-stage   { padding: 0 6px; }
    .fb-controls { max-width: 100%; padding: 0 4px; }
    .fb-btn-zoom-reset { display: none; }
}

/* ── Plein écran ────────────────────────────────────────────── */
:fullscreen .fb-stage, :-webkit-full-screen .fb-stage { flex: 1; }
:fullscreen .fb-controls, :-webkit-full-screen .fb-controls { max-width: 440px; }
