/* Read: the full-window presentation player shared by every /read/<book> page */
:root{--ink:#efe6d0;--soft:#cbbf9f;--gilt:#d4b066;--glass:rgba(8,9,14,.6);--line:rgba(212,176,102,.28);
  --serif:'Spectral',Georgia,'Times New Roman',serif;--display:'Marcellus','Trajan Pro',Georgia,serif}
*,*::before,*::after{box-sizing:border-box}
html,body{margin:0;height:100%;background:#05060a;color:var(--ink);overflow:hidden;-webkit-font-smoothing:antialiased}
body{font-family:var(--serif);font-size:1.125rem;line-height:1.7;overscroll-behavior:none}
button{font:inherit;color:inherit}
:focus-visible{outline:2px solid var(--gilt);outline-offset:3px}

/* ---- stage: two image layers that crossfade */
.stage{position:fixed;inset:0;overflow:hidden;background:#05060a;touch-action:pan-y}
.layer{position:absolute;inset:0;opacity:0;transition:opacity 1.3s ease}
.layer.on{opacity:1}
.layer img{position:absolute;left:0;top:0;max-width:none;transform-origin:0 0;will-change:transform;user-select:none;-webkit-user-drag:none}
/* parables and visions: the soft dream edge from the book pages */
.layer.dream::after{content:"";position:absolute;inset:0;pointer-events:none;
  -webkit-backdrop-filter:blur(12px) saturate(.8) brightness(1.06);backdrop-filter:blur(12px) saturate(.8) brightness(1.06);
  -webkit-mask-image:radial-gradient(ellipse 70% 66% at 50% 50%,transparent 48%,#000 100%);
  mask-image:radial-gradient(ellipse 70% 66% at 50% 50%,transparent 48%,#000 100%)}
/* a gentle vignette so the panel and controls always read */
.stage::after{content:"";position:absolute;inset:0;pointer-events:none;
  background:radial-gradient(ellipse at center,transparent 55%,rgba(0,0,0,.35) 100%),
             linear-gradient(180deg,rgba(0,0,0,.35) 0%,transparent 14%,transparent 82%,rgba(0,0,0,.45) 100%)}

/* ---- the text panel */
.panel{position:fixed;z-index:5;bottom:clamp(5.5rem,11vh,7rem);max-height:calc(100svh - clamp(4.5rem,9vh,6rem) - clamp(5.5rem,11vh,7rem));width:min(34rem,36vw);
  display:flex;flex-direction:column;padding:1.6rem 1.8rem 1.2rem;background:var(--glass);
  -webkit-backdrop-filter:blur(14px) saturate(1.1);backdrop-filter:blur(14px) saturate(1.1);
  border:1px solid rgba(255,255,255,.06);border-radius:4px;box-shadow:0 30px 70px -30px rgba(0,0,0,.8);
  opacity:0;transform:translateY(10px);transition:opacity .9s ease,transform .9s ease}
.panel.left{left:clamp(1.25rem,3.5vw,3.5rem)}
.panel.right{right:clamp(1.25rem,3.5vw,3.5rem)}
.panel.on{opacity:1;transform:none}
.panel .ref{font-family:var(--display);color:var(--gilt);font-size:.95rem;letter-spacing:.06em;margin:0 0 .4rem}
.panel .ref .tag{font-style:italic;color:var(--soft);letter-spacing:.02em}
.panel h1{font-family:var(--display);font-weight:400;font-size:clamp(1.55rem,2.3vw,2.15rem);line-height:1.12;margin:0 0 .35rem}
.panel .sub{color:var(--soft);font-style:italic;font-size:1rem;margin:0 0 1rem;padding-bottom:1rem;border-bottom:1px solid var(--line)}
.verses{position:relative;flex:1 1 auto;min-height:0;overflow-y:auto;scrollbar-width:thin;scrollbar-color:var(--line) transparent;padding-right:.4rem;
  -webkit-mask-image:linear-gradient(180deg,transparent 0,#000 .9rem,#000 calc(100% - 1.2rem),transparent 100%);
  mask-image:linear-gradient(180deg,transparent 0,#000 .9rem,#000 calc(100% - 1.2rem),transparent 100%)}
.verses p{margin:0;padding:.18em 0 .38em;font-size:1.06rem;line-height:1.8;transition:color .6s ease,opacity .6s ease}
.verses p:first-child{padding-top:1rem}
.verses p:last-child{padding-bottom:3.2rem}  /* room for the Continue button over the end */
.verses sup{font-family:var(--display);color:var(--gilt);font-size:.62em;margin-right:.35em;vertical-align:.55em}
/* narration: the current verse stays bright, the rest step back */
.panel.narrating .verses p{opacity:.5}
.panel.narrating .verses p.now{opacity:1}

/* "continue" cue at the foot of the panel */
.cue{position:absolute;right:1.2rem;bottom:1rem;display:flex;align-items:center;gap:.55rem;border:1px solid var(--line);
  background:rgba(212,176,102,.08);color:var(--gilt);font-family:var(--display);font-size:1rem;letter-spacing:.04em;
  padding:.45rem 1rem .45rem 1.1rem;border-radius:999px;cursor:pointer;opacity:0;pointer-events:none;transition:opacity .8s ease,background .2s}
.cue::after{content:"";width:.45em;height:.45em;border-top:1.5px solid currentColor;border-right:1.5px solid currentColor;transform:rotate(45deg)}
.cue.on{opacity:1;pointer-events:auto;animation:breathe 2.8s ease-in-out infinite}
.cue:hover{background:rgba(212,176,102,.18)}
@keyframes breathe{50%{box-shadow:0 0 0 6px rgba(212,176,102,.12)}}

/* ---- top bar: hairline progress for the scene, and the place */
.progress{position:fixed;z-index:6;left:0;top:0;height:2px;width:100%;background:rgba(255,255,255,.06)}
.progress i{display:block;height:100%;width:100%;background:var(--gilt);transform-origin:0 50%;transform:scaleX(0)}
.top{position:fixed;z-index:6;left:0;right:0;top:0;display:flex;align-items:center;gap:1rem;padding:1rem clamp(1.25rem,3.5vw,3.5rem);
  font-family:var(--display);transition:opacity .6s ease}
.top a,.top .place{color:var(--ink);text-decoration:none;letter-spacing:.03em}
.top .back{display:flex;align-items:center;gap:.5rem;color:var(--soft)}
.top .back:hover{color:var(--ink)}
.top .back::before{content:"";width:.45em;height:.45em;border-left:1.5px solid currentColor;border-bottom:1.5px solid currentColor;transform:rotate(45deg)}
.top .place{margin-left:auto;color:var(--soft);font-size:.95rem}
.top .place b{color:var(--gilt);font-weight:400}
.top .report{border:0;background:none;cursor:pointer;width:2.25rem;height:2.25rem;margin:-.5rem -.6rem -.5rem 0;border-radius:999px;display:grid;place-items:center;color:var(--soft)}
.top .report:hover{color:var(--ink);background:rgba(255,255,255,.08)}
.top .report svg{width:1.05rem;height:1.05rem;fill:currentColor}
.top .report[hidden]{display:none}

/* ---- controls */
.controls{position:fixed;z-index:6;left:50%;bottom:clamp(1rem,3vh,1.75rem);transform:translateX(-50%);display:flex;align-items:center;gap:.25rem;
  padding:.3rem;background:rgba(8,9,14,.55);-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);
  border:1px solid rgba(255,255,255,.08);border-radius:999px;transition:opacity .6s ease}
.controls button{border:0;background:none;cursor:pointer;width:2.75rem;height:2.75rem;border-radius:999px;display:grid;place-items:center;color:var(--ink)}
.controls button:hover{background:rgba(255,255,255,.08)}
.controls button.main{width:3.25rem;height:3.25rem;background:var(--gilt);color:#14110a}
.controls button.main:hover{background:#e2c27e}
.controls button[aria-pressed="true"]{color:var(--gilt)}
.controls button[hidden]{display:none}
.controls svg{width:1.25rem;height:1.25rem;fill:currentColor}
.controls .sep{width:1px;height:1.6rem;background:rgba(255,255,255,.12);margin:0 .2rem}
.controls select{font-family:var(--display);font-size:.95rem;color:var(--ink);background:transparent;border:0;padding:0 .6rem;height:2.75rem;cursor:pointer}
.controls select option{color:#000}
body.idle .controls,body.idle .top{opacity:0;pointer-events:none}
body.idle{cursor:none}

/* ---- chapter card and start screen */
.card{position:fixed;z-index:4;inset:0;display:grid;place-items:center;pointer-events:none;opacity:0;transition:opacity 1.1s ease}
.card.on{opacity:1}
.card span{font-family:var(--display);font-size:clamp(2.2rem,6vw,4.4rem);letter-spacing:.06em;color:var(--ink);
  text-shadow:0 2px 30px rgba(0,0,0,.8);display:flex;align-items:center;gap:1.4rem}
.card span::before,.card span::after{content:"";width:clamp(2rem,8vw,6rem);height:1px;background:var(--gilt)}

.start{position:fixed;z-index:10;inset:0;display:grid;align-items:end;background:#05060a;overflow-y:auto;-webkit-overflow-scrolling:touch}
.start img{position:fixed;inset:0;width:100%;height:100%;object-fit:cover;opacity:.75;animation:dawn 3s ease-out both}
.start::after{content:"";position:fixed;inset:0;background:linear-gradient(180deg,rgba(5,6,10,.1) 30%,rgba(5,6,10,.92) 100%)}
@keyframes dawn{from{opacity:0;transform:scale(1.05)}}
.start .startback{position:fixed;z-index:2;top:0;left:0;padding:1rem clamp(1.25rem,3.5vw,3.5rem);border-radius:0;font-size:1rem;letter-spacing:.03em;
  display:flex;align-items:center;gap:.5rem;color:var(--soft)}
.start .startback:hover{color:var(--ink)}
.start .startback::before{content:"";width:.45em;height:.45em;border-left:1.5px solid currentColor;border-bottom:1.5px solid currentColor;transform:rotate(45deg)}
.start .inner{position:relative;z-index:1;padding:0 clamp(1.25rem,6vw,5rem) clamp(2.5rem,9vh,6rem);max-width:60rem}
.start h1{font-family:var(--display);font-weight:400;font-size:clamp(2.6rem,7vw,5.8rem);line-height:1;margin:0 0 1rem}
.start p{color:var(--soft);font-style:italic;margin:0 0 2rem;max-width:40ch}
.start .go{display:flex;flex-wrap:wrap;gap:.8rem}
.start button,.start a{font-family:var(--display);font-size:1.1rem;letter-spacing:.04em;border-radius:999px;padding:.75rem 1.6rem;cursor:pointer;text-decoration:none}
.start .primary{border:0;background:var(--gilt);color:#14110a}
.start .primary:hover{background:#e2c27e}
.start .ghost{border:1px solid rgba(239,230,208,.35);background:rgba(5,6,10,.35);color:var(--ink)}
.start .ghost:hover{border-color:var(--ink)}
.start[hidden]{display:none}

/* ---- tune mode (?tune): set the start and end frames by hand */
.tune{position:fixed;z-index:9;right:1rem;top:3.5rem;width:20rem;padding:1rem;background:rgba(8,9,14,.85);border:1px solid var(--line);border-radius:6px;font-size:.85rem;line-height:1.4}
.tune p{margin:0 0 .6rem;color:var(--soft)}
.tune .row{display:flex;flex-wrap:wrap;gap:.4rem;margin-bottom:.6rem}
.tune button{border:1px solid var(--line);background:none;border-radius:4px;padding:.3rem .6rem;cursor:pointer}
.tune button:hover{background:rgba(212,176,102,.15)}
.tune textarea{width:100%;height:5rem;background:#000;color:var(--ink);border:1px solid var(--line);font:12px ui-monospace,monospace}
body.tuning .layer.on img{cursor:grab}
body.tuning .panel{opacity:.25}

/* ---- phones and portrait windows: the panel becomes a sheet at the bottom */
@media (max-aspect-ratio:1/1),(max-width:760px){
  .panel,.panel.left,.panel.right{left:.6rem;right:.6rem;width:auto;top:auto;bottom:calc(4.6rem + env(safe-area-inset-bottom,0px));max-height:min(46svh,28rem);padding:.85rem 1rem .7rem}
  .panel.narrating h1{font-size:1.05rem}
  .panel .ref{font-size:.8rem;margin-bottom:.2rem}
  .panel h1{font-size:1.25rem;margin-bottom:.2rem}
  .panel .sub{font-size:.85rem;line-height:1.45;margin-bottom:.3rem;padding-bottom:.5rem}
  .panel.narrating .sub{display:none}
  .verses p{font-size:.95rem;line-height:1.6;padding:.12em 0 .3em}
  .verses p:first-child{padding-top:.6rem}
  .cue{right:.8rem;bottom:.7rem;font-size:.9rem;padding:.35rem .9rem .35rem 1rem}
  .top{padding:.8rem 1rem}
  .top .place{font-size:.85rem}
  .controls{bottom:calc(.6rem + env(safe-area-inset-bottom,0px))}
  .controls select{padding:0 .3rem}
  .controls .sep:first-of-type{display:none}
  .controls button{width:2.5rem;height:2.5rem}
}
@media (prefers-reduced-motion:reduce){
  .layer{transition-duration:.6s}
  .cue.on{animation:none}
  .start img{animation:none}
}
/* very narrow windows (large text zoom on a phone): the control bar keeps only what fits */
@media (max-width:340px){
  .controls{max-width:calc(100vw - 1rem)}
  .controls select,.controls .sep{display:none}
}
