/* FrancaisFacile Interactive Book Styles */
.ffib-wrapper,
.ffib-wrapper * {
  box-sizing: border-box;
}

.ffib-wrapper {
  --ffib-text-scale: 1;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.08);
  overflow: hidden;
  margin: 24px auto;
  max-width: 1060px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #000000;
}

.ffib-wrapper.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 999990;
  max-width: none;
  margin: 0;
  border-radius: 0;
  display: flex;
  flex-direction: column;
}

.ffib-wrapper.is-fullscreen .ffib-reader-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: auto;
}

.ffib-wrapper.is-fullscreen .ffib-body,
.ffib-wrapper.is-fullscreen .ffib-cover-screen {
  flex: 1;
  overflow: auto;
}

.ffib-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 18px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
}

.ffib-toc-toggle,
.ffib-btn-prev,
.ffib-btn-next,
.ffib-btn-fullscreen {
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #000000;
  border-radius: 8px;
  width: 34px;
  height: 34px;
  font-size: 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}

.ffib-toc-toggle:hover:not(:disabled),
.ffib-btn-prev:hover:not(:disabled),
.ffib-btn-next:hover:not(:disabled),
.ffib-btn-fullscreen:hover:not(:disabled) {
  background: #eef2ff;
  border-color: #818cf8;
}

.ffib-btn-prev:disabled,
.ffib-btn-next:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ffib-book-title {
  font-size: 17px;
  font-weight: 700;
  color: #000000;
  flex: 1;
  min-width: 140px;
  text-align: center;
}

.ffib-nav-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

/* Text Size Controls */
.ffib-font-controls {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 2px 6px;
  height: 34px;
}

.ffib-font-btn {
  border: 0;
  background: transparent;
  color: #000000;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 5px;
  cursor: pointer;
  line-height: 1.2;
}

.ffib-font-btn:hover {
  background: #eef2ff;
}

.ffib-font-label {
  font-size: 12px;
  font-weight: 700;
  color: #000000;
  min-width: 36px;
  text-align: center;
}

.ffib-page-indicator {
  font-size: 13px;
  font-weight: 600;
  color: #000000;
  margin-right: 2px;
}

/* =========================================================
 * H5P-STYLE COVER PAGE
 * ========================================================= */
.ffib-cover-screen {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 490px;
  background: #ffffff;
  overflow: hidden;
  color: #000000;
}

.ffib-cover-pattern {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 34px;
  background-color: #f1f5f9;
  background-image: repeating-linear-gradient(
    -45deg,
    #e2e8f0,
    #e2e8f0 4px,
    #f8fafc 4px,
    #f8fafc 10px
  );
  border-right: 1px solid #e2e8f0;
}

.ffib-cover-inner {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 54px;
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 44px 48px 44px 68px;
}

.ffib-cover-art-col {
  flex-shrink: 0;
}

.ffib-cover-image {
  display: block;
  width: 310px;
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 16px 38px rgba(15, 23, 42, 0.22);
  object-fit: cover;
}

.ffib-cover-placeholder {
  width: 280px;
  height: 360px;
  border-radius: 10px;
  background: linear-gradient(145deg, #f3e8d2 0%, #e5d4b3 100%);
  box-shadow: 0 16px 38px rgba(15, 23, 42, 0.18);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  color: #000000;
}

.ffib-cover-placeholder-icon {
  font-size: 46px;
  margin-bottom: 14px;
}

.ffib-cover-placeholder-title {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  color: #000000;
}

.ffib-cover-info-col {
  flex: 1;
  max-width: 380px;
  text-align: left;
}

.ffib-cover-book-icon {
  color: #000000;
  margin-bottom: 12px;
  display: inline-flex;
}

.ffib-cover-heading {
  margin: 0 0 10px;
  font-size: 28px;
  font-weight: 800;
  line-height: 1.22;
  color: #000000;
}

.ffib-cover-subtitle {
  font-size: 16px;
  font-weight: 500;
  color: #000000;
  margin-bottom: 10px;
}

.ffib-cover-narrator {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  color: #000000;
  margin-bottom: 16px;
}

.ffib-cover-narrator svg {
  color: #000000;
  flex-shrink: 0;
}

.ffib-cover-desc {
  font-size: 14px;
  line-height: 1.6;
  color: #000000;
  margin: 0 0 20px;
}

.ffib-cover-cta-wrap {
  margin-top: 8px;
}

.ffib-cover-read-btn {
  background: #0072ce;
  color: #ffffff;
  border: 0;
  border-radius: 8px;
  padding: 13px 44px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 114, 206, 0.28);
  transition: background 0.15s, transform 0.1s;
}

.ffib-cover-read-btn:hover {
  background: #005ba6;
}

.ffib-cover-read-btn:active {
  transform: translateY(1px);
}

/* =========================================================
 * READER VIEW & SIDEBAR
 * ========================================================= */
.ffib-tip-bar {
  background: #eef2ff;
  color: #000000;
  font-size: 13px;
  padding: 8px 18px;
  border-bottom: 1px solid #e0e7ff;
}

.ffib-body {
  display: flex;
  min-height: 460px;
}

.ffib-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: #ffffff;
  border-right: 1px solid #e2e8f0;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #000000;
}

.ffib-wrapper.toc-collapsed .ffib-sidebar {
  display: none;
}

.ffib-sidebar-heading {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: #000000;
  margin-bottom: 10px;
}

.ffib-toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ffib-toc-list li {
  margin-bottom: 6px;
}

.ffib-toc-item,
.ffib-toc-cover-btn {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: calc(14px * var(--ffib-text-scale, 1));
  color: #000000;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ffib-toc-cover-btn {
  color: #000000;
  border-bottom: 1px solid #f1f5f9;
  margin-bottom: 4px;
}

.ffib-toc-item:hover,
.ffib-toc-cover-btn:hover {
  background: #f1f5f9;
}

.ffib-toc-item.is-active {
  background: #eef2ff;
  color: #000000;
  font-weight: 600;
  border-color: #c7d2fe;
}

.ffib-toc-label {
  flex: 1;
}

.ffib-toc-check {
  color: #16a34a;
  font-weight: 700;
  opacity: 0;
}

.ffib-toc-item.is-visited .ffib-toc-check {
  opacity: 1;
}

.ffib-progress-box {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #e2e8f0;
}

.ffib-progress-text {
  font-size: 12px;
  color: #000000;
  margin-bottom: 6px;
}

.ffib-progress-bar {
  height: 6px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.ffib-progress-fill {
  height: 100%;
  background: #4f46e5;
  transition: width 0.25s ease;
}

.ffib-stage {
  flex: 1;
  padding: 28px 34px;
  background: #f8fafc;
}

.ffib-chapter {
  display: none;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 28px 32px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
  color: #000000;
}

.ffib-chapter.is-active {
  display: block;
}

.ffib-chapter-title {
  margin: 0 0 18px;
  font-size: calc(24px * var(--ffib-text-scale, 1));
  font-weight: 750;
  color: #000000;
  border-bottom: 2px solid #f1f5f9;
  padding-bottom: 12px;
  line-height: 1.3;
}

/* Chapter MP3 Audio Bar */
.ffib-audio-box {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 20px;
  color: #000000;
}

.ffib-audio-label {
  font-size: 13px;
  font-weight: 700;
  color: #000000;
  white-space: nowrap;
}

.ffib-chapter-audio {
  flex: 1;
  height: 36px;
  width: 100%;
}

/* Chapter Images (Top/Bottom Figure & Inline Text Images) */
.ffib-chapter-figure {
  margin: 18px 0 22px;
  text-align: center;
}

.ffib-chapter-img,
.ffib-reading-area img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 14px auto;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
}

.ffib-chapter-caption {
  margin-top: 8px;
  font-size: calc(13px * var(--ffib-text-scale, 1));
  color: #000000;
}

.ffib-wrapper .ffib-reading-area,
.ffib-wrapper .ffib-reading-area p,
.ffib-wrapper .ffib-reading-area span,
.ffib-wrapper .ffib-reading-area em,
.ffib-wrapper .ffib-reading-area strong,
.ffib-wrapper .ffib-reading-area li,
.ffib-wrapper .ffib-reading-area blockquote,
.ffib-wrapper .ffib-reading-area div {
  font-size: calc(17px * var(--ffib-text-scale, 1));
  line-height: 1.75;
  color: #000000;
}

.ffib-reading-area {
  cursor: text;
  user-select: text;
}

.ffib-reading-area p {
  margin: 0 0 16px;
  color: #000000;
}

.ffib-reading-area p:first-of-type::first-letter {
  font-size: 2.6em;
  font-weight: 700;
  float: left;
  line-height: 0.9;
  margin-right: 8px;
  color: #000000;
}

/* Optional Comprehension Quiz */
.ffib-quiz-card {
  margin-top: 26px;
  padding: 20px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  color: #000000;
}

.ffib-quiz-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #e0e7ff;
  color: #000000;
  padding: 3px 8px;
  border-radius: 6px;
  margin-bottom: 8px;
}

.ffib-quiz-question {
  font-size: calc(16px * var(--ffib-text-scale, 1));
  font-weight: 650;
  margin-bottom: 12px;
  color: #000000;
}

.ffib-quiz-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  margin-bottom: 8px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  cursor: pointer;
  color: #000000;
  font-size: calc(15px * var(--ffib-text-scale, 1));
}

.ffib-quiz-option:hover {
  border-color: #818cf8;
}

.ffib-quiz-actions {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.ffib-quiz-check {
  background: #4f46e5;
  color: #ffffff;
  border: 0;
  border-radius: 8px;
  padding: 8px 16px;
  font-weight: 600;
  cursor: pointer;
}

.ffib-quiz-check:hover {
  background: #4338ca;
}

.ffib-quiz-feedback {
  font-size: 14px;
  font-weight: 600;
  color: #000000;
}

.ffib-chapter-footer {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
}

.ffib-footer-prev,
.ffib-footer-next {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #000000;
  border-radius: 8px;
  padding: 8px 16px;
  font-weight: 600;
  cursor: pointer;
}

.ffib-footer-prev:hover:not(:disabled),
.ffib-footer-next:hover:not(:disabled) {
  background: #eef2ff;
  border-color: #818cf8;
}

.ffib-footer-prev:disabled,
.ffib-footer-next:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

@media (max-width: 768px) {
  .ffib-cover-inner {
    flex-direction: column;
    text-align: center;
    padding: 32px 24px 32px 48px;
    gap: 24px;
  }
  .ffib-cover-info-col {
    text-align: center;
  }
  .ffib-cover-image {
    width: 220px;
  }
  .ffib-body {
    flex-direction: column;
  }
  .ffib-sidebar {
    width: 100%;
    border-right: 0;
    border-bottom: 1px solid #e2e8f0;
  }
  .ffib-stage {
    padding: 16px;
  }
  .ffib-chapter {
    padding: 18px;
  }
  .ffib-audio-box {
    flex-direction: column;
    align-items: stretch;
  }
}
