/* Case Club+ book reader: full screen, cosy, big buttons */
.page-reader .site-header, .page-reader .site-footer, .page-reader .tabbar { display: none; }
.page-reader main { padding: 0 !important; }
body.page-reader {
  padding-bottom: 0;
  background-color: var(--navy);
  background-image: radial-gradient(rgba(255,201,40,.22) 1.6px, transparent 2px), radial-gradient(rgba(255,255,255,.12) 1.2px, transparent 1.6px);
  background-size: 46px 46px, 23px 23px; background-position: 0 0, 11px 17px;
}
.reader {
  min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr auto; color: var(--snow);
  background: radial-gradient(ellipse at 50% 40%, rgba(255,201,40,.18), transparent 60%);
}

/* top bar */
.reader__bar { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--gutter); }
.reader__title { flex: 1; min-width: 0; display: grid; line-height: 1.1; }
.reader__title strong { font-family: var(--font-display); font-weight: 400; font-size: clamp(1.1rem, .9rem + 1vw, 1.6rem); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader__title span { color: var(--sun); font-weight: 700; font-size: .95rem; }
.reader__tools { display: flex; gap: var(--s2); align-items: center; }
.rbtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 16px;
  background: var(--snow); color: var(--navy); border: 3px solid var(--navy); border-radius: 999px; box-shadow: 0 4px 0 #0b1035;
  font: 400 1.05rem var(--font-display); text-decoration: none; cursor: pointer; transition: transform var(--t-fast);
}
.rbtn:hover { transform: translateY(-2px); }
.rbtn:active { transform: translateY(2px); box-shadow: 0 1px 0 #0b1035; }
.rbtn--round { width: 46px; padding: 0; }
.rbtn svg { width: 22px; height: 22px; }
.rbtn--sun { background: var(--sun); }
.rbtn[aria-pressed="true"] { background: var(--meadow); color: var(--snow); }
.rbtn__ico { font-size: .9rem; }

/* stage and book */
.reader__stage { display: flex; align-items: center; justify-content: center; gap: var(--s4); padding: var(--s3) var(--s4); min-height: 0; }
.turn {
  flex: none; display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%;
  background: var(--tie); color: var(--snow); border: 3px solid var(--snow); box-shadow: 0 5px 0 #0b1035;
  font: 400 2.6rem/1 var(--font-display); text-decoration: none; padding-bottom: 6px; transition: transform var(--t-fast) var(--ease-pop);
}
.turn:hover { transform: scale(1.08); }
.turn--next { background: var(--meadow); }
.turn[hidden] { display: grid; visibility: hidden; }

.book {
  --w: min(1120px, calc(100vw - 190px), calc((100dvh - 190px) * 1.5));
  position: relative; width: var(--w); aspect-ratio: 1.5; display: grid; grid-template-columns: 1fr 1fr;
  perspective: 2400px; color: var(--navy); filter: drop-shadow(0 10px 0 #0b1035);
}
.page {
  position: relative; background: #fffaf0; border: 4px solid var(--navy); overflow: hidden auto;
  padding: clamp(18px, 3.2%, 40px) clamp(18px, 4.5%, 52px) 46px; display: flex; flex-direction: column; gap: 14px;
  font-size: clamp(1rem, .55rem + 1.05vw, 1.4rem); line-height: 1.5;
}
.page--left { border-radius: 22px 4px 4px 22px; border-right-width: 2px; background-image: linear-gradient(to left, rgba(24,33,88,.14), transparent 9%); }
.page--right { border-radius: 4px 22px 22px 4px; border-left-width: 2px; background-image: linear-gradient(to right, rgba(24,33,88,.14), transparent 9%); }
.page__text { display: grid; gap: .6em; }
.page__text :is(h1, h2, h3) { font-family: var(--font-display); font-weight: 400; line-height: 1.05; color: var(--navy); }
.page__text h1 { font-size: 2.1em; color: var(--tie); }
.page__text h2 { font-size: 1.5em; }
.page__text p { margin: 0; }
.page__text blockquote { margin: 0; padding: .6em .9em; background: var(--sun); border: 3px solid var(--navy); border-radius: 16px; font-weight: 700; transform: rotate(-1deg); }
.page__text .page-chapter { font-family: var(--font-display); color: var(--tie); text-transform: uppercase; letter-spacing: .06em; font-size: .85em; }
.page__text .page-ornament { color: var(--sun-dark); letter-spacing: .4em; }
.page__text .reader-illustration-note { display: none; }
.page__text .soon { color: #6b739c; font-style: italic; }
.page__text .is-reading { background: rgba(255,201,40,.45); border-radius: 6px; box-shadow: 0 0 0 4px rgba(255,201,40,.45); }
.page__art { flex: 1 1 auto; min-height: 0; display: grid; place-items: center; }
.page__art img { max-height: 100%; max-width: 100%; object-fit: contain; }
.page__art[hidden] { display: none; }
.page__no { position: absolute; bottom: 12px; font-family: var(--font-display); color: #8a91b8; }
.page--left .page__no { left: 22px; }
.page--right .page__no { right: 22px; }

/* page turn */
.flip { position: absolute; top: 0; bottom: 0; width: 50%; transform-style: preserve-3d; z-index: 5; pointer-events: none;
  transition: transform 560ms cubic-bezier(.45, .05, .3, 1); }
.flip--next { left: 50%; transform-origin: left center; }
.flip--prev { left: 0; transform-origin: right center; }
.flip.go.flip--next { transform: rotateY(-180deg); }
.flip.go.flip--prev { transform: rotateY(180deg); }
.flip .page { position: absolute; inset: 0; backface-visibility: hidden; }
.flip .flip__back { transform: rotateY(180deg); }
.book.fade { animation: bookfade 360ms var(--ease-out); }
@keyframes bookfade { from { opacity: .2; transform: translateX(var(--dir, 20px)); } }

/* overlays: locked pages and the end */
.book__lock, .book__end {
  position: absolute; inset: 0; z-index: 6; display: grid; grid-template-columns: auto 1fr; gap: var(--s5); align-items: center;
  padding: clamp(20px, 5%, 60px); background: rgba(255,250,240,.96); border: 4px solid var(--navy); border-radius: 22px;
}
.book__lock[hidden], .book__end[hidden] { display: none; }
.book__lock img, .book__end img { width: clamp(90px, 14vw, 180px); position: relative; z-index: 1; }
.book__lock > div, .book__end > div { min-width: 0; }
.book__lock h2, .book__end h2 { font-size: var(--text-2xl); margin-bottom: var(--s3); color: var(--navy); line-height: 1; }
.book__lock p, .book__end p { font-size: var(--text-lg); margin-bottom: var(--s4); max-width: 36ch; }
.book__lock .btn, .book__end .btn { margin: 0 var(--s2) var(--s2) 0; }
.book__end { background: var(--sun); overflow: hidden; }
.book__end > div:not(.book__burst) { position: relative; z-index: 1; }
.book__burst { position: absolute; inset: -40%; background: repeating-conic-gradient(rgba(255,255,255,.35) 0 10deg, transparent 10deg 20deg); animation: spin 26s linear infinite; }
@keyframes spin { to { transform: rotate(1turn); } }
.book__coins { display: inline-flex; align-items: center; gap: 10px; background: var(--snow); border: 3px solid var(--navy); border-radius: 999px;
  padding: 6px 18px; font-family: var(--font-display); font-size: 1.5rem !important; animation: pop 600ms var(--ease-pop); }
.book__coins[hidden] { display: none; }
@keyframes pop { from { transform: scale(.2) rotate(-20deg); opacity: 0; } }
.book.is-locked .page__text, .book.is-locked .page__art { visibility: hidden; }

/* bottom */
.reader__foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--s3) var(--s5); padding: var(--s3) var(--gutter) var(--s4); }
.reader__foot p { margin: 0; font-weight: 700; }
.track { position: relative; width: min(520px, 70vw); height: 14px; background: rgba(255,255,255,.18); border: 2px solid var(--snow); border-radius: 999px; }
.track__fill { position: absolute; inset: 0 auto 0 0; background: var(--sun); border-radius: 999px; transition: width var(--t-med); }
.track__paw { position: absolute; top: 50%; width: 34px; height: 34px; margin-left: -17px; margin-top: -17px; display: grid; place-items: center;
  background: var(--fox); border: 3px solid var(--snow); border-radius: 50%; color: var(--snow); transition: left var(--t-med); }
.track__paw svg { width: 18px; height: 18px; }

.chapters { border: var(--ink); border-radius: 22px; padding: var(--s5) var(--s6); box-shadow: 0 8px 0 var(--navy); max-width: 420px; width: calc(100% - 32px); color: var(--navy); }
.chapters::backdrop { background: rgba(11,16,53,.6); }
.chapters h2 { font-size: var(--text-xl); margin-bottom: var(--s3); }
.chapters ol { display: grid; gap: var(--s2); margin: 0 0 var(--s4); padding-left: 1.4em; font-weight: 700; font-size: 1.1rem; }

/* phones and narrow tablets: one page under the other, arrows below */
@media (max-width: 760px), (max-aspect-ratio: 1/1) {
  .reader__stage { display: grid; grid-template-columns: 1fr 1fr; grid-template-areas: "book book" "prev next"; gap: var(--s4); align-content: start; padding: var(--s2) var(--s3) var(--s3); }
  .book { grid-area: book; --w: 100%; aspect-ratio: auto; grid-template-columns: 1fr; }
  .page { min-height: 46dvh; font-size: 1.2rem; overflow: visible; }
  .page--left { border-radius: 22px 22px 4px 4px; border-right-width: 4px; border-bottom-width: 2px; background-image: linear-gradient(to top, rgba(24,33,88,.12), transparent 6%); }
  .page--right { border-radius: 4px 4px 22px 22px; border-left-width: 4px; border-top-width: 2px; background-image: linear-gradient(to bottom, rgba(24,33,88,.12), transparent 6%); }
  .page__art img { max-height: 40dvh; }
  .turn--prev { grid-area: prev; justify-self: start; }
  .turn--next { grid-area: next; justify-self: end; }
  .turn { width: 72px; height: 72px; }
  .reader__bar { flex-wrap: wrap; }
  .reader__title { order: 3; flex-basis: 100%; }
  .reader__tools { margin-left: auto; }
  [data-chapters-open] { display: none; }
  .book__lock, .book__end { grid-template-columns: 1fr; text-align: center; justify-items: center; align-content: center; position: fixed; inset: 12px; z-index: 50; }
}
@media (prefers-reduced-motion: reduce) {
  .flip, .track__fill, .track__paw { transition: none; }
  .book.fade, .book__burst, .book__coins { animation: none; }
}

/* Picture books from a PDF: each page is the designed artwork, shown edge to edge */
.book--pages { --w: min(1500px, calc(100vw - 190px), calc((100dvh - 170px) * 1.973)); aspect-ratio: 1.973; }
.book--pages .page { padding: 0; overflow: hidden; background: #fff; display: block; }
.book--pages .page--left { border-right-width: 1px; }
.book--pages .page--right { border-left-width: 1px; }
.book--pages .page__text { display: block; height: 100%; }
.book--pages .page__img { display: block; width: 100%; height: 100%; object-fit: cover; }
.book--pages .page__no { display: none; }
.book--pages .page::after { content: ""; position: absolute; inset: 0; pointer-events: none; }
.book--pages .page--left::after { background: linear-gradient(to left, rgba(0,0,0,.22), transparent 7%); }
.book--pages .page--right::after { background: linear-gradient(to right, rgba(0,0,0,.22), transparent 7%); }
.book--pages .page--blank { visibility: hidden; }
.page__say { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.page.is-voiced { box-shadow: 0 0 0 5px var(--sun), 0 0 34px 6px rgba(255,201,40,.6); z-index: 1; }
.book--pages .flip .page { visibility: visible; }
/* the cover alone sits on the right like a closed book; the back cover alone on the left */
.book--pages .page--right.page--blank, .book--pages .page--left.page--blank { border-color: transparent; }

@media (max-width: 760px), (max-aspect-ratio: 1/1) {
  .book--pages { --w: 100%; width: 100%; aspect-ratio: auto; }
  .book--pages .page { min-height: 0; aspect-ratio: 1381 / 1400; border-width: 3px; border-radius: 16px; }
  .book--pages .page--left, .book--pages .page--right { border-radius: 16px; background-image: none; }
  .book--pages .page--blank { display: none; }
  .book--pages { gap: 12px; }
  .book--pages .page::after { display: none; }
}
