.reader-page {
  background: #ecebe8;
}

.reader-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 100vh;
  gap: 16px;
  padding: 16px 0;
}

.reader-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.15);
}

.reader-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.icon-button,
.page-status {
  display: grid;
  min-width: 42px;
  height: 42px;
  place-items: center;
  background: var(--white);
  border: 1px solid rgba(0, 0, 0, 0.18);
  font-weight: 900;
}

.book-stage {
  position: relative;
  display: grid;
  min-height: 560px;
  place-items: center;
  overflow: hidden;
  padding: 34px 58px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: radial-gradient(
    circle at 50% 45%,
    #fff 0%,
    #f3f2ee 45%,
    #d9d5ca 100%
  );
}

.page-flip-book {
  width: min(92vw, calc(72vh * 1.3333), 1080px);
  height: min(72vh, calc(92vw * 0.75), 810px);
  transition: transform 180ms ease;
}

.reader-error {
  max-width: 28rem;
  padding: 24px;
  color: #fff;
  background: #121212;
  border: 1px solid rgba(255, 255, 255, 0.24);
  font-weight: 900;
  text-align: center;
}

.turn-button {
  position: absolute;
  top: 50%;
  z-index: 3;
  width: 44px;
  height: 64px;
  color: var(--white);
  background: rgba(0, 0, 0, 0.52);
  border: 1px solid rgba(255, 255, 255, 0.4);
  font-size: 42px;
  transform: translateY(-50%);
  cursor: pointer;
}

.turn-button.previous {
  left: 12px;
}

.turn-button.next {
  right: 12px;
}

.thumbnail-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(0, 0, 0, 0.15);
}

.thumbnail {
  flex: 0 0 64px;
  height: 96px;
  padding: 0;
  overflow: hidden;
  background: var(--white);
  border: 2px solid transparent;
}

.thumbnail[aria-current='true'] {
  border-color: var(--teal);
}

.thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.embedded-reader {
  overflow: hidden;
}

.embedded-reader .reader-shell {
  width: 100%;
  min-height: 100vh;
  gap: 8px;
  padding: 10px;
}

.embedded-reader .reader-toolbar {
  gap: 10px;
  padding-bottom: 8px;
}

.embedded-reader .reader-toolbar .back-link {
  display: none;
}

.embedded-reader .reader-toolbar h1 {
  margin-top: 2px;
  font-size: 20px;
  line-height: 1;
  text-transform: uppercase;
}

.embedded-reader .icon-button,
.embedded-reader .page-status {
  min-width: 36px;
  height: 36px;
}

.embedded-reader .book-stage {
  min-height: 350px;
  padding: 12px 52px;
}

.embedded-reader .page-flip-book {
  width: min(100%, calc(68vh * 1.3333), 520px);
  height: min(68vh, 390px);
}

.embedded-reader .thumbnail-strip {
  gap: 6px;
  padding-top: 8px;
}

.embedded-reader .thumbnail {
  flex-basis: 42px;
  height: 62px;
}

.book-stage:fullscreen {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  padding: 16px 72px;
  border: 0;
}

.book-stage:fullscreen .page-flip-book,
.embedded-reader .book-stage:fullscreen .page-flip-book {
  width: min(calc(100vw - 160px), calc((100vh - 32px) * 1.3333));
  height: min(calc(100vh - 32px), calc((100vw - 160px) * 0.75));
  max-width: none;
  max-height: none;
}

@media (max-width: 620px) {
  .reader-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .book-stage {
    min-height: 460px;
    padding: 34px 52px;
  }

  .page-flip-book {
    width: min(76vw, calc(70vh * 0.6667), 390px);
    height: min(70vh, calc(76vw * 1.5), 585px);
  }

  .embedded-reader .reader-toolbar {
    align-items: center;
    flex-direction: row;
  }

  .embedded-reader .reader-toolbar h1 {
    max-width: 220px;
    font-size: 16px;
  }

  .embedded-reader .book-stage {
    min-height: 370px;
    padding: 12px 46px;
  }

  .embedded-reader .page-flip-book {
    width: min(72vw, calc(72vh * 0.6667), 300px);
    height: min(72vh, calc(72vw * 1.5), 450px);
  }

  .book-stage:fullscreen {
    padding: 16px;
  }

  .book-stage:fullscreen .page-flip-book,
  .embedded-reader .book-stage:fullscreen .page-flip-book {
    width: min(calc(100vw - 32px), calc((100vh - 32px) * 0.6667));
    height: min(calc(100vh - 32px), calc((100vw - 32px) * 1.5));
  }
}
