/* Book timeline: fixed physical book; toolbar stays put; only chronology scrolls. */
.book-timeline .right-leaf,
.book-timeline .archive-paper,
.book-timeline .archive-main,
.book-timeline .book-timeline-scroll { min-height: 0; }

.book-timeline .archive-paper,
.book-timeline .archive-main {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.book-timeline .book-timeline-toolbar {
  flex: 0 0 auto;
  margin: 0 0 8px;
  padding: 10px;
  border: 1px solid #cbbf9e;
  border-radius: 3px 8px 8px 3px;
  background: rgba(255,252,239,.78);
  box-shadow: 1px 2px 0 rgba(126,108,69,.08);
}
.book-timeline .book-timeline-toolbar .finder__search { display: block; }
.book-timeline .book-timeline-toolbar .finder__search > span {
  display: block;
  margin: 0 0 5px;
  font-size: .78rem;
  letter-spacing: .04em;
  color: #52634b;
}
.book-timeline .book-timeline-toolbar input,
.book-timeline .book-timeline-toolbar select {
  width: 100%;
  min-height: 38px;
  margin: 0;
  padding: 7px 32px 7px 10px;
  border: 1px solid #b5ad91;
  border-radius: 3px 7px 7px 3px;
  background: #fffdf3;
  color: var(--book-ink);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.8);
  font: inherit;
}
.book-timeline .book-timeline-toolbar input { padding-right: 10px; }
.book-timeline .book-timeline-control { position: relative; display: block; }
.book-timeline .book-timeline-control::after {
  content: "⌄";
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-54%);
  color: #6a765d;
  pointer-events: none;
}
.book-timeline .book-timeline-toolbar select {
  appearance: none;
  -webkit-appearance: none;
}
.book-timeline .book-timeline-controls {
  display: grid;
  grid-template-columns: minmax(180px,260px);
  gap: 7px;
  margin-top: 7px;
}
.book-timeline .book-year-control { display: none; }
.book-timeline .book-filter-proxy { display: none !important; }

.book-timeline .book-timeline-scroll {
  flex: 1 1 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0 8px 16px 0;
  scroll-behavior: smooth;
}
.book-timeline .book-timeline-scroll .year { scroll-margin-top: 8px; }

@media (min-width:721px) {
  .book-timeline .spread {
    height: clamp(580px,calc(100svh - 130px),760px);
    min-height: 0;
    overflow: hidden;
  }
  .book-timeline .left-leaf,
  .book-timeline .right-leaf { height: 100%; min-height: 0; }
  .book-timeline .left-leaf { overflow: hidden; }
  .book-timeline .right-leaf { overflow: hidden; }
  .book-timeline .archive-index {
    position: static;
    height: 100%;
    max-height: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    padding-right: 6px;
  }
}

@media (max-width:720px) {
  /* Hard-lock the root and body. This deliberately removes document scrolling
     on the Book timeline; only .book-timeline-scroll may scroll. */
  html.book-timeline-root {
    width: 100%;
    height: 100%;
    min-height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }
  html.book-timeline-root body.book-reader.book-timeline {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100dvh;
    min-height: 0;
    max-height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .book-timeline .reader-header { flex: 0 0 auto; }
  .book-timeline .volume {
    flex: 1 1 0;
    min-height: 0;
    height: auto;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .book-timeline .bookmarks {
    flex: 0 0 43px;
    height: 43px;
  }
  .book-timeline .spread,
  .book-timeline.book-archive .spread {
    flex: 1 1 0;
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
    overflow: hidden;
    display: block;
  }
  .book-timeline .right-leaf {
    height: 100% !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 10px 10px 8px;
  }
  .book-timeline .archive-paper,
  .book-timeline .archive-main {
    flex: 1 1 0;
    height: auto;
    min-height: 0;
    overflow: hidden;
  }
  .book-timeline .book-timeline-toolbar {
    flex: 0 0 auto;
    margin-bottom: 7px;
    padding: 8px;
  }
  .book-timeline .book-timeline-controls {
    grid-template-columns: minmax(0,1fr) minmax(0,1fr);
    gap: 6px;
    margin-top: 6px;
  }
  .book-timeline .book-year-control { display: block; }
  .book-timeline .book-timeline-toolbar input,
  .book-timeline .book-timeline-toolbar select {
    min-height: 36px;
    font-size: .82rem;
  }
  .book-timeline .book-timeline-scroll {
    flex: 1 1 0;
    min-height: 0;
    max-height: 100%;
    overflow-y: auto;
    padding-right: 3px;
  }
  .book-timeline footer {
    flex: 0 0 auto;
    margin: 5px 0 0;
    padding: 0;
    line-height: 1.3;
  }
}

@media (prefers-reduced-motion:reduce) {
  .book-timeline .book-timeline-scroll { scroll-behavior: auto; }
}
