/* ==========================================================================
   E-BOOK ZONE INDIA — 3D FLIPBOOK & 7 KINDLE-KILLER READER ENGINE STYLES
   File: /assets/css/reader-mode.css (Phase 1 — File 7/30)
   Covers: 3D Flipbook Page Physics, Dual PDF/EPUB Canvas & Selectable I-Beam
           Text Layer, Canvas Annotation Bar, Smart Dictionary/Wikipedia
           Tooltip, X-Ray Vision Drawer, Word Runner RSVP, Bird's Eye Grid,
           Holographic 3D Mind-Map, and Adaptive Typography Engine
   ========================================================================== */

/* ==========================================================================
   1. READER TOP COMMAND HUD & 7 KINDLE-KILLER TOOLBAR
   ========================================================================== */
.reader-hud-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.25rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.reader-hud-left {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.reader-title-text {
  font-family: var(--font-heading, 'Space Grotesk', sans-serif);
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--text-primary, #f2f7ff);
}

.reader-sub-telemetry {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  margin-top: 0.2rem;
}

.hud-metric {
  font-family: var(--font-mono, monospace);
  font-size: 0.72rem;
  color: var(--text-secondary, #b4c6e0);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.hud-metric strong {
  color: var(--neon-cyan, #00f3ff);
}

.hud-metric.sync-active strong {
  color: var(--neon-emerald, #00ff9d);
}

.reader-hud-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.hud-tool-btn {
  padding: 0.44rem 0.78rem;
  border-radius: var(--radius-sm, 8px);
  background: rgba(10, 17, 36, 0.85);
  border: 1px solid rgba(0, 243, 255, 0.24);
  color: var(--text-secondary, #b4c6e0);
  font-family: var(--font-heading, sans-serif);
  font-size: 0.78rem;
  font-weight: 600;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.hud-tool-btn:hover,
.hud-tool-btn.active {
  background: rgba(0, 243, 255, 0.16);
  border-color: var(--neon-cyan, #00f3ff);
  color: #ffffff;
  box-shadow: 0 0 14px rgba(0, 243, 255, 0.24);
}

.hud-tool-btn.neon-highlight {
  background: linear-gradient(135deg, rgba(0, 243, 255, 0.2), rgba(176, 38, 255, 0.26));
  border-color: rgba(176, 38, 255, 0.55);
  color: #f3dcff;
}

/* ==========================================================================
   2. HTML5 CANVAS FREEHAND ANNOTATION TOOLBAR & TYPOGRAPHY POPOVER
   ========================================================================== */
.annotation-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  padding: 0.65rem 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.annot-tool {
  padding: 0.38rem 0.75rem;
  border-radius: var(--radius-sm, 8px);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text-primary, #f2f7ff);
  font-size: 0.78rem;
  font-weight: 600;
}

.annot-tool.active,
.annot-tool:hover {
  background: rgba(0, 243, 255, 0.18);
  border-color: var(--neon-cyan, #00f3ff);
}

.typography-popover {
  position: absolute;
  top: 76px;
  right: 1.5rem;
  width: min(340px, 92vw);
  padding: 1.25rem;
  z-index: 1250;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(0, 243, 255, 0.18);
  padding-bottom: 0.55rem;
}

.typo-control-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--text-secondary, #b4c6e0);
}

/* ==========================================================================
   3. 3D FLIPBOOK STAGE, PAGE TURN PHYSICS & SELECTABLE I-BEAM TEXT LAYER
   ========================================================================== */
.flipbook-stage-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  min-height: 620px;
  perspective: 2400px;
  margin-bottom: 1rem;
  user-select: text;
}

.flipbook-3d-viewport {
  position: relative;
  width: 100%;
  max-width: 1180px;
  min-height: 600px;
  display: grid;
  grid-template-columns: 1fr 18px 1fr;
  background: rgba(8, 12, 26, 0.92);
  border: 1.5px solid rgba(0, 243, 255, 0.32);
  border-radius: 16px;
  box-shadow:
    0 30px 70px rgba(0, 0, 0, 0.88),
    0 0 40px rgba(0, 243, 255, 0.12),
    inset 0 0 30px rgba(0, 0, 0, 0.6);
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden;
}

/* Single-Page / Continuous Scroll Mode Toggle */
html[data-reading-mode='continuous-scroll'] .flipbook-3d-viewport {
  grid-template-columns: 1fr;
  max-width: 820px;
}
html[data-reading-mode='continuous-scroll'] .flipbook-center-spine,
html[data-reading-mode='continuous-scroll'] #book-page-right {
  display: none;
}

/* 3D Page Turn Animations */
.flipbook-3d-viewport.flipping-next {
  animation: pageTurnNext3D 0.52s cubic-bezier(0.22, 1, 0.36, 1);
}

.flipbook-3d-viewport.flipping-prev {
  animation: pageTurnPrev3D 0.52s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes pageTurnNext3D {
  0% {
    transform: rotateY(0deg) scale(1);
  }
  45% {
    transform: rotateY(-12deg) scale(0.985);
    box-shadow: -25px 25px 60px rgba(0, 243, 255, 0.25);
  }
  100% {
    transform: rotateY(0deg) scale(1);
  }
}

@keyframes pageTurnPrev3D {
  0% {
    transform: rotateY(0deg) scale(1);
  }
  45% {
    transform: rotateY(12deg) scale(0.985);
    box-shadow: 25px 25px 60px rgba(176, 38, 255, 0.25);
  }
  100% {
    transform: rotateY(0deg) scale(1);
  }
}

.flipbook-page {
  position: relative;
  padding: 1.75rem 2.1rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  background: radial-gradient(circle at center, rgba(16, 24, 48, 0.55), rgba(8, 12, 24, 0.94));
  overflow-y: auto;
  max-height: 650px;
}

.page-left {
  box-shadow: inset -18px 0 28px rgba(0, 0, 0, 0.55);
}

.page-right {
  box-shadow: inset 18px 0 28px rgba(0, 0, 0, 0.55);
}

.flipbook-center-spine {
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.85) 0%,
    rgba(0, 243, 255, 0.25) 50%,
    rgba(0, 0, 0, 0.85) 100%
  );
  box-shadow: 0 0 18px rgba(0, 0, 0, 0.95);
}

.page-header-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid rgba(0, 243, 255, 0.16);
  font-family: var(--font-mono, monospace);
  font-size: 0.72rem;
  color: var(--text-muted, #7589a6);
}

/* PDF Render Canvas & Coordinate-Aligned Selectable PDF Text Overlay */
.pdf-canvas-stage-wrap {
  position: relative;
  width: 100%;
  display: none;
  margin-bottom: 1.15rem;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(0, 243, 255, 0.22);
  background: #ffffff;
  user-select: text !important;
  -webkit-user-select: text !important;
}

.pdf-canvas-stage-wrap.pdf-stage-active {
  display: block;
}

.pdf-render-canvas {
  width: 100%;
  height: auto;
  display: none;
  pointer-events: none;
}

.pdf-render-canvas.canvas-active {
  display: block;
}

.pdf-canvas-text-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: 12;
  pointer-events: auto !important;
  user-select: text !important;
  -webkit-user-select: text !important;
  cursor: text !important;
}

.pdf-canvas-text-overlay .pdf-selectable-span {
  position: absolute;
  color: transparent;
  white-space: pre;
  cursor: text !important;
  user-select: text !important;
  -webkit-user-select: text !important;
  pointer-events: auto !important;
  transform-origin: 0% 0%;
  line-height: 1.1;
}

.pdf-canvas-text-overlay .pdf-selectable-span::selection,
.pdf-canvas-text-overlay ::selection {
  background: rgba(0, 195, 255, 0.42);
  color: transparent;
}

.selectable-text-layer {
  position: relative;
  z-index: 10;
  font-family: var(--reader-font-family, 'Merriweather', Georgia, serif);
  font-size: var(--reader-font-size, 18px);
  line-height: var(--reader-line-height, 1.75);
  letter-spacing: var(--reader-letter-spacing, 0.01em);
  color: #e9f1ff;
  cursor: text !important;
  user-select: text !important;
  -webkit-user-select: text !important;
  pointer-events: auto !important;
  outline: none;
}

.selectable-text-layer p {
  margin-bottom: 1.1rem;
  text-align: justify;
  user-select: text !important;
  -webkit-user-select: text !important;
}

.selectable-text-layer h3,
.selectable-text-layer h4 {
  font-family: var(--font-heading, 'Space Grotesk', sans-serif);
  color: var(--neon-cyan, #00f3ff);
  margin: 0.5rem 0 0.75rem;
  user-select: text !important;
  -webkit-user-select: text !important;
}

.selectable-text-layer ::selection {
  background: rgba(0, 243, 255, 0.35);
  color: #ffffff;
}

/* Bionic Reading Emphasis & Whispersync Active Sentence Highlight */
.bionic-bold {
  font-weight: 800;
  color: #ffffff;
}

.whispersync-active-sentence {
  background: linear-gradient(90deg, rgba(0, 243, 255, 0.24), rgba(176, 38, 255, 0.24));
  border-bottom: 2px solid var(--neon-cyan, #00f3ff);
  border-radius: 4px;
  padding: 0.08rem 0.25rem;
  box-shadow: 0 0 14px rgba(0, 243, 255, 0.2);
}

.saved-user-highlight {
  background: rgba(0, 255, 157, 0.25);
  border-bottom: 2px solid var(--neon-emerald, #00ff9d);
  border-radius: 3px;
  padding: 0 0.15rem;
}

/* Freehand HTML5 Annotation Overlay Canvas */
.annotation-overlay-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 15;
}

.annotation-overlay-canvas.drawing-enabled {
  pointer-events: auto;
  cursor: crosshair !important;
}

/* Left & Right Page Flip Paddles */
.page-nav-paddle {
  width: 48px;
  height: 120px;
  border-radius: 999px;
  background: rgba(10, 16, 34, 0.82);
  border: 1px solid rgba(0, 243, 255, 0.32);
  color: var(--neon-cyan, #00f3ff);
  font-size: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.page-nav-paddle:hover {
  background: rgba(0, 243, 255, 0.22);
  box-shadow: 0 0 22px rgba(0, 243, 255, 0.38);
  transform: scale(1.06);
}

/* Reader Bottom Scrubber Bar */
.reader-footer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 0.8rem 1.35rem;
  flex-wrap: wrap;
}

.page-counter-pill {
  font-family: var(--font-mono, monospace);
  font-size: 0.8rem;
  color: var(--text-secondary, #b4c6e0);
}

.cyber-scrubber {
  flex: 1;
  min-width: 180px;
  accent-color: var(--neon-cyan, #00f3ff);
}

.reader-footer-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ==========================================================================
   4. KINDLE-KILLER #1: SMART DICTIONARY & WIKIPEDIA FLOATING TOOLTIP
   ========================================================================== */
.smart-tooltip-card {
  position: fixed;
  bottom: 96px;
  left: 50%;
  transform: translateX(-50%);
  width: min(440px, 92vw);
  padding: 1.15rem 1.25rem;
  z-index: 1600;
  border-color: var(--neon-cyan, #00f3ff);
  box-shadow: 0 22px 55px rgba(0, 0, 0, 0.9), 0 0 30px rgba(0, 243, 255, 0.28);
  animation: tooltipPopIn 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes tooltipPopIn {
  from {
    opacity: 0;
    transform: translate(-50%, 10px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
}

.tooltip-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.45rem;
}

.dict-word {
  font-family: var(--font-heading, sans-serif);
  font-size: 1.15rem;
  color: var(--neon-cyan, #00f3ff);
  margin-right: 0.5rem;
}

.dict-phonetic {
  font-family: var(--font-mono, monospace);
  font-size: 0.78rem;
  color: var(--text-muted, #7589a6);
}

.tooltip-tabs {
  display: flex;
  gap: 0.45rem;
  margin-bottom: 0.55rem;
}

.tooltip-badge {
  font-family: var(--font-mono, monospace);
  font-size: 0.66rem;
  padding: 0.14rem 0.5rem;
  border-radius: 4px;
  background: rgba(0, 243, 255, 0.12);
  color: var(--neon-cyan, #00f3ff);
}

.tooltip-badge.wiki-badge {
  background: rgba(176, 38, 255, 0.18);
  color: #e3a8ff;
}

.dict-body {
  font-size: 0.86rem;
  color: var(--text-primary, #f2f7ff);
  line-height: 1.55;
  margin-bottom: 0.85rem;
}

.tooltip-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ==========================================================================
   5. KINDLE-KILLER #4: X-RAY VISION ENTITY DRAWER
   ========================================================================== */
.xray-drawer {
  position: fixed;
  top: calc(var(--header-height, 70px) + 14px);
  left: 1.25rem;
  bottom: calc(var(--dock-height, 74px) + 24px);
  width: min(380px, 90vw);
  padding: 1.25rem;
  z-index: 1350;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  overflow-y: auto;
}

.xray-entities-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.xray-entity-card {
  padding: 0.85rem;
  border-radius: var(--radius-md, 14px);
  background: rgba(5, 9, 22, 0.82);
  border: 1px solid rgba(0, 243, 255, 0.24);
}

.xray-entity-card h4 {
  font-size: 0.92rem;
  color: var(--neon-cyan, #00f3ff);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.3rem;
}

.xray-entity-card p {
  font-size: 0.8rem;
  color: var(--text-secondary, #b4c6e0);
}

/* ==========================================================================
   6. KINDLE-KILLER #6: WORD RUNNER RSVP SPEED-READER MODAL
   ========================================================================== */
.word-runner-stage {
  margin: 1.5rem 0;
  padding: 2.5rem 1.5rem;
  border-radius: var(--radius-lg, 20px);
  background: #04060e;
  border: 2px solid rgba(0, 243, 255, 0.45);
  box-shadow: inset 0 0 35px rgba(0, 243, 255, 0.12);
  text-align: center;
  position: relative;
}

.orp-reticle-top,
.orp-reticle-bottom {
  font-size: 0.75rem;
  color: var(--neon-danger, #ff2a6d);
  letter-spacing: 0.1em;
}

.word-runner-word {
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 700;
  color: #ffffff;
  margin: 0.65rem 0;
  letter-spacing: 0.03em;
}

.orp-pivot {
  color: var(--neon-danger, #ff2a6d);
  text-shadow: 0 0 16px var(--neon-danger, #ff2a6d);
}

.word-runner-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ==========================================================================
   7. KINDLE-KILLER #7: BIRD'S EYE PAGE FLIP GRID & 3D MIND-MAP MODAL
   ========================================================================== */
.birds-eye-thumbnails-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.bird-page-thumb {
  padding: 1rem;
  border-radius: var(--radius-md, 14px);
  background: rgba(8, 14, 30, 0.88);
  border: 1px solid rgba(0, 243, 255, 0.25);
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 180px;
}

.bird-page-thumb:hover,
.bird-page-thumb.active-page-thumb {
  transform: translateY(-4px);
  border-color: var(--neon-cyan, #00f3ff);
  box-shadow: 0 0 20px rgba(0, 243, 255, 0.28);
}

.mindmap-split-layout {
  display: grid;
  grid-template-columns: 1.35fr 0.95fr;
  gap: 1.25rem;
  margin-top: 1rem;
}

.mindmap-canvas-container {
  background: #040711;
  border: 1px solid rgba(0, 243, 255, 0.3);
  border-radius: var(--radius-md, 14px);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#holo-mindmap-canvas {
  width: 100%;
  height: auto;
  display: block;
}

.five-min-summary-pane {
  background: rgba(8, 13, 28, 0.8);
  border: 1px solid rgba(176, 38, 255, 0.35);
  border-radius: var(--radius-md, 14px);
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.summary-scroll-box {
  max-height: 390px;
  overflow-y: auto;
  font-size: 0.88rem;
  color: var(--text-secondary, #b4c6e0);
  line-height: 1.65;
}

/* Mobile Responsive Single-Page Reader */
@media (max-width: 960px) {
  .flipbook-3d-viewport {
    grid-template-columns: 1fr;
  }
  .flipbook-center-spine,
  #book-page-right {
    display: none;
  }
  .mindmap-split-layout {
    grid-template-columns: 1fr;
  }
  .page-nav-paddle {
    width: 38px;
    height: 84px;
    font-size: 1.5rem;
  }
}

@media (max-width: 768px) {
  .reader-hud-bar {
    padding: 0.7rem;
    gap: 0.55rem;
  }

  .reader-hud-left {
    width: 100%;
    flex-wrap: wrap;
    gap: 0.45rem;
  }

  .reader-book-meta {
    min-width: 0;
    flex: 1 1 100%;
  }

  .reader-book-meta h2 {
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .reader-telemetry-pills {
    width: 100%;
    flex-wrap: wrap;
    gap: 0.35rem;
  }

  .telemetry-pill {
    font-size: 0.64rem;
    padding: 0.14rem 0.42rem;
  }

  .reader-hud-tools {
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 0.25rem;
    scrollbar-width: none;
  }

  .reader-hud-tools::-webkit-scrollbar {
    display: none;
  }

  .hud-tool-btn {
    flex-shrink: 0;
    padding: 0.38rem 0.65rem;
    font-size: 0.74rem;
  }

  .flipbook-stage-container {
    gap: 0;
    min-height: 460px;
  }

  .flipbook-page {
    padding: 1.1rem 0.95rem 3.5rem;
  }

  .page-nav-paddle {
    position: absolute;
    bottom: 10px;
    z-index: 25;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    font-size: 1.35rem;
    background: rgba(8, 13, 28, 0.92);
  }

  #prev-page-btn {
    left: 12px;
  }

  #next-page-btn {
    right: 12px;
  }

  .reader-footer-bar {
    padding: 0.7rem;
    gap: 0.55rem;
  }

  .cyber-scrubber {
    width: 100%;
    flex: 1 1 100%;
  }

  .reader-footer-actions {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .reader-footer-actions .tiny-cyber-btn {
    flex: 1 1 auto;
    text-align: center;
    justify-content: center;
  }
}