/* TTEL World-Class Realistic Flipbook v1 */
.rf-realistic-overlay {
  --rf-paper: #fffef9;
  --rf-ink: #0b211a;
  --rf-spine: rgba(0, 24, 17, .72);
  --rf-duration: 820ms;
  background:
    radial-gradient(circle at 50% 18%, rgba(79, 126, 110, .55), transparent 35%),
    linear-gradient(155deg, #173b31 0%, #071d17 58%, #03110d 100%) !important;
  isolation: isolate;
}

.rf-realistic-overlay::before {
  content: '';
  position: absolute;
  inset: 66px 0 70px;
  z-index: -1;
  pointer-events: none;
  opacity: .32;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,.015) 0 1px, transparent 1px 5px),
    radial-gradient(ellipse at center bottom, rgba(0,0,0,.58), transparent 60%);
}

.rf-topbar {
  backdrop-filter: blur(18px);
  background: linear-gradient(90deg, rgba(2, 27, 20, .94), rgba(4, 48, 36, .82)) !important;
  border-bottom: 1px solid rgba(255,255,255,.1);
  box-shadow: 0 10px 28px rgba(0,0,0,.2);
}

.rf-stage {
  position: relative;
  grid-template-columns: auto minmax(0, 1fr) !important;
  gap: 18px !important;
  overflow: hidden !important;
  perspective: 2400px !important;
  perspective-origin: 50% 42%;
  padding: 18px 28px 30px !important;
  touch-action: none;
}

.rf-book-shell {
  position: relative !important;
  width: min(1380px, 92vw) !important;
  height: min(820px, calc(100vh - 188px)) !important;
  display: block !important;
  filter: none !important;
  transform-style: preserve-3d;
  transform-origin: center center;
  contain: layout paint style;
  will-change: transform;
}

.rf-book {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  perspective: 2400px;
  perspective-origin: 50% 45%;
  border-radius: 4px;
  z-index: 4;
}

.rf-static-spread,
.rf-animation-scene,
.rf-generic-under,
.rf-generic-leaf,
.rf-generic-face {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}

.rf-static-spread.rf-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
}

.rf-static-spread.rf-single {
  display: grid;
  place-items: center;
  padding-inline: min(18vw, 250px);
}

.rf-static-spread.rf-landscape {
  display: block;
}

.rf-page-slot {
  position: relative;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: var(--rf-paper);
  box-shadow: inset 0 0 0 1px rgba(21, 51, 41, .12);
}

.rf-page-slot > .book-page,
.rf-page-slot > .book-page.exact-template,
.rf-page-slot > .book-page.structured-native-page {
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  max-height: none !important;
  aspect-ratio: auto !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  background: var(--rf-paper) !important;
}

.rf-page-slot iframe,
.rf-page-slot img {
  width: 100% !important;
  height: 100% !important;
  display: block;
  border: 0;
  object-fit: contain;
  background: var(--rf-paper);
}

.rf-pair .rf-left-page,
.rf-animation-static.rf-left-static {
  border-radius: 5px 0 0 5px;
  box-shadow:
    inset -17px 0 28px rgba(0, 34, 23, .09),
    inset -1px 0 0 rgba(0,0,0,.22),
    0 20px 44px rgba(0,0,0,.3);
}

.rf-pair .rf-right-page,
.rf-animation-static.rf-right-static {
  border-radius: 0 5px 5px 0;
  box-shadow:
    inset 17px 0 28px rgba(0, 34, 23, .09),
    inset 1px 0 0 rgba(255,255,255,.7),
    0 20px 44px rgba(0,0,0,.3);
}

.rf-single .rf-single-page,
.rf-landscape .rf-landscape-page {
  width: 100%;
  border-radius: 5px;
  box-shadow: 0 24px 58px rgba(0,0,0,.36), inset 0 0 0 1px rgba(0,0,0,.13);
}

.rf-spine {
  position: absolute;
  z-index: 70;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 34px;
  transform: translateX(-50%) translateZ(6px);
  pointer-events: none;
  opacity: .92;
  background:
    linear-gradient(90deg,
      transparent 0%,
      rgba(0,0,0,.09) 14%,
      rgba(0,0,0,.36) 43%,
      rgba(255,255,255,.28) 51%,
      rgba(0,0,0,.26) 59%,
      rgba(0,0,0,.07) 84%,
      transparent 100%);
  mix-blend-mode: multiply;
}

.rf-static-spread.rf-single + .rf-spine,
.rf-static-spread.rf-landscape + .rf-spine {
  opacity: .28;
}

.rf-ambient-shadow {
  position: absolute;
  z-index: 0;
  left: 5%;
  right: 5%;
  bottom: -24px;
  height: 70px;
  border-radius: 50%;
  filter: blur(20px);
  background: rgba(0,0,0,.62);
  transform: translateZ(-20px);
}

.rf-page-stack {
  position: absolute;
  top: 7px;
  bottom: 7px;
  width: 12px;
  z-index: 2;
  border-radius: 2px;
  background:
    repeating-linear-gradient(to bottom, #f9f5e8 0 2px, #d9d1bd 2px 3px),
    #f6f0df;
  box-shadow: 0 14px 25px rgba(0,0,0,.24);
}
.rf-stack-left { left: -7px; transform: rotateY(9deg); }
.rf-stack-right { right: -7px; transform: rotateY(-9deg); }

.rf-turn-zone {
  position: absolute;
  z-index: 95;
  top: 0;
  bottom: 0;
  width: clamp(44px, 5vw, 72px);
  padding: 0;
  border: 0;
  outline: 0;
  color: transparent;
  background: transparent;
  cursor: grab;
  touch-action: none;
}
.rf-turn-zone:active { cursor: grabbing; }
.rf-prev-zone { left: 0; }
.rf-next-zone { right: 0; }
.rf-turning .rf-turn-zone { pointer-events: none; }
.flip-stage.is-zoomed .rf-turn-zone { display: none; }

.rf-corner-fold {
  position: absolute;
  width: 42px;
  height: 42px;
  bottom: 0;
  opacity: 0;
  transition: opacity .18s ease, transform .18s ease;
  filter: drop-shadow(0 5px 5px rgba(0,0,0,.2));
}
.rf-next-zone .rf-corner-fold {
  right: 0;
  transform-origin: 100% 100%;
  background: linear-gradient(135deg, transparent 49%, rgba(255,255,255,.92) 50%, rgba(216,207,183,.95) 100%);
  transform: scale(.45);
}
.rf-prev-zone .rf-corner-fold {
  left: 0;
  transform-origin: 0 100%;
  background: linear-gradient(225deg, transparent 49%, rgba(255,255,255,.92) 50%, rgba(216,207,183,.95) 100%);
  transform: scale(.45);
}
.rf-turn-zone:hover .rf-corner-fold,
.rf-turn-zone:focus-visible .rf-corner-fold {
  opacity: .95;
  transform: scale(1);
}

.rf-animation-static {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  overflow: hidden;
  background: var(--rf-paper);
}
.rf-left-static { left: 0; }
.rf-right-static { right: 0; }

.rf-turning-leaf {
  position: absolute;
  z-index: 60;
  top: 0;
  bottom: 0;
  width: 50%;
  transform-style: preserve-3d;
  will-change: transform;
}
.rf-forward-leaf {
  left: 50%;
  transform-origin: 0 50%;
}
.rf-backward-leaf {
  left: 0;
  transform-origin: 100% 50%;
}

.rf-leaf-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--rf-paper);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.rf-leaf-front { transform: rotateY(0deg) translateZ(.5px); }
.rf-leaf-back { transform: rotateY(180deg) translateZ(.5px); }
.rf-forward-leaf .rf-leaf-front { border-radius: 0 5px 5px 0; }
.rf-forward-leaf .rf-leaf-back { border-radius: 5px 0 0 5px; }
.rf-backward-leaf .rf-leaf-front { border-radius: 5px 0 0 5px; }
.rf-backward-leaf .rf-leaf-back { border-radius: 0 5px 5px 0; }

.rf-leaf-face iframe,
.rf-generic-face iframe { pointer-events: none !important; }

.rf-leaf-shadow,
.rf-leaf-highlight {
  position: absolute;
  inset: 0;
  z-index: 12;
  pointer-events: none;
  backface-visibility: hidden;
}
.rf-leaf-shadow {
  opacity: var(--rf-shadow-opacity, .36);
  background: linear-gradient(90deg, rgba(0,0,0,.48), rgba(0,0,0,.03) 42%, transparent 75%);
  mix-blend-mode: multiply;
}
.rf-backward-leaf .rf-leaf-shadow {
  background: linear-gradient(270deg, rgba(0,0,0,.48), rgba(0,0,0,.03) 42%, transparent 75%);
}
.rf-leaf-highlight {
  background: linear-gradient(90deg, transparent 34%, rgba(255,255,255,.42) 58%, transparent 78%);
  opacity: .38;
}

.rf-generic-under { z-index: 1; }
.rf-generic-leaf {
  z-index: 30;
  transform-style: preserve-3d;
  will-change: transform;
}
.rf-generic-forward { transform-origin: 0 50%; }
.rf-generic-backward { transform-origin: 100% 50%; }
.rf-generic-face {
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: transparent;
}
.rf-generic-front { transform: rotateY(0deg) translateZ(.5px); }
.rf-generic-back { transform: rotateY(180deg) translateZ(.5px); }

.rf-reading-status {
  position: absolute;
  z-index: 105;
  left: 50%;
  bottom: 8px;
  display: flex;
  align-items: center;
  gap: 9px;
  transform: translateX(-50%);
  padding: 6px 12px;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 999px;
  color: rgba(255,255,255,.84);
  background: rgba(0, 24, 17, .54);
  backdrop-filter: blur(10px);
  font-size: 10px;
  pointer-events: none;
}
.rf-reading-status b { color: white; font-size: 11px; }

.rf-page-progress {
  position: absolute;
  z-index: 108;
  left: 17%;
  right: 17%;
  bottom: -18px;
  width: 66%;
  height: 4px;
  accent-color: #71e3b5;
  cursor: pointer;
}

.rf-accessible-instructions,
.rf-sound-status {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.rf-preload {
  position: fixed;
  left: -100000px;
  top: -100000px;
  width: 2px;
  height: 2px;
  overflow: hidden;
  opacity: .001;
  pointer-events: none;
}
.rf-preload .book-page { width: 2px !important; height: 2px !important; }

.rf-controls {
  position: relative;
  z-index: 120;
  background: linear-gradient(180deg, rgba(1, 16, 12, .25), rgba(1, 16, 12, .72)) !important;
  border-top: 1px solid rgba(255,255,255,.08);
  backdrop-filter: blur(14px);
}
.rf-controls .flip-control-btn {
  width: 46px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.16);
  color: white;
  background: rgba(255,255,255,.08);
  box-shadow: 0 8px 20px rgba(0,0,0,.17);
}
.rf-controls .flip-control-btn:hover:not(:disabled) {
  transform: translateY(-1px) scale(1.03);
  background: rgba(113, 227, 181, .2);
  border-color: rgba(113, 227, 181, .52);
}

.rf-form-nav {
  z-index: 130;
  background: rgba(1, 31, 22, .66) !important;
  border-color: rgba(255,255,255,.15) !important;
  box-shadow: 0 18px 40px rgba(0,0,0,.24) !important;
}

.rf-dragging-page,
.rf-dragging-page * { cursor: grabbing !important; }

@media (max-width: 1100px) {
  .rf-book-shell { width: min(1100px, 90vw) !important; }
  .rf-stage { grid-template-columns: 1fr !important; padding-inline: 18px !important; }
  .rf-form-nav { display: none !important; }
}

@media (max-width: 860px) {
  .rf-book-shell {
    width: min(760px, 94vw) !important;
    height: min(900px, calc(100vh - 188px)) !important;
  }
  .rf-static-spread.rf-single { padding-inline: 0; }
  .rf-static-spread.rf-single .rf-single-page { width: 100%; }
  .rf-spine, .rf-page-stack { display: none; }
  .rf-turn-zone { width: 16%; }
  .rf-page-progress { left: 10%; right: 10%; width: 80%; }
  .rf-reading-status span { display: none; }
}

@media (max-width: 560px) {
  .rf-topbar .flipbook-title small { max-width: 56vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .rf-top-tools .icon-button { width: 34px; height: 34px; }
  .rf-stage { padding: 10px 8px 26px !important; }
  .rf-book-shell { width: 96vw !important; height: calc(100vh - 174px) !important; }
}

@media (prefers-reduced-motion: reduce) {
  .rf-realistic-overlay { --rf-duration: 130ms; }
  .rf-corner-fold { transition: none !important; }
  .rf-controls .flip-control-btn { transition: none !important; }
  .rf-page-stack, .rf-ambient-shadow { opacity: .35; }
}

/* BEGIN FULLSCREEN COVER CLARITY STYLES */

/*
   Use almost the complete browser height for the
   booklet rather than reserving large header/footer areas.
*/
.rf-realistic-overlay {
  width: 100vw !important;
  height: 100dvh !important;
  grid-template-rows:
    48px
    minmax(0, 1fr)
    48px !important;
  overflow: hidden !important;
}

.rf-stage {
  min-width: 0 !important;
  min-height: 0 !important;
  padding: 6px 28px 18px !important;
}

/*
   Normal spreads use the largest safe area.
*/
.rf-book-shell {
  width: min(1500px, 94vw) !important;
  height: min(
    900px,
    calc(100dvh - 120px)
  ) !important;
}

/*
   Page 1 uses 125% by default. Reduce its base
   height so that the complete enlarged cover remains
   visible inside the screen.
*/
@supports selector(
  .rf-book-shell:has(
    .rf-static-spread.rf-single
  )
) {
  .rf-book-shell:has(
    .rf-static-spread.rf-single
    [data-page-number="1"]
  ) {
    height: min(
      820px,
      calc((100dvh - 120px) / 1.25)
    ) !important;
  }
}

/*
   A cover or a single landscape page is not an
   open two-page book. Therefore it must not show
   the centre spine.
*/
.rf-static-spread.rf-single + .rf-spine,
.rf-static-spread.rf-landscape + .rf-spine {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
}

/*
   Remove the fake left/right paper stacks from
   single-page covers.
*/
@supports selector(
  .rf-book-shell:has(
    .rf-static-spread.rf-single
  )
) {
  .rf-book-shell:has(
    .rf-static-spread.rf-single
  ) > .rf-page-stack,
  .rf-book-shell:has(
    .rf-static-spread.rf-landscape
  ) > .rf-page-stack {
    display: none !important;
  }
}

/*
   Keep realistic edge dragging available at the
   default 125% cover size.
*/
.flip-stage.is-zoomed .rf-turn-zone {
  display: block !important;
}

.rf-reading-status {
  bottom: 3px !important;
}

.rf-page-progress {
  bottom: -13px !important;
}

@media (max-width: 860px) {
  .rf-book-shell {
    width: 96vw !important;
    height: calc(
      100dvh - 118px
    ) !important;
  }

  @supports selector(
    .rf-book-shell:has(
      .rf-static-spread.rf-single
    )
  ) {
    .rf-book-shell:has(
      .rf-static-spread.rf-single
      [data-page-number="1"]
    ) {
      height: calc(
        (100dvh - 118px) / 1.25
      ) !important;
    }
  }
}

/* END FULLSCREEN COVER CLARITY STYLES */

/* BEGIN FULL VIEWPORT BOOK CLARITY */

/*
   Use almost the complete browser viewport.
   This changes only the viewer layout—not the booklet files.
*/
.rf-realistic-overlay {
    width: 100vw !important;
    height: 100dvh !important;
    max-width: none !important;
    max-height: none !important;
    overflow: hidden !important;
}

.rf-stage,
.flip-stage {
    width: 100% !important;
    height: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    padding: 6px 12px 56px !important;
    box-sizing: border-box !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/*
   Previously the book shell occupied only part of the screen.
   Allow it to use the full available width and height.
*/
.rf-book-shell {
    width: min(96vw, 1900px) !important;
    max-width: 96vw !important;
    height: calc(100dvh - 125px) !important;
    max-height: calc(100dvh - 125px) !important;
    margin: 0 auto !important;
    position: relative !important;
    transform-origin: center center !important;
}

/*
   Expand the active spread inside the shell.
*/
.rf-static-spread,
.rf-current-spread,
.flip-spread {
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 auto !important;
    box-sizing: border-box !important;
    align-items: center !important;
    justify-content: center !important;
}

/*
   Normal two-page spread: each page receives half of
   the available width while retaining its aspect ratio.
*/
.rf-static-spread:not(.rf-single):not(.rf-landscape) {
    display: flex !important;
    gap: 0 !important;
}

.rf-static-spread:not(.rf-single):not(.rf-landscape)
.book-page {
    flex: 0 1 50% !important;
    width: 50% !important;
    max-width: 50% !important;
    height: 100% !important;
    min-width: 0 !important;
}

/*
   Single cover and single landscape pages remain centred.
*/
.rf-static-spread.rf-single,
.rf-static-spread.rf-landscape {
    display: flex !important;
    justify-content: center !important;
}

.rf-static-spread.rf-single .book-page {
    width: auto !important;
    max-width: 54% !important;
    height: 100% !important;
    margin: 0 auto !important;
}

.rf-static-spread.rf-landscape .book-page {
    width: 92% !important;
    max-width: 92% !important;
    height: 100% !important;
    margin: 0 auto !important;
}

/*
   Preserve the original image aspect ratio and allow the
   browser to use its normal high-quality resampling.
*/
.rf-book-shell .book-page img,
.rf-book-shell .exact-template img {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain !important;
    object-position: center center !important;
    image-rendering: auto !important;
}

/*
   A single cover is not an open two-page spread.
*/
.rf-static-spread.rf-single + .rf-spine,
.rf-static-spread.rf-landscape + .rf-spine {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

/*
   Keep navigation and status controls visible.
*/
.rf-reading-status {
    bottom: 5px !important;
}

.rf-page-progress {
    bottom: -12px !important;
}

@media (max-width: 900px) {
    .rf-stage,
    .flip-stage {
        padding: 4px 5px 52px !important;
    }

    .rf-book-shell {
        width: 98vw !important;
        max-width: 98vw !important;
        height: calc(100dvh - 112px) !important;
        max-height: calc(100dvh - 112px) !important;
    }

    .rf-static-spread.rf-single .book-page {
        max-width: 82% !important;
    }
}

/* END FULL VIEWPORT BOOK CLARITY */
