/* Reader chrome and responsive pages. The print studio keeps its own stylesheet. */
.book-reader {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: #15191f;
  color: #f4f0e7;
}
.book-masthead, .book-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .75rem clamp(1rem, 4vw, 4rem);
  background: #15191f;
}
.book-masthead {
  justify-content: space-between;
  border-bottom: 1px solid #3e4249;
}
.book-title {
  display: block;
  color: inherit;
  text-decoration: none;
  font: 600 clamp(1.6rem, 3vw, 2.4rem)/1 var(--font-serif);
}
.book-imprint { display: block; margin-top: .38rem; font-size: .8125rem; color: #b8b6b1; }
.book-reader button {
  min-height: 44px;
  padding: .5rem 1rem;
  border: 1px solid #747981;
  background: transparent;
  color: inherit;
  font: 500 .875rem var(--font-sans);
  cursor: pointer;
}
.book-reader button:hover:not(:disabled) { background: #2a3038; }
.book-reader button:disabled { opacity: .42; cursor: default; }
.book-reader :focus-visible { outline: 2px solid #e5b86d; outline-offset: 3px; }
.book-stage {
  --page-scale: .78;
  --page-scale: min(.9, (100vw - 32px) / 794px);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  flex: 1;
  padding: clamp(1.25rem, 4vw, 3.5rem) 1rem;
}
.book-leaf[hidden] { display: none; }
.book-leaf { flex: 0 0 auto; }
.book-leaf .sheet { zoom: var(--page-scale); }
.book-controls {
  position: sticky;
  bottom: 0;
  z-index: 2;
  justify-content: center;
  border-top: 1px solid #3e4249;
}
#position { min-width: 7ch; text-align: center; font-size: .875rem; }
#contents {
  margin: auto;
  padding: 1.2rem;
  width: min(34rem, calc(100vw - 2rem));
  max-height: 85dvh;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule-light);
}
#contents::backdrop { background: #101318c9; }
#contents header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
#contents h2 { font: 600 2.25rem/1 var(--font-serif); }
#contents button:hover { background: var(--paper-warm); }
#contents ol { list-style: none; margin-top: 1rem; }
#contents a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: .5rem;
  border-top: 1px solid var(--rule-light);
  color: var(--ink);
  text-decoration: none;
}
#contents a:hover, #contents a[aria-current] { background: var(--paper-warm); }

@media print {
  .book-masthead, .book-controls, #contents { display: none !important; }
  .book-stage, .book-leaf, .book-leaf[hidden] { display: block; padding: 0; }
  .book-leaf .sheet { zoom: 1; }
  .book-leaf:not(:last-child) { break-after: page; }
}


html:has(.book-reader) { scroll-behavior: auto; }
@media screen {
  .book-reader { padding-bottom: 70px; }
  .book-controls { position: fixed; inset: auto 0 0; }
}

@media screen and (max-width: 760px) {
  .book-masthead { gap: .5rem; }
  .book-imprint { line-height: 1.35; }
  .book-stage {
    --page-scale: min(.9, (100vw - 16px) / 794px);
    padding: .75rem .5rem;
  }
  .book-reader { padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
  .book-controls { padding-bottom: calc(.75rem + env(safe-area-inset-bottom)); }
}
