/* Browser verification corrections to Fable's stage build. */
.closed-book{height:min(calc(100svh - 310px),560px)}
.cover{opacity:clamp(0,min(calc(var(--unfold)*9),calc((1 - var(--unfold))*12)),1)}
.leaf-right{opacity:clamp(0,calc(var(--unfold)*9),1)}
.stage[data-state="closed"] .margin,.stage[data-state="closed"] .folio{visibility:hidden}
.stage[data-state="closed"] .stage-title{pointer-events:none}
.stage-title .stage-hint{pointer-events:auto}
@media(max-width:700px){
 :root{--folio-h:94px}
 .folio{display:grid;grid-template-columns:1fr auto;grid-template-rows:42px 42px;gap:0 8px;padding:4px 10px}
 .folio-place{grid-column:1/-1;justify-content:space-between;width:100%}
 .folio select{max-width:60vw}
 .folio-turn{grid-column:1;grid-row:2}
 .folio-view{grid-column:2;grid-row:2;justify-content:flex-end}
 .closed-book{height:min(calc(100svh - 360px),430px)}
}
.stage{--closed-center-offset:0px}
@media(min-width:1101px){.stage[data-notes="open"]{--closed-center-offset:150px}}
.book-body{transform:translateX(calc(-25% * (1 - var(--unfold)) + var(--closed-center-offset) * (1 - var(--unfold)))) rotateX(calc(6deg * (1 - var(--unfold))))}
.stage[data-layout="single"] .book-body{transform:translateX(calc(var(--closed-center-offset) * (1 - var(--unfold))))}
.stage-title{transform:translate(calc(var(--closed-center-offset) * (1 - var(--unfold))),calc(var(--unfold)*-14px))}
@media(prefers-reduced-motion:reduce){.book-body{transform:translateX(calc(var(--closed-center-offset) * (1 - var(--unfold))))}}

/* Keep chapter, page number, arrows, and notes controls above the open book. */
.stage { grid-template-rows: var(--folio-h) minmax(0, 1fr); }
.folio { grid-row: 1; border-top: 0; border-bottom: 1px solid var(--rule); }
.pan { grid-column: 1; grid-row: 2; }
.stage > .margin { grid-row: 2; }

/* Isolated review: keep the chapter distinct from printed-page navigation. */
.folio button[aria-expanded="true"]{background:#fff;border-color:var(--rule)}
.folio-chapter{min-width:0}
@media(max-width:700px){
 :root{--folio-h:138px}
 .folio{grid-template-columns:1fr auto;grid-template-rows:42px 42px 42px}
 .folio-place{display:contents}
 .folio-chapter{grid-column:1/-1;grid-row:1}
 .folio select{width:100%;max-width:100%;font-size:13px}
 .folio-page{grid-column:1;grid-row:2}
 .folio-turn{grid-column:2;grid-row:2}
 .folio-view{grid-column:1/-1;grid-row:3;justify-content:flex-end}
 .folio button{height:40px;min-width:40px}
 .folio-page span:last-child{display:inline}
}

.book-nav .book-home { display: flex; align-items: center; flex-shrink: 0; }
.book-home img { display: block; width: 110px; height: auto; }
@media(max-width: 480px) { .book-home img { width: 92px; } }

/* Keep page turns over the book center, independent of chapter title length. */
@media(min-width:701px) {
 .stage { --turn-center: 50%; }
 .folio { position: relative; }
 .folio-chapter select { width: clamp(90px, 14vw, 140px); max-width: 140px; }
 .folio-place { gap: 10px; justify-content: flex-start; }
 .folio-page { white-space: nowrap; }
 .folio-turn { position: absolute; left: var(--turn-center); transform: translateX(-50%); }
 .folio-view { margin-left: auto; }
}
@media(min-width:1101px) {
 .stage[data-notes="open"] { --turn-center: calc((100% - var(--margin-w)) / 2); }
}

.page-turn-hint { position: absolute; top: calc(100% + 26px); left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 12px; font-style: italic; font-weight: 400; color: var(--muted); pointer-events: none; }
.stage:not([data-state="open"]) .page-turn-hint, .stage[data-zoomed="true"] .page-turn-hint { display: none; }


/* Reserve space beneath the fitted book for its visible page-turn hint. */
.stage[data-state="open"]:not([data-zoomed="true"]) .table{padding:20px 40px 64px}
@media(max-width:700px){
 .stage[data-state="open"]:not([data-zoomed="true"]) .table{padding:20px 18px 64px}
}

/* Optional chapter connections: keep the book full width until requested. */
.margin { overscroll-behavior: contain; }
.margin > .margin-chapter { font: 700 19px/1.3 Lato, sans-serif; margin: 0 0 22px; }
.chapter-resource { padding: 18px 0; border-top: 1px solid var(--rule); }
.chapter-resource .eyebrow { margin-bottom: 8px; }
.chapter-resource-link { display: block; font-size: 16px; line-height: 1.45; font-weight: 700; }
.chapter-video { position: relative; display: block; width: 100%; padding: 0; border: 0; background: transparent; text-align: left; color: var(--teal); }
.chapter-video img { display: block; width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 5px; }
.chapter-video-title { display: block; margin-top: 10px; font: 700 16px/1.45 Lato, sans-serif; text-decoration: underline; text-underline-offset: 4px; }
.chapter-play { position: absolute; left: 50%; top: calc((100cqw) * .28125); transform: translate(-50%, -50%); display: grid; place-items: center; padding-left: 3px; width: 56px; height: 56px; border-radius: 50%; background: white; color: #12667a; font-size: 22px; box-shadow: 0 2px 12px #0004; }
.chapter-video { container-type: inline-size; }
.chapter-link-hint { font-size: 12px; line-height: 1.5; color: var(--muted); margin: 14px 0 0; }
.book-buy { white-space: nowrap; color: var(--rust); font-size: 13px; margin-right: 10px; }
#toggle-notes { white-space: nowrap; font-size: 13px; }
@media (min-width: 701px) and (max-width: 1100px) {
 :root { --folio-h: 92px; }
 .folio { display: grid; grid-template-columns: 1fr auto; grid-template-rows: 42px 42px; }
 .folio-place { grid-column: 1; grid-row: 1; }
 .folio-turn { grid-column: 2; grid-row: 1; position: static; transform: none; }
 .folio-view { grid-column: 1/-1; grid-row: 2; justify-content: flex-end; }
}
@media (max-width: 700px) {
 .folio-view { gap: 2px; justify-content: space-between; width: 100%; }
 .folio-view button { min-width: 30px; padding: 0 4px; }
 #toggle-notes { font-size: 11px; white-space: normal; max-width: 110px; line-height: 1.25; }
 .book-buy { font-size: 11px; margin-right: 3px; }
 .folio output { min-width: 34px; }
 .margin > .margin-chapter { font-size: 15px; }
 .chapter-resource-link, .chapter-video-title { font-size: 14px; }
 .chapter-play { width: 46px; height: 46px; font-size: 19px; }
}
