/* "Read the chapter" without losing one's place (js/side-reader.js): on a wide screen, the panel that slides out from
   the right edge over the study with the chapter in it; on a phone, the trail back to the study at the top of the Bible
   reader; and the glow of a citation come back to. The chapter in the panel wears the reader's own classes (.bb-text,
   .bb-t, .bb-step, .bb-ver, .bb-more, .bb-foot: css/manuscript.css and css/reader.css), so it is set as the reader sets
   it. Square corners and thin rules, as everywhere; every colour is a theme token, so the dark theme and the light are
   both served. --tk-h is the height of the bar at the foot of the screen, above which the panel stops (0px where there
   is no such bar). */

/* ---- the panel ----
   Fixed to the right edge and slid out past it when closed; shown, it lies over the page and does not push it aside.
   It sets its own type and colours, since it may sit inside a dialog that sets others (the blueprint). */
.sr {
  --sr-w: clamp(340px, 38vw, 560px);
  position: fixed;
  z-index: 480;
  top: 0;
  right: 0;
  bottom: var(--tk-h, 0px);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  width: var(--sr-w);
  min-width: 320px;
  max-width: 70vw;
  margin: 0;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--press);
  border-radius: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--text);
  font-size: 1.125rem;
  font-style: normal;
  font-weight: 400;
  line-height: 1.58;
  letter-spacing: normal;
  text-align: left;
  text-transform: none;
  box-shadow: none;
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 0.3s cubic-bezier(0.22, 0.8, 0.25, 1), box-shadow 0.3s ease, visibility 0s linear 0.3s;
}
.sr.is-open {
  transform: none;
  visibility: visible;
  box-shadow: -14px 0 36px var(--shadow), -2px 0 8px var(--lift);
  transition: transform 0.3s cubic-bezier(0.22, 0.8, 0.25, 1), box-shadow 0.3s ease, visibility 0s;
}
.sr.is-sizing { transition: none; -webkit-user-select: none; user-select: none; }
/* inside a full-window dialog (the blueprint) the bar at the foot of the screen lies beneath the dialog, out of sight: the
   panel goes down to the edge; it begins below the dialog's own bar (js/side-reader.js sets its top) */
dialog > .sr { bottom: 0; }

/* the tabs across the top, one chapter to each: the one shown joined to the head beneath it, the others behind, each
   with its ×; the row scrolls sideways when there are more than it holds */
.sr-tabs { flex: none; display: flex; align-items: flex-end; gap: 4px; padding-right: 8px; background: var(--bg); border-bottom: 1px solid var(--press); }
.sr-tablist { flex: 1 1 auto; min-width: 0; display: flex; align-items: flex-end; gap: 2px; padding: 6px 4px 0 8px; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; overscroll-behavior-x: contain; }
.sr-tabi { position: relative; flex: 0 0 auto; display: inline-flex; align-items: stretch; max-width: 12rem; margin-bottom: -1px; border: 1px solid var(--rule); border-bottom-color: var(--press); background: color-mix(in srgb, var(--panel) 45%, var(--bg)); }
.sr-tabi.is-on { border-color: var(--press); border-bottom-color: var(--panel); background: var(--panel); }
.sr-tabi.is-on::before { content: ""; position: absolute; left: -1px; right: -1px; top: -1px; height: 2px; background: var(--rubric); }
.sr-tb { min-width: 0; max-width: 100%; padding: 6px 4px 6px 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 0; border-radius: 0; background: none; box-shadow: none; font: inherit; font-family: var(--caps); font-weight: var(--caps-wt); font-size: 0.95rem; letter-spacing: 0.01em; line-height: 1.2; color: var(--muted); cursor: pointer; }
.sr-tabi.is-on .sr-tb { color: var(--ink); }
.sr-tb:hover { color: var(--rubric); }
.sr-tbx { flex: none; width: 1.7rem; padding: 0 0 2px; border: 0; border-radius: 0; background: none; box-shadow: none; font: inherit; font-size: 1.15rem; line-height: 1; color: var(--muted); cursor: pointer; }
.sr-tbx:hover { color: var(--rubric); }
.sr-tb:focus-visible, .sr-tbx:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }

/* + (a new tab), and every tab in the Bible reader, at the end of the row */
.sr-add, .sr-allout { flex: none; display: grid; place-items: center; width: 2rem; height: 1.9rem; margin: 6px 0 5px; padding: 0; border: 1px solid var(--rule); border-radius: 0; background: none; box-shadow: none; color: var(--rubric); cursor: pointer; text-decoration: none; }
.sr-add svg, .sr-allout svg { fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.sr-allout { margin-left: 2px; }
.sr-add:hover, .sr-allout:hover { border-color: var(--rubric); background: color-mix(in srgb, var(--rubric) 12%, transparent); }
.sr-add:focus-visible, .sr-allout:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

/* the arrow on the panel's edge, half way down, that slides it shut */
.sr-hide { position: absolute; z-index: 2; top: 50%; left: -26px; display: grid; place-items: center; width: 26px; height: 58px; margin-top: -29px; padding: 0; border: 1px solid var(--press); border-right: 0; border-radius: 8px 0 0 8px; background: var(--panel); box-shadow: -4px 0 10px var(--lift); color: var(--muted); cursor: pointer; }
.sr-hide svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sr-hide:hover { color: var(--rubric); }
.sr-hide:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* the head: ‹ the chapter › and ×, then the version and "New tab", over a thick-and-thin rule */
.sr-head { flex: none; padding: 8px 10px 9px 12px; background: var(--panel); border-bottom: 3px double var(--press); }
.sr-nav { display: flex; align-items: center; gap: 8px; }
.sr .bb-step { flex: none; }
.sr-title { flex: 1 1 auto; min-width: 0; margin: 0; padding: 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; font-family: var(--display); font-size: 1.55rem; font-weight: 400; font-style: normal; line-height: 1.25; letter-spacing: 0.02em; color: var(--ink); }
.sr-title { cursor: pointer; }
.sr-title::after { content: " ▾"; content: " ▾" / ""; font-size: 0.6em; vertical-align: 0.2em; color: var(--muted); }
.sr-title:hover::after, .sr.is-picking .sr-title::after { color: var(--rubric); }
.sr-title:focus { outline: none; }
.sr-title:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-x { flex: none; width: 2.6rem; height: 2.5rem; margin: 0 0 0 6px; padding: 0 0 3px 6px; border: 0; border-left: 1px solid var(--rule); border-radius: 0; background: none; box-shadow: none; font: inherit; font-size: 1.75rem; line-height: 1; color: var(--muted); cursor: pointer; }
.sr-x:hover { color: var(--rubric); }
.sr-x:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-tools { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }
.sr-ver-l { display: inline-flex; }
.sr-goto { min-height: 2.3rem; margin-right: auto; padding: 0 12px; border: 1px solid var(--rule); border-radius: 0; background: none; box-shadow: none; font: inherit; font-family: var(--caps); font-weight: var(--caps-wt); font-size: 0.95rem; letter-spacing: 0.01em; line-height: 1; color: var(--ink); cursor: pointer; }
.sr-goto:hover, .sr.is-picking .sr-goto { border-color: var(--rubric); color: var(--rubric); }
.sr-goto:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr .bb-ver { height: 2.3rem; }
.sr-tab { display: inline-flex; align-items: center; gap: 7px; min-height: 2.3rem; padding: 0 12px; border: 1px solid var(--rule); border-radius: 0; background: none; font-family: var(--caps); font-weight: var(--caps-wt); font-size: 0.95rem; letter-spacing: 0.01em; line-height: 1; color: var(--ink); text-decoration: none; }
.sr-tab svg { flex: none; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; color: var(--rubric); }
.sr-tab:hover { border-color: var(--rubric); color: var(--rubric); }
.sr-tab:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* the verses cited, to bring back into view; away from their chapter, the way back to it */
.sr-cited { flex: none; margin: 0; padding: 7px 12px; background: var(--bg); border-bottom: 1px solid var(--rule); line-height: 1; }
.sr-cited[hidden] { display: none; }
.sr-cite { display: inline-block; max-width: 100%; padding: 4px 10px 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: top; border: 1px solid var(--rubric); border-radius: 0; background: color-mix(in srgb, var(--rubric) 12%, transparent); box-shadow: none; font: inherit; font-family: var(--caps); font-weight: var(--caps-wt); font-size: 0.95rem; letter-spacing: 0.01em; line-height: 1.25; color: var(--rubric); cursor: pointer; }
.sr-cite:hover { background: color-mix(in srgb, var(--rubric) 22%, transparent); }
.sr-cite.is-away { border-color: var(--rule); background: none; color: var(--muted); }
.sr-cite.is-away:hover { border-color: var(--rubric); color: var(--rubric); }
.sr-cite:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* the chooser, in the place of the text while it is open: a passage typed, or a book and then a chapter */
.sr-pick { display: none; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 12px 16px 24px; }
.sr.is-picking .sr-pick { display: block; }
.sr.is-picking .sr-scroll, .sr.is-picking .sr-cited { display: none; }
.sr-go { display: flex; gap: 6px; }
.sr-go-in { flex: 1 1 auto; min-width: 0; height: 2.5rem; padding: 0 10px; border: 1px solid var(--rule); border-radius: 0; background: var(--panel); color: var(--ink); font: inherit; font-size: 1.05rem; }
.sr-go-in:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--rubric); }
.sr-go-btn, .sr-pick-x { flex: none; height: 2.5rem; padding: 0 14px; border: 1px solid var(--rule); border-radius: 0; background: none; box-shadow: none; font: inherit; font-family: var(--caps); font-weight: var(--caps-wt); font-size: 0.95rem; letter-spacing: 0.01em; color: var(--rubric); cursor: pointer; }
.sr-pick-x { width: 2.5rem; padding: 0 0 3px; font-family: inherit; font-size: 1.5rem; line-height: 1; color: var(--muted); }
.sr-go-btn:hover, .sr-pick-x:hover { border-color: var(--rubric); color: var(--rubric); }
.sr-go-btn:focus-visible, .sr-pick-x:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-go-err { margin: 8px 0 0; font-size: 0.95rem; font-style: normal; color: var(--rubric); }
.sr-go-err[hidden], .sr-books[hidden], .sr-chs[hidden] { display: none; }
.sr-bk-h { margin: 18px 0 4px; font-family: var(--display); font-size: 1.25rem; font-weight: 400; color: var(--ink); border-bottom: 3px double var(--press); }
.sr-bk-part { margin: 10px 0 5px; font-family: var(--caps); font-weight: var(--caps-wt); font-size: 0.95rem; letter-spacing: 0.01em; color: var(--muted); }
.sr-bk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.2rem, 1fr)); gap: 4px; }
.sr-bk, .sr-ch { min-height: 2.2rem; padding: 2px 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 1px solid var(--rule); border-radius: 0; background: none; box-shadow: none; font: inherit; font-size: 0.98rem; line-height: 1.2; color: var(--ink); text-align: left; cursor: pointer; }
.sr-ch { padding: 2px 0; text-align: center; font-feature-settings: "lnum"; }
.sr-bk:hover, .sr-ch:hover { border-color: var(--rubric); color: var(--rubric); }
.sr-bk.is-on, .sr-ch.is-on { border-color: var(--rubric); background: color-mix(in srgb, var(--rubric) 14%, transparent); }
.sr-bk:focus-visible, .sr-ch:focus-visible, .sr-chs-back:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.sr-chs-head { display: flex; align-items: center; gap: 12px; margin: 16px 0 10px; }
.sr-chs-back { padding: 4px 10px; border: 1px solid var(--rule); border-radius: 0; background: none; box-shadow: none; font: inherit; font-family: var(--caps); font-weight: var(--caps-wt); font-size: 0.95rem; letter-spacing: 0.01em; color: var(--ink); cursor: pointer; }
.sr-chs-back:hover { border-color: var(--rubric); color: var(--rubric); }
.sr-chs-t { margin: 0; font-family: var(--display); font-size: 1.35rem; font-weight: 400; }
.sr-chgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(2.8rem, 1fr)); gap: 4px; }

/* the chapter, which scrolls on its own and never hands its scrolling on to the page */
.sr-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 20px 24px; }
.sr-scroll:focus { outline: none; }
.sr-scroll:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.sr .bb-text { padding: 16px 0 4px; font-size: calc(1.14rem * var(--bb-scale, 1)); line-height: 1.72; scroll-margin-top: 0; }
.sr .bb-t.is-cite { background: color-mix(in srgb, var(--rubric) 18%, transparent); -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.sr .bb-foot { margin-top: 16px; }
.sr .bb-more { font-size: 1rem; line-height: 1.3; }
.sr-src { margin: 14px 0 0; text-align: center; font-size: 0.95rem; font-style: normal; line-height: 1.4; color: var(--muted); }

/* the reader's own choices for the text (its Display), as the panel takes them from it */
.sr.no-nums .bb-n { display: none; }
.sr.lh-compact .bb-text { line-height: 1.5; }
.sr.lh-compact .bb-s { line-height: 1.42; }
.sr.lh-loose .bb-text { line-height: 2.05; }
.sr.lh-loose .bb-s { line-height: 1.9; }
.sr.bb-sans .bb-text { font-family: var(--text); font-size: calc(1.02rem * var(--bb-scale, 1)); }
.sr.bb-sans .bb-n { font-family: inherit; }
.sr.no-heads .bb-head { display: none; }

/* the left edge, to pull wider or narrower: two thin rules show where to take hold */
.sr-grip { position: absolute; z-index: 1; top: 0; bottom: 0; left: -6px; width: 11px; cursor: col-resize; touch-action: none; }
.sr-grip::after { content: ""; position: absolute; top: 50%; left: 3px; width: 5px; height: 48px; margin-top: -100px; border-left: 1px solid var(--press); border-right: 1px solid var(--press); background: var(--bg); opacity: 0; transition: opacity 0.2s ease; }
.sr-grip:hover::after, .sr-grip:focus-visible::after, .sr.is-sizing .sr-grip::after { opacity: 1; }
.sr-grip:focus { outline: none; }
.sr-grip:focus-visible { outline: 2px solid var(--focus); outline-offset: -3px; }

/* a window narrowed while the panel is open: it takes the whole width */
@media (max-width: 767.98px) {
  .sr { width: 100%; min-width: 0; max-width: none; border-left: 0; }
  .sr-grip, .sr-hide { display: none; }
  .sr-scroll { padding: 0 14px 20px; }
}

/* ---- the trail back, at the top of the Bible reader ----
   "‹ The Jubilee", then Bible › Leviticus › 25 › 10. It keeps to the top of the screen, and the reader's own bar keeps
   to the top just beneath it: js/side-reader.js measures it into --bb-crumb-h on the reader's panel. */
.bb-crumbbar { position: sticky; top: 0; z-index: 6; display: flex; align-items: center; gap: 10px; padding: 3px 0; background: var(--bg); border-bottom: 1px solid var(--rule); font-size: 0.95rem; line-height: 1.2; }
.bb-crumbbar[hidden] { display: none; }
.bb-cb-back { flex: 0 1 auto; min-width: 0; max-width: 48%; display: inline-flex; align-items: center; gap: 6px; min-height: 1.95rem; padding: 2px 10px 3px 7px; border: 1px solid var(--rule); border-radius: 0; background: none; box-shadow: none; font: inherit; font-family: var(--display); font-weight: 400; font-size: 1rem; color: var(--ink); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.bb-cb-arr { flex: none; font-size: 1.35em; line-height: 0.7; color: var(--rubric); }
.bb-cb-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bb-cb-back:hover { border-color: var(--rubric); color: var(--rubric); }
.bb-cb-trail { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; justify-content: flex-end; margin: 0; padding: 0; list-style: none; white-space: nowrap; }
.bb-cb-trail[hidden] { display: none; }
.bb-cb-trail li { flex: none; display: flex; align-items: center; min-width: 0; margin: 0; padding: 0; }
.bb-cb-trail li.bb-cb-bk { flex: 0 1 auto; }
.bb-cb-trail li + li::before { content: "›"; content: "›" / ""; flex: none; padding: 0 2px; color: var(--muted); }
.bb-cb { min-width: 0; max-width: 100%; min-height: 1.95rem; padding: 2px 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 0; border-radius: 0; background: none; box-shadow: none; font: inherit; font-feature-settings: "lnum"; color: var(--ink); text-decoration: underline dotted var(--muted); text-underline-offset: 0.22em; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.bb-cb-root { font-family: var(--caps); font-weight: var(--caps-wt); letter-spacing: 0.01em; color: var(--muted); text-decoration: none; }
.bb-cb.is-empty { font-style: normal; color: var(--muted); }
.bb-cb[aria-current] { color: var(--rubric); }
.bb-cb:hover { color: var(--rubric); text-decoration-color: var(--rubric); }
.bb-cb-back:focus-visible, .bb-cb:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
/* where the name of the book would be cut short, the trail begins with the book instead, and the way back gives up a
   little room (js/side-reader.js) */
.bb-crumbbar.is-tight .bb-cb-back { max-width: 42%; }
.bb-crumbbar.is-tight .bb-cb-trail li:first-child { display: none; }
.bb-crumbbar.is-tight .bb-cb-trail li:nth-child(2)::before { content: none; }

/* while the trail shows, the reader's own bar keeps to the top of the screen beneath it (css/reader.css), and whatever the
   reader brings into view stops below both; its panes, which fill the screen beneath the bar, stop above the bars at
   the foot (the site's, and on a phone the reader's row of tools): --bb-rbar-h and --bb-row-h, measured by js/bible.js */
#panel-bible .bb-text, #panel-bible .bb-tip { scroll-margin-top: calc(var(--bb-rbar-h, 3.6rem) + 0.6rem + var(--bb-crumb-h, 0px)); }
#panel-bible .bb-t { scroll-margin-top: calc(var(--bb-rbar-h, 3.6rem) + 1.4rem + var(--bb-crumb-h, 0px)); }
#panel-bible .bb-work { scroll-margin-top: calc(var(--bb-rbar-h, 3.6rem) + var(--bb-crumb-h, 0px)); }
#panel-bible .bb.multi .bb-work { height: calc(100vh - var(--tk-real, var(--tk-h, 0px)) - var(--bb-crumb-h, 0px) - var(--bb-rbar-h, 3.6rem) - var(--bb-row-h, 0px)); height: calc(100svh - var(--tk-real, var(--tk-h, 0px)) - var(--bb-crumb-h, 0px) - var(--bb-rbar-h, 3.6rem) - var(--bb-row-h, 0px)); }

/* ---- a citation come back to: it glows for a moment (js/side-reader.js adds the class, and takes it away) ---- */
.ref-flash { animation: ref-flash 1.6s ease-out; }
@keyframes ref-flash {
  0%, 30% { background-color: color-mix(in srgb, var(--rubric) 26%, transparent); outline: 2px solid var(--rubric); outline-offset: 3px; }
  100% { background-color: transparent; outline: 2px solid transparent; outline-offset: 3px; }
}

@media (prefers-reduced-motion: reduce) {
  .sr, .sr.is-open { transition: none; }
  .ref-flash { outline: 2px solid var(--rubric); outline-offset: 3px; }     /* still: a ring, while the class is there */
}
@media print { .sr, .bb-crumbbar { display: none !important; } }
