/* In the reader, the book leads; navigation floats in the surrounding margin. */
body[data-view="reader"]{--reader-top:calc(56px + env(safe-area-inset-top));--reader-bottom:calc(96px + env(safe-area-inset-bottom));overflow:hidden}
body[data-view="reader"] header{position:fixed;inset:0 0 auto;height:var(--reader-top);padding:env(safe-area-inset-top) max(16px,env(safe-area-inset-right)) 0 max(16px,env(safe-area-inset-left));gap:8px;pointer-events:none}
body[data-view="reader"] header .brand,body[data-view="reader"] footer{display:none}
body[data-view="reader"] header button{pointer-events:auto;flex-shrink:0;min-width:44px;min-height:44px;background:#173b32bf;color:#fff0cc;border:0;backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px)}
body[data-view="reader"] header .library-back{margin:0 auto 0 0;border-radius:24px;padding:8px 14px}
body[data-view="reader"] header .sound{position:static;width:44px;height:44px}
body[data-view="reader"] #reader{position:fixed;inset:0;height:100dvh;min-height:0;display:block;padding:var(--reader-top) max(12px,env(safe-area-inset-right)) var(--reader-bottom) max(12px,env(safe-area-inset-left))}
body[data-view="reader"] .reading-room{height:100%;width:min(100%,calc((100dvh - var(--reader-top) - var(--reader-bottom))*1.5));max-width:1400px;min-height:0;padding:0;margin:auto}
body[data-view="reader"] .book{height:100%;width:100%;transform:none}
body[data-view="reader"] .text-page{overflow-y:auto;scrollbar-width:thin}
body[data-view="reader"] .reader-bar{position:fixed;left:50%;bottom:calc(16px + env(safe-area-inset-bottom));transform:translateX(-50%);z-index:12;display:flex;flex-direction:row;flex-wrap:nowrap;align-items:center;gap:24px;width:max-content;max-width:calc(100% - 24px);min-height:64px;margin:0;padding:8px 20px 12px;border-radius:24px;background:#16382dcc;color:#fff0cc;box-shadow:0 8px 24px #06171340;backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px)}
#reader .controls{margin:0;gap:12px}
#reader .reader-options{display:flex;align-items:center;gap:12px;min-height:44px}
#reader .play-button{background:#f8e7bf26;color:#fff0cc;box-shadow:none;min-width:150px;height:44px}
#reader .round-button,#reader .scene-replay{background:transparent;color:#fff0cc;border:0;min-width:44px;min-height:44px;width:44px;height:44px}
#reader .page-count{color:#fff0cc;font-size:12px}
#reader .auto-label{color:#fff0cc}
#reader .chapter-dot:after{background:#fff0cc70}
#reader .chapter-dot.active:after{background:#ffe0a0;box-shadow:0 0 0 3px #ffe0a026}
/* A longer story must not push navigation beyond the viewport. */
#reader .chapter-dots.many-chapters{display:none}
#reader .progress-track{position:absolute;bottom:0;left:24px;right:24px;width:auto;height:3px;margin:0;background:#fff0cc24;border-radius:3px;overflow:hidden}
#reader .progress-fill{background:#f1d19db3}
#reader .status{position:fixed;left:16px;right:16px;bottom:calc(84px + env(safe-area-inset-bottom));margin:0;text-align:center;color:#fff0cc;font-size:12px;pointer-events:none}
#reader .status:not(:empty){width:fit-content;max-width:calc(100% - 32px);margin:auto;padding:4px 12px;background:#173b32ed;border-radius:8px}
body[data-view="reader"] button:focus-visible{outline:2px solid #ffe0a0;outline-offset:3px}
@media(hover:hover){#reader .play-button:hover,#reader .round-button:not(:disabled):hover,#reader .scene-replay:hover,body[data-view="reader"] header button:hover{background:#f8e7bf40;transform:none}}
@media(max-width:1000px){#reader .chapter-dots{display:none}#reader .reader-options{gap:8px}#reader .reader-bar{gap:16px}}
@media(max-width:700px){body[data-view="reader"]{--reader-bottom:calc(144px + env(safe-area-inset-bottom))}body[data-view="reader"] .reader-bar{flex-wrap:wrap;justify-content:center;gap:0 12px;width:320px;padding:6px 12px 10px;border-radius:20px}#reader .controls{width:100%;justify-content:space-between}#reader .reader-options{min-height:36px;gap:16px}#reader .scene-replay{min-height:44px;height:44px}#reader .auto-label{display:flex;font-size:10px}#reader .status{bottom:calc(104px + env(safe-area-inset-bottom))}body[data-view="reader"] .reading-room{max-width:none}body[data-view="reader"] .story-copy{font-size:clamp(17px,3.8vw,21px)}}
@media(max-width:540px){body[data-view="reader"] #reader{padding-inline:8px}body[data-view="reader"] .spread .text-page{max-height:50%;padding:12px 20px 16px}body[data-view="reader"] header .library-back span{display:none}body[data-view="reader"] header .library-back{width:44px;padding:0;justify-content:center}}
@media(max-height:540px) and (orientation:landscape){body[data-view="reader"]{--reader-top:48px;--reader-bottom:76px}body[data-view="reader"] .reader-bar{width:max-content;flex-wrap:nowrap;gap:16px;min-height:52px;padding:4px 12px 8px;bottom:8px}#reader .controls{width:auto}#reader .reader-options{min-height:44px}#reader .auto-label{display:none}#reader .status{bottom:64px}body[data-view="reader"] .reading-room{width:min(100%,calc((100dvh - 124px)*2.1))}body[data-view="reader"] .text-page{padding:12px 20px}body[data-view="reader"] .story-copy{font-size:17px}}
@media(prefers-reduced-transparency:reduce){body[data-view="reader"] header button,body[data-view="reader"] .reader-bar{background:#173b32;backdrop-filter:none;-webkit-backdrop-filter:none}}

/* Painted atlas cells retain their proportions on live and turning pages. */
.ukhdud-reader #story-scene,.ukhdud-reader .frozen-scene{object-fit:contain}
.ukhdud-reader .scene-wrap{border-radius:4px}

/* Leave the bird story's illustration paper empty for the forthcoming scenes. */
.birds-reader .scene-wrap{background:transparent;box-shadow:none;border:0}
.birds-reader .scene-replay{display:none!important}

.birds-reader #story-scene,.birds-reader .frozen-scene{object-fit:contain}
.birds-reader .scene-wrap{border-radius:4px}

/* Keep the anger story’s portrait artwork intact in both live and turning pages. */
.anger-reader #story-scene,.anger-reader .frozen-scene{object-fit:contain}
.anger-reader .scene-wrap{border-radius:4px;background:transparent;box-shadow:none;border:0}

/* Preserve the gardens' 640×960 painted composition at every book size. */
.gardens-reader #story-scene,.gardens-reader .frozen-scene{object-fit:contain}
.gardens-reader .scene-wrap{border-radius:4px;background:transparent;box-shadow:none;border:0}

/* Intrinsic text widths must not enlarge the page or the playback controls. */
body[data-view="reader"] .text-page,body[data-view="reader"] .story-copy{min-width:0;overflow-wrap:anywhere}
#reader .controls{min-width:0}
@media(max-width:360px){#reader .play-button{min-width:0;flex:1;font-size:12px;gap:6px}#reader .controls{gap:8px}#reader .reader-options{gap:10px}}
@media(max-height:540px) and (orientation:landscape) and (max-width:700px){#reader .reader-options{display:none}}

/* Word highlights should land promptly with the spoken word. */
.story-copy span{transition:color 80ms linear}

/* Portrait phones: an illustrated story fills the viewport. */
.mobile-story-progress{display:none}
@media(max-width:700px) and (orientation:portrait){
 body[data-view="reader"]{background:#10271f}
 body[data-view="reader"] header{z-index:20;max-width:none;height:calc(72px + env(safe-area-inset-top));padding-inline:max(12px,env(safe-area-inset-left));background:linear-gradient(#09221f99,transparent)}
 body[data-view="reader"] header .library-back{width:44px;padding:0;margin-right:auto;justify-content:center}
 body[data-view="reader"] header .library-back span{display:none}
 body[data-view="reader"] header .reader-notes,body[data-view="reader"] header .reader-fullscreen{position:fixed;top:calc(76px + env(safe-area-inset-top));width:44px;height:44px;border-radius:50%}
 body[data-view="reader"] header .reader-notes{left:12px}
 body[data-view="reader"] header .reader-fullscreen{right:12px}
 body[data-view="reader"] #reader{padding:0}
 body[data-view="reader"] .reading-room{width:100%;max-width:none;perspective:none}
 body[data-view="reader"] .book{padding:0;border-radius:0;background:transparent;box-shadow:none;transform-style:flat}
 body[data-view="reader"] .binding,body[data-view="reader"] .ribbon,body[data-view="reader"] .book:before,body[data-view="reader"] .book:after,body[data-view="reader"] .spread:before,body[data-view="reader"] .spread:after{display:none}
 body[data-view="reader"] .spread{display:block;border-radius:0;background:#10271f}
 body[data-view="reader"] .spread .art-page{position:absolute;inset:0;height:100%;padding:0;border-radius:0;background:none;box-shadow:none}
 body[data-view="reader"] .scene-wrap{border:0;border-radius:0;background:none;box-shadow:none}
 body[data-view="reader"] #story-scene{object-fit:cover;object-position:center;mix-blend-mode:normal}
 body[data-view="reader"] .illustration-caption,body[data-view="reader"] .chapter-line,body[data-view="reader"] .page-bottom{display:none}
 body[data-view="reader"] .spread .text-page{position:absolute;z-index:2;inset:auto 0 132px;height:auto;max-height:40%;padding:32px 24px 12px;border-radius:0;box-shadow:none;background:linear-gradient(transparent,#0b211bd9 32px,#0b211bf5);text-align:center;display:block;scrollbar-width:thin;scroll-padding:24px}
 body[data-view="reader"] .text-page h2{font-size:20px!important;line-height:1.5!important;color:#f3dfae;margin:0 0 12px}
 body[data-view="reader"] .story-copy{font-family:Friendly,sans-serif;font-size:clamp(20px,5.5vw,27px);line-height:1.75;color:#fff8e9;text-shadow:0 2px 6px #061510}
 body[data-view="reader"] .story-copy p{margin:0 0 14px}
 body[data-view="reader"] .story-copy p:last-child{margin-bottom:0}
 body[data-view="reader"] .story-copy .spoken{color:#ffda87}
 body[data-view="reader"] .reader-bar{left:0;right:0;bottom:0;width:100%;max-width:none;min-height:132px;padding:8px 20px max(12px,env(safe-area-inset-bottom));transform:none;border-radius:0;background:#0b211bf5;box-shadow:none;backdrop-filter:none;-webkit-backdrop-filter:none}
 #reader .reader-options{gap:18px}
 #reader .reader-options .page-count,#reader .reader-options .chapter-dots{display:none}
 #reader .status{bottom:132px;z-index:14;font-size:11px}
 #reader .status:not(:empty){max-width:calc(100% - 48px)}
 body[data-view="reader"] .mobile-story-progress{position:absolute;left:68px;right:68px;top:calc(14px + env(safe-area-inset-top));height:44px;display:flex;align-items:center;gap:10px;color:#fff8e9;pointer-events:auto}
 body[data-view="reader"] .mobile-story-progress .chapter-dots{display:flex;flex:1;min-width:0;gap:3px}
 body[data-view="reader"] .mobile-story-progress .chapter-dot{flex:1;min-width:0;width:auto;height:44px;min-height:44px;border-radius:0;padding:0;background:none;backdrop-filter:none;-webkit-backdrop-filter:none}
 body[data-view="reader"] .mobile-story-progress .chapter-dot:after{left:0;right:0;top:20px;width:auto;height:3px;transform:none;border-radius:3px;background:#fff8e950;box-shadow:none}
 body[data-view="reader"] .mobile-story-progress .chapter-dot.complete:after{background:#fff8e9}
 body[data-view="reader"] .mobile-story-progress .chapter-dot.active:after{background:#ffda87}
 .mobile-page-count{flex:none;font-size:11px;white-space:nowrap;text-shadow:0 1px 4px #09221f}
}

/* Two visible lines scroll continuously with the narration. */
.mobile-captions{display:none}
@media(max-width:700px) and (orientation:portrait){
 body[data-view="reader"] .spread .text-page{max-height:none;padding:24px 24px 4px;overflow:visible}
 body[data-view="reader"] .text-page>.story-copy,body[data-view="reader"] .text-page>h2{display:none}
 body[data-view="reader"] .mobile-captions{display:block}
 .caption-copy{font:400 clamp(16px,4.3vw,18px)/1.65 Friendly,sans-serif;color:#fff8e9;text-shadow:0 2px 6px #061510;overflow-wrap:anywhere;position:relative;height:3.3em;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:none}
 .caption-copy .spoken{color:#ffda87}
 .caption-copy p{margin:0}
 .caption-copy::-webkit-scrollbar{display:none}
 .caption-copy:focus-visible{outline:2px solid #ffda87;outline-offset:4px}
}

/* Secondary controls live in a disclosure beside the mobile playback controls. */
.mobile-reader-menu,.reader-option-label{display:none}
@media(max-width:700px) and (orientation:portrait){
 body[data-view="reader"]{--mobile-controls-height:calc(68px + env(safe-area-inset-bottom))}
 body[data-view="reader"] .reader-bar{height:var(--mobile-controls-height);min-height:0;flex-wrap:nowrap;gap:8px;padding:8px 16px calc(16px + env(safe-area-inset-bottom))}
 body[data-view="reader"] .spread .text-page{bottom:var(--mobile-controls-height)}
 #reader .status{bottom:var(--mobile-controls-height)}
 #reader .controls{flex:1;width:auto;gap:8px}
 #reader .play-button{min-width:0;flex:1;max-width:170px}
 #reader .reader-options{display:none}
 .mobile-reader-menu{display:block;position:relative;flex:none;color:#fff0cc}
 .mobile-reader-menu summary{display:grid;place-items:center;width:44px;height:44px;list-style:none;border-radius:50%;cursor:pointer;touch-action:manipulation}
 .mobile-reader-menu summary::-webkit-details-marker{display:none}
 .mobile-reader-menu summary svg{width:24px;height:24px}
 .mobile-reader-menu summary:focus-visible{outline:2px solid #ffe0a0;outline-offset:2px}
 .mobile-reader-menu[open] summary{background:#f8e7bf26}
 .mobile-reader-menu-panel{position:absolute;bottom:56px;right:0;width:min(280px,calc(100vw - 32px));padding:8px;border-radius:16px;background:#173b32;box-shadow:0 8px 28px #06171366;display:flex;flex-direction:column;gap:4px}
 #reader .mobile-reader-menu-panel button,#reader .mobile-reader-menu-panel .auto-label{display:flex;align-items:center;justify-content:flex-start;gap:12px;width:100%;min-height:44px;height:auto;margin:0;padding:10px 12px;border:0;border-radius:8px;background:transparent;color:#fff0cc;font:13px/1.6 Friendly,sans-serif;text-align:left}
 #reader .mobile-reader-menu-panel button[hidden]{display:none}
 #reader .mobile-reader-menu-panel button:hover{background:#f8e7bf18}
 .mobile-reader-menu-panel svg{flex:none;width:20px;height:20px}
 .mobile-reader-menu-panel .reader-option-label{display:inline}
 .mobile-reader-menu-panel input{flex:none;margin:0;width:20px;height:20px}
}
/* Let the artwork reach both edges, with a small lower allowance for controls.
   Captions float over a feathered blur rather than a separate solid panel. */
@media(max-width:700px) and (orientation:portrait){
 body[data-view="reader"] .spread .art-page{bottom:calc(var(--mobile-controls-height) - 20px);height:auto}
 body[data-view="reader"] #story-scene{object-fit:cover;object-position:center bottom}
 body[data-view="reader"] .spread .text-page{background:none;isolation:isolate}
 body[data-view="reader"] .spread .text-page:before{content:'';position:absolute;inset:-24px 0 calc(-1 * var(--mobile-controls-height));z-index:-1;pointer-events:none;background:linear-gradient(transparent,#0b211ba6 30%,#0b211bf2 85%);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);mask-image:linear-gradient(transparent,#000 32%);-webkit-mask-image:linear-gradient(transparent,#000 32%)}
 body[data-view="reader"] .reader-bar{background:linear-gradient(#0b211b99,#0b211bf2)}
}
@media(max-width:700px) and (orientation:portrait) and (prefers-reduced-transparency:reduce){
 body[data-view="reader"] .spread .text-page:before{backdrop-filter:none;-webkit-backdrop-filter:none;background:linear-gradient(transparent,#0b211bf2 30%)}
}

/* Completion is separate from the final page and appears after its narration. */
.story-complete{position:fixed;inset:0;margin:auto;width:min(360px,calc(100vw - 32px));max-height:calc(100dvh - 48px);padding:44px 28px 32px;border:0;border-radius:20px;background:#173b32;color:#fff0cc;text-align:center;box-shadow:0 20px 60px #06171366;font-family:Friendly,sans-serif}
.story-complete::backdrop{background:#061713b3}
.story-complete .completion-close{position:absolute;right:8px;top:8px;width:44px;height:44px;color:#fff0cc;background:transparent;border:0}
.story-complete h2{margin:0 0 24px;font:500 28px/1.5 StoryHand,Friendly,sans-serif}
.story-complete .completion-replay{display:flex;align-items:center;justify-content:center;gap:12px;min-height:48px;width:100%;border:0;border-radius:24px;background:#f5dfac;color:#173b32;font:500 17px/1.6 Friendly,sans-serif;padding:10px 16px;cursor:pointer}
.story-complete svg{width:22px;height:22px}
.story-complete p{margin:24px 0 0;font-size:13px}
.story-complete a{display:inline-flex;align-items:center;min-height:44px;color:#fff0cc;font-size:14px;text-underline-offset:4px}
.story-complete :focus-visible{outline:2px solid #ffe0a0;outline-offset:3px}
