/* ═══════════════════════════════════════════════════════════
   StoryNest — Flipbook Styles
   Professional page-turn book preview
═══════════════════════════════════════════════════════════ */

/* ── Flipbook Wrapper ─────────────────────────── */
.scai-flipbook-wrap {
  background: linear-gradient(180deg, #1a0d35 0%, #0d0520 100%);
  border-radius: 20px;
  padding: 40px 20px 60px;
  position: relative;
  overflow: hidden;
}
.scai-flipbook-wrap::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(108,63,197,0.3) 0%, transparent 60%);
  pointer-events: none;
}

/* Stage lighting effect */
.scai-flipbook-wrap::after {
  content: '';
  position: absolute;
  top: 0; left: 50%; transform: translateX(-50%);
  width: 200px; height: 4px;
  background: linear-gradient(90deg, transparent, var(--scai-primary), transparent);
  border-radius: 2px;
}

.scai-flipbook-outer {
  max-width: 900px;
  margin: 0 auto;
}

/* ── Navigation ───────────────────────────────── */
.scai-flipbook-nav {
  display: flex; align-items: center; justify-content: center;
  gap: 20px; margin-bottom: 24px;
}
.scai-flip-btn {
  width: 44px; height: 44px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 50%;
  color: #fff; font-size: 22px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.2s ease; backdrop-filter: blur(4px);
  line-height: 1;
}
.scai-flip-btn:hover { background: rgba(255,255,255,0.22); transform: scale(1.1); }
.scai-flip-btn:disabled { opacity: 0.3; cursor: default; transform: none; }
#flip-page-indicator {
  color: rgba(255,255,255,0.7); font-size: 13px; font-weight: 500;
  min-width: 100px; text-align: center;
}

/* ── Flipbook Stage ───────────────────────────── */
#scai-flipbook {
  perspective: 2000px;
  display: flex; justify-content: center; align-items: center;
  min-height: 500px; position: relative;
}

/* ── Book Container ───────────────────────────── */
.scai-book-container {
  position: relative;
  display: flex;
  transform-style: preserve-3d;
}

/* ── Individual Pages ─────────────────────────── */
.scai-fb-page {
  position: relative;
  width: 380px;
  min-height: 520px;
  background: #fff;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.6s cubic-bezier(0.645, 0.045, 0.355, 1.0),
              box-shadow 0.3s ease;
  transform-origin: left center;
  transform-style: preserve-3d;
}

/* Left page (even) — spine side on right */
.scai-fb-page.left-page {
  border-radius: 4px 0 0 4px;
  box-shadow: -4px 0 20px rgba(0,0,0,0.3), inset -2px 0 8px rgba(0,0,0,0.1);
}
/* Right page (odd) — spine side on left */
.scai-fb-page.right-page {
  border-radius: 0 4px 4px 0;
  box-shadow: 4px 0 20px rgba(0,0,0,0.3), inset 2px 0 8px rgba(0,0,0,0.1);
}

/* Page spine shadow */
.scai-book-spine {
  width: 10px;
  background: linear-gradient(to right, #1a1028, #3d2066);
  flex-shrink: 0;
  box-shadow: inset 2px 0 4px rgba(0,0,0,0.5);
}

/* ── Cover Page ───────────────────────────────── */
.scai-fb-page.cover-page {
  background: linear-gradient(135deg, var(--scai-primary) 0%, #9b5de5 100%);
}
.scai-fb-cover-img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
}
.scai-fb-cover-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(transparent 40%, rgba(0,0,0,0.7) 100%);
}
.scai-fb-cover-content {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 28px 24px;
  z-index: 2;
  color: #fff;
}
.scai-fb-cover-title {
  font-size: 26px; font-weight: 800;
  text-shadow: 0 2px 12px rgba(0,0,0,0.6);
  line-height: 1.2; margin-bottom: 8px;
  font-family: var(--scai-serif);
}
.scai-fb-cover-subtitle { font-size: 14px; opacity: 0.85; }

/* ── Story Page ───────────────────────────────── */
.scai-fb-page-content {
  flex: 1; display: flex; flex-direction: column;
  background: #fff; overflow: hidden;
}
.scai-fb-page-image {
  flex: 0 0 55%; overflow: hidden; position: relative;
}
.scai-fb-page-image img {
  width: 100%; height: 100%; object-fit: cover;
  display: block;
}
.scai-fb-page-text-area {
  flex: 1; padding: 20px;
  display: flex; flex-direction: column; justify-content: center;
  background: linear-gradient(180deg, #fdf8ff 0%, #f8f3ff 100%);
}
.scai-fb-page-text {
  font-family: var(--scai-serif);
  font-size: 15px; line-height: 1.75;
  color: #2d2016;
}
.scai-fb-page-num {
  text-align: center; font-size: 11px;
  color: var(--scai-text-light);
  letter-spacing: 2px; text-transform: uppercase;
  margin-top: 12px;
}

/* ── Title / Dedication page ─────────────────── */
.scai-fb-title-page {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; padding: 32px;
  background: linear-gradient(180deg, #fdf8ff, #f0eaff);
  height: 100%;
}
.scai-fb-title-page .book-title {
  font-family: var(--scai-serif);
  font-size: 26px; font-weight: 700;
  color: var(--scai-primary); margin-bottom: 12px; line-height: 1.2;
}
.scai-fb-title-page .book-subtitle { font-size: 14px; color: var(--scai-text-light); margin-bottom: 32px; }
.scai-fb-title-page .book-decoration {
  font-size: 48px; margin-bottom: 28px;
  animation: scai-float 3s ease-in-out infinite;
}
.scai-fb-title-page .book-dedication {
  font-style: italic; font-size: 14px; color: #555;
  border-left: 3px solid var(--scai-primary); padding: 12px 16px;
  text-align: left; border-radius: 0 8px 8px 0;
  background: rgba(108,63,197,0.06);
  max-width: 280px;
}

/* ── Back cover ───────────────────────────────── */
.scai-fb-back-cover {
  background: linear-gradient(135deg, #0d0520, #1a0d35);
  color: #fff;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; padding: 32px; height: 100%;
  position: relative;
}
.scai-fb-back-cover img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; opacity: 0.25;
}
.scai-fb-back-cover-content {
  position: relative; z-index: 2;
}
.scai-fb-back-blurb {
  font-style: italic; font-size: 15px; line-height: 1.7;
  margin-bottom: 24px; color: rgba(255,255,255,0.9);
  font-family: var(--scai-serif);
}
.scai-fb-stars { font-size: 20px; letter-spacing: 4px; margin-bottom: 16px; }
.scai-fb-back-logo { font-size: 12px; color: rgba(255,255,255,0.5); letter-spacing: 2px; text-transform: uppercase; }

/* ── Page turn animation ──────────────────────── */
.scai-fb-page.turning-forward {
  animation: page-turn-forward 0.6s ease-in-out;
}
.scai-fb-page.turning-backward {
  animation: page-turn-backward 0.6s ease-in-out;
}
@keyframes page-turn-forward {
  0%   { transform: rotateY(0deg); box-shadow: 4px 0 20px rgba(0,0,0,0.3); }
  50%  { transform: rotateY(-90deg); box-shadow: 0 0 40px rgba(0,0,0,0.5); }
  100% { transform: rotateY(0deg); }
}
@keyframes page-turn-backward {
  0%   { transform: rotateY(0deg); }
  50%  { transform: rotateY(90deg); box-shadow: 0 0 40px rgba(0,0,0,0.5); }
  100% { transform: rotateY(0deg); }
}

/* ── Page loading skeleton ────────────────────── */
.scai-fb-skeleton {
  background: linear-gradient(90deg, #f0eaff 0%, #e8deff 50%, #f0eaff 100%);
  background-size: 200% 100%;
  animation: scai-skeleton 1.4s ease-in-out infinite;
  border-radius: 4px;
}
@keyframes scai-skeleton {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

/* ── Responsive ───────────────────────────────── */
@media (max-width: 860px) {
  .scai-fb-page { width: 300px; min-height: 420px; }
  .scai-fb-cover-title { font-size: 20px; }
  .scai-fb-page-text { font-size: 13px; }
  .scai-fb-title-page .book-title { font-size: 20px; }
}
@media (max-width: 640px) {
  .scai-fb-page { width: calc(100vw - 60px); min-height: 400px; }
  .right-page { display: none; }
  .scai-book-spine { display: none; }
  .scai-fb-page { border-radius: 8px !important; }
  .scai-flipbook-wrap { padding: 24px 12px 40px; }
}
