/* Risen Word Bible reader.
   Layout: one reading column (~34em) under a slim sticky bar; chapter turns at the foot.
   Sheets (books, search, text settings) cover the page and keep the place underneath. */
:root {
  --paper: #f4f5f7;
  --ink: #1d2230;
  --ink-soft: #5d6578;
  --rule: #d9dde5;
  --raised: #ffffff;
  --accent: #2c4a86;
  --accent-wash: #e3e9f5;
  --mark: #fbeeb8;
  --font-text: "Literata", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-ui: "Alegreya Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --size: 19px;
  --measure: 34em;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #13161c; --ink: #e2e5eb; --ink-soft: #969db0; --rule: #2a303b;
    --raised: #1b1f27; --accent: #9db4e6; --accent-wash: #232c40; --mark: #4a3f17;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #13161c; --ink: #e2e5eb; --ink-soft: #969db0; --rule: #2a303b;
  --raised: #1b1f27; --accent: #9db4e6; --accent-wash: #232c40; --mark: #4a3f17;
  color-scheme: dark;
}

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---- top bar ---- */
.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 4px;
  padding: calc(6px + env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) 6px max(12px, env(safe-area-inset-left, 0px));
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}
.where {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px;
  font-size: 1.08rem; font-weight: 700;
  min-width: 0;
}
.where span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.where::after {
  content: ""; width: 7px; height: 7px; flex: none;
  border-right: 2px solid var(--ink-soft); border-bottom: 2px solid var(--ink-soft);
  transform: translateY(-2px) rotate(45deg);
}
.where:hover, .icon:hover { background: var(--accent-wash); }
.spacer { flex: 1; }
.icon { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.icon svg { width: 21px; height: 21px; stroke: var(--ink); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon .aa { font-family: var(--font-text); font-size: 1.1rem; font-weight: 600; }

/* ---- reading ---- */
main {
  padding-inline: max(20px, env(safe-area-inset-left, 0px)) max(20px, env(safe-area-inset-right, 0px));
  padding-block: 8px calc(40px + env(safe-area-inset-bottom, 0px));
}
.page { max-width: var(--measure); margin: 0 auto; font-family: var(--font-text); font-size: var(--size); line-height: 1.62; }
.head { padding-block: 28px 18px; display: grid; gap: 4px; }
.head .book { font-family: var(--font-ui); font-size: .8rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft); }
.head .ch { font-size: 3.1em; line-height: 1; font-weight: 300; color: var(--accent); font-variant-numeric: lining-nums; }
.title { font-style: italic; color: var(--ink-soft); font-size: .92em; margin: 0 0 .9em; }
.page p { margin: 0 0 .85em; text-wrap: pretty; hyphens: auto; -webkit-hyphens: auto; }
.v { scroll-margin-top: 96px; border-radius: 3px; transition: background-color .8s; cursor: pointer; }
.v.sel { background: var(--accent-wash); transition: none; }
.v.hit { background: var(--mark); }
sup.n {
  font-family: var(--font-ui); font-size: .58em; font-weight: 700; color: var(--accent);
  vertical-align: .55em; line-height: 0; margin-right: .2em; font-variant-numeric: tabular-nums;
}
.sc { font-variant: small-caps; letter-spacing: .03em; }
.lines .page p { margin: 0; }
.lines .v { display: block; padding-left: 1.8em; text-indent: -1.8em; margin-bottom: .4em; }
.lines sup.n { display: inline-block; width: 1.6em; text-indent: 0; vertical-align: .25em; }

.turn { max-width: var(--measure); margin: 30px auto 0; display: flex; gap: 12px; }
.turn button {
  flex: 1; min-width: 0; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--rule);
  background: var(--raised); text-align: left; display: grid; gap: 2px;
}
.turn button:last-child { text-align: right; }
.turn small { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft); font-weight: 700; }
.turn b { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.turn button:disabled { visibility: hidden; }

/* ---- sheets ---- */
.sheet {
  position: fixed; inset: 0; z-index: 10;
  background: var(--paper);
  display: flex; flex-direction: column;
}
.sheet-head {
  display: flex; align-items: center; gap: 8px;
  padding: calc(6px + env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) 6px max(12px, env(safe-area-inset-left, 0px));
  border-bottom: 1px solid var(--rule);
}
.sheet-head h2 { margin: 0; font-size: 1.08rem; padding-left: 8px; flex: 1; min-width: 0; }
.sheet-body {
  overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch;
  padding-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px));
  padding-block: 14px calc(40px + env(safe-area-inset-bottom, 0px));
}
.inner { max-width: 40rem; margin: 0 auto; }

.tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.tabs button { padding: 8px 16px; border-radius: 999px; border: 1px solid var(--rule); font-weight: 700; font-size: .92rem; }
.tabs button[aria-selected="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.books { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: 6px; }
.books button {
  text-align: left; padding: 11px 12px; border-radius: 10px; background: var(--raised);
  border: 1px solid var(--rule); font-size: 1rem; min-width: 0;
}
.books button.here { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.group-label { font-size: .72rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft); margin: 20px 0 8px; }
.group-label:first-child { margin-top: 0; }
.chapters { display: grid; grid-template-columns: repeat(auto-fill, minmax(3.2rem, 1fr)); gap: 6px; }
.chapters button {
  aspect-ratio: 1; max-width: 100%; border-radius: 10px; background: var(--raised); border: 1px solid var(--rule);
  font-variant-numeric: tabular-nums; font-size: 1rem; font-weight: 600;
}
.chapters button.here { background: var(--accent); color: var(--paper); border-color: var(--accent); }
.back { font-weight: 700; color: var(--accent); padding: 4px 0; margin-bottom: 12px; }

.search-box { flex: 1; min-width: 0; }
.search-box input {
  width: 100%; box-sizing: border-box; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--rule); background: var(--raised); color: var(--ink); font: inherit; font-size: 1rem;
}
.count { font-size: .88rem; color: var(--ink-soft); margin: 0 0 8px; }
.results { display: grid; }
.results button { text-align: left; padding: 11px 4px; border-bottom: 1px solid var(--rule); display: grid; gap: 3px; }
.results b { font-size: .86rem; color: var(--accent); }
.results span { font-family: var(--font-text); font-size: 1rem; line-height: 1.5; }
.results mark { background: var(--mark); color: inherit; border-radius: 2px; }
.hint { color: var(--ink-soft); font-size: .95rem; line-height: 1.55; margin: 0; }
.page .hint { padding-top: 40px; font-family: var(--font-ui); }
.reset { margin: 10px 0 4px; padding: 10px 14px; border-radius: 10px; background: var(--accent); color: var(--paper); font-weight: 700; }
.page .hint small { color: var(--ink-soft); }

.setting { display: grid; gap: 10px; padding-block: 18px; border-bottom: 1px solid var(--rule); }
.setting:first-child { padding-top: 4px; }
.setting > label, .setting > .label { font-weight: 700; }
.setting input[type="range"] { width: 100%; accent-color: var(--accent); }
.sample { font-family: var(--font-text); font-size: var(--size); line-height: 1.6; margin: 0; }
.seg { display: flex; border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; }
.seg button { flex: 1; padding: 10px 6px; font-weight: 600; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.downloads { display: grid; gap: 8px; }
.download {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: baseline;
  padding: 12px 14px; border-radius: 10px; border: 1px solid var(--rule); background: var(--raised);
  color: var(--ink); text-decoration: none;
}
.download b { color: var(--accent); }
.download .size { font-size: .85rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.download small { grid-column: 1 / -1; color: var(--ink-soft); font-size: .88rem; line-height: 1.45; }
.download:hover { border-color: var(--accent); }
.about { color: var(--ink-soft); font-size: .9rem; line-height: 1.55; padding-top: 18px; margin: 0; }

/* ---- compare with the KJV (bottom panel) ---- */
.panel {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 8;
  max-height: 62vh; display: flex; flex-direction: column;
  background: var(--raised); border-top: 1px solid var(--rule);
  border-radius: 16px 16px 0 0; box-shadow: 0 -8px 30px rgba(15, 22, 40, .18);
}
.panel-head {
  display: flex; align-items: center; gap: 4px;
  padding: 6px max(10px, env(safe-area-inset-right, 0px)) 0 max(18px, env(safe-area-inset-left, 0px));
}
.panel-head h2 { margin: 0; flex: 1; min-width: 0; font-size: 1rem; }
.panel-body {
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 4px max(18px, env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-left, 0px));
  max-width: 40rem; width: 100%; box-sizing: border-box; margin: 0 auto;
}
.cmp { display: grid; gap: 4px; padding-block: 10px; }
.cmp + .cmp { border-top: 1px solid var(--rule); }
.cmp p { margin: 0; font-family: var(--font-text); font-size: calc(var(--size) * .92); line-height: 1.55; }
.cmp.kjv p { color: var(--ink-soft); }
.cmp-label { font-size: .72rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); }
.chg { background: var(--mark); border-radius: 3px; padding: 0 2px; }
.old { text-decoration: line-through; text-decoration-color: var(--accent); text-decoration-thickness: 1.5px; color: var(--ink); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: baseline; font-size: .8rem; color: var(--ink-soft); margin: 8px 0 0; }
.legend i { font-family: var(--font-text); }
.same { font-size: .9rem; color: var(--ink-soft); margin: 6px 0 0; }

/* ---- about ---- */
.prose { font-size: 1rem; line-height: 1.6; }
.prose h4 { margin: 22px 0 6px; font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft); }
.prose p { margin: 0 0 10px; }
.prose ul { margin: 0 0 10px; padding-left: 1.2em; display: grid; gap: 6px; }
.prose a { color: var(--accent); }
.about-head { display: flex; align-items: center; gap: 14px; padding-bottom: 6px; }
.about-head img { border-radius: 14px; flex: none; }
.about-head h3 { margin: 0; font-family: var(--font-text); font-size: 1.45rem; font-weight: 600; }
.about-head p { margin: 2px 0 0; color: var(--ink-soft); }

@media (prefers-reduced-motion: reduce) { .v { transition: none; } }
