/* /read — the book corner's reader chrome (docs/prompts/reader.md).
   Typography IS the product (the Standard Ebooks lesson): serif, ~65ch measure,
   1.75 leading, generous margins. Three page themes — sepia (the reading default),
   paper, dark — while the CHROME (bars, drawers) stays brand navy in all of them.
   Long-form on navy is fatiguing; navy stays in the frame, not behind the words. */

:root {
  --r-navy: #0e1730;
  --r-navy2: #131d38;
  --r-border: #23304f;
  --r-ink-on-navy: #eef2fb;
  --r-muted-on-navy: #97a3c2;
  --r-gold: #f3c849;
  --r-amber: #c98b2d;
  --r-blue: #3b6fe0;
}
/* the three reading themes */
body.reader-page { --p-bg: #f4ecd8; --p-ink: #43382b; --p-soft: #8a7a63; --p-line: #e0d3b8; --p-mark: #f7dd9a; --p-link: #8a5a18; }
body.reader-page[data-theme="paper"] { --p-bg: #fbf9f3; --p-ink: #2f2f33; --p-soft: #77777f; --p-line: #e7e3d8; --p-mark: #ffe9a8; --p-link: #2456b8; }
body.reader-page[data-theme="dark"] { --p-bg: #10131a; --p-ink: #e6e9f2; --p-soft: #a4adc4; --p-line: #29303f; --p-mark: #5f4f16; --p-link: #9cc0ff; }

body.reader-page {
  margin: 0; background: var(--p-bg); color: var(--p-ink);
  font-family: Georgia, "Iowan Old Style", Charter, "Palatino Linotype", "Songti SC", "Noto Serif SC", serif;
  -webkit-font-smoothing: antialiased;
  transition: background .25s, color .25s;
}
@media (prefers-reduced-motion: reduce) { body.reader-page, body.reader-page * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
body.reader-page * { box-sizing: border-box; }

/* ---- top chrome: back-bar + tools (collapses on scroll down, returns on scroll up) ---- */
.r-top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  display: flex; align-items: center; gap: 4px;
  background: var(--r-navy); color: var(--r-ink-on-navy);
  border-bottom: 1px solid var(--r-border);
  padding: 7px 10px; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", sans-serif;
  transition: transform .22s ease;
}
.r-top.hidden { transform: translateY(-110%); }
.r-back {
  color: var(--r-gold); text-decoration: none; font-size: 14px; font-weight: 600;
  padding: 6px 8px; border-radius: 8px; white-space: nowrap;
}
.r-back:hover { background: rgba(243, 200, 73, .12); }
.r-toptitle { flex: 1; font-size: 13px; color: var(--r-muted-on-navy); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 4px; }
.r-btn {
  background: none; border: none; color: var(--r-ink-on-navy); font-size: 17px;
  padding: 6px 8px; border-radius: 8px; cursor: pointer; line-height: 1;
}
.r-btn:hover { background: rgba(255, 255, 255, .08); }
.r-btn[aria-pressed="true"] { background: rgba(243, 200, 73, .18); }
.r-progress { position: fixed; top: 0; left: 0; height: 3px; background: var(--r-gold); z-index: 41; width: 0; }

/* ---- resume bar ---- */
.r-resume {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px;
  margin: 0 0 14px; padding: 9px 12px; border-radius: 10px;
  background: var(--r-navy2); color: var(--r-ink-on-navy); border: 1px solid var(--r-border);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", sans-serif; font-size: 13.5px;
}
.r-resume a { color: var(--r-gold); font-weight: 600; text-decoration: none; }
.r-resume .x { margin-left: auto; cursor: pointer; border: 0; background: none; color: var(--r-muted-on-navy); font-size: 15px; }

/* ---- the page ---- */
.r-wrap { max-width: 46rem; margin: 0 auto; padding: 64px 20px 40px; }
.r-bookhead { margin: 18px 0 6px; }
.r-bookhead h1 { font-size: 1.35rem; line-height: 1.35; margin: 0 0 2px; font-weight: 700; }
.r-bookhead .who { color: var(--p-soft); font-size: .95rem; font-style: italic; }
.r-chaphead { margin: 26px 0 6px; }
.r-chaphead h2 { font-size: 1.1rem; letter-spacing: .02em; margin: 0; font-weight: 700; }
.r-chapmeta { color: var(--p-soft); font-size: .82rem; margin-top: 3px; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", sans-serif; }

.r-text { font-size: var(--r-fs, 18px); line-height: 1.75; }
.r-text p { margin: 0 0 1em; max-width: 65ch; }
.r-text p.tts-on { background: var(--p-mark); border-radius: 4px; box-shadow: 0 0 0 6px var(--p-mark); }
.r-text mark.hit { background: var(--p-mark); color: inherit; border-radius: 3px; padding: 0 1px; }
.r-text .verse { white-space: pre-wrap; }
.r-text sup.fn { cursor: pointer; color: var(--p-link); font-family: -apple-system, sans-serif; font-size: .72em; padding: 0 2px; }
.r-text .fn-body { border-left: 3px solid var(--p-line); background: rgba(0, 0, 0, .035); padding: 8px 12px; margin: 8px 0 14px; font-size: .9em; color: var(--p-soft); border-radius: 0 6px 6px 0; }
body.reader-page[data-theme="dark"] .r-text .fn-body { background: rgba(255, 255, 255, .04); }
/* modern-rendering block (輕世金書 both registers — ours is labeled, never the original) */
.r-modern { border-left: 3px solid var(--r-amber); padding: 10px 14px; margin: 4px 0 1.2em; border-radius: 0 8px 8px 0; background: rgba(201, 139, 45, .07); }
.r-modern .tag { display: block; font-size: .74rem; color: var(--r-amber); margin-bottom: 4px; font-family: -apple-system, "PingFang SC", sans-serif; }

/* ---- tianlu: cover plate + cross-language pair + three-register UI + woodcut plates ---- */
.r-cover { margin: 4px 0 14px; text-align: center; }
.r-cover img { max-width: min(100%, 22rem); border-radius: 6px; box-shadow: 0 2px 14px rgba(0, 0, 0, .16); }
.r-cover figcaption { font-size: .82rem; color: var(--p-soft); margin-top: 6px; font-family: "Songti SC", "Noto Serif SC", serif; letter-spacing: .04em; }
.r-pair { display: inline-flex; align-items: baseline; gap: 4px; margin-top: 10px; padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--r-amber); color: var(--r-amber); text-decoration: none; font-size: .8rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", sans-serif; }
.r-pair:hover { background: rgba(201, 139, 45, .1); }
.r-pair .pl { font-weight: 600; }
.r-reg { min-width: 30px; font-size: 15px; font-family: "Songti SC", "Noto Serif SC", serif; }
.r-reglabel { font-size: .74rem; color: var(--p-soft); margin: 0 0 10px; letter-spacing: .03em;
  font-family: -apple-system, "PingFang SC", sans-serif; }
.r-inprog { border-left: 3px solid var(--r-amber); background: rgba(201, 139, 45, .08); color: var(--p-soft);
  padding: 10px 14px; margin: 4px 0 16px; border-radius: 0 8px 8px 0; font-size: .9rem; line-height: 1.7;
  font-family: -apple-system, "PingFang SC", sans-serif; }
.r-plate { margin: 8px 0 22px; text-align: center; }
.r-plate img { max-width: min(100%, 24rem); border-radius: 5px; box-shadow: 0 1px 10px rgba(0, 0, 0, .14); }
.r-plate figcaption { font-size: .82rem; color: var(--p-soft); margin-top: 6px; font-family: "Songti SC", "Noto Serif SC", serif; letter-spacing: .05em; }
.r-margin { border-top: 1px dashed var(--p-line); margin-top: 26px; padding-top: 12px; }
.r-margin .tag { display: block; font-size: .74rem; color: var(--p-soft); margin-bottom: 6px; font-family: -apple-system, "PingFang SC", sans-serif; }
.r-margin p { font-size: .92em; color: var(--p-soft); line-height: 1.8; margin: 0 0 .5em; font-family: "Songti SC", "Noto Serif SC", STSong, serif; }
/* provenance block in the foot */
.r-prov { margin-top: 12px; }
.r-prov dt { font-weight: 600; color: var(--p-ink); margin-top: 8px; font-size: .82rem; }
.r-prov dd { margin: 2px 0 0; }

/* per-script rules (site policy): CJK serif + taller leading; fa RTL */
.r-text:lang(zh-Hans), .r-text:lang(zh-Hant), .r-text:lang(zh) { line-height: 1.85; font-family: "Songti SC", "Noto Serif SC", STSong, SimSun, serif; }
.r-text:lang(ja) { line-height: 1.85; font-family: "Hiragino Mincho ProN", "Noto Serif JP", serif; }
.r-text:lang(ko) { line-height: 1.85; font-family: "Apple Myungjo", "Noto Serif KR", serif; }
.r-text:lang(fa) { direction: rtl; text-align: right; line-height: 2; font-family: "Geeza Pro", "Noto Naskh Arabic", serif; }

/* ---- chapter nav footer ---- */
.r-nav { display: flex; gap: 10px; align-items: center; margin: 30px 0 8px; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", sans-serif; }
.r-nav button, .r-nav a.nbtn {
  flex: 1; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--p-line);
  background: none; color: var(--p-ink); font-size: 14px; cursor: pointer; text-align: center; text-decoration: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.r-nav button:hover, .r-nav a.nbtn:hover { border-color: var(--p-soft); }
.r-nav button[disabled] { opacity: .35; cursor: default; }
.r-fin { text-align: center; color: var(--p-soft); font-style: italic; margin: 26px 0 6px; }
.r-fin a { color: var(--p-link); }

/* ---- book footer: edition/license/privacy ---- */
.r-foot { border-top: 1px solid var(--p-line); margin-top: 34px; padding-top: 14px; color: var(--p-soft); font-size: .8rem; line-height: 1.7; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", sans-serif; }
.r-foot a { color: var(--p-link); }
.r-chip {
  display: inline-block; margin: 4px 6px 4px 0; padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--r-amber); color: var(--r-amber); text-decoration: none; font-size: .8rem;
}
.r-chip:hover { background: rgba(201, 139, 45, .1); }

/* ---- drawers (ToC / tools / search) ---- */
.r-scrim { position: fixed; inset: 0; background: rgba(4, 8, 18, .5); z-index: 48; }
.r-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(360px, 92vw); z-index: 50;
  background: var(--r-navy); color: var(--r-ink-on-navy); border-left: 1px solid var(--r-border);
  overflow-y: auto; padding: 14px 16px 24px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", sans-serif;
}
.r-drawer h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--r-muted-on-navy); margin: 18px 0 8px; }
.r-drawer h3:first-child { margin-top: 4px; }
.r-toc a { display: block; padding: 7px 9px; border-radius: 8px; color: var(--r-ink-on-navy); text-decoration: none; font-size: 13.5px; line-height: 1.4; }
.r-toc a:hover { background: rgba(255, 255, 255, .07); }
.r-toc a.cur { background: rgba(243, 200, 73, .15); color: var(--r-gold); }
.r-close { position: sticky; top: 0; float: right; background: none; border: 0; color: var(--r-muted-on-navy); font-size: 20px; cursor: pointer; padding: 2px 6px; }
.r-bm { display: flex; align-items: center; gap: 6px; }
.r-bm a { flex: 1; }
.r-bm .del { background: none; border: 0; color: var(--r-muted-on-navy); cursor: pointer; font-size: 14px; }
.r-drawer .meta { color: var(--r-muted-on-navy); font-size: 12.5px; line-height: 1.65; }

/* theme + font controls */
.r-seg { display: flex; gap: 6px; margin: 6px 0 2px; }
.r-seg button {
  flex: 1; padding: 9px 6px; border-radius: 9px; border: 1px solid var(--r-border);
  background: var(--r-navy2); color: var(--r-ink-on-navy); cursor: pointer; font-size: 13px;
}
.r-seg button[aria-pressed="true"] { border-color: var(--r-gold); color: var(--r-gold); }
.r-seg .sw-sepia { background: #f4ecd8; color: #43382b; }
.r-seg .sw-paper { background: #fbf9f3; color: #2f2f33; }
.r-seg .sw-dark { background: #0d1424; color: #c3cde4; }

/* in-book search */
.r-search input {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--r-border);
  background: var(--r-navy2); color: var(--r-ink-on-navy); font-size: 15px; outline: none;
}
.r-search input:focus { border-color: var(--r-gold); }
.r-hits { margin-top: 10px; }
.r-hits a { display: block; padding: 8px 9px; border-radius: 8px; color: var(--r-ink-on-navy); text-decoration: none; font-size: 12.5px; line-height: 1.5; }
.r-hits a:hover { background: rgba(255, 255, 255, .07); }
.r-hits a b { color: var(--r-gold); font-weight: 600; display: block; font-size: 11.5px; }
.r-hits mark { background: rgba(243, 200, 73, .3); color: inherit; border-radius: 2px; }
.r-hits .none { color: var(--r-muted-on-navy); font-size: 12.5px; padding: 6px 2px; }

/* ---- TTS bar (bottom-LEFT — house rule: bottom-right belongs to floaty helpers) ---- */
.r-tts {
  position: fixed; left: 12px; bottom: 12px; z-index: 45; display: flex; gap: 7px; align-items: center;
  background: var(--r-navy); color: var(--r-ink-on-navy); border: 1px solid var(--r-border);
  border-radius: 999px; padding: 7px 10px; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", sans-serif;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .35); max-width: calc(100vw - 24px);
}
.r-tts select { background: var(--r-navy2); color: var(--r-ink-on-navy); border: 1px solid var(--r-border); border-radius: 8px; font-size: 12px; padding: 4px 6px; max-width: 34vw; }
.r-tts .stop { background: var(--r-gold); color: #1c2440; border: 0; border-radius: 999px; padding: 6px 12px; font-weight: 700; cursor: pointer; font-size: 13px; }

/* selection share chip */
.r-selshare {
  position: absolute; z-index: 46; background: var(--r-navy); color: var(--r-gold);
  border: 1px solid var(--r-border); border-radius: 999px; padding: 6px 12px; font-size: 12.5px;
  cursor: pointer; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", sans-serif;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .35);
}

/* toast */
.r-toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 60;
  background: var(--r-navy); color: var(--r-ink-on-navy); border: 1px solid var(--r-border);
  padding: 9px 16px; border-radius: 999px; font-size: 13px; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", sans-serif;
}

/* Bible reader extras */
.r-vnum { color: var(--p-link); font-size: .68em; vertical-align: super; margin-right: 3px; font-family: -apple-system, sans-serif; }
.r-text:lang(fa) .r-vnum { margin-right: 0; margin-left: 3px; }
.r-text p.v { margin: 0 0 .45em; }
.r-text h3.sect { font-size: 1em; margin: 1.2em 0 .5em; color: var(--p-soft); font-style: italic; font-weight: 600; }
.r-pickrow { display: flex; gap: 8px; margin: 12px 0 4px; flex-wrap: wrap; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", sans-serif; }
.r-pickrow select {
  padding: 8px 10px; border-radius: 9px; border: 1px solid var(--p-line); background: var(--p-bg);
  color: var(--p-ink); font-size: 14px; max-width: 46vw;
}
.r-loading { color: var(--p-soft); font-size: .9rem; margin: 30px 0; text-align: center; }

@media (max-width: 640px) {
  .r-wrap { padding: 58px 16px 34px; }
  .r-text { font-size: calc(var(--r-fs, 18px) - 1px); }
  .r-toptitle { display: none; }
  .r-top { padding: 6px 6px; }
}

/* tap-a-paragraph to read aloud from there (owner request) */
#rText.tap-read p[data-p]{position:relative}
#rText.tap-read p[data-p]:hover::before{content:"\25B6";position:absolute;left:-1.35em;top:.28em;font-size:.62em;color:var(--p-soft);opacity:.5}
#rText .r-sent.tts-on{background:var(--p-mark);border-radius:3px;-webkit-box-decoration-break:clone;box-decoration-break:clone;box-shadow:0 0 0 2px var(--p-mark)}
@media(hover:hover){#rText.tap-read .r-sent:hover{background:rgba(128,128,128,.14);border-radius:3px}}
@media(hover:none){#rText.tap-read p[data-p]:hover::before{content:none}}
