/* bible.sonsofscripture.com
   Colours follow sonsofscripture.com (README "Design"): black ground, bone ink,
   brass for links and markers, ember for the one action colour. Paper is the
   same family turned light for reading in daylight. Every colour is a token
   here and nowhere else. */

:root {
  --bg: #0b0b0b;
  --raised: #141516;
  --sheet: #121314;
  --ink: #ece2cf;
  --ink-strong: #f4ead8;
  --muted: #b9ad9b;
  --quiet: #8f99a0;
  --brass: #c6a15b;
  --ember: #a73a25;
  --on-ember: #fff6ea;
  --woj: #e8866e;
  --line: rgba(244, 234, 216, 0.12);
  --line-strong: rgba(198, 161, 91, 0.45);
  --sel: rgba(198, 161, 91, 0.2);
  --mark: rgba(198, 161, 91, 0.32);
  --scrim: rgba(0, 0, 0, 0.6);
  --shadow: 0 -12px 40px rgba(0, 0, 0, 0.45);

  --font-display: "Bebas Neue", Impact, "Arial Narrow", sans-serif;
  --font-ui: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-read: "Literata", Georgia, "Times New Roman", serif;
  --read-size: 20px;
  --measure: 34em;
  --bar-h: 60px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

:root[data-theme="paper"] {
  --bg: #f6f0e4;
  --raised: #fffaf1;
  --sheet: #fbf6ec;
  --ink: #1f1b16;
  --ink-strong: #120f0b;
  --muted: #5f564b;
  --quiet: #59636a;
  --brass: #7d5d1f;
  --ember: #a73a25;
  --on-ember: #fff6ea;
  --woj: #a3261a;
  --line: rgba(31, 27, 22, 0.13);
  --line-strong: rgba(125, 93, 31, 0.45);
  --sel: rgba(198, 161, 91, 0.28);
  --mark: rgba(198, 161, 91, 0.45);
  --scrim: rgba(20, 16, 10, 0.4);
  --shadow: 0 -12px 40px rgba(60, 40, 10, 0.16);
  color-scheme: light;
}

:root[data-font="sans"] { --font-read: "Inter", ui-sans-serif, system-ui, sans-serif; }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--bar-h) + var(--safe-b));
}

a { color: var(--brass); text-underline-offset: 3px; }
button { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; border-radius: 4px; }

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 50;
  background: var(--raised); color: var(--ink-strong); padding: 10px 14px; border-radius: 8px;
}
.skip:focus { top: 12px; }

/* ---------- Header and the control bar ----------
   Phone: the brand scrolls away at the top, the bar sits at the bottom where a
   thumb reaches it. Desktop: one sticky row at the top. */

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink-strong); min-height: 44px; }
.brand img { border-radius: 6px; }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-name { font-family: var(--font-display); font-size: 21px; letter-spacing: 0.04em; }
.brand-sub { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--brass); margin-top: 3px; }

.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; align-items: center; gap: 2px;
  height: calc(var(--bar-h) + var(--safe-b));
  padding: 0 6px var(--safe-b);
  background: var(--sheet);
  border-top: 1px solid var(--line);
}

.bar-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-width: 44px; height: 46px; padding: 0 8px;
  background: transparent; border: 0; border-radius: 10px; cursor: pointer;
  color: var(--ink-strong);
}
.bar-btn:hover { background: var(--line); }
.bar-btn:disabled { opacity: 0.3; cursor: default; background: transparent; }
.bar-btn.place { flex: 1; min-width: 0; font-weight: 600; font-size: 16px; justify-content: center; }
.bar-btn.place span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-btn.place .chev { width: 16px; height: 16px; color: var(--brass); flex: none; }
.bar-btn.ver { font-size: 13px; font-weight: 600; letter-spacing: 0.06em; color: var(--brass); border: 1px solid var(--line-strong); height: 34px; padding: 0 9px; }
.bar-btn .aa { font-family: var(--font-read); font-size: 19px; }

@media (min-width: 760px) {
  body { padding-bottom: 0; }
  .top {
    position: sticky; top: 0; z-index: 20;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 8px max(20px, calc((100% - 1100px) / 2));
    gap: 20px;
  }
  .bar { position: static; height: auto; padding: 0; background: transparent; border: 0; gap: 4px; }
  .bar-btn.place { flex: none; min-width: 190px; }
}

/* ---------- The chapter ---------- */

main { padding: 0 16px; }

.chapter { max-width: var(--measure); margin: 0 auto; font-size: var(--read-size); }

.ch-head { padding: 28px 0 10px; }
.ch-title {
  margin: 0; font-family: var(--font-display); font-weight: 400;
  font-size: clamp(44px, 10vw, 68px); line-height: 0.95; letter-spacing: 0.02em; color: var(--ink-strong);
}
.ch-title #ch-num { color: var(--brass); }

.ch-ver {
  display: inline-block; margin-top: 8px; padding: 4px 0; border: 0; background: none; cursor: pointer;
  font-family: var(--font-read); font-style: italic; font-size: 17px; color: var(--muted);
  text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 4px;
}
.ch-ver:hover { color: var(--ink-strong); }
.ch-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; font-size: 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 6px 12px;
  border: 1px solid var(--line); border-radius: 999px;
  background: transparent; color: var(--muted); text-decoration: none; cursor: pointer;
  font-size: 14px; line-height: 1.2;
}
.chip:hover { border-color: var(--line-strong); color: var(--ink-strong); }
.chip svg { width: 14px; height: 14px; fill: currentColor; stroke: none; }

.text {
  font-family: var(--font-read);
  font-size: 1em;
  line-height: 1.75;
  color: var(--ink);
  padding: 10px 0 8px;
  font-optical-sizing: auto;
  hanging-punctuation: first;
}
.text:focus { outline: none; }
.text.loading { opacity: 0.35; transition: opacity 0.2s; }
.hide-headings .sect { display: none; }
html.dialog-open { overflow: hidden; }

.text .para { margin: 0 0 0.9em; }
.text .sect {
  font-family: var(--font-ui); font-size: 0.72em; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--brass);
  margin: 1.8em 0 0.7em; line-height: 1.4;
}
.text .sect:first-child { margin-top: 0.6em; }
.text .psalm-title { font-style: italic; color: var(--muted); margin: 0 0 0.8em; }

.v { border-radius: 3px; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background-color 0.15s; }
.v.sel { background: var(--sel); box-shadow: 0 0 0 2px var(--sel); }
.v.flash { animation: flash 2.2s ease-out; }
@keyframes flash { 0%, 30% { background: var(--mark); } 100% { background: transparent; } }

.vn {
  font-family: var(--font-ui); font-size: 0.58em; font-weight: 600;
  color: var(--brass); vertical-align: 0.42em; line-height: 0;
  margin-right: 0.25em; user-select: none;
}
.v:first-child .vn, .para > .v:first-child .vn { margin-left: 0; }
.hide-numbers .vn { display: none; }

/* Poetry: each line is its own line, the second level indented. */
.q { display: block; padding-left: 1.4em; text-indent: -1.4em; }
.q.q2 { padding-left: 2.6em; }
.q.q3 { padding-left: 3.6em; }
.pbr { display: block; height: 0.9em; }

.woj { color: inherit; }
.red .woj { color: var(--woj); }

.fn {
  font-family: var(--font-ui); font-size: 0.56em; font-style: normal; font-weight: 600;
  vertical-align: 0.5em; line-height: 0;
  color: var(--brass); background: none; border: 0; cursor: pointer;
  padding: 0.5em 0.18em; margin: -0.5em 0;
}
.hide-notes .fn { display: none; }

/* Verse by verse: each verse on its own line with its number in the margin. */
.by-verse .para { margin: 0; }
.by-verse .v { display: block; margin-bottom: 0.55em; padding-left: 1.6em; position: relative; }
.by-verse .v .vn { position: absolute; left: 0; top: 0.9em; width: 1.2em; text-align: right; margin: 0; font-size: 0.6em; }
.by-verse.hide-numbers .v { padding-left: 0; }
.by-verse .q { padding-left: 1.4em; }

.status { color: var(--muted); font-size: 16px; padding: 20px 0; }
.status button { margin-top: 10px; }

.ch-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 26px 0 8px; }
.ch-link {
  display: flex; flex-direction: column; gap: 2px;
  padding: 14px 16px; min-height: 64px;
  border: 1px solid var(--line); border-radius: 12px;
  text-decoration: none; color: var(--ink-strong); font-size: 16px;
}
.ch-link:hover { border-color: var(--line-strong); }
.ch-link .dir { font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--brass); }
.ch-link.next { text-align: right; }
.ch-link[aria-disabled="true"] { visibility: hidden; }

.foot {
  max-width: var(--measure); margin: 30px auto 0; padding: 22px 0 40px;
  border-top: 1px solid var(--line);
  color: var(--quiet); font-size: 13px;
}
.foot p { margin: 0 0 8px; }

/* ---------- Selection bar, player, toast ---------- */

.selbar, .player {
  position: fixed; left: 8px; right: 8px; z-index: 25;
  bottom: calc(var(--bar-h) + var(--safe-b) + 8px);
  display: flex; align-items: center; gap: 4px;
  padding: 6px 6px 6px 14px;
  background: var(--raised); border: 1px solid var(--line-strong); border-radius: 14px;
  box-shadow: var(--shadow);
}
.selbar[hidden], .player[hidden], .toast[hidden] { display: none; }
.sel-ref { flex: 1; min-width: 0; font-weight: 600; color: var(--ink-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.selbar button {
  min-height: 44px; padding: 0 10px; border: 0; border-radius: 10px;
  background: transparent; color: var(--brass); font-weight: 600; font-size: 14px; cursor: pointer;
}
.selbar button:hover { background: var(--line); }
.selbar .sel-x, .player-x { color: var(--muted); min-width: 44px; display: inline-flex; align-items: center; justify-content: center; }
.player { padding: 6px; }
.player audio { flex: 1; min-width: 0; height: 40px; }
.player-x { background: transparent; border: 0; height: 44px; border-radius: 10px; cursor: pointer; }
.selbar:not([hidden]) ~ .player { bottom: calc(var(--bar-h) + var(--safe-b) + 74px); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 40;
  bottom: calc(var(--bar-h) + var(--safe-b) + 80px);
  background: var(--ink-strong); color: var(--bg);
  padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow); white-space: nowrap;
}

@media (min-width: 760px) {
  .selbar, .player { left: 50%; right: auto; transform: translateX(-50%); bottom: 24px; width: min(620px, calc(100% - 40px)); }
  .selbar:not([hidden]) ~ .player { bottom: 92px; }
  .toast { bottom: 100px; }
}

/* ---------- Sheets (native <dialog>) ----------
   Phone: a sheet rising from the bottom. Desktop: a centred panel. */

dialog.sheet {
  border: 0; padding: 0; margin: auto 0 0; max-width: none; width: 100%;
  max-height: 86vh; max-height: 86dvh;
  background: var(--sheet); color: var(--ink);
  border-radius: 18px 18px 0 0;
  box-shadow: var(--shadow);
  display: none; flex-direction: column;
  overscroll-behavior: contain;
}
dialog.sheet[open] { display: flex; animation: rise 0.22s ease-out; }
dialog.sheet.tall { height: 86vh; height: 86dvh; }
dialog.sheet::backdrop { background: var(--scrim); }
@keyframes rise { from { transform: translateY(24px); opacity: 0.4; } to { transform: none; opacity: 1; } }

.sheet-head {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 8px 10px 18px; border-bottom: 1px solid var(--line); flex: none;
}
.sheet-head h2 { flex: 1; margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 28px; letter-spacing: 0.03em; color: var(--ink-strong); line-height: 1.1; }
.sheet-head .close, .sheet-head .back {
  width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.sheet-head .back { margin-left: -10px; color: var(--brass); }
.sheet-head .close:hover, .sheet-head .back:hover { background: var(--line); }
.sheet-body { overflow-y: auto; padding: 14px 16px calc(20px + var(--safe-b)); -webkit-overflow-scrolling: touch; flex: 1; }

@media (min-width: 760px) {
  dialog.sheet { margin: auto; width: min(760px, calc(100% - 40px)); max-height: 82vh; border-radius: 18px; }
  dialog.sheet.tall { height: 82vh; }
  dialog.sheet.small { width: min(520px, calc(100% - 40px)); }
  .sheet-body { padding: 18px 22px 24px; }
}

.find input {
  width: 100%; height: 50px; padding: 0 16px;
  font: inherit; font-size: 17px; color: var(--ink-strong);
  background: var(--bg); border: 1px solid var(--line-strong); border-radius: 12px;
}
.find input::placeholder { color: var(--quiet); }
.find input:focus { outline: none; border-color: var(--brass); box-shadow: 0 0 0 3px var(--sel); }

.group { font-size: 12px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--brass); margin: 20px 0 10px; }

.book-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
@media (min-width: 520px) { .book-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 760px) { .book-grid { grid-template-columns: repeat(4, 1fr); } }
.book-grid button {
  min-height: 46px; padding: 8px 12px; text-align: left;
  border: 1px solid var(--line); border-radius: 10px; background: transparent; color: var(--ink-strong);
  cursor: pointer; font-size: 15px; line-height: 1.2;
}
.book-grid button:hover { border-color: var(--line-strong); }
.book-grid button.current { border-color: var(--brass); color: var(--brass); font-weight: 600; }
.book-grid button[hidden] { display: none; }

.ch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 8px; }
.ch-grid button {
  height: 52px; border: 1px solid var(--line); border-radius: 10px; background: transparent;
  color: var(--ink-strong); font-size: 17px; font-weight: 500; cursor: pointer;
}
.ch-grid button:hover { border-color: var(--line-strong); }
.ch-grid button.current { background: var(--brass); border-color: var(--brass); color: var(--bg); font-weight: 600; }

.go-btn {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  margin-top: 10px; min-height: 52px; padding: 0 16px;
  background: var(--ember); color: var(--on-ember); border: 0; border-radius: 12px;
  font-size: 16px; font-weight: 600; cursor: pointer;
}

/* Versions */
.ver-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ver-list button, .ver-out {
  display: flex; align-items: flex-start; gap: 14px; width: 100%; text-align: left;
  padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: transparent;
  color: var(--ink); cursor: pointer; text-decoration: none;
}
.ver-list button:hover, .ver-out:hover { border-color: var(--line-strong); }
.ver-list button[aria-current="true"] { border-color: var(--brass); background: var(--sel); }
.ver-short { flex: none; width: 46px; font-weight: 600; font-size: 14px; letter-spacing: 0.06em; color: var(--brass); padding-top: 2px; }
.ver-main { display: flex; flex-direction: column; gap: 2px; }
.ver-name { color: var(--ink-strong); font-weight: 600; }
.ver-note { color: var(--muted); font-size: 14px; }
.ver-out { margin-top: 14px; border-style: dashed; }

/* Search */
.scope { display: flex; gap: 6px; overflow-x: auto; margin: 12px -16px 0; padding: 0 16px 2px; scrollbar-width: none; }
.scope::-webkit-scrollbar { display: none; }
.scope button {
  flex: none; min-height: 38px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; font-size: 14px;
}
.scope button[aria-pressed="true"] { border-color: var(--brass); color: var(--ink-strong); background: var(--sel); }
.hint { color: var(--muted); font-size: 14px; margin: 14px 0; }
.results { list-style: none; margin: 0; padding: 0; }
.results li + li { border-top: 1px solid var(--line); }
.results a { display: block; padding: 12px 2px; text-decoration: none; color: var(--ink); }
.results a:hover .r-ref { text-decoration: underline; }
.r-ref { display: block; font-size: 13px; font-weight: 600; color: var(--brass); margin-bottom: 2px; }
.r-text { font-family: var(--font-read); font-size: 16px; line-height: 1.55; }
.results mark { background: var(--mark); color: inherit; border-radius: 2px; padding: 0 1px; }

/* Settings */
.settings { display: grid; gap: 4px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; flex-wrap: wrap; }
.set-label { font-weight: 600; color: var(--ink-strong); }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; }
.seg button { min-height: 42px; padding: 0 14px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 14px; }
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button[aria-pressed="true"] { background: var(--brass); color: var(--bg); font-weight: 600; }
.stepper { display: inline-flex; align-items: center; gap: 4px; }
.stepper button { width: 46px; height: 42px; border: 1px solid var(--line-strong); border-radius: 10px; background: transparent; color: var(--ink-strong); cursor: pointer; font-family: var(--font-read); }
.stepper output { min-width: 40px; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }
.a-sm { font-size: 14px; } .a-lg { font-size: 22px; }
.set-toggle { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 12px 0; border-top: 1px solid var(--line); cursor: pointer; color: var(--ink-strong); }
.set-toggle input { width: 22px; height: 22px; accent-color: var(--brass); margin: 0; }
.set-hint { flex-basis: 100%; padding-left: 34px; color: var(--muted); font-size: 13px; }

/* Compare and notes */
.cmp-ref { font-family: var(--font-display); font-size: 24px; letter-spacing: 0.03em; color: var(--brass); margin: 0 0 6px; font-weight: 400; }
.cmp { padding: 14px 0; border-top: 1px solid var(--line); }
.cmp:first-of-type { border-top: 0; }
.cmp-ver { display: block; font-size: 12px; font-weight: 600; letter-spacing: 0.1em; color: var(--brass); margin-bottom: 4px; }
.cmp-text { font-family: var(--font-read); font-size: 18px; line-height: 1.65; margin: 0; color: var(--ink); }
.cmp-text .cvn { font-family: var(--font-ui); font-size: 0.6em; font-weight: 600; color: var(--brass); vertical-align: 0.4em; margin-right: 0.2em; }
.cmp-out { display: inline-flex; margin-top: 8px; }
.note-text { font-family: var(--font-read); font-size: 18px; line-height: 1.6; margin: 0; }
.note-text b { color: var(--brass); font-weight: 600; }
.note-ref { color: var(--muted); font-size: 14px; margin: 0 0 8px; }

.noscript { padding: 24px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

@media print {
  .top, .bar, .ch-tools, .ch-nav, .selbar, .player, .foot { display: none !important; }
  body { background: #fff; color: #000; padding: 0; }
  .chapter { max-width: none; }
}
