/*!
 * Open Flipbook — engine styles (book, pages, views, text layer)
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

.ofb-engine {
  --ofb-link-color: rgba(0, 0, 0, 0);
  --ofb-link-hover: rgba(255, 255, 0, 1);
  --ofb-link-opacity: 0.4;
  --ofb-highlight: rgba(255, 196, 0, 0.45);
  --ofb-selection: rgba(0, 110, 255, 0.28);
  --ofb-page-bg: #fff;
  overflow: hidden;
}

.ofb-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}
.ofb-mode-scroll .ofb-viewport {
  touch-action: auto;
}
.ofb-zoomed .ofb-viewport {
  cursor: grab;
}
.ofb-panning .ofb-viewport,
.ofb-panning .ofb-viewport * {
  cursor: grabbing !important;
}

.ofb-zoom {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  transform-origin: 0 0;
  will-change: transform;
}

.ofb-view {
  position: absolute;
}

/* ------------------------------------------------------------------ */
/* Spread / slots                                                      */
/* ------------------------------------------------------------------ */

.ofb-spread {
  position: absolute;
  left: 0;
  top: 0;
  will-change: transform;
}
.ofb-slot {
  position: absolute;
  top: 0;
}
.ofb-slot--empty .ofb-middle-shadow {
  display: none !important;
}
.ofb-middle-shadow {
  position: absolute;
  top: 0;
  height: 100%;
  z-index: 4;
  pointer-events: none;
}
.ofb-middle-shadow--left {
  right: 0;
}
.ofb-middle-shadow--right {
  left: 0;
}

/* ------------------------------------------------------------------ */
/* Pages                                                               */
/* ------------------------------------------------------------------ */

.ofb-page {
  position: absolute;
  left: 0;
  top: 0;
  overflow: hidden;
  background: var(--ofb-page-bg);
  contain: layout paint;
}
.ofb-page--blank {
  position: absolute;
  background: var(--ofb-page-bg);
}
.ofb-page-bitmap,
.ofb-page-content,
.ofb-page-overlay {
  position: absolute;
  inset: 0;
}
.ofb-page-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  -webkit-user-drag: none;
  user-select: none;
  pointer-events: none;
}
.ofb-page-content {
  z-index: 1;
}
.ofb-page-overlay {
  z-index: 3;
  pointer-events: none;
}
.ofb-page-overlay > * {
  pointer-events: auto;
}
.ofb-page--loading::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border-radius: 50%;
  border: 3px solid rgba(0, 0, 0, 0.12);
  border-top-color: rgba(0, 0, 0, 0.45);
  animation: ofb-spin 0.9s linear infinite;
  z-index: 2;
}
.ofb-page--error::after {
  content: "!";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font: 700 28px/1 system-ui, sans-serif;
  color: rgba(0, 0, 0, 0.35);
}
@keyframes ofb-spin {
  to {
    transform: rotate(360deg);
  }
}
.ofb-is-flipping .ofb-page-content {
  pointer-events: none;
}

.ofb-page-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  padding: 6px 10px;
  font: 13px/1.35 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #fff;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.62), rgba(0, 0, 0, 0));
  pointer-events: none;
}

/* links */
.ofb-page-links {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}
.ofb-link {
  position: absolute;
  display: block;
  pointer-events: auto;
  background: var(--ofb-link-color);
  opacity: var(--ofb-link-opacity);
  cursor: pointer;
  transition: background-color 0.15s;
}
.ofb-link:hover,
.ofb-link:focus-visible {
  background: var(--ofb-link-hover);
  outline: none;
}

/* html content and items */
.ofb-page-html {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  z-index: 2;
  pointer-events: none;
}
.ofb-page-html * {
  pointer-events: auto;
}
.ofb-page-items {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}
.ofb-item {
  position: absolute;
  pointer-events: auto;
  box-sizing: border-box;
}
.ofb-item-link,
.ofb-item-spotlight {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
}
.ofb-item--link .ofb-item-link {
  background: var(--ofb-link-color);
  opacity: var(--ofb-link-opacity);
}
.ofb-item--link .ofb-item-link:hover {
  background: var(--ofb-link-hover);
}
.ofb-item-spotlight {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 4px;
  transition: box-shadow 0.15s, background-color 0.15s;
}
.ofb-item-spotlight:hover,
.ofb-item-spotlight:focus-visible {
  background: rgba(255, 255, 255, 0.12);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.8), 0 0 14px rgba(0, 0, 0, 0.35);
  outline: none;
}
.ofb-item-image,
.ofb-item-media,
.ofb-item-iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  object-fit: contain;
  background: transparent;
}
.ofb-item--video .ofb-item-media,
.ofb-item--youtube .ofb-item-iframe,
.ofb-item--iframe .ofb-item-iframe {
  background: #000;
}

/* ------------------------------------------------------------------ */
/* Text layer (own rules for the pdf.js TextLayer markup)              */
/* ------------------------------------------------------------------ */

.ofb-textlayer {
  position: absolute;
  inset: 0;
  overflow: clip;
  z-index: 2;
  opacity: 1;
  line-height: 1;
  text-align: initial;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  forced-color-adjust: none;
  transform-origin: 0 0;
  caret-color: CanvasText;
  -webkit-user-select: text;
  user-select: text;
  --scale-round-x: 1px;
  --scale-round-y: 1px;
  --min-font-size: 1;
  --min-font-size-inv: calc(1 / var(--min-font-size));
  --text-scale-factor: calc(var(--total-scale-factor, 1) * var(--min-font-size));
}
.ofb-textlayer :is(span, br) {
  color: transparent;
  position: absolute;
  white-space: pre;
  cursor: text;
  transform-origin: 0% 0%;
}
.ofb-textlayer > :not(.markedContent),
.ofb-textlayer .markedContent span:not(.markedContent) {
  z-index: 1;
}
.ofb-textlayer span[role="img"] {
  -webkit-user-select: none;
  user-select: none;
  cursor: default;
}
.ofb-textlayer span:not(.markedContent),
.ofb-textlayer span[role="presentation"] {
  --font-height: 0;
  font-size: calc(var(--text-scale-factor) * var(--font-height));
  --scale-x: 1;
  --rotate: 0deg;
  transform: rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv));
}
.ofb-textlayer .markedContent {
  display: contents;
}
.ofb-textlayer br::selection {
  background: transparent;
}
.ofb-textlayer ::selection {
  background: var(--ofb-selection);
  color: transparent;
}
.ofb-textlayer .endOfContent {
  display: block;
  position: absolute;
  inset: 100% 0 0;
  z-index: 0;
  cursor: default;
  -webkit-user-select: none;
  user-select: none;
}
.ofb-textlayer.selecting .endOfContent {
  top: 0;
}
.ofb-textlayer mark.ofb-highlight {
  position: static;
  color: transparent;
  background: var(--ofb-highlight);
  border-radius: 2px;
  padding: 0;
  margin: 0;
}

/* ------------------------------------------------------------------ */
/* 3D view                                                             */
/* ------------------------------------------------------------------ */

.ofb-view--3d,
.ofb-view--webgl {
  perspective-origin: 50% 45%;
}
.ofb-r3d-camera {
  position: absolute;
  left: 0;
  top: 0;
  transform-style: preserve-3d;
  transform-origin: 50% 50%;
}
.ofb-r3d-book {
  transform-style: preserve-3d;
}
.ofb-r3d-book > .ofb-slot {
  transform: translateZ(0);
}
.ofb-r3d-cast {
  position: absolute;
  top: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 5;
  transform: translateZ(0.3px);
}
.ofb-r3d-cast > i {
  position: absolute;
  left: 0;
  top: 0;
  width: 100px;
  height: 100%;
  opacity: 0;
  transform-origin: 0 0;
  will-change: transform, opacity;
}
.ofb-r3d-cast__up {
  background: linear-gradient(to right, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.15) 50%, rgba(0, 0, 0, 0.45) 80%, #000);
}
.ofb-r3d-cast__down {
  background: linear-gradient(to right, #000, rgba(0, 0, 0, 0.45) 20%, rgba(0, 0, 0, 0.15) 50%, rgba(0, 0, 0, 0));
}
.ofb-r3d-sheet {
  position: absolute;
  top: 0;
  width: 0;
  transform-style: preserve-3d;
  pointer-events: none;
  z-index: 6;
}
.ofb-r3d-strip {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 50%;
  transform-style: preserve-3d;
}
.ofb-r3d-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  background: var(--ofb-page-bg);
}
.ofb-r3d-face--back {
  transform: rotateY(180deg);
}
.ofb-r3d-face canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.ofb-r3d-face > .ofb-r3d-tex {
  position: absolute;
  top: 0;
  max-width: none;
  max-height: none;
  margin: 0;
  border: 0;
  pointer-events: none;
  user-select: none;
}
.ofb-r3d-gutter,
.ofb-r3d-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-repeat: no-repeat;
}
.ofb-r3d-shade {
  opacity: 0;
  will-change: opacity;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.ofb-r3d-shade--a {
  background: linear-gradient(to right, #000, rgba(0, 0, 0, 0));
}
.ofb-r3d-shade--b {
  background: linear-gradient(to right, rgba(0, 0, 0, 0), #000);
}

/* ------------------------------------------------------------------ */
/* 2D view                                                             */
/* ------------------------------------------------------------------ */

.ofb-r2d-undershadow,
.ofb-r2d-front {
  position: absolute;
  top: 0;
  pointer-events: none;
}
.ofb-r2d-undershadow {
  z-index: 5;
}
.ofb-r2d-front {
  z-index: 6;
  overflow: hidden;
}
.ofb-r2d-flapwrap {
  position: absolute;
  inset: 0;
  z-index: 7;
  pointer-events: none;
}
.ofb-r2d-flap {
  position: absolute;
  top: 0;
  overflow: hidden;
}
.ofb-r2d-back {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
}
.ofb-r2d-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 8;
}

/* ------------------------------------------------------------------ */
/* Swipe view                                                          */
/* ------------------------------------------------------------------ */

.ofb-swipe-track {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  will-change: transform;
}
.ofb-swipe-slide {
  position: absolute;
  top: 0;
}
.ofb-swipe-spread {
  position: absolute;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.22);
}

/* ------------------------------------------------------------------ */
/* Scroll view                                                         */
/* ------------------------------------------------------------------ */

.ofb-scroll {
  position: absolute;
  inset: 0;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
}
.ofb-scroll-content {
  position: relative;
  box-sizing: border-box;
  min-width: 100%;
  min-height: 100%;
}
.ofb-scroll-row {
  position: relative;
  margin-left: auto;
  margin-right: auto;
}
.ofb-scroll-row .ofb-page {
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.2);
}

/* ------------------------------------------------------------------ */
/* Book shadow for flat views                                          */
/* ------------------------------------------------------------------ */

.ofb-view--simple .ofb-slot:not(.ofb-slot--empty),
.ofb-view--2d .ofb-slot:not(.ofb-slot--empty),
.ofb-view--3d .ofb-slot:not(.ofb-slot--empty),
.ofb-view--webgl .ofb-slot:not(.ofb-slot--empty) {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
}

@media (prefers-reduced-motion: reduce) {
  .ofb-spread {
    transition: none !important;
  }
}
