/* ============================================================
   HOPE Centre — Programmes Flipbook
   ============================================================ */

/* Outer layout: TOC + Book side-by-side */
.flipbook-outer-wrapper {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 24px;
  padding: 0 20px;
  max-width: 1400px;
  margin: 0 auto;
}

/* ── Table of Contents ───────────────────────────────────── */
.toc-panel {
  flex-shrink: 0;
  width: 210px;
  margin-top: 50px;
  background: #fff;
  border: 1px solid rgba(123, 207, 136, 0.4);
  border-radius: 12px;
  padding: 18px 14px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  max-height: 560px;
  overflow-y: auto;
}

.toc-panel h3 {
  font-size: 0.92rem;
  font-weight: 700;
  color: #2f6e3b;
  margin: 0 0 12px;
  padding-bottom: 9px;
  border-bottom: 2px solid #7bcf88;
  text-align: center;
}

.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.toc-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s, color 0.2s;
  border-left: 3px solid transparent;
  font-size: 0.82rem;
  font-weight: 500;
  color: #3a4a3c;
  line-height: 1.3;
  user-select: none;
}

.toc-item:hover {
  background: #edf8ea;
  border-left-color: #7bcf88;
  transform: translateX(3px);
  color: #2f6e3b;
}

.toc-item.active {
  background: #5aaa67;
  border-left-color: #3d8b4f;
  color: #ffffff;
  font-weight: 600;
}

.toc-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(90,170,103,0.15);
  color: #2f6e3b;
  flex-shrink: 0;
}

.toc-item.active .toc-num {
  background: rgba(255,255,255,0.25);
  color: #fff;
}

/* ── Book wrapper ────────────────────────────────────────── */
.book-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}

/* ── Book container ──────────────────────────────────────── */
.flipbook-container {
  position: relative;
  width: 1100px;
  height: 560px;
  perspective: 2000px;
  perspective-origin: 50% 50%;
  border: 3px solid #654321;
  border-radius: 8px;
  box-shadow:
    0 20px 60px rgba(0,0,0,0.3),
    inset 0 0 30px rgba(101,67,33,0.1);
  background: #e0ddd8;
  overflow: hidden;
}

/* Book spine strip */
.book-spine {
  position: absolute;
  left: 50%;
  top: 0;
  width: 32px;
  height: 100%;
  transform: translateX(-50%);
  background: linear-gradient(to right,
    #7a3e10 0%, #5d2e0a 25%, #8b4513 50%, #5d2e0a 75%, #7a3e10 100%);
  z-index: 50;
  box-shadow:
    3px 0 10px rgba(0,0,0,0.35),
    -3px 0 10px rgba(0,0,0,0.35);
}

/* ── Individual pages ────────────────────────────────────── */
.book-page {
  position: absolute;
  width: 550px;
  height: 560px;
  background-color: #fefefe;
  background-image: linear-gradient(rgba(0,0,0,0.018) 1px, transparent 1px);
  background-size: 100% 28px;
  overflow: hidden;
  transform-style: preserve-3d;
  opacity: 0;
  z-index: 1;
}

/* Left pages: anchored left, pivot from right edge */
.book-page.left-page {
  left: 0;
  right: auto;
  transform-origin: right center;
  border-right: 1px solid #ddd;
  box-shadow: inset -6px 0 12px rgba(0,0,0,0.06);
}

/* Right pages: anchored right, pivot from left edge */
.book-page.right-page {
  right: 0;
  left: auto;
  transform-origin: left center;
  border-left: 1px solid #ddd;
  box-shadow: inset 6px 0 12px rgba(0,0,0,0.06);
}

/* Visible states */
.book-page.current-left,
.book-page.current-right {
  opacity: 1;
  z-index: 10;
}

.book-page.behind {
  opacity: 0;
  z-index: 1;
}

.book-page.revealing {
  opacity: 1;
  z-index: 8;
}

/* Shadow cast onto revealing pages during flip */
.book-page.revealing::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to left, rgba(0,0,0,0.22) 0%, transparent 65%);
  animation: revealShadowFade 0.65s ease forwards;
  pointer-events: none;
  z-index: 30;
}

@keyframes revealShadowFade {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

/* Hover lift — simulates page about to be turned */
.book-page.current-right:hover {
  cursor: pointer;
  transform: rotateY(-2.5deg);
  box-shadow: -8px 12px 28px rgba(0,0,0,0.22);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.book-page.current-left:hover {
  cursor: pointer;
  transform: rotateY(2.5deg);
  box-shadow: 8px 12px 28px rgba(0,0,0,0.22);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* ── Page-turn animations ─────────────────────────────────── */
.book-page.flip-right-out {
  z-index: 15;
  opacity: 1;
  animation: flipRightOut 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.book-page.flip-left-out {
  z-index: 15;
  opacity: 1;
  animation: flipLeftOut 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes flipRightOut {
  0%   { transform: rotateY(0deg);    }
  100% { transform: rotateY(-180deg); }
}

@keyframes flipLeftOut {
  0%   { transform: rotateY(0deg);   }
  100% { transform: rotateY(180deg); }
}

/* ── Navigation ──────────────────────────────────────────── */
.flipbook-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 16px 0 0;
}

.flip-btn {
  background: linear-gradient(135deg, #5aaa67, #3d8b4f);
  color: #fff;
  border: none;
  padding: 10px 26px;
  border-radius: 25px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 4px 14px rgba(90,170,103,0.35);
}

.flip-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #3d8b4f, #2f6e3b);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(90,170,103,0.45);
}

.flip-btn:disabled {
  background: #c8d6c8;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.page-indicator {
  font-size: 0.88rem;
  color: #666;
  min-width: 150px;
  text-align: center;
}

/* ── Page content ─────────────────────────────────────────── */
.page-content {
  padding: 28px 30px;
  height: 100%;
  box-sizing: border-box;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* Thin scrollbar inside pages */
.page-content::-webkit-scrollbar { width: 4px; }
.page-content::-webkit-scrollbar-track { background: #f0f0f0; }
.page-content::-webkit-scrollbar-thumb { background: #b7dfb8; border-radius: 2px; }

.page-content h2 {
  color: #2c3e50;
  font-size: 1.3rem;
  margin: 0 0 10px;
  padding-bottom: 7px;
  border-bottom: 2px solid #5aaa67;
}

.page-content h3 {
  color: #2f6e3b;
  font-size: 0.95rem;
  margin: 10px 0 4px;
  font-weight: 600;
}

.page-content p {
  font-size: 0.87rem;
  line-height: 1.6;
  color: #3a4a3c;
  margin: 0 0 8px;
}

.page-content ul {
  margin: 0 0 10px 1rem;
  padding: 0;
}

.page-content li {
  font-size: 0.86rem;
  line-height: 1.55;
  color: #3a4a3c;
  margin-bottom: 4px;
}

/* Chapter badge */
.page-badge {
  display: inline-block;
  background: #edf8ea;
  border: 1px solid #b7dfb8;
  color: #2f6e3b;
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 0.76rem;
  font-weight: 600;
  margin-bottom: 7px;
  align-self: flex-start;
}

/* Feature bullet */
.page-feature {
  background: #f4fbf2;
  border-left: 3px solid #5aaa67;
  padding: 7px 11px;
  border-radius: 4px;
  font-size: 0.85rem;
  color: #2c3e50;
  margin-bottom: 6px;
  line-height: 1.45;
}

/* Page number */
.page-number {
  position: absolute;
  bottom: 10px;
  right: 14px;
  font-size: 0.72rem;
  color: #bbb;
  font-style: italic;
  pointer-events: none;
}

/* ── Cover & back pages ──────────────────────────────────── */
.page-cover,
.page-back {
  background: linear-gradient(145deg, #edf8ea 0%, #c8e6c9 100%) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
  padding: 40px !important;
}

.page-cover h1 {
  font-size: 1.8rem;
  color: #2f6e3b;
  font-weight: 700;
  margin: 14px 0 8px;
  border: none !important;
}

.page-back h2 {
  border: none !important;
  color: #2f6e3b;
  margin: 14px 0 8px;
}

.cover-logo {
  width: 88px;
  height: 88px;
  object-fit: contain;
}

/* ── Scroll hint ─────────────────────────────────────────── */
.flipbook-scroll-hint {
  text-align: center;
  font-size: 0.85rem;
  color: #888;
  margin-bottom: 12px;
}

/* ── Chapter overlay ──────────────────────────────────────────── */
.chapter-overlay {
  position: absolute;
  top: 0; left: 0; right: 0;
  background: linear-gradient(135deg, rgba(90,170,103,0.93), rgba(47,110,59,0.93));
  color: #fff;
  text-align: center;
  padding: 13px 20px;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
  border-radius: 4px 4px 0 0;
}
.chapter-overlay.visible { opacity: 1; }

/* ── Progress dots ─────────────────────────────────────────────── */
.flipbook-dots {
  display: flex;
  gap: 9px;
  justify-content: center;
  margin-top: 10px;
  min-height: 22px;
}
.flipbook-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #c5d9c5;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: background 0.25s, transform 0.2s;
}
.flipbook-dot.active            { background: #5aaa67; transform: scale(1.35); }
.flipbook-dot:hover:not(.active){ background: #7bcf88; transform: scale(1.15); }

/* ── View toggle bar ──────────────────────────────────────────── */
.view-toggle-bar {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 18px 0 6px;
}
.view-toggle-btn {
  padding: 8px 22px;
  border-radius: 24px;
  border: 2px solid #5aaa67;
  background: transparent;
  color: #2f6e3b;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
}
.view-toggle-btn.active,
.view-toggle-btn:hover {
  background: #5aaa67;
  color: #fff;
}

/* ── Mobile swipe hints ─────────────────────────────────────────── */
.swipe-hint-left,
.swipe-hint-right {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.6rem;
  color: rgba(90,170,103,0.7);
  pointer-events: none;
  z-index: 40;
  display: none;
  animation: pulseHint 2s ease-in-out infinite;
}
.swipe-hint-left  { left: 8px; }
.swipe-hint-right { right: 8px; }
@keyframes pulseHint {
  0%, 100% { opacity: 0.4; }
  50%       { opacity: 0.9; }
}
@media (max-width: 768px) {
  .swipe-hint-left, .swipe-hint-right { display: block; }
}

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 1200px) and (min-width: 1025px) {
  .flipbook-container { width: 860px !important; height: 540px !important; }
  .book-page          { width: 430px !important; }
}
@media (max-width: 1250px) {
  .flipbook-outer-wrapper {
    flex-direction: column;
    align-items: center;
    padding: 0 16px;
  }

  .toc-panel {
    width: 100%;
    max-width: 700px;
    max-height: 160px;
    margin-top: 0;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .toc-list {
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 6px;
  }

  .toc-item {
    white-space: nowrap;
    flex-shrink: 0;
  }
}

@media (max-width: 768px) {
  .flipbook-container {
    width: min(96vw, 400px) !important;
    height: 500px !important;
    border-radius: 6px !important;
  }

  .book-spine { display: none !important; }

  .book-page {
    width: 100% !important;
    left: 0 !important;
    right: auto !important;
    transform-origin: center center !important;
  }

  .book-page.mobile-single {
    opacity: 1 !important;
    z-index: 10 !important;
  }

  .book-page.mobile-hidden {
    opacity: 0 !important;
    z-index: 1 !important;
  }

  .page-content { padding: 16px 18px !important; }
  .page-content h2 { font-size: 1.05rem !important; }
  .page-content p,
  .page-content li   { font-size: 0.82rem !important; }
  .page-feature      { font-size: 0.8rem  !important; }
  .flip-btn          { padding: 9px 18px  !important; font-size: 0.83rem !important; }
}
