/* The reader is a quiet piece of the case study; the specimen supplies the color. */
.rui-book-reader {
  --book-paper: #f3f1e9;
  --book-ink: #302748;
  padding: clamp(1rem, 4vw, 4rem) 0;
  color: var(--rui-case-ink, var(--book-ink));
}

.rui-book-sr-only {
  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;
}

.rui-book-surface {
  width: 100%;
  padding-block: clamp(1rem, 4vw, 4rem);
  overflow: hidden;
  background: transparent;
}

.rui-book-viewport {
  position: relative;
  width: min(100%, 1040px);
  aspect-ratio: 2 / 1;
  margin-inline: auto;
  overflow: visible;
  isolation: isolate;
  touch-action: pan-y pinch-zoom;
}

.rui-book {
  width: 100%;
  height: 100%;
  min-width: 0 !important;
  min-height: 0 !important;
  outline: none;
  transition: transform 700ms cubic-bezier(.22, .61, .36, 1);
}

.rui-book:focus-visible {
  outline: none;
}

.rui-book-viewport:has(.rui-book:focus-visible) {
  outline: 2px solid currentColor;
  outline-offset: 7px;
}

/* Before the engine takes ownership, retain a useful 16-page scroll-snap gallery. */
.rui-book:not(.stf__parent) {
  display: flex;
  align-items: center;
  gap: clamp(.75rem, 2vw, 1.5rem);
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
}

.rui-book:not(.stf__parent) .rui-book-page {
  position: relative;
  flex: 0 0 min(50%, 520px);
  width: min(50%, 520px);
  height: 100%;
  aspect-ratio: 1;
  scroll-snap-align: center;
}

.rui-book-page {
  position: relative;
  overflow: hidden;
  background: var(--book-paper);
  border: 0;
  box-shadow: 0 12px 28px -22px rgba(32, 28, 42, .55);
}

.rui-book-image {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.rui-book-page--left .rui-book-image,
.rui-book-page--right .rui-book-image {
  width: 200%;
  object-fit: fill;
}

.rui-book-page--right .rui-book-image {
  transform: translateX(-50%);
}

/* A restrained gutter and edge catch the light without turning the stage into a card. */
.rui-book-page::after {
  position: absolute;
  inset: 0;
  pointer-events: none;
  content: "";
  box-shadow: inset 0 0 0 1px rgba(48, 39, 72, .08);
}

.rui-book-page--left::after {
  background: linear-gradient(to left, rgba(48, 39, 72, .1), transparent 7%);
}

.rui-book-page--right::after {
  background: linear-gradient(to right, rgba(48, 39, 72, .1), transparent 7%);
}

[data-book-mode="landscape"][data-book-cover="front"] .rui-book {
  transform: translateX(-25%);
}

[data-book-mode="landscape"][data-book-cover="back"] .rui-book {
  transform: translateX(25%);
}

[data-book-ready="true"] .rui-book-viewport {
  cursor: grab;
}

[data-book-state="flipping"] .rui-book-viewport {
  cursor: grabbing;
}

.rui-book-fallback:not([hidden]) {
  margin: 1rem 0 0;
  font-size: .8rem;
  line-height: 1.5;
}

/* One invitation beneath the closed cover; reserve its space after dismissal. */
.rui-book-entry {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  height: 62px;
}

.rui-book-open {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 108px;
  min-height: 44px;
  padding: 5px 10px 5px 16px;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.rui-book-open[hidden] { display: none; }
.rui-book-open:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.rui-book-open-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
}
.rui-book-open-icon svg { transition: transform 180ms ease; }
@media (hover: hover) {
  .rui-book-open:hover .rui-book-open-icon svg { transform: translateX(2px); }
  .rui-book-back:hover .rui-book-open-icon svg { transform: translateX(-2px); }
}
.rui-book-open[data-book-invite="true"] .rui-book-open-icon {
  animation: rui-book-invite 1.1s ease-in-out 250ms 2;
}
@keyframes rui-book-invite {
  0%, 100% { transform: translateX(0); }
  45% { transform: translateX(5px); }
}

@media (max-width: 767px) {
  .rui-book-viewport {
    aspect-ratio: 1;
    overflow: hidden;
  }

  .rui-book:not(.stf__parent) .rui-book-page {
    flex-basis: 100%;
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rui-book {
    transition: none;
  }
  .rui-book-open[data-book-invite="true"] .rui-book-open-icon { animation: none; }
  .rui-book-open-icon svg { transition: none; }
}
