/* Reader: your own book's reader, the export notice, the book bar and the book sheet */

.reader-export-notice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  margin-bottom: 13px;
  border: 1px solid var(--book-line);
  border-radius: 13px;
  color: var(--ink);
  background: var(--green-pale);
  font-size: 0.82rem;
  font-weight: 800;
}

.reader-export-notice > span {
  display: grid;
  width: 25px;
  height: 25px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--green-fill);
}

.reader-export-notice p {
  margin: 0;
}

.reader-export-notice[data-state="error"] {
  color: var(--error-ink);
  border-color: var(--error-line);
  background: var(--coral-pale);
}

.reader-export-notice[data-state="error"] > span {
  background: var(--coral-fill);
}

.reader-outdated-banner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid var(--reader-banner-line);
  border-radius: 15px;
  color: var(--reader-banner-ink);
  background: var(--gold-pale);
}

.reader-outdated-banner > span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 10px;
  background: var(--reader-banner-icon);
  font-weight: 900;
}

.reader-outdated-banner p {
  margin-bottom: 0;
  font-size: 0.84rem;
  font-weight: 800;
}

.reader-outdated-banner strong {
  display: block;
  margin-bottom: 2px;
  font-size: 0.9rem;
}

.reader-review-banner {
  border-color: var(--reader-review-line);
  color: var(--reader-review-ink);
  background: var(--reader-review);
}

.reader-review-banner > span {
  background: var(--reader-review-icon);
}

.reader-review-banner strong {
  display: block;
  margin-bottom: 2px;
  font-size: 0.9rem;
}

.reader-review-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.change-chapter-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 17px;
  padding: 18px 20px;
  border: 1px solid var(--book-line);
  border-radius: 18px;
  color: var(--book-ink);
}

.change-chapter-card p {
  margin-bottom: 0;
  color: var(--book-muted);
  font-size: 0.82rem;
}

.change-chapter-card strong {
  display: block;
  margin-bottom: 2px;
  font-size: 0.93rem;
}

.change-chapter-card .button {
  flex: 0 0 auto;
  color: var(--book-ink);
  border-color: var(--book-line);
  background: transparent;
}

.change-chapter-card .button:hover {
  border-color: var(--book-muted);
  background: var(--book-tint);
}

.book-icon {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
}

/* Shown at 900px and below. */
.book-bar {
  position: sticky;
  z-index: 20;
  bottom: 0;
  display: none;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  gap: 4px;
  padding: 6px 10px max(6px, env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  background: var(--book-bar);
}

.book-bar-item {
  display: grid;
  min-height: 56px;
  align-content: center;
  justify-items: center;
  gap: 3px;
  padding: 6px 4px;
  border: 0;
  border-radius: 14px;
  color: #c8c3df;
  background: transparent;
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1.1;
}

.book-bar-item:hover:not([aria-current="page"]) {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.book-bar-item[aria-current="page"] {
  color: #ffdc7e;
  cursor: default;
}

.book-bar-item:focus-visible {
  outline: 3px solid #ffe094;
  outline-offset: -3px;
}

.book-sheet {
  width: min(calc(100% - 32px), 520px);
}

.book-sheet-shell {
  padding: 10px 14px 18px;
}

.book-sheet-grabber {
  display: block;
  width: 40px;
  height: 5px;
  margin: 0 auto 6px;
  border-radius: 999px;
  background: var(--line);
}

.book-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px 8px 8px;
}

.book-sheet-header h2 {
  margin: 0;
  font-size: 1.3rem;
}

.book-sheet-header h2:focus {
  outline: none;
}

.book-sheet-close {
  display: inline-grid;
  width: 44px;
  height: 44px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--ink-soft);
  background: var(--violet-faint);
}

.book-sheet-close:hover {
  color: var(--ink);
  background: var(--violet-pale);
}

.book-sheet-list {
  display: grid;
  gap: 4px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.book-sheet-row {
  display: grid;
  width: 100%;
  min-height: 56px;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 8px 10px;
  border: 0;
  border-radius: 16px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.book-sheet-row:hover:not(:disabled) {
  background: var(--violet-faint);
}

.book-sheet-row:disabled {
  color: #9a96a8;
}

.book-sheet-row[aria-current="true"] {
  background: var(--violet-pale);
}

.book-sheet-row > .book-icon {
  color: var(--violet);
}

.book-sheet-tile {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 12px;
  color: var(--violet-dark);
  background: var(--violet-pale);
  font-weight: 900;
}

.book-sheet-row[aria-current="true"] .book-sheet-tile {
  color: #fff;
  background: var(--violet-fill);
}

.book-sheet-row-copy {
  display: grid;
  min-width: 0;
  line-height: 1.25;
}

.book-sheet-row-copy strong {
  overflow-wrap: anywhere;
}

.book-sheet-row-copy small {
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 700;
}

@media (max-width: 900px) {
  /* The phone reader: the page fits between the top bar, the page count,
     the notice slot and the book bar. They take 180px, the base chrome that
     sets the screen's extra lines (js/reading.js); a notice takes 70px
     more, and the notice of changed moments, whose title and line wrap,
     110px, which narrows the page but never changes its lines. */
  .reader-view.reader-phone {
    --reader-chrome-base: 180px;
    --reader-chrome-height: var(--reader-chrome-base);
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
    flex-direction: column;
  }

  .reader-view.reader-phone.has-reader-notice {
    --reader-chrome-height: 250px;
  }

  .reader-view.reader-phone.has-reader-notice.has-moments-notice {
    --reader-chrome-height: 290px;
  }

  .reader-phone-bar {
    display: grid;
    width: min(calc(100% - 16px), 650px);
    min-height: 56px;
    grid-template-columns: 44px minmax(0, 1fr) 44px 44px;
    align-items: center;
    gap: 8px;
    margin: 0 auto;
    color: var(--book-ink);
  }

  .reader-phone-title {
    min-width: 0;
    margin: 0;
    font-size: 1rem;
    letter-spacing: normal;
  }

  .reader-title-button {
    display: grid;
    width: 100%;
    min-height: 44px;
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    gap: 1px;
    padding: 4px 8px;
    border: 0;
    border-radius: 12px;
    color: var(--book-ink);
    background: transparent;
    line-height: 1.2;
  }

  .reader-title-button:hover {
    background: var(--book-tint);
  }

  .reader-title-book {
    max-width: 100%;
    overflow: hidden;
    color: var(--book-muted);
    font-size: 0.64rem;
    font-weight: 900;
    letter-spacing: 0.09em;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
  }

  .reader-title-chapter {
    display: flex;
    max-width: 100%;
    align-items: center;
    gap: 4px;
    font-size: 0.92rem;
    font-weight: 900;
  }

  .reader-title-chapter > span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .reader-title-chapter .book-icon {
    width: 18px;
    height: 18px;
    color: var(--book-muted);
  }

  /* Spare height splits above and below the page and its count. The shell
     grows to fit a taller text page, which starts at the top. */
  .reader-phone .reader-shell {
    display: flex;
    flex: 1 0 auto;
    flex-direction: column;
    padding: 4px 0 12px;
  }

  .reader-phone .reader-stage {
    margin-block: auto;
  }

  .reader-dock {
    position: sticky;
    z-index: 20;
    bottom: 0;
    padding-top: 10px;
    background: linear-gradient(to bottom, transparent, var(--book-paper) 18px);
  }

  .reader-notice-slot {
    width: min(calc(100% - 16px), 650px);
    margin: 0 auto 8px;
  }

  .reader-notice {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 8px 8px 8px 10px;
    border: 1px solid var(--reader-banner-line);
    border-radius: 16px;
    color: var(--reader-banner-ink);
    background: var(--gold-pale);
    box-shadow: 0 10px 25px rgba(13, 11, 35, 0.28);
  }

  .reader-notice-review {
    border-color: var(--reader-review-line);
    color: var(--reader-review-ink);
    background: var(--reader-review);
  }

  .reader-notice-icon {
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border-radius: 10px;
    background: var(--reader-banner-icon);
  }

  .reader-notice-review .reader-notice-icon {
    background: var(--reader-review-icon);
  }

  .reader-notice-icon .book-icon {
    width: 18px;
    height: 18px;
  }

  .reader-notice-copy {
    min-width: 0;
    line-height: 1.25;
  }

  .reader-notice-copy strong {
    display: block;
    font-size: 0.86rem;
  }

  .reader-notice-copy p {
    margin: 0;
    font-size: 0.76rem;
    font-weight: 800;
  }

  .reader-notice-actions {
    display: flex;
    gap: 6px;
  }

  .reader-notice-actions .button {
    padding-inline: 12px;
    font-size: 0.84rem;
    white-space: nowrap;
  }

  .reader-notice-slot .reader-export-notice {
    min-height: 52px;
    margin: 0;
  }

  .book-bar {
    display: grid;
  }

  .book-sheet {
    width: 100%;
    max-width: none;
    max-height: 85vh;
    max-height: 85dvh;
    margin: auto 0 0;
    border-radius: 26px 26px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
    animation: book-sheet-rise 220ms ease-out;
  }
}

@keyframes book-sheet-rise {
  from {
    opacity: 0.6;
    transform: translateY(32px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
