/* =========================================================
   PDF Flipbook Reader — Hyperzine-style
   ========================================================= */

/* shell */
.reader-shell{
  margin-top:var(--header-h);
  min-height:calc(100vh - var(--header-h));
  background:#1c1a16;
  display:flex;flex-direction:column;
  user-select:none;
}

/* top bar */
.reader-bar{
  display:flex;align-items:center;justify-content:space-between;
  gap:10px;padding:10px 18px;
  background:#111;
  color:#fff;
  position:sticky;top:var(--header-h);z-index:200;
  flex-wrap:wrap;
  border-bottom:1px solid rgba(255,255,255,.06);
}
.rb-back{color:#aaa;text-decoration:none;font-size:13px;font-weight:600;
  display:inline-flex;align-items:center;gap:7px;transition:.15s}
.rb-back:hover{color:#fff}
.rb-title{font-weight:700;font-size:14px;color:#e8c86a;flex:1;
  text-align:center;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.rb-tools{display:flex;align-items:center;gap:5px}
.rb-btn{background:rgba(255,255,255,.08);border:none;color:#ccc;
  width:36px;height:36px;border-radius:8px;cursor:pointer;font-size:14px;
  transition:.15s;display:inline-flex;align-items:center;justify-content:center}
.rb-btn:hover{background:rgba(255,255,255,.2);color:#fff}
.rb-btn:disabled{opacity:.3;cursor:default}
.rb-page{font-size:12.5px;color:#999;min-width:60px;text-align:center}

/* stage — the 3D scene container */
.reader-stage{
  flex:1;display:flex;align-items:center;justify-content:center;
  padding:24px 16px 48px;
  overflow:hidden;
  background:radial-gradient(ellipse at 50% 30%,#2a2520 0%,#1c1a16 70%);
  position:relative;
  perspective:2200px;
}

/* ---- Book wrapper ---- */
#flipbook{
  position:relative;
  display:flex;
  align-items:stretch;
  box-shadow:0 30px 80px rgba(0,0,0,.7), 0 4px 12px rgba(0,0,0,.5);
  border-radius:1px;
  /* width/height set by JS */
}

/* Left & right page slots */
.fb-left, .fb-right{
  position:relative;
  overflow:hidden;
  background:#f8f4ee;
  flex:0 0 auto;
}
.fb-left{
  border-radius:3px 0 0 3px;
  box-shadow:inset -6px 0 18px rgba(0,0,0,.15);
}
.fb-right{
  border-radius:0 3px 3px 0;
  box-shadow:inset 6px 0 18px rgba(0,0,0,.12);
}
.fb-left canvas, .fb-right canvas{display:block}

/* spine */
.fb-spine{
  width:8px;flex-shrink:0;
  background:linear-gradient(90deg,
    rgba(0,0,0,.25) 0%,
    rgba(0,0,0,.08) 40%,
    rgba(255,255,255,.06) 50%,
    rgba(0,0,0,.08) 60%,
    rgba(0,0,0,.25) 100%);
  z-index:10;
}

/* ---- Flipping page (CSS 3D) ---- */
#flipPage{
  position:absolute;
  top:0;
  width:50%;        /* half the book = one page width */
  height:100%;
  transform-origin:left center;
  transform-style:preserve-3d;
  pointer-events:none;
  z-index:50;
  display:none;     /* shown only during flip animation */
}
#flipPage.from-right{
  left:50%;
  transform-origin:left center;
}
#flipPage.from-left{
  left:0;
  transform-origin:right center;
}

.flip-front, .flip-back{
  position:absolute;inset:0;
  backface-visibility:hidden;
  -webkit-backface-visibility:hidden;
  overflow:hidden;
}
.flip-back{
  transform:rotateY(180deg);
}
#flipPage canvas{display:block;width:100%;height:100%}

/* page-turn gradient (shadow that moves with the fold) */
.flip-front::after,.flip-back::after{
  content:'';
  position:absolute;inset:0;
  pointer-events:none;
  background:linear-gradient(90deg,
    rgba(0,0,0,.0) 70%,
    rgba(0,0,0,.18) 88%,
    rgba(0,0,0,.32) 100%);
  opacity:0;
  transition:opacity .05s;
}

/* loading */
.reader-loading{
  position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);
  color:#ccc;font-size:15px;display:flex;align-items:center;gap:10px;
  background:rgba(0,0,0,.55);padding:14px 26px;border-radius:14px;
  z-index:100;
}

/* single page mode */
#flipbook.single .fb-right,
#flipbook.single .fb-spine{ display:none; }
#flipbook.single .fb-left{ border-radius:3px; }

/* mobile */
@media(max-width:640px){
  .reader-bar{flex-wrap:wrap}
  .rb-title{order:3;width:100%;text-align:left;font-size:13px}
  .reader-stage{padding:12px 6px 36px;perspective:1200px}
}
