/* ============================================================
   MOURCHID.COM — Flipbook Reader Styles
   ============================================================ */

/* ---- Flipbook Modal Overlay ---- */
.flipbook-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.96);
  z-index: 3000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
  backdrop-filter: blur(12px);
}

.flipbook-overlay.open {
  opacity: 1;
  pointer-events: all;
}

/* ---- Top Bar ---- */
.flipbook-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 60px;
  background: rgba(3, 11, 24, 0.95);
  border-bottom: 1px solid rgba(0, 212, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 3001;
  gap: 1rem;
}

.flipbook-book-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #f0f6ff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 350px;
}

.flipbook-topbar-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.flipbook-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #8faac3;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  white-space: nowrap;
}

.flipbook-btn:hover {
  background: rgba(0, 212, 255, 0.1);
  border-color: rgba(0, 212, 255, 0.3);
  color: #00d4ff;
}

.flipbook-btn-close {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.flipbook-btn-close:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
  color: #ef4444;
}

/* ---- Main Viewer Area ---- */
.flipbook-viewer {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100vh;
  padding: 70px 80px 80px;
  position: relative;
}

/* ---- Page Container (the "book") ---- */
.flipbook-pages {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 1200px;
}

/* ---- Individual Page ---- */
.flipbook-page {
  flex: 1;
  max-width: 580px;
  height: 100%;
  background: #fff;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  box-shadow: 0 10px 60px rgba(0, 0, 0, 0.8);
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Book spine shadow */
.flipbook-pages::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 0; bottom: 0;
  width: 8px;
  transform: translateX(-50%);
  background: linear-gradient(to right, rgba(0,0,0,0.4), rgba(0,0,0,0.1), rgba(0,0,0,0.4));
  z-index: 5;
  pointer-events: none;
}

.flipbook-page canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  object-fit: contain;
}

.flipbook-page-left {
  border-radius: 4px 0 0 4px;
  box-shadow: -4px 0 20px rgba(0,0,0,0.3), 0 10px 60px rgba(0,0,0,0.8);
}

.flipbook-page-right {
  border-radius: 0 4px 4px 0;
  box-shadow: 4px 0 20px rgba(0,0,0,0.3), 0 10px 60px rgba(0,0,0,0.8);
}

/* Single page mode (first/last pages) */
.flipbook-single .flipbook-page {
  max-width: 580px;
  border-radius: 4px;
}

/* Page turn animation */
@keyframes flipLeft {
  0%   { transform: perspective(2000px) rotateY(0deg); transform-origin: right; }
  100% { transform: perspective(2000px) rotateY(-180deg); transform-origin: right; }
}

@keyframes flipRight {
  0%   { transform: perspective(2000px) rotateY(0deg); transform-origin: left; }
  100% { transform: perspective(2000px) rotateY(180deg); transform-origin: left; }
}

.flipbook-page.turning-left {
  animation: flipLeft 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  z-index: 10;
}

.flipbook-page.turning-right {
  animation: flipRight 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  z-index: 10;
}

/* ---- Navigation Arrows ---- */
.flipbook-nav-btn {
  position: absolute;
  top: 50%; transform: translateY(-50%);
  width: 52px; height: 52px;
  background: rgba(0, 212, 255, 0.1);
  border: 1px solid rgba(0, 212, 255, 0.25);
  border-radius: 50%;
  color: #00d4ff;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  font-family: inherit;
  z-index: 10;
}

.flipbook-nav-btn:hover {
  background: rgba(0, 212, 255, 0.2);
  border-color: #00d4ff;
  transform: translateY(-50%) scale(1.08);
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
}

.flipbook-nav-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
  transform: translateY(-50%) scale(1);
}

.flipbook-prev { left: 1rem; }
.flipbook-next { right: 1rem; }

/* ---- Bottom Bar ---- */
.flipbook-bottombar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 60px;
  background: rgba(3, 11, 24, 0.95);
  border-top: 1px solid rgba(0, 212, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 0 1.5rem;
  z-index: 3001;
}

.flipbook-page-info {
  font-size: 0.875rem;
  color: #8faac3;
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
}

.flipbook-page-info span { color: #00d4ff; font-weight: 600; }

.flipbook-progress {
  flex: 1;
  max-width: 300px;
  height: 3px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
  overflow: hidden;
}

.flipbook-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #00d4ff, #8b5cf6);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.flipbook-zoom-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.flipbook-zoom-btn {
  width: 32px; height: 32px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  color: #8faac3;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  font-family: inherit;
}

.flipbook-zoom-btn:hover {
  background: rgba(0, 212, 255, 0.1);
  border-color: rgba(0, 212, 255, 0.3);
  color: #00d4ff;
}

.flipbook-zoom-label {
  font-size: 0.8rem;
  color: #8faac3;
  min-width: 45px;
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
}

/* ---- Loading Spinner ---- */
.flipbook-loading {
  position: absolute;
  inset: 0;
  background: #0a1628;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  z-index: 20;
}

.flipbook-spinner {
  width: 44px; height: 44px;
  border: 3px solid rgba(0, 212, 255, 0.15);
  border-top-color: #00d4ff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.flipbook-loading-text {
  font-size: 0.85rem;
  color: #8faac3;
}

.flipbook-loading-text span { color: #00d4ff; }

/* ---- Page number input ---- */
.flipbook-page-input {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(0, 212, 255, 0.2);
  border-radius: 6px;
  color: #00d4ff;
  font-size: 0.85rem;
  font-family: 'JetBrains Mono', monospace;
  width: 55px;
  text-align: center;
  padding: 0.3rem;
  outline: none;
}

.flipbook-page-input:focus {
  border-color: #00d4ff;
  box-shadow: 0 0 0 2px rgba(0, 212, 255, 0.15);
}

/* ---- Table of Contents ---- */
.flipbook-toc {
  position: fixed;
  top: 60px; left: 0; bottom: 60px;
  width: 280px;
  background: rgba(7, 16, 32, 0.98);
  border-right: 1px solid rgba(0, 212, 255, 0.12);
  padding: 1.5rem 1rem;
  overflow-y: auto;
  z-index: 3002;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
}

.flipbook-toc.open { transform: translateX(0); }

.flipbook-toc-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #00d4ff;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(0, 212, 255, 0.12);
}

.flipbook-toc-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
  font-size: 0.85rem;
  color: #8faac3;
  margin-bottom: 0.25rem;
}

.flipbook-toc-item:hover {
  background: rgba(0, 212, 255, 0.07);
  color: #f0f6ff;
}

.flipbook-toc-page {
  font-size: 0.75rem;
  color: #4a6080;
  margin-left: auto;
  font-family: 'JetBrains Mono', monospace;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .flipbook-viewer {
    padding: 65px 10px 65px;
  }

  .flipbook-pages {
    flex-direction: column;
    gap: 2px;
  }

  .flipbook-page {
    max-width: 100%;
    max-height: 45%;
  }

  .flipbook-pages::after { display: none; }

  .flipbook-page-left { border-radius: 4px 4px 0 0; }
  .flipbook-page-right { border-radius: 0 0 4px 4px; }

  .flipbook-nav-btn { display: none; }
  .flipbook-book-title { max-width: 180px; }
  .flipbook-progress { max-width: 150px; }
  .flipbook-toc { width: 100%; }
}
