/* ===== KADOSH STORY READER ===== */
/* Themed by the book: --sr-accent, --sr-paper, --sr-ink, --sr-highlight. No web fonts. */

.sr {
    --sr-accent: #7c3aed;
    --sr-paper: #fffaf0;
    --sr-paper-back: color-mix(in srgb, var(--sr-paper) 88%, #d9cbb0);
    --sr-ink: #1e293b;
    --sr-highlight: #fde68a;
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: radial-gradient(ellipse at 50% 40%, #1c2d57 0%, #0b1733 70%);
    color: #fff;
    font-family: "Nunito", ui-rounded, "Segoe UI Rounded", "Segoe UI", system-ui, sans-serif;
    outline: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.sr svg { display: block; width: 1em; height: 1em; }
.sr-loading { margin: auto; font-size: 18px; font-weight: 800; color: rgba(255, 255, 255, .8); }

/* ---------- Toolbar ---------- */
.sr-bar { display: flex; align-items: center; gap: 12px; flex: none; padding: 10px 14px; }
.sr-title { flex: 1; min-width: 0; overflow: hidden; font-size: 17px; font-weight: 900; text-overflow: ellipsis; white-space: nowrap; }
.sr-counter { font-size: 14px; font-weight: 800; color: rgba(255, 255, 255, .72); white-space: nowrap; }
.sr-icon-btn { display: grid; place-items: center; flex: none; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .12); color: #fff; font-size: 22px; cursor: pointer; }
.sr-icon-btn:hover, .sr-icon-btn:focus-visible { background: rgba(255, 255, 255, .22); outline: none; }
.sr-icon-btn:disabled { opacity: .25; cursor: default; }
.sr-sound { background: var(--sr-accent); }
.sr-sound.is-off { background: rgba(255, 255, 255, .12); }

/* ---------- Stage and book ---------- */
.sr-stage { position: relative; display: flex; align-items: center; justify-content: center; flex: 1; min-height: 0; padding: 8px 0 18px; }
.sr-nav { position: absolute; top: 50%; z-index: 10; width: 48px; height: 48px; margin-top: -24px; font-size: 26px; }
.sr-nav.is-prev { left: 8px; }
.sr-nav.is-next { right: 8px; }

.sr-book {
    position: relative;
    border-radius: 6px 14px 14px 6px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .45), 6px 0 0 -2px #efe6d2, 11px 0 0 -4px #e3d7bd;
    color: var(--sr-ink);
    touch-action: pan-y;
    line-height: 1.55;
}

.sr-page {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    overflow: hidden;
    border-radius: inherit;
    background: var(--sr-paper);
}
.sr-page[hidden] { display: none !important; }
.sr-page.is-top { z-index: 2; }
/* The spine's shade on every page. */
.sr-page::before { content: ""; position: absolute; inset: 0 auto 0 0; z-index: 4; width: 5%; background: linear-gradient(90deg, rgba(60, 40, 10, .22), rgba(60, 40, 10, 0)); pointer-events: none; }
.sr-page.is-fading { animation: sr-fade .4s ease; }
@keyframes sr-fade { from { opacity: 0; } }

.sr-under-shade { position: absolute; inset: 0; z-index: 3; display: none; border-radius: inherit; pointer-events: none; }
.sr-flap-wrap { position: absolute; z-index: 5; display: none; pointer-events: none; filter: drop-shadow(0 0 14px rgba(0, 0, 0, .28)); }
.sr-flap { position: absolute; inset: 0; background: var(--sr-paper-back); }

/* ---------- Page layouts ---------- */
.sr-art { position: relative; flex: 0 0 50%; overflow: hidden; background: color-mix(in srgb, var(--sr-accent) 22%, var(--sr-paper)); }
.sr-art img { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.sr-text { position: relative; display: flex; flex-direction: column; gap: .7em; flex: 1; min-width: 0; padding: 1.3em 1.8em 2em; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
/* Centred while it fits, scrollable from the top when it doesn't. */
.sr-text > :first-child { margin-top: auto; }
.sr-text > :last-child { margin-bottom: auto; }
.sr-text > * { flex: none; }

.sr-page.layout-art-right { flex-direction: row-reverse; }
.sr-page.layout-art-top, .sr.is-portrait .sr-page.is-story { flex-direction: column; }
.sr-page.layout-art-top .sr-art { flex-basis: 52%; }
.sr.is-portrait .sr-page.is-story .sr-art { flex-basis: 44%; }
.sr-page.layout-full-art .sr-art { position: absolute; inset: 0; }
.sr-page.layout-full-art .sr-text { position: absolute; right: 4%; bottom: 6%; left: 4%; flex: none; justify-content: flex-end; padding: 1em 1.4em 1.6em; border-radius: 1em; background: color-mix(in srgb, var(--sr-paper) 90%, transparent); }

.sr-folio { position: absolute; right: 1.2em; bottom: .7em; z-index: 3; font-size: .7em; font-weight: 800; color: color-mix(in srgb, var(--sr-ink) 45%, transparent); }

/* ---------- Words ---------- */
.sr-block { margin: 0; font-size: 1em; font-weight: 700; }
.sr-word { border-radius: .25em; cursor: pointer; transition: background-color .12s, box-shadow .12s; }
.sr-word.is-now { background: var(--sr-highlight); box-shadow: 0 0 0 .14em var(--sr-highlight); }
.sr-block.is-scripture { padding: .2em 0 .2em .9em; border-left: .22em solid var(--sr-accent); font-size: 1.04em; font-style: italic; font-weight: 800; }
.sr-ref { display: inline-flex; align-items: center; gap: .35em; margin-top: .35em; font-size: .72em; font-style: normal; font-weight: 800; color: color-mix(in srgb, var(--sr-accent) 70%, var(--sr-ink)); }
blockquote .sr-ref { display: flex; }

/* ---------- Cover ---------- */
.sr-page.is-cover .sr-art { position: absolute; inset: 0; }
.sr-cover-panel { position: relative; z-index: 3; align-self: flex-end; width: 100%; padding: 1.2em 1.6em 1.4em; background: linear-gradient(180deg, transparent, rgba(8, 18, 40, .75) 38%); color: #fff; text-align: center; }
.sr-cover-title { margin: 0; font-size: 2.1em; font-weight: 900; line-height: 1.1; letter-spacing: -.01em; text-shadow: 0 3px 12px rgba(0, 0, 0, .35); }
.sr-cover-subtitle { margin: .3em 0 0; font-size: .95em; font-weight: 700; opacity: .9; }
.sr-cover-panel .sr-ref { justify-content: center; color: #fde68a; }
.sr-cover-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: .6em; margin-top: 1em; }
.sr-btn { display: inline-flex; align-items: center; gap: .45em; min-height: 44px; padding: .55em 1.3em; border: 2px solid rgba(255, 255, 255, .7); border-radius: 999px; background: rgba(255, 255, 255, .12); color: #fff; font: inherit; font-size: .9em; font-weight: 900; cursor: pointer; }
.sr-btn.is-main { border-color: var(--sr-accent); background: var(--sr-accent); box-shadow: 0 4px 0 color-mix(in srgb, var(--sr-accent) 60%, #000); }
.sr-btn:hover, .sr-btn:focus-visible { filter: brightness(1.08); outline: none; }
.sr-btn svg { font-size: 1.1em; }

/* ---------- Ending ---------- */
.sr-page.is-ending { background: radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--sr-accent) 20%, var(--sr-paper)), var(--sr-paper) 65%); }
.sr-ending { display: flex; flex-direction: column; justify-content: center; gap: .7em; width: 100%; padding: 1.4em 2.2em; overflow: auto; }
.sr-ending-title { margin: 0; font-size: 1.9em; font-weight: 900; color: var(--sr-accent); text-align: center; }
.sr-ending-label { margin: .3em 0 0; font-size: .72em; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; color: color-mix(in srgb, var(--sr-ink) 55%, transparent); }
.sr-talk ul { margin: .2em 0 0; padding-left: 1.2em; font-size: .88em; font-weight: 700; }
.sr-ending .sr-btn { border-color: color-mix(in srgb, var(--sr-ink) 25%, transparent); background: #fff; color: var(--sr-ink); }
.sr-ending .sr-btn.is-main { border-color: var(--sr-accent); background: var(--sr-accent); color: #fff; }

/* ---------- Interactions ---------- */
.sr-prompt { position: absolute; top: .7em; left: 50%; z-index: 3; margin: 0; padding: .3em .9em; border-radius: 999px; background: rgba(255, 255, 255, .92); font-size: .72em; font-weight: 900; white-space: nowrap; transform: translateX(-50%); }
.sr-spot { position: absolute; z-index: 3; width: 2.2em; height: 2.2em; min-width: 38px; min-height: 38px; padding: 0; border: 4px solid #fff; border-radius: 50%; background: radial-gradient(circle, #fff 0 22%, color-mix(in srgb, var(--sr-accent) 75%, transparent) 26%); box-shadow: 0 0 0 0 rgba(255, 255, 255, .9), 0 4px 14px rgba(0, 0, 0, .35); cursor: pointer; transform: translate(-50%, -50%); animation: sr-pulse 1.6s ease-out infinite; }
.sr-spot.is-found { animation: none; background: rgba(255, 255, 255, .45); border-color: rgba(255, 255, 255, .8); }
@keyframes sr-pulse { 70% { box-shadow: 0 0 0 1em rgba(255, 255, 255, 0), 0 4px 14px rgba(0, 0, 0, .35); } 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0), 0 4px 14px rgba(0, 0, 0, .35); } }
.sr-bubble { position: absolute; z-index: 4; width: max-content; max-width: 60%; margin: 0; padding: .55em .9em; border-radius: .8em; background: #fff; box-shadow: 0 8px 20px rgba(0, 0, 0, .2); font-size: .8em; font-weight: 800; line-height: 1.35; text-align: center; transform: translateX(-50%); }

.sr-choose { flex: none; margin-top: .1em; padding: .6em .8em; border-radius: .8em; background: color-mix(in srgb, var(--sr-accent) 10%, var(--sr-paper)); }
.sr-question { margin: 0 0 .5em; font-size: .85em; font-weight: 900; }
.sr-choices { display: flex; flex-direction: column; gap: .35em; }
.sr-choice { min-height: 40px; padding: .35em .8em; border: 2px solid color-mix(in srgb, var(--sr-accent) 40%, transparent); border-radius: .7em; background: #fff; color: var(--sr-ink); font: inherit; font-size: .8em; font-weight: 800; text-align: left; cursor: pointer; }
.sr-choice.is-right { border-color: #22a34a; background: #dcfce7; }
.sr-choice.is-wrong { border-color: #f59e0b; animation: sr-shake .4s; }
.sr-choose.is-done .sr-choice:not(.is-right) { opacity: .5; }
.sr-feedback { min-height: 1.3em; margin: .45em 0 0; font-size: .8em; font-weight: 800; }
@keyframes sr-shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

@media (max-width: 720px) {
    .sr-nav { display: none; }
    .sr-bar { padding: 8px 10px; }
    .sr-title { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
    .sr-spot { animation: none; }
    .sr-page.is-fading { animation: none; }
}

/* Popup animation spots: the picture pops out of the dot, then fades. */
.sr-spot-anim {
  position: absolute;
  z-index: 3;
  width: 38%;
  max-width: 260px;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -50%) scale(.2);
  animation: sr-spot-pop .35s ease-out forwards;
}
.sr-spot-anim.is-leaving { opacity: 0; transition: opacity .4s ease; animation: none; transform: translate(-50%, -50%) scale(1); }
@keyframes sr-spot-pop { to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
@media (prefers-reduced-motion: reduce) { .sr-spot-anim { animation-duration: .01s; } }
