/* The Way Back Home: full-screen reader.
   Each page: the picture fills the width of the screen, the space below it is filled
   with a blurred continuation of the same picture, and the bottom of the page melts
   into a soft, chapter-coloured blur that the text sits on. */
:root{
  --display:'Grandstander','Trebuchet MS',system-ui,sans-serif;
  --body:'Andika','Verdana',system-ui,sans-serif;
  --gold:#FFD166;--ink:#2B2233;--paper:#FFFDF8;
  --artw:942;--arth:1670;
  --k:1; /* text scale, lowered automatically when a page has a lot of text */
}
*{box-sizing:border-box}
html,body{height:100%;margin:0;background:var(--edge,#15121f);transition:background-color .5s;overflow:hidden;overscroll-behavior:none}
body{font-family:var(--body);color:#fff;-webkit-font-smoothing:antialiased;-webkit-text-size-adjust:100%}
button{font:inherit}
[hidden]{display:none!important}

/* the book is ordinary page content, not a fixed layer: Safari on iOS 26 paints a solid bar over the bottom of the
   screen in the colour of any fixed layer that touches the bottom edge, which hid the bottom of every picture */
.book{position:absolute;left:0;right:0;top:0;bottom:0;overflow:hidden;touch-action:none;-webkit-user-select:none;user-select:none}
/* the pages run all the way to the bottom of the screen, under the phone's toolbar or home bar; the words
   are lifted by exactly the part of the screen the phone covers (--gap), so nothing important hides there */
:root{--gap:0px}
@supports (height:100lvh){:root{--gap:max(0px,calc(100lvh - 100dvh))}.book{bottom:auto;height:100lvh}}
.track{position:absolute;left:0;right:0;top:0;height:100%;will-change:transform;transform:translate3d(0,0,0)}
.track.anim{transition:transform .5s cubic-bezier(.2,.8,.2,1)}

.pg{position:relative;height:100%;overflow:hidden;background:var(--tint)}
.pg>.bg{position:absolute;inset:-4%;width:108%;height:108%;object-fit:cover;filter:brightness(.72) saturate(1.1)}
.stage{position:relative;height:100%;margin:0 auto;container-type:inline-size;width:min(100%,calc(100vh * var(--artw) / var(--arth)));overflow:hidden}
@supports (height:100dvh){.stage{width:min(100%,calc(100dvh * var(--artw) / var(--arth)))}}
/* wider screens (tablets, computers): the book becomes a tall column with soft edges */
@media (min-aspect-ratio:10/16){.stage{box-shadow:0 0 80px rgba(0,0,0,.45)}}

.art{position:absolute;left:0;top:0;width:100%;aspect-ratio:var(--artw)/var(--arth);
  -webkit-mask-image:linear-gradient(#000 93%,transparent);mask-image:linear-gradient(#000 93%,transparent)}
.art img,.art video{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;display:block}
.art video{opacity:0;transition:opacity .4s}
.art video.on{opacity:1}
.art img.hold{z-index:1;opacity:0;transition:opacity .15s;pointer-events:none}.art img.hold.on{opacity:1}

/* the progressive blur: a softened copy of the whole page, revealed toward the bottom.
   --th is the height of the text block, measured per page, so short pages show more picture */
.listening .pg.story .soft{
  -webkit-mask-image:linear-gradient(to bottom,transparent calc(100% - var(--th,40%) - 30px),rgba(0,0,0,.6) calc(100% - var(--th,40%) - 8px),#000 calc(100% - var(--th,40%) + 14px));
  mask-image:linear-gradient(to bottom,transparent calc(100% - var(--th,40%) - 30px),rgba(0,0,0,.6) calc(100% - var(--th,40%) - 8px),#000 calc(100% - var(--th,40%) + 14px))}
.listening .pg.story .shade{background:linear-gradient(to bottom,rgba(0,0,0,0) calc(100% - var(--th,40%) - 56px),var(--shade-mid) calc(100% - var(--th,40%) + 10px),var(--shade) 100%)}
.soft{position:absolute;inset:0;pointer-events:none;
  -webkit-mask-image:linear-gradient(to bottom,transparent calc(100% - var(--th,40%) - 44px),rgba(0,0,0,.6) calc(100% - var(--th,40%) - 14px),#000 calc(100% - var(--th,40%) + 16px));
  mask-image:linear-gradient(to bottom,transparent calc(100% - var(--th,40%) - 44px),rgba(0,0,0,.6) calc(100% - var(--th,40%) - 14px),#000 calc(100% - var(--th,40%) + 16px))}
.soft img{position:absolute;left:0;width:100%;display:block}
.soft .ext{top:0;height:100%;object-fit:cover}
.soft .top{top:0;aspect-ratio:var(--artw)/var(--arth);height:auto;object-fit:cover;
  -webkit-mask-image:linear-gradient(#000 93%,transparent);mask-image:linear-gradient(#000 93%,transparent)}
/* chapter colour, deepening toward the bottom */
.shade{position:absolute;inset:0;pointer-events:none;
  background:linear-gradient(to bottom,rgba(0,0,0,0) calc(100% - var(--th,40%) - 80px),var(--shade-mid) calc(100% - var(--th,40%) + 10px),var(--shade) 100%)}
/* a faint dark fade at the top keeps the controls readable over bright skies */
.stage::before{content:"";position:absolute;left:0;right:0;top:0;height:150px;z-index:2;pointer-events:none;
  background:linear-gradient(rgba(0,0,0,.38),rgba(0,0,0,0))}

.txt{position:absolute;left:0;right:0;bottom:0;z-index:3;margin:0 auto;max-width:680px;
  padding:0 calc(24px + env(safe-area-inset-right,0px)) calc(30px + env(safe-area-inset-bottom,0px) + var(--gap)) calc(24px + env(safe-area-inset-left,0px));
  text-shadow:0 1px 3px rgba(0,0,0,.55),0 0 18px rgba(0,0,0,.25);font-size:calc(var(--k) * clamp(16px,4.3vw,21px));line-height:1.42}

[dir=rtl] .txt{text-align:right}
.num{font-family:var(--display);font-weight:800;color:var(--gold);font-size:.86em;margin:0 0 .2em}
.para{margin:0 0 .5em}
.ref{font-size:.7em;opacity:.78;margin:.55em 0 0}
.untranslated{outline:1.5px dashed rgba(255,209,102,.8);outline-offset:6px;border-radius:4px}

/* listening: one sentence at a time, fading in and out with the narration */
.caps{display:none}
.listening .pg.story .full{display:none}
.listening .pg.story .caps{display:grid}
/* while listening the single caption sits lower, near the bottom edge, so more of the picture shows */
.listening .pg.story .txt{padding-bottom:calc(12px + env(safe-area-inset-bottom,0px) * .6 + var(--gap))}
.caps .cap{grid-area:1/1;align-self:end;margin:0;font-size:1.12em;line-height:1.38;opacity:0;transform:translateY(6px);transition:opacity .45s ease,transform .45s ease}
.caps .cap.on{opacity:1;transform:none}
.render .caps .cap{transition:none}

/* cover */
.pg.cover .txt{text-align:center;padding-bottom:calc(18px + env(safe-area-inset-bottom,0px) + var(--gap))}
.cover h1{font-family:var(--display);font-weight:900;font-size:calc(var(--k) * clamp(48px,14vw,84px));line-height:.98;margin:0;text-shadow:0 4px 0 rgba(0,0,0,.18),0 2px 18px rgba(0,0,0,.35)}
.cover .sub{font-size:1.08em;margin:.6em 0 1.1em;opacity:.96}
.ctas{display:flex;justify-content:center;gap:12px;max-width:360px;margin:0 auto}
.cta{flex:1 1 0;max-width:170px;display:inline-flex;align-items:center;justify-content:center;gap:.45em;font-family:var(--display);font-weight:800;font-size:.95em;background:var(--gold);color:#2B2233;border:2px solid transparent;border-radius:999px;padding:.66em 1.1em;box-shadow:0 4px 0 #C99A1E,0 8px 22px rgba(0,0,0,.25);cursor:pointer;text-shadow:none;white-space:nowrap;-webkit-tap-highlight-color:transparent}
.cta svg{width:1.15em;height:1.15em;flex:none}
.cta:active{transform:translateY(3px);box-shadow:0 1px 0 #C99A1E}
.cta.alt{background:rgba(255,255,255,.16);color:#fff;border-color:rgba(255,255,255,.7);box-shadow:0 8px 22px rgba(0,0,0,.2);-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px)}
.cta.alt:active{box-shadow:none;background:rgba(255,255,255,.28)}
/* the cover keeps its buttons and QR code while the book reads aloud */
/* cover footer: QR code bottom left; Listen and Read stacked on the right, above the round buttons (thumb reach) */
.cfoot{display:flex;gap:14px;align-items:flex-end;direction:ltr;max-width:440px;margin:0 auto}
.cfoot .ctas{flex:1 1 auto;flex-direction:column;gap:10px;max-width:none;margin:0}
[dir=rtl] .cfoot .ctas{direction:rtl}
.cfoot .cta{max-width:none;width:100%}
.qr{flex:none;box-sizing:border-box;width:min(132px,35vw);aspect-ratio:1;padding:6px;border:0;border-radius:14px;background:#fff;box-shadow:0 6px 20px rgba(0,0,0,.28);cursor:pointer;-webkit-tap-highlight-color:transparent}
.qr svg{display:block;width:100%;height:100%;border-radius:8px}
.qr:empty{visibility:hidden}
.qrbig{position:fixed;inset:0;z-index:30;background:rgba(20,16,30,.62);display:grid;place-items:center;-webkit-backdrop-filter:blur(6px);backdrop-filter:blur(6px)}
.qrbig>div{width:min(82vw,420px);background:#fff;border-radius:24px;padding:16px 16px 10px;box-shadow:0 18px 50px rgba(0,0,0,.4)}
.qrbig svg{display:block;width:100%;height:auto}
.qrbig p{margin:6px 0 0;text-align:center;font:700 18px var(--body);color:#2B2233}
@keyframes nudge{0%,100%{transform:translateY(0)}50%{transform:translateY(3px)}}
.chip{font:700 15px var(--body);white-space:nowrap;background:rgba(255,255,255,.94);color:#2B2233;border-radius:999px;padding:9px 15px;text-decoration:none;box-shadow:0 4px 14px rgba(0,0,0,.25);text-shadow:none}
/* on the cover the round buttons live in the page itself: the menu beside the subtitle, the language under Read.
   The top bar then only shows the pause button while the cover is being read aloud. */
.at-cover #read:not([aria-pressed=true]){display:none}
.subrow{position:relative;direction:ltr}
.subrow .sub{padding:0 54px}
.mslot{position:absolute;right:0;top:50%;transform:translateY(-50%)}
.mslot .menu{top:auto;bottom:56px;text-align:start;text-shadow:none}
.cfoot .lang{text-decoration:none}

/* prayer and grown-ups pages */
.pg.prayer .txt,.pg.grownups .txt{font-size:calc(var(--k) * clamp(15px,4vw,20px))}
.big{font-family:var(--display);font-weight:900;font-size:1.75em;line-height:1.08;margin:0 0 .25em}
.intro{opacity:.85;font-size:.86em;margin:0 0 .9em}
.steps{list-style:none;margin:0 0 1em;padding:0;display:grid;gap:.6em}
.steps li{display:flex;gap:.7em;align-items:flex-start}
.steps .key{flex:none;width:1.75em;height:1.75em;border-radius:.45em;background:var(--gold);color:#3c230f;display:grid;place-items:center;font:900 1em var(--display);text-shadow:none;margin-top:.05em}
.steps b{font-weight:700}
.pray{margin:0 0 .8em;padding:.8em 1em;border-radius:18px;background:rgba(255,255,255,.14);border:1.5px solid rgba(255,255,255,.3)}
.note{font-size:.75em;opacity:.8;margin:0}
.qs{margin:0 0 .9em;padding-inline-start:1.3em;display:grid;gap:.45em}

/* controls */
.bar{position:fixed;z-index:10;left:12px;right:12px;top:calc(12px + env(safe-area-inset-top,0px));display:flex;gap:10px;align-items:center;pointer-events:none}
.bar>*{pointer-events:auto}
/* while the book reads aloud the buttons fade away; any touch brings them back for a few seconds */
.bar,.stage::before{transition:opacity .45s ease}
.hud-off .bar{opacity:0}.hud-off .bar>*{pointer-events:none}.hud-off .stage::before{opacity:0}
.sp{flex:1}
.count{font:700 14px var(--body);color:#fff;background:rgba(0,0,0,.32);padding:8px 13px;border-radius:999px;transition:opacity .2s;-webkit-backdrop-filter:blur(6px);backdrop-filter:blur(6px)}
.count.hide{opacity:0;pointer-events:none}
.rb{width:46px;height:46px;border-radius:50%;border:1.5px solid rgba(255,255,255,.45);background:rgba(255,255,255,.22);color:#fff;display:grid;place-items:center;cursor:pointer;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);box-shadow:0 4px 14px rgba(0,0,0,.18)}
.rb[aria-pressed=true]{background:var(--gold);color:#2B2233;border-color:var(--gold);animation:pulse 1.6s ease-in-out infinite}
@keyframes pulse{0%,100%{box-shadow:0 0 0 0 rgba(255,209,102,.6)}50%{box-shadow:0 0 0 9px rgba(255,209,102,0)}}
.rb:focus-visible,.cta:focus-visible,.chip:focus-visible{outline:3px solid var(--gold);outline-offset:3px}
.mwrap{position:relative}
.menu{position:absolute;top:56px;right:0;min-width:220px;max-width:calc(100vw - 24px);background:var(--paper);color:var(--ink);border-radius:18px;box-shadow:0 12px 36px rgba(0,0,0,.35);padding:6px;display:flex;flex-direction:column}
.menu[hidden]{display:none}
.menu a,.menu button{display:flex;align-items:center;gap:12px;padding:12px 14px;border-radius:12px;font:600 16px var(--body);color:var(--ink);text-decoration:none;background:none;border:0;cursor:pointer;text-align:start;width:100%}
.menu a:hover,.menu button:hover,.menu a:focus-visible,.menu button:focus-visible{background:rgba(47,127,217,.12);outline:none}
.menu .off{opacity:.35;pointer-events:none}
.menu small{display:block;font-weight:500;font-size:12px;opacity:.6}
.menu .note{font:500 12.5px/1.35 var(--body);opacity:.7;padding:6px 14px 10px}
.emo{width:20px;text-align:center;font-size:17px}
.tip{position:fixed;z-index:20;left:50%;top:calc(70px + env(safe-area-inset-top,0px));transform:translateX(-50%);width:min(88vw,380px);background:#1F1A2E;color:#fff;font:600 15px/1.4 var(--body);padding:14px 18px;border-radius:16px;box-shadow:0 10px 30px rgba(0,0,0,.35);text-align:center}
.tip.bottom{top:auto;bottom:calc(14px + env(safe-area-inset-bottom,0px));left:auto;right:12px;transform:none}
.toast{position:fixed;z-index:20;left:50%;bottom:calc(24px + env(safe-area-inset-bottom,0px));transform:translateX(-50%);background:rgba(20,20,30,.88);color:#fff;font:600 15px var(--body);padding:10px 18px;border-radius:99px;opacity:0;transition:opacity .25s;pointer-events:none}
.toast.on{opacity:1}
.render .bar,.render .chip,.render .cta,.render .qr,.render .mslot{display:none}
.render .track{transition:none}

@media (prefers-reduced-motion:reduce){.track.anim{transition-duration:.01s}.caps .cap{transition:opacity .2s}.rb[aria-pressed=true]{animation:none}}

/* text grows with the page itself, so an iPad's wider page gets bigger words, not just more empty space */
@supports (width:1cqw){.txt{font-size:calc(var(--k) * clamp(16px,4.3cqw,30px))}.pg.prayer .txt,.pg.grownups .txt{font-size:calc(var(--k) * clamp(15px,4cqw,28px))}.cover h1{font-size:calc(var(--k) * clamp(48px,14cqw,110px))}}
/* story pages: home, sound and menu stacked on the right edge (thumb side), home lowest, floating just above the
   page's text (app.js sets --bb from where the text starts, so they never cover a word); the menu opens to their left.
   The page count stays small at the top. */
.bar{left:auto;top:auto;right:calc(12px + env(safe-area-inset-right,0px));bottom:var(--bb,calc(40% - 79px));flex-direction:column-reverse;direction:ltr;transition:opacity .45s ease,bottom .35s ease}
.bar .sp{display:none}
.bar .count{position:fixed;left:calc(12px + env(safe-area-inset-left,0px));top:calc(12px + env(safe-area-inset-top,0px))}
.bar .menu{top:auto;bottom:0;right:58px}
/* Furigana (Japanese): small readings above the kanji; a little extra line height so they never touch the line above */
ruby rt{font-size:.5em;font-weight:600;letter-spacing:0;line-height:1;text-transform:none}
.cover h1 ruby rt{font-size:.3em;font-weight:700}
.big ruby rt{font-size:.4em}
html[lang=ja] .txt{line-height:1.72}
html[lang=ja] .para,html[lang=ja] .caps .cap{line-height:1.8}
html[lang=ja] .cover h1{line-height:1.22}
html[lang=ja] .big{line-height:1.3}

/* message form */
.msgf{position:fixed;inset:0;z-index:30;background:rgba(20,16,30,.62);display:grid;place-items:center;padding:12px;overflow:auto}
.msgf form{position:relative;width:min(100%,440px);background:var(--paper);color:var(--ink);border-radius:22px;padding:20px 18px 12px;box-shadow:0 18px 50px rgba(0,0,0,.4);display:flex;flex-direction:column;gap:10px;font:500 16px var(--body)}
.msgf h2{margin:0 36px 2px 0;font:800 22px var(--body)}
.msgf .x{position:absolute;top:8px;right:8px;width:40px;height:40px;border:0;border-radius:50%;background:rgba(0,0,0,.06);color:inherit;font-size:24px;line-height:1;cursor:pointer}
.msgf .cats{display:flex;flex-wrap:wrap;gap:6px}
.msgf .cats input{position:absolute;opacity:0;pointer-events:none}
.msgf .cats span{display:block;padding:7px 11px;border-radius:99px;border:1.5px solid rgba(0,0,0,.15);font:600 14px var(--body);cursor:pointer}
.msgf .cats input:checked+span{background:#2F7FD9;border-color:#2F7FD9;color:#fff}
.msgf .cats input:focus-visible+span{outline:3px solid var(--gold);outline-offset:2px}
.msgf textarea,.msgf input:not([type=radio]):not(.hp){width:100%;box-sizing:border-box;border:1.5px solid rgba(0,0,0,.18);border-radius:12px;padding:11px 12px;font:500 16px var(--body);color:var(--ink);background:#fff;resize:vertical}
.msgf textarea:focus,.msgf input:focus{outline:3px solid rgba(47,127,217,.35);border-color:#2F7FD9}
.msgf .hp{display:none}
.msgf .note{margin:0;font-size:12.5px;line-height:1.35;opacity:.7}
.msgf .send{border:0;border-radius:99px;background:#2F7FD9;color:#fff;font:700 17px var(--body);padding:13px;cursor:pointer}
.msgf .send[disabled]{opacity:.6}
.msgf .alt{margin:0;text-align:center;font-size:12.5px;opacity:.6}
.msgf .alt a,.msgf .err a{color:inherit}
.msgf .err{margin:0;color:#B3261E;font-size:14px}
.msgf .done{text-align:center;padding:14px 0 6px;display:flex;flex-direction:column;gap:14px}
.msgf .done .big{font-size:44px}
