/* Continuous reading uses the original catalogue pages at every screen size. */
body.continuous-reader {
  --reader-header-height: 78px;
  --reader-page-width: 900px;
  padding: 0;
}

body.continuous-reader #catalogue-scroll-wrapper {
  display: block;
  width: 100%;
}

body.continuous-reader #catalogue-scroll-content {
  display: block;
  width: 100%;
  padding-top: var(--reader-header-height);
  overflow: visible;
}

body.continuous-reader .reader-header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 40;
  height: 78px;
  margin: 0;
  padding: 0 4vw;
  background: var(--ivory);
  border-bottom: 1px solid var(--hairline);
  box-shadow: 0 3px 16px #1d1a150b;
  transform: translateY(0);
  transition: transform 180ms ease;
}

body.continuous-reader .reader-header.reader-header-hidden {
  transform: translateY(-100%);
  pointer-events: none;
}

body.continuous-reader .reader-header:focus-within {
  pointer-events: auto;
}

body.continuous-reader .reader-header:has(:focus-visible) {
  transform: translateY(0);
}

body.continuous-reader #reader {
  display: block;
  height: auto;
  min-height: 0;
  max-height: none;
  padding: 24px 20px 40px;
  overflow: visible;
  touch-action: pan-y pinch-zoom;
}

body.continuous-reader .book {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  width: min(var(--reader-page-width), 100%);
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  perspective: none;
  touch-action: pan-y pinch-zoom;
}

body.continuous-reader .book > .paper,
body.continuous-reader .book > .paper[hidden] {
  display: block;
  position: relative;
  inset: auto;
  width: 100%;
  min-width: 0;
  height: auto;
  aspect-ratio: 1;
  visibility: visible;
  opacity: 1;
  transform: none;
  filter: none;
  clip-path: none;
  animation: none;
  transition: none;
  cursor: auto;
  touch-action: pan-y pinch-zoom;
  scroll-margin-top: calc(var(--reader-header-height) + 12px);
}

body.continuous-reader .book > .paper:hover {
  outline: none;
}

body.continuous-reader .book::before,
body.continuous-reader .book::after {
  content: none;
  display: none;
}

body.continuous-reader .stpage-stage,
body.continuous-reader .reader-footer,
body.continuous-reader #overview {
  display: none;
}

/* Keep the catalogue's copy guards without intercepting native scrolling. */
body.continuous-reader #book,
body.continuous-reader #book * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

body.continuous-reader #book img {
  -webkit-user-drag: none;
}

/* The default desktop view fits one whole square page below the menu,
   then leaves the gutter and a small preview of the following page. */
@media screen and (min-width: 801px) {
  body.continuous-reader:not(.zoom-mode) .book {
    width: min(var(--reader-page-width), 100%, max(240px, calc(100vh - var(--reader-header-height) - 84px)));
    width: min(var(--reader-page-width), 100%, max(240px, calc(100dvh - var(--reader-header-height) - 84px)));
  }
}

@media (min-width: 801px) {
  body.continuous-reader.zoom-mode {
    --reader-page-width: 1200px;
  }
}

@media (max-width: 800px) {
  body.continuous-reader {
    --reader-header-height: 70px;
  }

  body.continuous-reader .reader-header {
    height: 70px;
    padding: 0 18px;
    gap: 12px;
  }

  body.continuous-reader #reader {
    padding: 14px 10px 24px;
  }

  body.continuous-reader .book {
    width: 100%;
    margin: 0;
    gap: 14px;
  }

  body.continuous-reader #zoom {
    display: none;
  }
}

@media (max-width: 480px) {
  body.continuous-reader {
    --reader-header-height: 94px;
  }

  body.continuous-reader .reader-header {
    height: 94px;
    padding: 12px 14px 6px;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0;
  }

  body.continuous-reader .brand-home {
    width: 166px;
  }

  body.continuous-reader .brand-home img {
    height: 29px;
  }

  body.continuous-reader .reader-tools {
    width: 100%;
    justify-content: center;
    margin: 0;
    gap: 18px;
  }

  body.continuous-reader .reader-tools button {
    padding: 8px 0;
    white-space: nowrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.continuous-reader .reader-header {
    transition: none;
  }
}

/* reference.css remains the authority for the 200 mm square print format. */
@media print {
  body.continuous-reader {
    height: auto !important;
    min-height: 0;
    padding: 0;
  }

  body.continuous-reader #catalogue-scroll-wrapper,
  body.continuous-reader #catalogue-scroll-content {
    position: static !important;
    inset: auto !important;
    width: auto !important;
    height: auto !important;
    padding: 0 !important;
    overflow: visible !important;
    transform: none !important;
  }

  body.continuous-reader .reader-header {
    display: none;
  }

  body.continuous-reader #reader {
    padding: 0;
  }

  body.continuous-reader .book {
    display: block;
    width: 200mm;
    max-width: none;
    margin: 0;
  }

  body.continuous-reader .book > .paper,
  body.continuous-reader .book > .paper[hidden] {
    width: 200mm;
    height: 200mm;
    break-inside: avoid;
    break-after: page;
    box-shadow: none;
  }

  body.continuous-reader .book > .paper:last-child {
    break-after: auto;
  }
}
