.stf__parent {
  position: relative;
  display: block;
  box-sizing: border-box;
  transform: translateZ(0);

  -ms-touch-action: pan-y;
  touch-action: pan-y;
}

.stf__wrapper {
  position: relative;
  width: 100%;
  box-sizing: border-box;
}

.stf__parent canvas {
  position: absolute;
  width: 100%;
  height: 100%;
  left: 0;
  top: 0;
}

.stf__block {
  position: absolute;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  perspective: 2000px;
}

.stf__item {
  display: none;
  position: absolute;
  transform-style: preserve-3d;
}

.stf__outerShadow {
  position: absolute;
  left: 0;
  top: 0;
}

.stf__innerShadow {
  position: absolute;
  left: 0;
  top: 0;
}

.stf__hardShadow {
  position: absolute;
  left: 0;
  top: 0;
}

.stf__hardInnerShadow {
  position: absolute;
  left: 0;
  top: 0;
}

/* Right-to-left: mirror the book, then mirror each page's content back so the
   pages read normally while the spine and the page order swap sides. */
.stf__wrapper.--rtl {
  transform: scaleX(-1);
}

.stf__wrapper.--rtl .stf__item > * {
  transform: scaleX(-1);
}

/* Everything themeable is a custom property, and every default lives in the
   var() call rather than in a declaration on .fv-root. Declaring them here would
   beat any value an embedding page sets on an ancestor, since an inherited value
   only applies where the element declares nothing itself.

   The tokens: --fv-page-bg, --fv-page-fg, --fv-cover-bg, --fv-bar-bg, --fv-bar-fg,
   --fv-bar-hover, --fv-bar-height, --fv-radius, --fv-gap. */
.fv-root {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--fv-gap, 12px);
  width: 100%;
}

.fv-stage {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: var(--fv-gap, 12px);
  width: 100%;
  outline: none;
}

/* Where the sections of a book that reflows are laid out: off-screen, but really
   laid out, because a browser does not paginate what it is not showing. */
.fv-flow-hidden {
  position: fixed;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  overflow: hidden;
  visibility: hidden;
  pointer-events: none;
}

.fv-flow-frame {
  display: block;
  border: 0;
  background: transparent;
}

/* A page that is a document rather than a picture: an EPUB page is XHTML, and it
   is shown as itself. */
.fv-page-mount {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.fv-page-mount img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.fv-page-frame {
  display: block;
  border: 0;
  background: transparent;
}

/* --- contents and pages --- */
.fv-panel[hidden] {
  /* display beats the hidden attribute, so it has to be said out loud. */
  display: none;
}

.fv-panel {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  width: 176px;
  /* The real cap is set in pixels by the viewer, from the book's own height. */
  max-height: 100%;
  border-radius: var(--fv-radius, 8px);
  background: var(--fv-panel-bg, #f3f5f8);
  color: var(--fv-panel-fg, #1b2733);
  overflow: hidden;
}

.fv-panel-tabs {
  display: flex;
  flex: 0 0 auto;
}

.fv-panel-tab {
  flex: 1;
  padding: 8px 6px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: inherit;
  font: 600 13px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
  cursor: pointer;
}

.fv-panel-tab[aria-selected="true"] {
  border-bottom-color: var(--fv-bar-bg, #1976d2);
}

.fv-panel-list {
  position: relative;
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 6px;
}

.fv-panel-line {
  display: block;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: 5px;
  background: none;
  color: inherit;
  font: 13px/1.35 system-ui, -apple-system, "Segoe UI", sans-serif;
  text-align: start;
  cursor: pointer;
}

.fv-panel-line:hover:not(:disabled),
.fv-panel-line:focus-visible {
  background: rgba(0, 0, 0, 0.07);
}

.fv-panel-line:disabled {
  cursor: default;
  opacity: 0.75;
}

.fv-thumb {
  display: block;
  width: 100%;
  margin-bottom: 8px;
  padding: 4px;
  border: 2px solid transparent;
  border-radius: 6px;
  background: none;
  color: inherit;
  font: 12px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
  cursor: pointer;
}

.fv-thumb-img {
  display: block;
  width: 100%;
  /* The box exists before the picture does, so the list does not grow underneath
     a reader as the thumbnails arrive. The ratio is a guess until the first page
     paints and says what shape this document's pages are. */
  aspect-ratio: var(--fv-thumb-ratio, 1 / 1.414);
  object-fit: contain;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 3px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.24);
}

.fv-thumb-number {
  display: block;
  padding-top: 4px;
}

/* The page a reader is on. The border is drawn by the marker below, which slides
   from one page to the next; this is only the tint underneath it. */
.fv-thumb-here {
  background: var(--fv-thumb-here-bg, rgba(25, 118, 210, 0.08));
}

.fv-thumb-marker {
  position: absolute;
  left: 6px;
  right: 6px;
  top: 0;
  border: 2px solid var(--fv-bar-bg, #1976d2);
  border-radius: 6px;
  pointer-events: none;
}

.fv-thumb-marker-live {
  transition:
    transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
    height 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Someone who asked for less motion gets the mark, not the journey. */
@media (prefers-reduced-motion: reduce) {
  .fv-thumb-marker-live {
    transition: none;
  }
}

.fv-stage:focus-visible {
  outline: 2px solid var(--fv-bar-bg, #1976d2);
  outline-offset: 4px;
}

.fv-book {
  margin: 0 auto;
  touch-action: pan-y;
}

.fv-zoomed .fv-stage {
  cursor: grab;
  overflow: hidden;
  /* While zoomed the drag belongs to the pan, so the browser's own gestures stay
     out of it: no scrolling the page, no native pinch on top of ours, and no
     selection dragged across the page's text. */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.fv-panning {
  cursor: grabbing;
}

.fv-page {
  background: var(--fv-page-bg, #ffffff);
  overflow: hidden;
}

.fv-page[data-density="hard"] {
  background: var(--fv-cover-bg, #f3f5f8);
}

.fv-page-inner {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fv-page-inner {
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;
}

/* The page's own text, laid over the picture of it. Transparent, so it changes
   nothing about how a page looks, and positioned by pdf.js.
   
   These rules are pdf.js's own, from its text layer stylesheet, renamed onto our
   class. They are not decoration: pdf.js writes each span's position as a
   percentage and its size into custom properties, and leaves the arithmetic to
   the stylesheet. Hand-rolling something similar produces text at the default
   font size in roughly the right place, which is what happened first. */
.fv-text-layer {
  --total-scale-factor: calc(var(--scale-factor, 1) * var(--device-pixel-ratio, 1));
  --min-font-size: 1;
  --text-scale-factor: calc(var(--total-scale-factor) * var(--min-font-size));
  --min-font-size-inv: calc(1 / var(--min-font-size));

  position: absolute;
  inset: 0;
  overflow: clip;
  text-align: initial;
  opacity: 1;
  line-height: 1;
  text-size-adjust: none;
  forced-color-adjust: none;
  transform-origin: 0 0;
  z-index: 2;
}

.fv-text-layer :is(span, br) {
  position: absolute;
  color: transparent;
  white-space: pre;
  cursor: text;
  transform-origin: 0% 0%;
}

.fv-text-layer > :not(.markedContent),
.fv-text-layer .markedContent span:not(.markedContent) {
  z-index: 1;
  --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));
}

.fv-text-layer .markedContent {
  display: contents;
}

.fv-text-layer ::selection {
  background: rgba(25, 118, 210, 0.35);
}

.fv-page-canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Placeholder page number, hidden as soon as the page has been painted. */
.fv-page-number {
  position: absolute;
  font: 600 14px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--fv-page-fg, #9aa4b1);
}

.fv-rendered .fv-page-number {
  display: none;
}

.stf__parent {
  margin: 0 auto;
}

/* --- toolbar ---
   StPageFlip's wrapper is taller than the book itself, so without a stacking
   context of its own the toolbar sits under it and never receives a click. */
.fv-toolbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 2px;
  height: var(--fv-bar-height, 44px);
  padding: 0 6px;
  border-radius: var(--fv-radius, 8px);
  background: var(--fv-bar-bg, #1976d2);
  color: var(--fv-bar-fg, #ffffff);
  font: 500 14px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.fv-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.fv-btn:hover,
.fv-btn:focus-visible {
  background: var(--fv-bar-hover, rgba(255, 255, 255, 0.22));
}

.fv-btn svg {
  width: 20px;
  height: 20px;
  /* Stroked by default. Most of the glyphs are lines rather than shapes, and a
     filled line is an invisible one: the panel button spent a release with no
     icon at all because it was the one nobody remembered to list here. */
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* The page arrows are solid shapes, and are the exception. */
.fv-btn-first svg,
.fv-btn-prev svg,
.fv-btn-next svg,
.fv-btn-last svg {
  fill: currentColor;
  stroke: none;
}

.fv-toast {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(92vw, 460px);
  padding: 8px 12px;
  border-radius: var(--fv-radius, 8px);
  background: var(--fv-bar-bg, #1976d2);
  color: var(--fv-bar-fg, #ffffff);
  font-size: 13px;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.24);
}

.fv-toast-link {
  width: 20em;
  max-width: 52vw;
  padding: 3px 6px;
  border: 0;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.92);
  color: #223;
  font: inherit;
}

/* The tick is drawn a little heavier than the rest. */
.fv-btn-done svg {
  stroke-width: 2.4;
}

.fv-btn-done {
  background: rgba(255, 255, 255, 0.34);
}

.fv-btn-share svg,
/* A hit, marked on the transparent text: the box is the whole point. */
.fv-text-layer span.fv-hit {
  background: rgba(255, 214, 0, 0.45);
  border-radius: 2px;
}

.fv-search {
  width: 9em;
  height: 26px;
  padding: 0 8px;
  border: 0;
  border-radius: 5px;
  background: var(--fv-field-bg, rgba(255, 255, 255, 0.94));
  color: var(--fv-field-fg, #1b2733);
  font: inherit;
}

.fv-search-count {
  padding: 0 4px;
  font-size: 12px;
  white-space: nowrap;
}

.fv-toolbar-spacer {
  width: 10px;
}

.fv-toolbar-pages {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 6px;
}

/* A solid field with dark text. White on a translucent tint over the bar came out
   at 3.19 against WCAG's 4.5 for text, and a page number is text a reader edits. */
.fv-page-input {
  width: 3.2em;
  height: 26px;
  padding: 0 4px;
  border: 0;
  border-radius: 5px;
  background: var(--fv-field-bg, rgba(255, 255, 255, 0.94));
  color: var(--fv-field-fg, #1b2733);
  font: inherit;
  text-align: center;
}

/* Full strength: dimming this to 0.85 dropped it to 3.76. */
.fv-page-total {
  white-space: nowrap;
}

.fv-root:fullscreen,
.fv-root.fv-fullscreen {
  justify-content: center;
  padding: var(--fv-gap, 12px);
  background: #2b3138;
}

/* --- lightbox --- */
.fv-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(20, 24, 28, 0.82);
}

.fv-lightbox-stage {
  width: 100%;
  max-width: 1600px;
}

.fv-lightbox-close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  cursor: pointer;
}

.fv-lightbox-close:hover,
.fv-lightbox-close:focus-visible {
  background: rgba(255, 255, 255, 0.28);
}

.fv-lightbox-close svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

/* Hotspots: regions of a page bound to something, sized in percentages of it so
   they hold through zoom, a resize and the single-page layout. */
.fv-hotspots {
  position: absolute;
  inset: 0;
  z-index: 3;
}

.fv-hotspot {
  position: absolute;
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: var(--fv-hotspot-radius, 2px);
  cursor: pointer;
  /* Invisible until it is asked for: a catalogue should look like a catalogue. */
  box-shadow: inset 0 0 0 2px transparent;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.fv-hotspot:hover,
.fv-hotspot:focus-visible {
  background: var(--fv-hotspot-fill, rgb(59 130 246 / 0.18));
  box-shadow: inset 0 0 0 2px var(--fv-hotspot-line, rgb(59 130 246 / 0.9));
  outline: none;
}

/* Show them all, for a host that wants to advertise that the page is shoppable. */
.fv-root.fv-hotspots-shown .fv-hotspot {
  background: var(--fv-hotspot-fill, rgb(59 130 246 / 0.18));
  box-shadow: inset 0 0 0 2px var(--fv-hotspot-line, rgb(59 130 246 / 0.9));
}

/* Host-side styling for the container the PHP emits. The viewer brings its own
   stylesheet; this only gives the block somewhere to live on the page. */
.hikari-flipbook {
  width: 100%;
  margin: 0 0 1rem;
}

.hikari-flipbook-error {
  padding: 10px 14px;
  border-radius: 6px;
  background: #fdecec;
  color: #8a1c1c;
  font-size: 0.95em;
}

/* Where a book someone has to buy would have been. Quiet on purpose: it is an
   ordinary sentence on the page, not a warning about anything. */
.hikari-flipbook-buyers {
  margin: 0 0 1rem;
  opacity: 0.85;
  font-size: 0.95em;
}

.hikari-flipbook-cover {
  display: inline-block;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: none;
  cursor: pointer;
  line-height: 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.22);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.hikari-flipbook-cover:hover,
.hikari-flipbook-cover:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
}

.hikari-flipbook-cover img {
  display: block;
  /* The picture is drawn larger than it is shown, so it stays sharp on a retina
     screen. Without the cap it fills whatever column it lands in, and a cover
     that is the size of the book defeats the point of a cover. */
  width: 100%;
  max-width: var(--hikari-cover-width, 320px);
  height: auto;
  border-radius: 4px;
}
