/* =========================
   Book preview
========================= */

html.preview-open,
body.preview-open {
  overflow: hidden;
  height: 100%;
}

.book-preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: stretch;
  justify-content: center;
  background: var(--bg-overlay);
}

.book-preview-overlay.is-hidden {
  display: none;
}

.book-preview-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 980px;
  height: 100vh;
  background: var(--bg-main);
  color: var(--text-primary);
}

.book-preview-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-7) var(--space-8);
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-surface);
  flex: 0 0 auto;
}

.book-preview-title {
  color: var(--text-primary);
  font-size: var(--font-size-sm);
}

.book-preview-content {
  flex: 1 1 auto;
  overflow-y: scroll;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: var(--space-6);
  background: var(--bg-main);
  display: block;
}

.book-preview-page {
  display: flex;
  flex-direction: column;
  position: relative;
  width: min(100%, 8.5in);
  aspect-ratio: 8.5 / 11;
  margin: 0 auto var(--space-9);
  padding: 8% 8% 10%;
  box-sizing: border-box;
  overflow: hidden;
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 10px;
  line-height: 1.5;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}

.book-preview-page-inner {
  flex: 1;
  overflow: hidden;
}

.book-preview-header {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 5%;
  color: var(--text-primary);
  font-size: 10px;
  font-weight: 600;
}

.book-preview-page-number {
  position: absolute;
  right: 8%;
  bottom: 4%;
  color: var(--text-primary);
  font-size: 10px;
  line-height: 1;
}

.book-preview-first-page-heading {
  margin-bottom: 5%;
  color: var(--text-secondary);
}

.book-preview-first-page-heading div {
  margin-bottom: 0.15em;
}

.book-preview-book-title {
  text-align: center;
  color: var(--text-primary);
  font-weight: bold;
}

.book-preview-chapter-title {
  text-align: center;
  margin-bottom: 5%;
  color: var(--text-primary);
  font-weight: bold;
}

.book-preview-paragraph {
  margin: 0;
  text-indent: 0.25in;
  white-space: normal;
  color: var(--text-secondary);
  line-height: 1.8;
}

/* mobile */
@media (max-width: 640px) {
  .book-preview-content {
    padding: var(--space-4);
  }

  .book-preview-page {
    width: 100%;
    aspect-ratio: 8.5 / 11;
    padding: 24px;
  }

  .book-preview-page-inner {
    flex: 1;
  }
}