/* The original cover sequence continues into a hinged book and real page samples. */
.book-page { background: #211432; }
.book-experience {
  --book-original-height: 540svh;
  --book-frame-min-height: 540px;
  --book-frame-height: max(100svh, var(--book-frame-min-height));
  height: calc(var(--book-frame-height) + (var(--book-original-height) - var(--book-frame-height)) * var(--book-scroll-scale, .815));
}
.book-render { bottom: 112px; }
.book-render canvas { filter: none; }
.book-render::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: url('/assets/book-shadow.webp') center / 100% 100% no-repeat;
  transform: translate3d(8px, 20px, 0) scale(var(--book-shadow-x, .65), var(--book-shadow-y, .9));
  opacity: 0;
}
.book-render.is-ready:not(.is-loading-pages)::before { opacity: .42; }
.experience-frame.is-open .experience-side { opacity: 0; }
.experience-side { transition: opacity .25s; }
.book-render.is-previewing:not(.is-ready) .book-fallback { opacity: 0; }
.book-spread-fallback { display: grid; grid-template-columns: 1fr 1fr; width: min(86%, 1050px, calc((100svh - 260px) * 1.414)); max-height: 100%; background: white; box-shadow: 0 25px 50px #0d031f80; transform: rotate(-1deg); }
.book-spread-fallback img { width: 100%; max-height: 100%; object-fit: contain; }
.book-render.is-ready .book-spread-fallback { display: none; }
.book-render.is-loading-pages canvas { visibility: hidden; }
.book-render.is-loading-pages:not(.is-previewing) .book-fallback { opacity: 1; }
.book-render.is-loading-pages.is-previewing .book-fallback { opacity: 0; }
.book-render.is-loading-pages .book-spread-fallback:not([hidden]) { display: grid; }
.experience-progress>span { width: 100%; transform: scaleX(0); }
.book-end-footer {
  position: fixed;
  z-index: 8;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
  gap: 24px;
  width: min(680px, calc(100% - 32px));
  padding: 14px 18px;
  border: 1px solid #dbc08470;
  border-radius: 14px;
  background: #211432;
  color: #fff4d3;
  box-shadow: 0 8px 24px #0b041d66;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, calc(100% + 32px + env(safe-area-inset-bottom, 0px)));
  transition: opacity .24s ease, transform .32s ease, visibility 0s .32s;
}
.book-end-footer.is-visible { opacity: 1; visibility: visible; transform: translate(-50%, 0); transition-delay: 0s; }
.book-end-footer p { flex: 1; font-size: .875rem; line-height: 1.5; }
.book-end-footer a { display: inline-flex; align-items: center; justify-content: center; gap: 10px; flex-shrink: 0; min-height: 44px; padding: 10px 16px; border-radius: 8px; background: #ffdf4f; color: #211432; font-size: .875rem; font-weight: 700; white-space: nowrap; }
.book-end-footer a:hover { background: #ffe978; }
.book-end-footer .cover-buy-label, .preview-read-button .cover-buy-label { width: auto; height: 16px; }
.has-end-footer .scroll-invitation { visibility: hidden; }
.book-sample-controls { position: absolute; z-index: 5; bottom: 58px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; justify-content: center; gap: 24px; width: max-content; max-width: calc(100% - 40px); color: #fff4d3; }
.book-sample-controls>div { display: flex; flex-direction: column; gap: 3px; }
.book-sample-controls>div>span { font-size: .65rem; letter-spacing: .12em; color: #cfbfdf; }
.book-sample-controls strong { font-size: .95rem; font-weight: 600; line-height: 1.4; }
.preview-read-button { border: 0; background: #ffdf4f; color: #211432; display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 16px; border-radius: 8px; font-size: .875rem; white-space: nowrap; }
.preview-read-button:hover { background: #ffe978; }
.book-look-inside { display: flex; align-items: center; gap: 18px; border: 0; border-bottom: 1px solid #dbc08466; background: transparent; color: #ffdf4f; padding: 10px 0; margin-top: 12px; font-size: .9rem; min-height: 44px; }
.book-look-inside:hover { border-color: #ffdf4f; }
.book-reader { width: min(1250px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; border: 1px solid #dbc08470; border-radius: 14px; background: #211432; color: #fff7e6; box-shadow: 0 24px 90px #0b041db3; }
.book-reader::backdrop { background: #0d0719dc; backdrop-filter: blur(7px); }
.book-reader-heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 20px 24px; border-bottom: 1px solid #dbc08440; }
.book-reader-heading p { font-size: .65rem; letter-spacing: .1em; color: #ead6ac; margin-bottom: 7px; }
.book-reader-heading h2 { font-size: 1.1rem; line-height: 1.3; color: #fff7e6; }
.book-reader-heading button { flex-shrink: 0; width: 44px; height: 44px; border: 1px solid #dbc08466; border-radius: 50%; background: transparent; color: #fff7e6; font-size: 1.8rem; line-height: 1; }
.book-reader-scroll { max-height: calc(100dvh - 205px); overflow: auto; overscroll-behavior: contain; padding: 20px 24px; }
.book-reader-spread { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.book-reader-spread figure { margin: 0; min-width: 0; }
.book-reader-spread img { width: 100%; height: auto; background: white; }
.book-reader-spread figcaption { padding-top: 9px; font-size: .7rem; color: #cfbfdf; line-height: 1.5; }
.book-reader-navigation { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 13px 24px; border-top: 1px solid #dbc08440; }
.book-reader-navigation button { min-height: 44px; border: 1px solid #dbc08470; border-radius: 7px; color: #ffdf4f; background: transparent; padding: 9px 15px; font-size: .8rem; white-space: nowrap; }
.book-reader-navigation button:disabled { opacity: .35; cursor: default; }
.book-reader-navigation button:not(:disabled):hover { background: #42305e; }
.book-reader-navigation p { font-size: .75rem; text-align: center; color: #cfbfdf; }
body.book-reader-open { overflow: hidden; }
@media (max-width: 700px) {
  .book-experience { --book-original-height: 480svh; --book-frame-min-height: 460px; }
  .book-render { bottom: 132px; }
  .book-end-footer { flex-direction: column; gap: 6px; padding: 10px 14px; bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
  .book-end-footer p { flex: none; font-size: clamp(.625rem, 2.8vw, .75rem); line-height: 1.5; text-align: center; white-space: nowrap; }
  .book-end-footer a { gap: 8px; padding: 10px 12px; font-size: .75rem; }
  .book-end-footer .cover-buy-label, .preview-read-button .cover-buy-label { height: 13px; }
  .book-sample-controls { bottom: 56px; width: calc(100% - 40px); gap: 12px; }
  .book-sample-controls>div { flex: 1; min-width: 0; }
  .book-sample-controls>div>span { font-size: .6rem; letter-spacing: .05em; }
  .book-sample-controls strong { font-size: .8rem; }
  .preview-read-button { padding: 10px 12px; font-size: .75rem; }
  .book-reader { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); border-radius: 10px; }
  .book-reader-heading { padding: 15px; gap: 15px; }
  .book-reader-heading h2 { font-size: .95rem; }
  .book-reader-scroll { max-height: calc(100dvh - 188px); padding: 15px; }
  .book-reader-spread { grid-template-columns: 1fr; gap: 24px; }
  .book-reader-navigation { padding: 10px 12px; gap: 8px; }
  .book-reader-navigation button { padding: 8px 10px; font-size: .7rem; }
  .book-reader-navigation p { font-size: .65rem; }
}
@media (max-height: 600px) and (min-width: 701px) {
  .book-experience { --book-frame-min-height: 380px; }
}
@media (prefers-reduced-motion: reduce) {
  .book-experience { height: 100svh; }
  .experience-side { transition: none; }
  .book-end-footer, .book-end-footer.is-visible { position: relative; left: auto; bottom: auto; margin: 0 auto 24px; transform: none; transition: none; }
}

/* Phones use the same four illustrations without any animated SVG layers. */
@media (max-width: 700px), (pointer: coarse) {
  .book-page .experience-backdrop { background-image: url('/assets/maths-world-background-balanced.webp'); }
  .book-page .experience-backdrop .backdrop-corner { background-image: url('/assets/maths-world-background-balanced.webp'); }
  .book-page .experience-backdrop svg { display: none; }
}
@media (max-width: 700px) and (max-aspect-ratio: 1/1), (pointer: coarse) and (max-aspect-ratio: 1/1) {
  .book-page .experience-backdrop { background-image: none; }
}

/* The setting stays available without competing with the sample-page controls. */
.animation-settings { position: absolute; z-index: 6; right: 20px; bottom: 14px; }
.animation-settings select { min-height: 44px; max-width: 158px; padding: 8px 10px; border: 1px solid #dbc08488; border-radius: 8px; background: #211432; color: #fff4d3; font: inherit; font-size: .75rem; }
.animation-settings select:focus-visible { outline: 3px solid #ffdf4f; outline-offset: 3px; }
.has-end-footer .animation-settings { bottom: calc(116px + env(safe-area-inset-bottom, 0px)); }
.is-light-book .experience-backdrop svg { display: none; }
.is-basic-book .book-experience { height: max(100svh, 540px); }
.is-basic-book .experience-frame { min-height: 540px; }
.is-basic-book .book-flyup-layer, .is-basic-book .scroll-invitation { display: none; }
.is-basic-book .book-fallback { transform: none; will-change: auto; }
.is-basic-book .book-end-footer, .is-basic-book .book-end-footer.is-visible { position: relative; left: auto; bottom: auto; margin: 12px auto 24px; transform: none; transition: none; }
.is-basic-book .animation-settings { bottom: 14px; }
@media (max-width: 380px) { .animation-settings { right: 16px; } .animation-settings select { max-width: 143px; font-size: .6875rem; } }

.book-page.is-light-book .experience-backdrop, .book-page.is-light-book .experience-backdrop .backdrop-corner { background-image: url('/assets/maths-world-background-balanced.webp'); }
@media (max-aspect-ratio: 1/1) { .book-page.is-light-book .experience-backdrop { background-image: none; } }

/* Look inside stays available before the optional scroll showcase. */
.header-book-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.header-look-inside { border: 1px solid #dbc08488; background: #211432; }
.header-look-inside:hover { background: #42305e; }
.header-look-inside .cover-buy-label { filter: none; }
.book-load-status { max-width: 360px; font-size: .8rem; line-height: 1.45; color: #fff4d3; margin-top: 4px; }
@media (max-width: 700px) {
  .header-book-actions { flex-direction: column; gap: 4px; align-items: stretch; }
  .header-book-actions .header-buy, .header-look-inside { min-height: 44px; }
  .header-look-inside .cover-buy-label { height: 13px; }
  .book-load-status { font-size: .75rem; }
}

.book-sample-controls.has-load-status > div > span, .book-sample-controls.has-load-status strong { display: none; }

.experience-frame.is-waiting-for-pages .book-flyup-layer { display: none; }
