/* ============================================================
   Journal RP — Flipbook viewer (AnyFlip style)
   Couverture seule, puis double-pages, page-turn 3D
   ============================================================ */

* { box-sizing: border-box; }

/* ---- Wrapper immersif ---- */
.fb-wrapper {
    background: #111;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px;
    position: relative;
    user-select: none;
    overflow: hidden;
}

.fb-wrapper.fullscreen {
    position: fixed;
    inset: 0;
    z-index: 99999;
}

/* Subtle vignette */
.fb-wrapper::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,0.4) 100%);
    pointer-events: none;
}

/* ---- Top bar ---- */
.fb-topbar {
    position: relative;
    z-index: 10;
    text-align: center;
    margin-bottom: 14px;
}

.fb-topbar h1 {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1.3rem;
    color: rgba(255,255,255,0.8);
    margin: 0 0 4px;
    font-weight: 400;
}

.fb-topbar .fb-meta {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.3);
    display: flex;
    gap: 12px;
    justify-content: center;
}

.fb-topbar .fb-meta a {
    color: #C89B3C;
    text-decoration: none;
}

/* ---- Book container ---- */
.fb-scene {
    perspective: 2500px;
    position: relative;
    z-index: 10;
    width: 100%;
    display: flex;
    justify-content: center;
}

.fb-book {
    position: relative;
    display: flex;
    transform-style: preserve-3d;
    /* width is animated via JS requestAnimationFrame — no CSS transition needed */
}

/* Dynamic sizing — set via JS */
.fb-book {
    height: 75vh;
    max-height: 800px;
}

/* Book shadow on surface */
.fb-book::after {
    content: '';
    position: absolute;
    bottom: -30px;
    left: 5%;
    right: 5%;
    height: 30px;
    background: radial-gradient(ellipse at center, rgba(0,0,0,0.4) 0%, transparent 70%);
    pointer-events: none;
    filter: blur(5px);
}

/* ---- Pages ---- */
.fb-page {
    width: 50%;
    height: 100%;
    position: relative;
    overflow: hidden;
    background: #faf9f6;
    flex-shrink: 0;
}

.fb-page-left {
    border-radius: 6px 0 0 6px;
}

.fb-page-right {
    border-radius: 0 6px 6px 0;
}

/* Cover mode: single page, rounded both sides */
.fb-book.cover-mode .fb-page-left {
    display: none;
}
.fb-book.cover-mode .fb-page-right {
    width: 100%;
    border-radius: 6px;
}

/* Page image */
.fb-page img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    background: #faf9f6;
}

/* Spine shadow overlays */
.fb-page-left::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 40px;
    height: 100%;
    background: linear-gradient(to left, rgba(0,0,0,0.08), transparent);
    pointer-events: none;
}

.fb-page-right::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 40px;
    height: 100%;
    background: linear-gradient(to right, rgba(0,0,0,0.08), transparent);
    pointer-events: none;
    z-index: 1;
}

/* Page edge effect (right side of right page) */
.fb-page-right::after {
    content: '';
    position: absolute;
    top: 2%;
    right: 0;
    width: 3px;
    height: 96%;
    background: linear-gradient(to right,
        rgba(0,0,0,0.05),
        rgba(0,0,0,0.02) 40%,
        rgba(255,255,255,0.2) 60%,
        rgba(0,0,0,0.05)
    );
    pointer-events: none;
}

/* Page number */
.fb-pagenum {
    position: absolute;
    bottom: 10px;
    font-size: 10px;
    color: rgba(0,0,0,0.25);
    font-family: Georgia, serif;
    z-index: 2;
}

.fb-page-left .fb-pagenum { left: 16px; }
.fb-page-right .fb-pagenum { right: 16px; }

/* Empty page (blank) */
.fb-page-blank {
    background: #faf9f6;
}

/* ---- Click zones ---- */
.fb-zone {
    position: absolute;
    top: 0;
    height: 100%;
    cursor: pointer;
    z-index: 30;
}

.fb-zone-left {
    left: 0;
    width: 30%;
}

.fb-zone-right {
    right: 0;
    width: 30%;
}

/* ---- Corner peel hint ---- */
.fb-corner {
    position: absolute;
    bottom: 0;
    width: 50px;
    height: 50px;
    z-index: 35;
    cursor: pointer;
    transition: all 0.3s ease;
}

.fb-corner-right {
    right: 0;
    background:
        linear-gradient(225deg, #faf9f6 45%, rgba(0,0,0,0.06) 45%, rgba(0,0,0,0.06) 46%, transparent 46%);
    border-radius: 0 0 6px 0;
}

.fb-corner-right:hover {
    width: 70px;
    height: 70px;
    background:
        linear-gradient(225deg, #f0ede6 42%, rgba(0,0,0,0.1) 42%, rgba(0,0,0,0.1) 44%, transparent 44%);
}

.fb-corner-left {
    left: 0;
    background:
        linear-gradient(315deg, transparent 46%, rgba(0,0,0,0.06) 46%, rgba(0,0,0,0.06) 45%, #faf9f6 45%);
    border-radius: 0 0 0 6px;
}

.fb-corner-left:hover {
    width: 70px;
    height: 70px;
    background:
        linear-gradient(315deg, transparent 44%, rgba(0,0,0,0.1) 44%, rgba(0,0,0,0.1) 42%, #f0ede6 42%);
}

/* ---- Flip overlay (the turning page) ---- */
.fb-turn {
    position: absolute;
    top: 0;
    height: 100%;
    transform-style: preserve-3d;
    z-index: 100;
    will-change: transform;
}

/* Forward flip: right page turns left, pivot on left edge */
.fb-turn-fwd {
    right: 0;
    transform-origin: left center;
}

/* Backward flip: left page turns right, pivot on right edge */
.fb-turn-bwd {
    left: 0;
    transform-origin: right center;
}

.fb-turn-front,
.fb-turn-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    overflow: hidden;
    background: #faf9f6;
}

.fb-turn-back {
    transform: rotateY(180deg);
}

.fb-turn-front img,
.fb-turn-back img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Dynamic shadow on the flip front (as it turns, left side gets dark) */
.fb-turn-front::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to right, rgba(0,0,0,0.0) 0%, rgba(0,0,0,0) 100%);
    pointer-events: none;
}

/* Dynamic shadow on the page underneath */
.fb-shadow-under {
    position: absolute;
    top: 0;
    height: 100%;
    z-index: 90;
    pointer-events: none;
    opacity: 0;
}

.fb-shadow-under-right {
    right: 0;
    background: linear-gradient(to right,
        rgba(0,0,0,0.25) 0%,
        rgba(0,0,0,0.12) 15%,
        rgba(0,0,0,0.03) 40%,
        transparent 100%
    );
}

.fb-shadow-under-left {
    left: 0;
    background: linear-gradient(to left,
        rgba(0,0,0,0.25) 0%,
        rgba(0,0,0,0.12) 15%,
        rgba(0,0,0,0.03) 40%,
        transparent 100%
    );
}

/* ---- Bottom nav ---- */
.fb-nav {
    position: relative;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 16px;
    background: rgba(255,255,255,0.05);
    padding: 8px 20px;
    border-radius: 40px;
    backdrop-filter: blur(10px);
}

.fb-nav-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.12);
    background: transparent;
    color: rgba(255,255,255,0.6);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.fb-nav-btn:hover:not(:disabled) {
    background: #C89B3C;
    color: #000;
    border-color: #C89B3C;
}

.fb-nav-btn:disabled { opacity: 0.15; cursor: default; }

.fb-nav-btn svg { width: 14px; height: 14px; }

.fb-nav-info {
    font-size: 12px;
    color: rgba(255,255,255,0.35);
    min-width: 90px;
    text-align: center;
}

.fb-nav-fs {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.12);
    background: transparent;
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    margin-left: 6px;
}

.fb-nav-fs:hover { background: rgba(255,255,255,0.15); color: #fff; }
.fb-nav-fs svg { width: 13px; height: 13px; }

/* ---- Thumbnails ---- */
.fb-thumbs {
    position: relative;
    z-index: 10;
    display: flex;
    gap: 5px;
    margin-top: 10px;
    padding: 6px 10px;
    background: rgba(255,255,255,0.03);
    border-radius: 8px;
    overflow-x: auto;
    max-width: 90vw;
}

.fb-thumb {
    width: 44px;
    height: 62px;
    flex-shrink: 0;
    border-radius: 3px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    opacity: 0.4;
    transition: all 0.2s;
}

.fb-thumb:hover { opacity: 0.7; }
.fb-thumb.active { opacity: 1; border-color: #C89B3C; }

.fb-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ---- Hint ---- */
.fb-hint {
    position: relative;
    z-index: 10;
    text-align: center;
    margin-top: 8px;
    font-size: 11px;
    color: rgba(255,255,255,0.15);
}

/* ---- Retour ---- */
.fb-back-link {
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 50;
    color: rgba(255,255,255,0.4);
    text-decoration: none;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: color 0.2s;
}

.fb-back-link:hover { color: #C89B3C; }
.fb-back-link svg { width: 16px; height: 16px; }

/* ---- Mobile: single page ---- */
@media (max-width: 768px) {
    .fb-book {
        height: 65vh;
    }

    .fb-book .fb-page-left { display: none; }
    .fb-book .fb-page-right { width: 100%; border-radius: 6px; }
    .fb-book .fb-page-right::before { display: none; }

    .fb-turn { width: 100% !important; }

    .fb-thumbs { display: none; }

    .fb-topbar h1 { font-size: 1rem; }
}

/* ---- Legacy article (no flipbook) ---- */
.article-full-legacy .article-content {
    max-width: 780px;
    margin: 0 auto;
    line-height: 1.8;
    font-size: 1.05rem;
}
