/*
 * School reader menu: styles for reader-menu.js (optional reader chrome).
 *
 * Quiet school idiom: book serif, hairline rules, no heavy boxes. Colours come
 * from the book's own --c-* palette (so light/dark follow the book), with
 * parchment fallbacks. Screen only; the book's print.css hides .rm-root, and
 * the install note carries .no-print.
 *
 * The book supplies the dark palette under [data-theme="dark"] and
 * :root:not([data-theme]) + prefers-color-scheme. This file only sets
 * color-scheme so native controls and scrollbars match.
 */

html[data-theme="light"] { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }
html:not([data-theme]) { color-scheme: light dark; }

html[data-read-aloud="off"] .verse-tts-button { display: none !important; }

/* ---- Focus guide ------------------------------------------------------ */
.rm-sightline {
  position: fixed;
  left: 0; right: 0;
  top: 40vh;
  height: 4vh;
  z-index: 700;
  pointer-events: none;
  background: linear-gradient(to bottom, transparent, var(--c-sightline, rgba(0, 0, 0, 0.06)), transparent);
  opacity: 0;
  transition: opacity 0.15s ease;
}
.rm-sightline.rm-on { opacity: 1; }

.rm-current { outline: 2px solid currentColor; outline-offset: 6px; }
.focus-mode .rm-unit { transition: opacity 0.15s ease; }
.focus-mode .rm-unit:not(.rm-current) { opacity: 0.88; }

html.rm-locked { overflow: hidden; scrollbar-gutter: stable; }

.rm-root {
  --rm-bg: var(--c-bg, #fbf9f3);
  --rm-bg-offset: var(--c-bg-offset, #f2f0f5);
  --rm-text: var(--c-text, #2c2a2e);
  --rm-soft: var(--c-text-soft, #6d6a70);
  --rm-link: var(--c-link, #3a5c8d);
  --rm-rule: var(--c-border, #e0dce5);
  --rm-rule-strong: var(--c-border-strong, #bfbac9);
  --rm-accent: var(--c-wisdom, #2b6a73);
  font-family: var(--font-serif, Palatino, "Palatino Linotype", Georgia, serif);
  font-size: 12pt;
  line-height: 1.3;
  color: var(--rm-text);
}

.rm-root button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  margin: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.rm-root :focus-visible,
.rm-contents :focus-visible {
  outline: 2px solid var(--rm-link);
  outline-offset: 2px;
}

.rm-status {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---- Toggle: stays put; never auto-hides ------------------------------ */
.rm-toggle {
  position: fixed;
  right: max(0.75rem, env(safe-area-inset-right));
  bottom: max(0.75rem, env(safe-area-inset-bottom));
  z-index: 900;
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  min-height: 44px;
  padding: 0 1rem;
  background: var(--rm-bg);
  color: var(--rm-text);
  border: 1px solid var(--rm-rule-strong) !important;
  border-radius: 999px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.12);
  font-variant: small-caps;
  letter-spacing: 0.04em;
  transition: border-color 0.2s;
}
.rm-toggle:hover,
.rm-toggle:focus-visible,
.rm-toggle[aria-expanded="true"] { border-color: var(--rm-link) !important; }
.rm-toggle-icon { font-size: 1.2em; line-height: 1; }

/* ---- Menu card -------------------------------------------------------- */
.rm-menu {
  position: fixed;
  right: max(0.75rem, env(safe-area-inset-right));
  bottom: calc(max(0.75rem, env(safe-area-inset-bottom)) + 44px + 0.5rem);
  z-index: 900;
  width: min(19rem, calc(100vw - 1.5rem));
  box-sizing: border-box;
  padding: 0.25rem 0;
  background: var(--rm-bg);
  border: 1px solid var(--rm-rule-strong);
  border-radius: 6px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
  animation: rm-rise 0.16s ease-out;
}
.rm-menu[hidden] { display: none; }

.rm-item {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  width: 100%;
  min-height: 44px;
  box-sizing: border-box;
  padding: 0.6rem 1rem;
  text-align: left;
  align-items: center;
}
.rm-item + .rm-item { border-top: 1px solid var(--rm-rule) !important; }
/* .rm-item's display: flex would otherwise override the hidden attribute
   (the Install row is hidden wherever this browser cannot install). */
.rm-item[hidden] { display: none; }
button.rm-item:hover { background: var(--rm-bg-offset); }

.rm-label { flex: 1 1 auto; }
.rm-value {
  flex: 0 0 auto;
  color: var(--rm-soft);
  font-variant: small-caps;
  letter-spacing: 0.04em;
}
button.rm-item:hover .rm-value { color: var(--rm-text); }

.rm-item-size .rm-label { flex: 0 1 auto; }
.rm-item-size .rm-value { flex: 1 1 auto; }
.rm-steps { display: inline-flex; gap: 0.4rem; }
.rm-step {
  min-width: 44px;
  min-height: 36px;
  border: 1px solid var(--rm-rule-strong) !important;
  border-radius: 4px;
}
.rm-step-up { font-size: 1.2em; }
.rm-step:hover:not(:disabled) { background: var(--rm-bg-offset); border-color: var(--rm-link) !important; }
.rm-step:disabled { opacity: 0.35; cursor: default; }

/* Install steps: opened under the Install row, in the menu's own type. */
.rm-install-how {
  padding: 0 1rem 0.75rem;
  font-size: 11pt;
  line-height: 1.9;
  color: var(--rm-text);
}
.rm-install-how[hidden] { display: none; }

/* ---- Continue prompt -------------------------------------------------- */
.rm-resume {
  position: fixed;
  left: max(0.75rem, env(safe-area-inset-left));
  right: max(0.75rem, env(safe-area-inset-right));
  bottom: calc(max(0.75rem, env(safe-area-inset-bottom)) + 44px + 0.6rem);
  z-index: 800;
  max-width: 26rem;
  box-sizing: border-box;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.1rem 0.6rem;
  padding: 0.55rem 2.5rem 0.55rem 1rem;
  background: var(--rm-bg);
  border: 1px solid var(--rm-rule-strong);
  border-left: 3px solid var(--rm-accent);
  border-radius: 4px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.14);
  font-size: 11pt;
  animation: rm-rise 0.3s ease-out;
}
.rm-resume[hidden] { display: none; }
.rm-resume-lead { color: var(--rm-soft); font-style: italic; }
.rm-resume-go {
  padding: 0.2rem 0;
  min-height: 32px;
  text-align: left;
  color: var(--rm-link) !important;
  border-bottom: 1px solid currentColor !important;
}
.rm-resume-go:hover { color: var(--c-link-hover, var(--rm-link)) !important; }
.rm-resume-x {
  position: absolute;
  top: 0; right: 0;
  width: 44px; height: 100%;
  min-height: 44px;
  font-size: 1.4em;
  color: var(--rm-soft);
}
.rm-resume-x:hover { color: var(--rm-text); }

/* ---- Contents panel (native modal dialog) ----------------------------- */
.rm-contents {
  position: fixed;
  inset: 0 auto 0 0;
  width: min(26rem, 100vw);
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  background: var(--c-bg, #fbf9f3);
  color: var(--c-text, #2c2a2e);
  font-family: var(--font-serif, Palatino, "Palatino Linotype", Georgia, serif);
  font-size: 12pt;
  line-height: 1.35;
  border: 0;
  border-right: 1px solid var(--c-border-strong, #bfbac9);
  box-shadow: 6px 0 28px rgba(0, 0, 0, 0.2);
}
.rm-contents[open] {
  display: flex;
  flex-direction: column;
  animation: rm-slide 0.2s ease-out;
}
.rm-contents::backdrop { background: rgba(20, 20, 28, 0.45); }

.rm-contents button {
  font: inherit; color: inherit; background: none; border: 0; cursor: pointer;
}
.rm-contents-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.25rem 0 1.25rem;
  min-height: 56px;
  border-bottom: 1px solid var(--c-border, #e0dce5);
}
.rm-contents-head h2 {
  margin: 0; padding: 0; border: 0;
  text-transform: none;
  font-family: inherit;
  font-size: 1em;
  font-weight: normal;
  font-variant: small-caps;
  letter-spacing: 0.08em;
  color: var(--c-text-soft, #6d6a70);
}
.rm-close { width: 48px; height: 48px; font-size: 1.8em; line-height: 1; color: var(--c-text-soft, #6d6a70); }
.rm-close:hover { color: var(--c-text, #2c2a2e); }

.rm-contents-body {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.5rem 0 2rem;
}
.rm-list, .rm-list ul { list-style: none; margin: 0; padding: 0; }
.rm-list > li { margin: 0; padding: 0; text-indent: 0; border-bottom: 1px solid var(--c-border, #e0dce5); }
.rm-list li { padding-left: 0; text-indent: 0; }
.rm-list ul { padding-bottom: 0.6rem; }

.rm-link {
  display: block;
  box-sizing: border-box;
  padding: 0.55rem 1.25rem 0.55rem 1.1rem;
  color: var(--c-text, #2c2a2e);
  text-decoration: none;
  border: 0;
  border-left: 3px solid transparent;
}
.rm-list > li > a { font-weight: bold; padding-top: 0.7rem; padding-bottom: 0.7rem; }
.rm-list ul .rm-link { padding-left: 2.25rem; font-size: 11pt; }
.rm-link:hover { background: var(--c-bg-offset, #f2f0f5); color: var(--c-link-hover, #1e3250); }
.rm-link[aria-current="location"] {
  border-left-color: var(--c-wisdom, #2b6a73);
  background: var(--c-bg-offset, #f2f0f5);
  color: var(--c-link, #3a5c8d);
}
.rm-link[aria-current="location"]::after {
  content: " ·  you are here";
  font-weight: normal;
  font-style: italic;
  font-size: 0.8em;
  color: var(--c-text-soft, #6d6a70);
}

/* ---- Install note (in the page, before the contents) ------------------ */
/* Chrome, not a reading panel: a full hairline frame like the menu card, no
   fill, no accent rule. The book's own icon shows what will appear on the
   device; the one filled control on the page is the Install button. The
   note is `hidden` in the HTML and only reader-menu.js reveals it. */
.install {
  position: relative;
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr);
  grid-template-areas: "icon title" "icon lead" "icon how" "icon go";
  column-gap: 1.1rem;
  align-items: start;
  box-sizing: border-box;
  max-width: calc(650px + 2rem + 2px);     /* the contents box, border to border */
  margin: 4rem auto 0;
  padding: 1.1rem 1.25rem 1.2rem 1.1rem;
  color: var(--c-text, #2c2a2e);
  border: 1px solid var(--c-border-strong, #bfbac9);
  border-radius: 6px;
  font-size: 0.95em;
  line-height: 1.45;
  animation: rm-rise 0.3s ease-out;
}
.install[hidden] { display: none; }
@media (display-mode: standalone), (display-mode: fullscreen), (display-mode: minimal-ui) {
  .install { display: none !important; }
}

.install-icon {
  grid-area: icon;
  display: block;
  width: 60px;
  height: 60px;
  border-radius: 22%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.06);
}
.install p {
  margin: 0;
  text-align: left;
  hyphens: manual;
}
.install .install-title {
  grid-area: title;
  margin-bottom: 0.15rem;
  padding-right: 2rem;                       /* clear of the close button */
  font-variant: small-caps;
  letter-spacing: 0.08em;
  color: var(--c-text-soft, #6d6a70);
}
.install .install-lead { grid-area: lead; }
.install .install-how { grid-area: how; margin-top: 0.7rem; line-height: 1.9; }

/* On-screen button names, drawn as small keys so they are easy to spot. */
.install-ui {
  display: inline-flex;
  align-items: center;
  gap: 0.25em;
  padding: 0 0.4em;
  font-weight: normal;
  line-height: 1.45;
  white-space: nowrap;
  background: var(--c-bg-offset, #f2f0f5);
  border: 1px solid var(--c-border-strong, #bfbac9);
  border-radius: 4px;
}
.install-share {
  width: 1.05em;
  height: 1.05em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.install-go {
  grid-area: go;
  justify-self: start;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin-top: 0.8rem;
  padding: 0 1.4rem;
  font: inherit;
  font-variant: small-caps;
  letter-spacing: 0.06em;
  color: var(--c-bg, #fbf9f3);
  background: var(--c-link, #3a5c8d);
  border: 1px solid var(--c-link, #3a5c8d);
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.2s, border-color 0.2s;
}
.install-go[hidden] { display: none; }
.install-go:hover {
  background: var(--c-link-hover, #1e3250);
  border-color: var(--c-link-hover, #1e3250);
}

.install-x {
  position: absolute;
  top: 0.35rem;
  right: 0.25rem;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  font: inherit;
  font-size: 1.5em;
  line-height: 1;
  color: var(--c-text-soft, #6d6a70);
  background: none;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.install-x:hover { color: var(--c-text, #2c2a2e); }

.install :focus-visible {
  outline: 2px solid var(--c-link, #3a5c8d);
  outline-offset: 2px;
}

/* ---- Church options (data-goto, data-loop-*, data-share) --------------- */
/* Nothing below matches a school book: the markup only exists when the
   option is set on the script tag. */
.rm-menu-long {
  max-height: calc(100vh - max(0.75rem, env(safe-area-inset-bottom)) - 44px - 1.75rem);
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Go to verse: label, a short box and a Go button; the hint/error wraps below. */
.rm-item-goto { flex-wrap: wrap; row-gap: 0.25rem; margin: 0; }
.rm-item-goto .rm-label { flex: 1 1 auto; }
.rm-goto-input {
  flex: 0 0 5.2em;
  width: 5.2em;
  min-height: 36px;
  box-sizing: border-box;
  margin: 0;
  padding: 0 0.5em;
  font: inherit;
  font-variant-numeric: tabular-nums;
  color: var(--rm-text);
  background: var(--rm-bg);
  border: 1px solid var(--rm-rule-strong);
  border-radius: 4px;
}
.rm-goto-input::placeholder { color: var(--rm-soft); opacity: 0.8; }
.rm-goto-input:focus-visible { outline: 2px solid var(--rm-link); outline-offset: 1px; }
.rm-goto-input[aria-invalid="true"] { border-color: var(--c-king, #942939); }
.rm-goto-go {
  min-width: 44px;
  min-height: 36px;
  font-variant: small-caps;
  letter-spacing: 0.04em;
  border: 1px solid var(--rm-rule-strong) !important;
  border-radius: 4px;
}
.rm-goto-go:hover { background: var(--rm-bg-offset); border-color: var(--rm-link) !important; }
.rm-goto-hint {
  flex: 1 0 100%;
  margin: 0;
  font-size: 0.8em;
  line-height: 1.35;
  text-align: left;
  color: var(--rm-soft);
}
.rm-goto-hint.rm-goto-error { color: var(--c-king, #942939); font-style: italic; }

/* Loop links in the menu: direction in small caps above the book's title. */
.rm-menu a.rm-item {
  color: inherit;
  text-decoration: none;
  border-bottom: 0;
}
.rm-menu a.rm-item:hover { background: var(--rm-bg-offset); }
.rm-menu a.rm-item:hover .rm-loop-book { color: var(--rm-link); }
.rm-loop-item .rm-label { display: flex; flex-direction: column; line-height: 1.25; }
.rm-loop-item .rm-loop-dir {
  font-size: 0.8em;
  font-variant: small-caps;
  letter-spacing: 0.06em;
  color: var(--rm-soft);
}
.rm-loop-item .rm-value { font-size: 1.2em; font-variant: normal; }

/* Share a verse: the verse number stays as it was; a dotted underline and the
   link colour appear only on hover or keyboard focus. */
.rm-share {
  display: inline;
  margin: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
  background: none;
  border: 0;
  border-radius: 2px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.rm-share:hover {
  color: var(--c-link, #3a5c8d);
  text-decoration: underline dotted;
  text-underline-offset: 0.18em;
}
.rm-share:focus-visible {
  color: var(--c-link, #3a5c8d);
  outline: 2px solid var(--c-link, #3a5c8d);
  outline-offset: 2px;
}
.rm-copy { position: fixed; top: 0; left: -9999px; opacity: 0; }

/* Confirmation toast: a quiet pill above the Menu button. */
.rm-toast {
  position: fixed;
  left: 50%;
  bottom: calc(max(0.75rem, env(safe-area-inset-bottom)) + 44px + 0.6rem);
  z-index: 950;
  width: max-content;
  max-width: min(26rem, calc(100vw - 1.5rem));
  box-sizing: border-box;
  padding: 0.55rem 1.1rem;
  transform: translateX(-50%);
  background: var(--rm-bg);
  color: var(--rm-text);
  border: 1px solid var(--rm-rule-strong);
  border-left: 3px solid var(--rm-accent);
  border-radius: 4px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.16);
  font-size: 11pt;
  text-align: center;
  pointer-events: none;
}
.rm-toast[hidden] { display: none; }
.rm-toast-in { animation: rm-toast 0.25s ease-out; }
@keyframes rm-toast {
  from { opacity: 0; transform: translate(-50%, 6px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* Where Go to (or a jump) lands: a short teal wash. */
.rm-flash { animation: rm-flash 2s ease-out; }
@keyframes rm-flash {
  from { background-color: rgba(43, 106, 115, 0.22); background-color: color-mix(in srgb, var(--c-wisdom, #2b6a73) 24%, transparent); }
  to { background-color: transparent; }
}

/* "Continue the Loop", after the book's last chapter. */
.rm-loop {
  margin: 3rem 0 1rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--c-border, #e0dce5);
  text-align: center;
}
.rm-loop-title {
  margin: 0 0 0.75rem;
  text-align: center;
  font-variant: small-caps;
  letter-spacing: 0.08em;
  color: var(--c-text-soft, #6d6a70);
}
.rm-loop ul {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.rm-loop li { margin: 0; padding: 0; text-indent: 0; flex: 0 1 50%; }
.rm-loop-prev { text-align: left; }
.rm-loop-next { text-align: right; margin-left: auto !important; }
.rm-loop a {
  display: inline-flex;
  flex-direction: column;
  gap: 0.1rem;
  min-height: 44px;
  justify-content: center;
  border-bottom: 0;
  text-decoration: none;
}
.rm-loop-next a { align-items: flex-end; }
.rm-loop .rm-loop-dir {
  font-size: 0.8em;
  font-variant: small-caps;
  letter-spacing: 0.06em;
  color: var(--c-text-soft, #6d6a70);
}
.rm-loop .rm-loop-book { border-bottom: 1px dotted currentColor; }
.rm-loop a:hover .rm-loop-book,
.rm-loop a:focus-visible .rm-loop-book { border-bottom-style: solid; }
.rm-loop a:focus-visible { outline: 2px solid var(--c-link, #3a5c8d); outline-offset: 3px; }
@media (max-width: 30rem) {
  .rm-loop ul { flex-direction: column; gap: 0.5rem; }
  .rm-loop li { flex: none; }
}
/* data-loop-next-panel: the previous link, then the page's own teaser for the next book. */
.rm-loop-stacked ul { flex-direction: column; align-items: stretch; gap: 0.75rem; }
.rm-loop-stacked li { flex: none; }
.rm-loop-stacked .rm-loop-prev { text-align: center; }
.rm-loop-stacked .rm-loop-panel { margin-left: 0 !important; text-align: inherit; }

/* ---- Motion ----------------------------------------------------------- */
@keyframes rm-rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@keyframes rm-slide {
  from { transform: translateX(-24px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .rm-menu, .rm-resume, .rm-contents[open], .install, .rm-toast-in { animation: none; }  /* .rm-flash only fades a colour: kept */
  .rm-toggle, .rm-sightline, .focus-mode .rm-unit, .install-go { transition: none; }
}

/* ---- Phones: contents becomes a full-width sheet; prompt clears toggle -- */
@media (max-width: 700px) {
  .rm-sightline { top: 35vh; }
}
@media (max-width: 30rem) {
  .rm-contents { width: 100vw; border-right: 0; }
  .rm-resume { bottom: calc(max(0.75rem, env(safe-area-inset-bottom)) + 44px + 0.6rem); max-width: none; }
  /* Icon beside the label only; the text and the button take the full width. */
  .install {
    grid-template-columns: 44px minmax(0, 1fr);
    grid-template-areas: "icon title" "lead lead" "how how" "go go";
    column-gap: 0.8rem;
    margin-top: 3rem;
    padding: 0.9rem 1rem 1.1rem;
  }
  .install-icon { width: 44px; height: 44px; margin-bottom: 0.6rem; }
  .install .install-title { align-self: center; margin-bottom: 0.6rem; }
  .install-go { justify-self: stretch; }
  .install-x { top: 0.9rem; }
}
