/* Public reader: the public reader, its note, menu and Read in panel, Like, and share links */

/* On wide screens the pages fit between the bar and the page count. */
.public-reader-view .reader-shell {
  padding-block: 12px 24px;
}

/* On the paper. The Share sheet draws its own (css/publishing.css), all but
   the copied state. */
.publication-share-button,
.public-reader-login-button {
  color: var(--book-ink);
  border-color: var(--book-line);
  background: transparent;
  white-space: nowrap;
}

.publication-share-button:hover:not(:disabled),
.public-reader-login-button:hover:not(:disabled) {
  border-color: var(--book-muted);
  background: var(--book-tint);
}

.publication-share-button.is-copied {
  color: #352e55;
  border-color: #ffe093;
  background: #ffe093;
}

.publication-share-button.is-copied:hover:not(:disabled) {
  color: #352e55;
  border-color: #ffcf5d;
  background: #ffcf5d;
}

.publication-share-button.is-error {
  color: var(--error-ink);
  border-color: var(--publication-error-line);
  background: var(--coral-pale);
}

.publication-share-icon {
  font-size: 1.05rem;
  line-height: 1;
}

/* Like in the bar: the heart and the count, filled once liked. The
   author's count is not a control. */
.reader-like-count {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 0 10px;
  font-size: 0.86rem;
  font-weight: 850;
}

.reader-like.is-selected .book-icon path {
  fill: currentColor;
}

/* In the menu, under its row: where to undo Not for me. */
.reader-like-help {
  margin: 0 10px 6px 64px;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 700;
}

/* The phone menu's header: the book's author, pages and Likes under its
   title, then its two groups of rows. */
.reading-menu-byline {
  margin: -6px 8px 10px;
  color: var(--ink-soft);
  font-size: 0.86rem;
  font-weight: 750;
}

.reading-menu-actions {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line-soft);
}

/* Read in: the languages have no tile. */
.reading-language-list .book-sheet-row {
  min-height: 48px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.reading-language-note {
  margin: 10px 8px 0;
  color: var(--ink-soft);
  font-size: 0.8rem;
  font-weight: 700;
}

/* The note: one floating line at the bottom left, clear of the pages. Only
   the line itself takes clicks. */
.public-reader-note {
  position: fixed;
  z-index: 25;
  bottom: 16px;
  left: 16px;
  display: flex;
  max-width: min(460px, calc(100% - 32px));
  pointer-events: none;
}

.public-reader-note > * {
  pointer-events: auto;
}

.public-reader-note-line,
.public-reader-translation,
.public-reader-language-suggestion {
  display: flex;
  min-height: 44px;
  align-items: center;
  border: 1px solid var(--book-line);
  border-radius: 22px;
  color: var(--book-ink);
  background: var(--book-paper);
  box-shadow: var(--shadow-sm);
  font-size: 0.86rem;
  font-weight: 800;
}

.public-reader-note-line {
  margin: 0;
  padding: 8px 18px;
}

.public-reader-note-line[data-state="error"],
.public-reader-note-line[data-state="share-error"],
.public-reader-translation[data-state="error"] {
  border-color: var(--publication-error-line);
  background: var(--coral-pale);
}

.public-reader-translation {
  gap: 0 10px;
  padding: 0 4px 0 18px;
}

.public-reader-translation[data-state="loading"],
.public-reader-translation[data-state="off"] {
  padding-right: 18px;
}

/* "Translated by AI": a quiet line, no box. */
.public-reader-translation[data-state="ready"] {
  border-color: transparent;
  color: var(--book-muted);
  background: transparent;
  box-shadow: none;
}

/* Two lines beside the button even at 360px. */
.public-reader-translation p {
  min-width: 0;
  flex: 1 1 8rem;
  margin: 0;
  padding-block: 4px;
  line-height: 1.3;
}

.public-reader-translation .explore-spinner {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border-width: 2px;
}

.public-reader-translation .public-reader-translation-button {
  border-radius: 999px;
  color: var(--book-ink);
  border-color: var(--book-line);
  background: var(--book-paper);
  white-space: nowrap;
}

.public-reader-translation .public-reader-translation-button:hover:not(:disabled) {
  border-color: var(--book-muted);
  background: var(--book-tint);
}

.public-reader-translation-link {
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  color: var(--book-ink);
  background: transparent;
  font-weight: 850;
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
}

.public-reader-translation-link:hover {
  background: var(--book-tint);
}

.public-reader-language-suggestion {
  max-width: 100%;
  align-items: stretch;
}

.public-reader-suggestion-button,
.public-reader-suggestion-dismiss {
  min-height: 44px;
  border: 0;
  color: inherit;
  background: transparent;
  font-weight: 850;
}

.public-reader-suggestion-button {
  min-width: 0;
  padding: 8px 6px 8px 18px;
  border-radius: 22px 0 0 22px;
  font-size: 0.9rem;
  text-align: left;
}

.public-reader-suggestion-dismiss {
  width: 44px;
  flex: 0 0 44px;
  border-radius: 0 22px 22px 0;
  font-size: 1.25rem;
  line-height: 1;
}

.public-reader-suggestion-button:hover,
.public-reader-suggestion-dismiss:hover {
  background: var(--book-tint);
}

/* On phones the controls hide while the reader reads (js/public-reader.js)
   and keep their space; one that has focus shows. Just hidden by a page
   turn or a tap, they fade out. */
.public-reader-control,
.public-reader-translation[data-state="ready"] {
  transition: opacity 0.2s ease;
}

.public-reader-view.is-quiet .public-reader-control:not(:focus-within),
.public-reader-view.is-quiet .public-reader-translation[data-state="ready"]:not(:focus-within) {
  opacity: 0;
  pointer-events: none;
}

.public-reader-view.is-quieting .public-reader-control:not(:focus-within),
.public-reader-view.is-quieting .public-reader-translation[data-state="ready"]:not(:focus-within) {
  animation: public-reader-controls-out 0.2s ease;
}

/* The end view: after the last page, the end where the pages are. */
.public-reader-end-view {
  padding: 28px 0 6px;
}

.public-reader-end {
  display: grid;
  justify-items: center;
  gap: 8px;
  width: min(100%, 620px);
  margin: 0 auto;
  padding: 30px 28px;
  color: var(--book-ink);
  overflow-wrap: anywhere;
  text-align: center;
}

.public-reader-end h2 {
  margin: 0;
  font-size: clamp(2rem, 6vw, 2.8rem);
  line-height: 1;
}

/* Focused when the end view opens, as a page heading is on a page turn. */
.public-reader-end h2:focus {
  outline: none;
}

.public-reader-end > p {
  margin: 0;
  color: var(--book-muted);
  font-weight: 750;
}

.public-reader-end-actions {
  display: flex;
  width: 100%;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 14px;
}

.public-reader-end-login {
  flex-basis: 100%;
  margin: 0;
  color: var(--book-muted);
}

.public-reader-end-login button {
  min-height: 44px;
  padding: 7px 8px;
  border: 0;
  color: var(--violet);
  background: transparent;
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* The reaction panel on the card: Explore's buttons, centered. */
.public-reader-end .reaction-panel {
  flex: 1 1 100%;
}

.public-reader-end .reaction-actions {
  justify-content: center;
}

.public-reader-end .reaction-button {
  flex: 0 1 180px;
}

/* Loading, or a book that could not be opened: its card on the paper,
   under the bar. */
.public-reader-state {
  display: grid;
  min-height: calc(100vh - 90px);
  place-items: center;
  width: min(calc(100% - 28px), 760px);
  margin: 0 auto;
  padding: 40px 0 70px;
}

.public-reader-state-card {
  width: 100%;
  padding: 42px;
  border: 1px solid var(--book-line);
  border-radius: 25px;
  color: var(--book-ink);
  text-align: center;
}

.public-reader-state-card > p {
  color: var(--book-muted);
}

.public-reader-state-card h1 {
  font-size: clamp(2rem, 7vw, 3.7rem);
  line-height: 1;
}

.public-reader-state-card > .explore-spinner {
  margin-bottom: 18px;
}

.public-reader-state-icon {
  display: inline-flex;
  width: 48px;
  height: 48px;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  border-radius: 50%;
  color: #fff;
  background: var(--coral-fill);
  font-weight: 900;
}

.public-reader-state-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 22px;
}

/* The phone reader: the top row, the page centered under it, and the
   bottom row, the page count with the menu at its right end. The rows keep
   their space, which the page's width leaves them (--reader-chrome-base,
   css/reading.css), so the page never moves and nothing covers its prose.
   The note floats just above the bottom row, up to 46px tall and 8px over
   it, so the rows leave the page 36px more above and under it: the note
   then clears the prose of a page as narrow as its 240px floor, whose
   bottom margin is 8.24cqw (19.8px). A page with extra lines is no taller
   than the rows leave it, so it keeps the same 36px. */
@media (max-width: 900px) {
  .reader-view.public-reader-view {
    --public-reader-row: 56px;
    --reader-chrome-base: 184px;
    --reader-chrome-height: var(--reader-chrome-base);
    position: relative;
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
    flex-direction: column;
  }

  .public-reader-top {
    display: flex;
    min-height: var(--public-reader-row);
    align-items: center;
    justify-content: flex-end;
    padding: 0 12px;
  }

  /* A guest's mark, at the left. */
  .public-reader-top .reader-brand {
    margin-right: auto;
  }

  .public-reader-view .reader-shell {
    display: flex;
    flex: 1 0 auto;
    flex-direction: column;
    padding: 0;
  }

  .public-reader-view .reader-stage {
    display: flex;
    flex: 1 0 auto;
    flex-direction: column;
  }

  .public-reader-view .reader-pages {
    margin-block: auto;
  }

  /* On a landscape phone a page at its 240px floor (css/reading.css) is
     taller than the rows leave, so the reader grows and scrolls a little.
     36px under that page keep the note clear of the prose, as on a portrait
     phone. */
  .public-reader-view .reader-spread {
    min-height: calc(240px * 4 / 3 + 36px);
  }

  .public-reader-view .reader-count {
    min-height: var(--public-reader-row);
    padding: 0 12px;
  }

  .public-reader-menu {
    grid-row: 1;
    grid-column: 1 / -1;
    justify-self: end;
  }

  .public-reader-note {
    position: absolute;
    right: 12px;
    bottom: calc(var(--public-reader-row) + 8px);
    left: 12px;
    max-width: none;
    justify-content: center;
  }

  /* A sideways swipe here goes back to the last page (js/reading.js), as on
     the pages. */
  .public-reader-end-view {
    padding: 4px 12px 6px;
    touch-action: pan-y pinch-zoom;
  }
}

@media (max-width: 500px) {
  .public-reader-state-card {
    padding: 32px 20px;
  }

  .public-reader-state-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .public-reader-state-actions .button {
    width: 100%;
  }

  .public-reader-end {
    padding: 26px 18px;
  }

  .public-reader-end-actions > .button {
    width: 100%;
  }

  .public-reader-end .reaction-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .public-reader-end .reaction-button {
    width: 100%;
    flex: 0 0 auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .public-reader-control,
  .public-reader-translation[data-state="ready"] {
    transition: none;
  }

  .public-reader-view.is-quieting .public-reader-control:not(:focus-within),
  .public-reader-view.is-quieting .public-reader-translation[data-state="ready"]:not(:focus-within) {
    animation: none;
  }
}

@keyframes public-reader-controls-out {
  from {
    opacity: 1;
  }
}
