/* ==========================================================================
   PVS RAVINDRA VARMA - REALISTIC 3D PAGE-FLIP BOOK READER
   Hardware-Accelerated 3D Transforms, Page Curling & Ambient Shadows
   ========================================================================== */

:root {
  --fb-gold: #caa05b;
  --fb-gold-hover: #ddb26a;
  --fb-gold-glow: rgba(202, 160, 91, 0.35);
  --fb-bg-dark: #0d0f12;
  --fb-bg-surface: #14171d;
  --fb-paper: #fbf9f4;
  --fb-paper-alt: #f4efe4;
  --fb-text: #1f242d;
  --fb-text-muted: #5e6b7d;
  --fb-shadow-book: 0 30px 80px -15px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.08);
  --fb-radius: 6px;
  --fb-trans-turn: 0.7s cubic-bezier(0.25, 1, 0.5, 1);
}

/* Reader Viewport Layout */
.flipbook-viewport {
  position: relative;
  min-height: 100vh;
  width: 100%;
  background: radial-gradient(circle at 50% 30%, #1c2028 0%, #0d0f12 85%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem 1.5rem;
  overflow: hidden;
  user-select: none;
}

/* Reader Header Bar */
.fb-top-bar {
  width: 100%;
  max-width: 1300px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: rgba(20, 23, 29, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9999px;
  z-index: 50;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.fb-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  color: #fff;
  text-decoration: none;
}

.fb-brand img {
  height: 28px;
  width: auto;
}

.fb-book-meta {
  display: flex;
  flex-direction: column;
}

.fb-book-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.fb-book-author {
  font-size: 0.72rem;
  color: var(--fb-gold);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.fb-top-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.fb-btn-action {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
  padding: 0.45rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
  text-decoration: none;
}

.fb-btn-action:hover {
  background: rgba(202, 160, 91, 0.15);
  border-color: var(--fb-gold);
  color: var(--fb-gold);
}

.fb-btn-action.active {
  background: var(--fb-gold);
  color: #0d0f12;
  border-color: var(--fb-gold);
}

/* 3D Book Stage Container */
.fb-stage-wrapper {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  perspective: 2500px;
  -webkit-perspective: 2500px;
  margin: 1.5rem 0;
}

/* The 3D Book Wrapper */
.fb-book-spread {
  position: relative;
  width: 960px;
  height: 620px;
  max-width: 94vw;
  max-height: 72vh;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  box-shadow: var(--fb-shadow-book);
  border-radius: var(--fb-radius);
  transition: transform 0.3s ease;
}

/* Hardcover Spine & Shadow */
.fb-spine-shadow {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 44px;
  height: 100%;
  background: linear-gradient(to right, 
    rgba(0, 0, 0, 0.35) 0%, 
    rgba(0, 0, 0, 0.15) 30%, 
    rgba(0, 0, 0, 0.05) 50%, 
    rgba(0, 0, 0, 0.15) 70%, 
    rgba(0, 0, 0, 0.35) 100%
  );
  z-index: 25;
  pointer-events: none;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.4);
}

/* Left & Right Pages Static Base */
.fb-page-static {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  background: var(--fb-paper);
  overflow: hidden;
  box-sizing: border-box;
}

.fb-page-static.left-base {
  left: 0;
  border-radius: var(--fb-radius) 0 0 var(--fb-radius);
  border-right: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: inset -20px 0 25px -15px rgba(0, 0, 0, 0.2);
}

.fb-page-static.right-base {
  right: 0;
  border-radius: 0 var(--fb-radius) var(--fb-radius) 0;
  border-left: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: inset 20px 0 25px -15px rgba(0, 0, 0, 0.2);
}

/* 3D Flipping Sheet Layer */
.fb-sheet-layer {
  position: absolute;
  top: 0;
  left: 50%;
  width: 50%;
  height: 100%;
  transform-origin: left center;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform var(--fb-trans-turn);
  z-index: 20;
  pointer-events: none;
}

.fb-sheet-layer.turning-forward {
  transform: rotateY(-180deg);
}

.fb-sheet-layer.turning-backward {
  transform: rotateY(0deg);
}

/* Front & Back Faces of the Flipping Sheet */
.fb-sheet-face {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--fb-paper);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
  box-sizing: border-box;
}

.fb-sheet-face.front-face {
  border-radius: 0 var(--fb-radius) var(--fb-radius) 0;
  box-shadow: inset 20px 0 25px -15px rgba(0, 0, 0, 0.2);
}

.fb-sheet-face.back-face {
  transform: rotateY(180deg);
  border-radius: var(--fb-radius) 0 0 var(--fb-radius);
  box-shadow: inset -20px 0 25px -15px rgba(0, 0, 0, 0.2);
}

/* Dynamic Shadow Overlay when page is turning */
.fb-turn-shadow {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background: linear-gradient(to right, rgba(0, 0, 0, 0.4) 0%, transparent 40%);
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 30;
}

/* Page Interior Typography & Layout */
.fb-page-content {
  width: 100%;
  height: 100%;
  padding: 3rem 2.85rem 3.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  color: var(--fb-text);
  overflow-y: auto;
  box-sizing: border-box;
}

.fb-page-content::-webkit-scrollbar {
  width: 4px;
}
.fb-page-content::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 4px;
}

/* Page Header running head */
.fb-page-running-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #8b99aa;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  margin-bottom: 1.5rem;
}

/* Page Body Copy */
.fb-page-body {
  flex: 1;
  font-size: 0.95rem;
  line-height: 1.75;
  color: #334155;
}

.fb-page-body h1, 
.fb-page-body h2, 
.fb-page-body h3 {
  font-family: 'Playfair Display', Georgia, serif;
  color: #14171d;
  margin-bottom: 0.75rem;
  line-height: 1.25;
}

.fb-page-body h2 {
  font-size: 1.45rem;
  color: #14171d;
}

.fb-page-body h3 {
  font-size: 1.15rem;
  color: #825c2a;
  margin-top: 1.25rem;
}

.fb-page-body p {
  margin-bottom: 1.15rem;
  text-align: justify;
}

.fb-page-body p:first-of-type::first-letter {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 3.2rem;
  float: left;
  line-height: 0.8;
  margin-right: 0.5rem;
  color: var(--fb-gold);
  font-weight: 700;
}

.fb-page-body blockquote {
  border-left: 3px solid var(--fb-gold);
  padding: 0.65rem 1.25rem;
  background: rgba(202, 160, 91, 0.08);
  margin: 1.5rem 0;
  font-family: 'Playfair Display', Georgia, serif;
  font-style: italic;
  font-size: 1.05rem;
  color: #272c35;
  line-height: 1.6;
}

.fb-page-body ul {
  padding-left: 1.25rem;
  margin-bottom: 1.25rem;
}
.fb-page-body li {
  margin-bottom: 0.45rem;
}

/* Page Footer with number */
.fb-page-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: #94a3b8;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  margin-top: 1rem;
}

/* Cover Styling */
.fb-page-cover {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #1b1e26 0%, #0d0f12 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
  text-align: center;
  color: #fff;
  position: relative;
  overflow: hidden;
  border-radius: 0 var(--fb-radius) var(--fb-radius) 0;
}

.fb-page-cover::before {
  content: '';
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  bottom: 16px;
  border: 1px solid rgba(202, 160, 91, 0.4);
  pointer-events: none;
}

.fb-cover-emblem {
  width: 60px;
  height: auto;
  margin-bottom: 1.5rem;
}

.fb-cover-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.85rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.5rem;
  line-height: 1.2;
}

.fb-cover-subtitle {
  font-size: 0.85rem;
  color: #cbd5e1;
  max-width: 320px;
  margin-bottom: 2rem;
}

.fb-cover-author {
  font-family: 'Caveat', cursive;
  font-size: 1.5rem;
  color: var(--fb-gold);
}

/* Interactive Page Turning Arrows (Side Overlays) */
.fb-nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(20, 23, 29, 0.8);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 40;
  transition: all 0.2s ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.fb-nav-arrow:hover:not(:disabled) {
  background: var(--fb-gold);
  color: #0d0f12;
  border-color: var(--fb-gold);
  transform: translateY(-50%) scale(1.08);
}

.fb-nav-arrow:disabled {
  opacity: 0.2;
  cursor: not-allowed;
}

.fb-nav-arrow.prev {
  left: -70px;
}

.fb-nav-arrow.next {
  right: -70px;
}

/* Bottom Control Dock */
.fb-dock {
  width: 100%;
  max-width: 840px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 0.75rem 1.75rem;
  background: rgba(20, 23, 29, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9999px;
  z-index: 50;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

.fb-dock-left, .fb-dock-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.fb-dock-btn {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.fb-dock-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.fb-dock-btn.active {
  color: var(--fb-gold);
}

.fb-page-slider-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.fb-slider {
  flex: 1;
  height: 4px;
  accent-color: var(--fb-gold);
  cursor: pointer;
}

.fb-page-indicator {
  font-size: 0.82rem;
  font-weight: 600;
  color: #cbd5e1;
  white-space: nowrap;
  min-width: 90px;
  text-align: center;
}

/* Interactive Dog-Ear Corner Hover */
.fb-corner-curl {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 48px;
  height: 48px;
  cursor: pointer;
  z-index: 35;
  transition: all 0.2s ease;
}

.fb-corner-curl::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 0 28px 28px;
  border-color: transparent transparent rgba(202, 160, 91, 0.4) transparent;
  transition: all 0.25s ease;
}

.fb-page-static.right-base:hover .fb-corner-curl::after,
.fb-sheet-face.front-face:hover .fb-corner-curl::after {
  border-width: 0 0 44px 44px;
  border-color: transparent transparent var(--fb-gold) transparent;
}

/* Table of Contents Drawer Modal */
.fb-modal-dialog {
  border: none;
  background: transparent;
  padding: 0;
  max-width: 580px;
  width: 90vw;
  margin: 10vh auto auto auto;
  border-radius: 16px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.85);
  overflow: hidden;
}

.fb-modal-dialog::backdrop {
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
}

.fb-modal-box {
  background: #14171d;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 1.75rem;
}

.fb-toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 400px;
  overflow-y: auto;
  margin-top: 1rem;
}

.fb-toc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: #1b1e26;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  color: #cbd5e1;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.fb-toc-item:hover {
  background: rgba(202, 160, 91, 0.12);
  border-color: var(--fb-gold);
  color: var(--fb-gold);
}

/* PDF Upload Dropzone inside reader/studio */
.fb-upload-dropzone {
  border: 2px dashed rgba(202, 160, 91, 0.4);
  border-radius: 12px;
  padding: 2.5rem 1.5rem;
  text-align: center;
  background: rgba(20, 23, 29, 0.6);
  cursor: pointer;
  transition: all 0.25s ease;
}

.fb-upload-dropzone:hover, .fb-upload-dropzone.dragover {
  border-color: var(--fb-gold);
  background: rgba(202, 160, 91, 0.08);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .fb-nav-arrow.prev {
    left: 8px;
  }
  .fb-nav-arrow.next {
    right: 8px;
  }
  .fb-book-spread {
    width: 95vw;
    height: 68vh;
  }
  .fb-page-static.left-base {
    display: none;
  }
  .fb-page-static.right-base {
    width: 100%;
    left: 0;
  }
  .fb-sheet-layer {
    display: none;
  }
  .fb-spine-shadow {
    display: none;
  }
  .fb-page-content {
    padding: 2rem 1.5rem;
  }
}
