/* Moribund — cinematic reader: toolbar buttons, scene layer, beats.
   Nothing here applies until reader-cinema.js finds a valid cue sheet
   (html.has-cine) and cinematic mode is on (html.reader-cine-on). */

/* ---------- Toolbar: Cinematic / Just read, Sound ---------- */
.reader-cine { display: flex; gap: 6px; flex: none; }
.reader-cine[hidden], .reader-cine button[hidden] { display: none; }
.reader-cine button {
  display: inline-flex; align-items: center; gap: 7px; height: 40px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: 0; background: transparent; color: var(--muted);
  font-family: var(--sub); font-size: .86rem; letter-spacing: .06em; cursor: pointer;
  transition: color .2s ease, background .2s ease, border-color .2s ease;
}
.reader-cine button:hover { color: var(--text); }
.reader-cine button:focus-visible { outline: 1px solid var(--text); outline-offset: 2px; }
.reader-cine button[aria-pressed="true"] { color: var(--text); border-color: var(--text); background: rgba(242, 242, 240, .07); }
.reader-cine svg { flex: none; width: 17px; height: 17px; }
.reader-cine .ico-on, .reader-cine [aria-pressed="true"] .ico-off { display: none; }
.reader-cine [aria-pressed="true"] .ico-on { display: inline; }
html[data-theme="light"] .reader-cine button[aria-pressed="true"] { background: rgba(20, 20, 20, .06); }
/* Phones: icon only (the label stays for screen readers); the icons carry the state. */
@media (max-width: 580px) {
  .reader-cine button { width: 40px; padding: 0; justify-content: center; }
  .reader-cine .cine-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
}

/* ---------- Scene layer: fixed canvas under a dark scrim, behind the page ---------- */
.reader-scene-layer {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  opacity: 0; transition: opacity .4s ease; background: #040405;
}
.reader-scene-layer.is-on { opacity: 1; }
/* Sized to the large viewport so the phone address bar showing/hiding never resizes it. */
.reader-scene { position: absolute; top: 0; left: 0; width: 100%; height: 100vh; height: 100lvh; display: block; }
/* The text column sits on #040405 at .58; the edges let more of the scene through. While a
   scene shows (html.reader-scene-on, set by reader-cinema.js) the chapter text is a lighter
   grey with a soft dark shadow, so it holds 4.5:1 against the brightest frames. */
.reader-scrim {
  position: absolute; inset: 0;
  background:
    linear-gradient(90deg, rgba(4, 4, 5, .4) 0, rgba(4, 4, 5, .58) calc(50% - 23rem), rgba(4, 4, 5, .58) calc(50% + 23rem), rgba(4, 4, 5, .4) 100%),
    linear-gradient(180deg, rgba(4, 4, 5, .35) 0, transparent 22%, transparent 78%, rgba(4, 4, 5, .35) 100%);
}
@media (max-width: 760px) { .reader-scrim { background: rgba(4, 4, 5, .58); } }
html.reader-scene-on:not([data-theme="light"]) .chapter-body,
html.reader-scene-on:not([data-theme="light"]) .chapter-body p {
  color: #deded9;
  text-shadow: 0 0 3px rgba(0, 0, 0, .9), 0 1px 2px rgba(0, 0, 0, .85), 0 0 14px rgba(0, 0, 0, .65);
}
/* Light theme: dark text on a pale wash; a pale halo instead of a dark shadow. */
html[data-theme="light"] .reader-scene-layer { background: #ecebe7; }
html[data-theme="light"] .reader-scrim { background: rgba(243, 243, 241, .8); }
html[data-theme="light"].reader-scene-on .chapter-body { text-shadow: 0 0 2px rgba(243, 243, 241, .9), 0 0 12px rgba(243, 243, 241, .7); }
html.reader-cine-on #main, html.reader-cine-on .site-footer { position: relative; z-index: 1; }
@media (prefers-reduced-motion: reduce) { .reader-scene-layer { transition-duration: .15s; } }

/* ---------- Beats ---------- */
.chapter-body:not(.is-verse) > .beat:first-child > p:first-child:first-line { font-variant: small-caps; letter-spacing: .04em; }
/* Hold beats: the text pins while the scene plays through `hold` extra screens. */
html.reader-cine-on .beat-hold { min-height: calc(100svh * (1 + var(--hold, 0))); }
html.reader-cine-on .beat-pin {
  position: sticky; top: 0; min-height: 100svh;
  display: flex; flex-direction: column; justify-content: center;
}
/* Text taller than the screen (e.g. at the largest text size): not pinned, so no line is
   ever held off-screen. It scrolls normally and the scene plays through the hold
   distance as space below the text. reader-cinema.js sets .beat-tall on each re-measure. */
html.reader-cine-on .beat-hold.beat-tall { min-height: 0; padding-bottom: calc(100svh * var(--hold, 0)); }
html.reader-cine-on .beat-hold.beat-tall > .beat-pin { position: static; min-height: 0; }

/* ---------- Toolbar: Save offline ---------- */
.reader-offline {
  display: inline-flex; align-items: center; gap: 7px; height: 40px; padding: 0 12px; flex: none;
  border: 1px solid var(--line-strong); border-radius: 0; background: transparent; color: var(--muted);
  font-family: var(--sub); font-size: .86rem; letter-spacing: .06em; cursor: pointer;
  transition: color .2s ease, background .2s ease, border-color .2s ease;
}
.reader-offline[hidden] { display: none; }
.reader-offline:hover:not(:disabled) { color: var(--text); }
.reader-offline:focus-visible { outline: 1px solid var(--text); outline-offset: 2px; }
.reader-offline[aria-pressed="true"] { color: var(--text); border-color: var(--text); background: rgba(242, 242, 240, .07); }
html[data-theme="light"] .reader-offline[aria-pressed="true"] { background: rgba(20, 20, 20, .06); }
.reader-offline svg { flex: none; width: 17px; height: 17px; }
@media (max-width: 580px) {
  .reader-offline { width: 40px; padding: 0; justify-content: center; }
  .reader-offline .offline-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
}
