/* =========================================================
   flipbook-viewer.css  —  Motion Plus Corporation
   Premium book-style PDF viewer with page-flip animation
   ========================================================= */

/* ── Overlay backdrop ──────────────────────────────────── */
.fbv-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(4, 8, 20, 0.93);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease-out;
}
.fbv-overlay.fbv-open {
  opacity: 1;
  pointer-events: all;
}

/* ── Main viewer shell ──────────────────────────────────── */
.fbv-viewer {
  display: flex;
  flex-direction: column;
  background: #141924;
  border-radius: 14px;
  box-shadow:
    0 60px 140px rgba(0, 0, 0, 0.85),
    0 0 0 1px rgba(255, 255, 255, 0.07),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  width: min(96vw, 1100px);
  height: min(92vh, 840px);
  overflow: hidden;
  transform: scale(0.93) translateY(16px);
  transition: transform 0.32s cubic-bezier(0.23, 1, 0.32, 1);
}
.fbv-overlay.fbv-open .fbv-viewer {
  transform: scale(1) translateY(0);
}

/* ── Top toolbar ────────────────────────────────────────── */
.fbv-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0 0.75rem 0 1rem;
  background: #0d1220;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  min-height: 52px;
  flex-shrink: 0;
}
.fbv-toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex: 1;
  overflow: hidden;
}
.fbv-doc-icon {
  width: 30px;
  height: 30px;
  background: #0056a4;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0.92);
}
.fbv-doc-icon svg { width: 15px; height: 15px; }
.fbv-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.88);
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fbv-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}

/* ── Icon buttons ───────────────────────────────────────── */
.fbv-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: background 0.12s ease-out, color 0.12s ease-out, transform 0.1s ease-out;
  padding: 0;
  flex-shrink: 0;
}
.fbv-icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}
.fbv-icon-btn:active { transform: scale(0.9); }
.fbv-icon-btn svg { width: 15px; height: 15px; pointer-events: none; }

.fbv-sep {
  width: 1px;
  height: 18px;
  background: rgba(255, 255, 255, 0.1);
  margin: 0 0.15rem;
  flex-shrink: 0;
}

/* Download button */
.fbv-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 32px;
  padding: 0 0.9rem;
  border: none;
  border-radius: 7px;
  background: #0056a4;
  color: #ffffff;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.12s ease-out, transform 0.1s ease-out;
  flex-shrink: 0;
  white-space: nowrap;
}
.fbv-download-btn:hover  { background: #006acc; }
.fbv-download-btn:active { transform: scale(0.95); }
.fbv-download-btn svg    { width: 13px; height: 13px; }

/* ── PDF iframe area ────────────────────────────────────── */
.fbv-iframe-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #4a4d52;
  min-height: 0;
}
.fbv-iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* ── Page-flip animation ────────────────────────────────── */
.fbv-flipper {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  overflow: hidden;
}
.fbv-flipper-page {
  position: absolute;
  inset: 0;
  /* Warm paper tone that looks like a real page */
  background: linear-gradient(
    108deg,
    #f4ede3 0%,
    #ede5d8 35%,
    #f0e9df 60%,
    #e8dfd3 100%
  );
  will-change: transform, opacity;
  /* Subtle right-edge crease shadow */
  box-shadow: inset -12px 0 28px rgba(0, 0, 0, 0.1);
}

/* ── Forward flip (left-to-right page turn) ── */
.fbv-flipper--fwd .fbv-flipper-page {
  transform-origin: left center;
  animation: fbvFlipFwd 0.46s cubic-bezier(0.23, 1, 0.32, 1) both;
}
@keyframes fbvFlipFwd {
  0%   { transform: perspective(2600px) rotateY(0deg);    opacity: 1;   }
  30%  { transform: perspective(2600px) rotateY(-45deg);  opacity: 0.85; }
  60%  { transform: perspective(2600px) rotateY(-100deg); opacity: 0.35; }
  80%  { transform: perspective(2600px) rotateY(-145deg); opacity: 0.08; }
  100% { transform: perspective(2600px) rotateY(-180deg); opacity: 0;   }
}

/* ── Backward flip (right-to-left page turn) ── */
.fbv-flipper--back .fbv-flipper-page {
  transform-origin: right center;
  box-shadow: inset 12px 0 28px rgba(0, 0, 0, 0.1);
  animation: fbvFlipBack 0.46s cubic-bezier(0.23, 1, 0.32, 1) both;
}
@keyframes fbvFlipBack {
  0%   { transform: perspective(2600px) rotateY(0deg);   opacity: 1;   }
  30%  { transform: perspective(2600px) rotateY(45deg);  opacity: 0.85; }
  60%  { transform: perspective(2600px) rotateY(100deg); opacity: 0.35; }
  80%  { transform: perspective(2600px) rotateY(145deg); opacity: 0.08; }
  100% { transform: perspective(2600px) rotateY(180deg); opacity: 0;   }
}

/* ── Navigation bar ─────────────────────────────────────── */
.fbv-nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1rem;
  background: #0d1220;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  height: 50px;
  flex-shrink: 0;
}

.fbv-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  height: 34px;
  padding: 0 1.1rem;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: background 0.13s, color 0.13s, border-color 0.13s, transform 0.1s;
  flex-shrink: 0;
  white-space: nowrap;
  user-select: none;
}
.fbv-nav-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.25);
}
.fbv-nav-btn:active { transform: scale(0.96); }
.fbv-nav-btn:disabled {
  opacity: 0.22;
  cursor: default;
  pointer-events: none;
}
.fbv-nav-btn svg { width: 14px; height: 14px; pointer-events: none; }

.fbv-page-indicator {
  font-size: 0.77rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.38);
  letter-spacing: 0.06em;
  text-align: center;
  flex: 1;
  user-select: none;
}
.fbv-page-indicator strong {
  color: rgba(255, 255, 255, 0.82);
  font-weight: 800;
}

.fbv-nav-hint {
  font-size: 0.67rem;
  color: rgba(255, 255, 255, 0.2);
  letter-spacing: 0.04em;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Loading spinner ────────────────────────────────────── */
.fbv-loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  background: #4a4d52;
  z-index: 5;
  transition: opacity 0.22s ease-out;
}
.fbv-loader.fbv-hide {
  opacity: 0;
  pointer-events: none;
}
.fbv-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: fbvSpin 0.52s linear infinite;
}
@keyframes fbvSpin { to { transform: rotate(360deg); } }
.fbv-loader-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.45);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ── Error panel ────────────────────────────────────────── */
.fbv-error-panel {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 2.5rem;
  text-align: center;
  position: absolute;
  inset: 0;
  background: #4a4d52;
  z-index: 6;
}
.fbv-error-panel.fbv-show { display: flex; }
.fbv-error-icon { color: rgba(255, 255, 255, 0.38); }
.fbv-error-msg {
  font-size: 0.88rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.62);
  max-width: 320px;
  line-height: 1.55;
}
.fbv-error-link {
  font-size: 0.82rem;
  color: #7ec8e3;
  cursor: pointer;
  text-decoration: underline;
  background: none;
  border: none;
  padding: 0.5rem 1rem;
  font-weight: 700;
  border-radius: 6px;
  transition: background 0.12s;
}
.fbv-error-link:hover { background: rgba(126, 200, 227, 0.1); }

/* ── Fullscreen adjustments ─────────────────────────────── */
.fbv-overlay:-webkit-full-screen { padding: 0; }
.fbv-overlay:fullscreen          { padding: 0; }
.fbv-overlay:fullscreen .fbv-viewer {
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  max-height: 100vh;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 600px) {
  .fbv-overlay { padding: 0.3rem; }
  .fbv-viewer  { border-radius: 10px; height: min(94vh, 700px); }
  .fbv-title   { font-size: 0.72rem; }
  .fbv-download-btn span { display: none; }
  .fbv-download-btn { padding: 0; width: 34px; justify-content: center; }
  .fbv-nav-hint { display: none; }
  .fbv-nav-btn span { display: none; }
  .fbv-nav-btn { padding: 0; width: 38px; justify-content: center; }
  .fbv-nav-bar { gap: 0.5rem; padding: 0 0.75rem; }
}
