.textbook-preview-root {
  height: 100%;
  overflow: hidden;
}

.textbook-preview-body {
  --reader-anchor-offset: 6.5rem;
  --reader-sidebar-sticky-top: 6.5rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #f3efe7;
}

.textbook-preview-body .textbook-site-header {
  flex: 0 0 auto;
}

.textbook-preview-body #main {
  display: grid;
  flex: 1 1 0;
  grid-template-rows: auto minmax(0, 1fr);
  row-gap: 2rem;
  height: 0;
  min-height: 0;
  width: 100%;
  overflow: hidden;
  padding-bottom: 1rem;
}

.textbook-preview-intro {
  flex: 0 0 auto;
  /* Match the landing-page title inset and full-width section treatment. */
  padding: 2rem 1rem 0;
}

.textbook-preview-intro__header {
  scroll-margin-top: 6.5rem;
}

.textbook-preview-page {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
  width: calc(100% - 2rem);
  margin: 0 1rem;
  padding: clamp(1.25rem, 2.5vw, 1.5rem);
  border: 1px solid rgba(28, 24, 19, 0.08);
  border-radius: 1.25rem;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 14px 42px rgba(56, 47, 35, 0.07);
}

.textbook-preview-page__eyebrow {
  margin: 0 0 0.625rem;
  color: #98602e;
}

.textbook-preview-page__title {
  margin: 0;
  color: #10233f;
}

.textbook-preview-page__lead {
  margin: 0.25rem 0 0;
  color: #64748b;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.6;
}

.textbook-preview-page__description {
  margin: 0.75rem 0 0;
  color: #334155;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.5;
}

.reader-chapter-list .textbook-preview-sidebar__unlock {
  margin-top: 0.75rem;
  padding: 0.75rem 0.7rem 0.4rem;
  border-top: 1px solid #d8e2ef;
}

.textbook-preview-sidebar__unlock-copy {
  display: flex;
  justify-content: center;
  gap: 0.45rem;
  align-items: center;
  margin: 0;
  color: #365b8c;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.4;
  text-align: center;
}

.textbook-preview-sidebar__unlock-icon {
  width: 0.875rem;
  height: 0.875rem;
  color: #2f6fbd;
}

.reader-chapter-list .textbook-preview-sidebar__unlock-link {
  display: flex;
  justify-content: center;
  margin-top: 0.4rem;
  padding: 0.55rem 0.75rem;
  border-radius: 0.625rem;
  color: #fff;
  background: #132c4e;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: normal;
  line-height: 1.2;
}

.reader-chapter-list .textbook-preview-sidebar__unlock-link:hover,
.reader-chapter-list .textbook-preview-sidebar__unlock-link:focus-visible {
  color: #fff;
  background: #1e3c65;
}

.reader-chapter-list .textbook-preview-sidebar__unlock-link:active {
  color: #fff;
  background: #102642;
}

@media (hover: none), (pointer: coarse) {
  .reader-chapter-list .textbook-preview-sidebar__unlock-link {
    transition-duration: 0s;
  }

  .reader-chapter-list .textbook-preview-sidebar__unlock-link:is(:hover, :focus, :active) {
    color: #fff;
    background: #102642;
  }
}

.textbook-preview-tabs {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid #d8dee8;
}

.textbook-preview-tabs__link {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.25rem;
  min-height: 3.6rem;
  padding: 0.75rem 0.25rem;
  border-bottom: 3px solid transparent;
  color: #10233f;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.35;
  text-align: left;
  text-decoration: none;
}

.textbook-preview-tabs__link:hover,
.textbook-preview-tabs__link:focus-visible {
  color: #244f90;
  background: #f4f8fd;
}

.textbook-preview-tabs__link:focus-visible {
  outline: 2px solid #244f90;
  outline-offset: -2px;
}

.textbook-preview-tabs__link.is-active {
  border-bottom-color: #3f77ba;
  color: #244f90;
  background: #edf4fc;
}

.textbook-preview-reader-shell {
  min-width: 0;
}

.textbook-preview-sidebar__chapter-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.textbook-preview-sidebar__availability {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: auto;
  color: #2f6fbd;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
  text-align: right;
  white-space: nowrap;
}

.textbook-preview-sidebar__availability--locked {
  color: #64748b;
}

.textbook-preview-sidebar__lock-icon {
  width: 0.875rem;
  height: 0.875rem;
  flex: 0 0 auto;
  color: #2f6fbd;
}

.textbook-preview-sidebar__locked-chapter {
  display: grid;
  gap: 0.12rem;
  padding: 0.62rem 0.7rem;
  border-radius: 0.5rem;
  color: #64748b;
  cursor: default;
}

.textbook-preview-sidebar__locked-chapter .reader-chapter-list-order {
  color: #64748b;
}

.textbook-preview-sidebar__locked-chapter .reader-chapter-list-title {
  color: #64748b;
}

.textbook-preview-sidebar__chapter-note,
.textbook-preview-sidebar__section-note {
  flex: 0 0 auto;
  margin: -0.5rem 0 0.45rem;
  color: #53627a;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.4;
}

.reader-nav-group--chapters:not(.is-open) .textbook-preview-sidebar__chapter-note,
.reader-section-navigation:not(.is-open) .textbook-preview-sidebar__section-note {
  display: none;
}

.textbook-preview-sidebar__locked-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.2rem 0.35rem 0.2rem 0.55rem;
  color: #64748b;
}

.textbook-preview-sidebar__section-group {
  padding: 0.2rem 0.35rem 0.2rem 0.55rem;
  color: #292724;
}

.textbook-preview-sidebar__section-lock {
  width: 0.875rem;
  height: 0.875rem;
  flex: 0 0 auto;
  color: #2f6fbd;
}

.textbook-preview-drawer .textbook-preview-sidebar__chapter-note,
.textbook-preview-drawer .textbook-preview-sidebar__section-note {
  margin: 0.25rem 0 0.15rem;
}

.textbook-preview-drawer .reader-drawer-group:not(.is-open) .textbook-preview-sidebar__chapter-note,
.textbook-preview-drawer .reader-drawer-group:not(.is-open) .textbook-preview-sidebar__section-note {
  display: none;
}

.textbook-preview-drawer .textbook-preview-sidebar__locked-section {
  padding: 0.35rem 0.45rem 0.35rem 0.65rem;
  border-left: 2px solid transparent;
  border-radius: 0.45rem;
}

.textbook-preview-drawer .textbook-preview-sidebar__section-group {
  padding: 0.35rem 0.45rem 0.35rem 0.65rem;
}

.textbook-preview-drawer .reader-toc-h3 a,
.textbook-preview-drawer .reader-toc-h3 .textbook-preview-sidebar__locked-section {
  padding-left: 1.35rem;
}

.textbook-preview-drawer .reader-toc-h4 a,
.textbook-preview-drawer .reader-toc-h4 .textbook-preview-sidebar__locked-section {
  padding-left: 0.95rem;
}

.textbook-preview-drawer .reader-toc-h5 a,
.textbook-preview-drawer .reader-toc-h5 .textbook-preview-sidebar__locked-section,
.textbook-preview-drawer .reader-toc-h6 a,
.textbook-preview-drawer .reader-toc-h6 .textbook-preview-sidebar__locked-section {
  padding-left: 1.25rem;
}

.textbook-preview-excerpt {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  padding: 0 clamp(0rem, 1.5vw, 1.25rem);
  scroll-margin-top: 6.5rem;
}

.textbook-preview-excerpt__scroll {
  min-height: 0;
  padding: 0 0.5rem 1rem 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  scrollbar-gutter: stable;
}

.textbook-preview-excerpt__scroll:focus-visible {
  outline: 2px solid #244f90;
  outline-offset: 0.25rem;
}

.textbook-preview-excerpt__content.reader-content
  > .textbook-preview-excerpt__chapter-eyebrow {
  display: block;
}

.textbook-preview-conversion {
  width: fit-content;
  margin: 0.75rem auto 3rem;
  text-align: left;
}

.textbook-preview-conversion .textbook-hero__preview-link,
.textbook-preview-conversion .textbook-hero__preview-link:visited {
  color: #244f90;
  font-size: 1.0625rem;
  font-weight: 600;
}

.textbook-preview-conversion .textbook-hero__preview-arrow {
  color: currentColor;
}

.textbook-preview-conversion .textbook-hero__preview-link:active {
  color: #173f78;
}

.textbook-preview-conversion .textbook-hero__preview-link:hover,
.textbook-preview-conversion .textbook-hero__preview-link:focus-visible {
  color: #173f78;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2rem;
}

.textbook-preview-conversion .textbook-hero__preview-copy {
  margin-top: -0.25rem;
  color: #64748b;
  font-size: 0.9375rem;
  line-height: 1.55;
}

/* Desktop preview follows the paid reader's continuous document flow. The
 * public-page introduction and chapter tabs scroll away naturally; once the
 * white reader surface reaches the sticky site header, excerpt content keeps
 * moving without a nested scrollbar. The complete public preview still ends
 * as a contained card above the footer. */
@media (min-width: 768px) {
  /* The public Preview has a footer, unlike the paid reader. Its desktop
   * document must therefore override the shared sticky-footer shell and let
   * the footer follow the complete reader surface in normal page flow. */
  body.textbook-preview-body.textbook-site-page:not(.reader-body) {
    display: block;
    min-height: 100vh;
    height: auto;
    overflow: visible;
  }

  .textbook-preview-conversion {
    display: none;
  }

  .textbook-preview-root {
    height: auto;
    overflow: visible;
  }

  .textbook-preview-body {
    display: block;
    min-height: 100vh;
    height: auto;
    overflow: visible;
  }

  .textbook-preview-body #main {
    display: block;
    height: auto;
    min-height: 0;
    overflow: visible;
    padding-bottom: 0;
  }

  .textbook-preview-page {
    display: block;
    min-height: 0;
    overflow: visible;
    margin-top: 2rem;
    margin-bottom: 2.5rem;
  }

  .textbook-preview-excerpt {
    display: block;
    min-height: 0;
    overflow: visible;
  }

  .textbook-preview-excerpt__scroll {
    min-height: 0;
    padding-bottom: 1.5rem;
    overflow: visible;
    overscroll-behavior: auto;
    scrollbar-gutter: auto;
  }
}

@media (min-width: 980px) {
  .textbook-preview-tabs {
    display: none;
  }

  .textbook-preview-reader-shell {
    display: grid;
    grid-template-columns: 18rem minmax(0, 1fr);
    gap: 2rem;
    align-items: start;
  }

  .textbook-preview-sidebar {
    align-self: start;
  }

  .textbook-preview-sidebar .reader-toc-h3 a,
  .textbook-preview-sidebar .reader-toc-h3 .textbook-preview-sidebar__locked-section {
    padding-left: 1.25rem;
  }

  .textbook-preview-sidebar .reader-toc-h4 a {
    padding-left: 0.9rem;
  }

  .textbook-preview-sidebar .reader-toc-h5 a,
  .textbook-preview-sidebar .reader-toc-h6 a {
    padding-left: 1.25rem;
  }
}

@media (max-width: 979px) {
  .textbook-preview-body {
    --reader-anchor-offset: 6.25rem;
  }

  .textbook-preview-tabs {
    display: none;
  }

  .textbook-preview-drawer .reader-chapter-list .textbook-preview-sidebar__unlock {
    padding-bottom: 0.4rem;
  }

  .textbook-preview-drawer .reader-chapter-list .textbook-preview-sidebar__unlock-link {
    width: 90%;
    margin-inline: auto;
  }
}

/* The Preview eyebrow stays visible when the reader sidebar disappears. */
@media (max-width: 979px) {
  .textbook-preview-excerpt__content.reader-content
    > #preview-chapter-title {
    border-block-start: 0;
    border-top: 0;
  }
}

@media (max-width: 767px) {
  .textbook-preview-excerpt__content.reader-content
    > .textbook-preview-excerpt__chapter-eyebrow {
    text-align: left;
  }

  /* Match the paid reader's sizing contract. Some legacy figure fragments
   * request content-box sizing, but the paid reader deliberately overrides
   * that inside #main so presentation padding cannot make a figure wider than
   * its reader surface. Preview must resolve the same shared markup the same
   * way. */
  .textbook-preview-body #main,
  .textbook-preview-body #main *,
  .textbook-preview-body #main *::before,
  .textbook-preview-body #main *::after {
    box-sizing: border-box;
  }

  .textbook-preview-root {
    height: auto;
    overflow: visible;
  }

  .textbook-preview-body {
    min-height: 100vh;
    height: auto;
    overflow: visible;
  }

  .textbook-preview-body #main {
    flex: none;
    grid-template-rows: auto auto;
    row-gap: 1.5rem;
    height: auto;
    min-height: 0;
    overflow: visible;
    padding-bottom: 0;
  }

  body.textbook-preview-body.textbook-site-page:not(.reader-body) .textbook-site-main {
    flex: none;
  }

  .textbook-preview-intro {
    padding: 1.25rem 1rem 0;
  }

  .textbook-preview-page {
    display: block;
    /* Keep the white reader surface full width inside the shared main gutter.
     * The paid reader's content inset belongs on .reader-content itself; that
     * distinction matters for figures with intentional negative-margin bleeds. */
    width: 100%;
    min-height: 0;
    margin-inline: 0;
    padding: 1.25rem 0;
    border-radius: 1rem;
    overflow: visible;
  }

  .textbook-preview-tabs {
    grid-template-columns: repeat(4, minmax(12rem, 1fr));
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
  }

  .textbook-preview-tabs__link {
    justify-content: flex-start;
  }

  .textbook-preview-excerpt {
    display: block;
    min-height: 0;
    overflow: visible;
    /* Mobile must match the paid reader's single content inset. The preview's
     * desktop wrapper padding otherwise compounds with .reader-content and
     * changes the geometry of intentional figure bleeds. */
    padding: 0;
  }

  .textbook-preview-excerpt__scroll {
    min-height: 0;
    margin-top: 0;
    /* This wrapper is not a nested scroller on mobile, so it must not add a
     * second right inset around the shared reader markup. */
    padding: 0;
    overflow: visible;
    overscroll-behavior: auto;
    scrollbar-gutter: auto;
  }

  .textbook-preview-conversion {
    margin: 0.75rem 1rem 3rem;
  }
}
