/* THE BOOK — UI v2: context menu, selection, search, notes, categories */

/* Search button in topbar */
.topbar { grid-template-columns: auto 1fr auto auto; }
.iconbtn.search-btn { /* fits next to theme */ }

/* ---------- Verse field ---------- */
.verses {
  margin: 28px 0 0;
  padding: 0;
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.78;
  color: var(--ink);
}
.verses .v {
  display: block;
  position: relative;
  padding: 18px 12px 18px 44px;
  margin: 0 -12px;
  border-top: 1px solid color-mix(in oklab, var(--rule) 48%, transparent);
  border-radius: 8px;
  cursor: pointer;
  -webkit-user-select: text;
  user-select: text;
  -webkit-tap-highlight-color: transparent;
  transition: background .18s ease, transform .18s ease;
  animation: verseRise .5s cubic-bezier(.2,.7,.2,1) both;
  animation-delay: var(--d, 0ms);
}
.verses .v:first-child { border-top-color: transparent; }
.verses .v:hover {
  background: color-mix(in oklab, var(--bg-2) 60%, transparent);
}
.verses .v.is-selected {
  background: color-mix(in oklab, var(--accent) 18%, transparent);
  box-shadow: inset 3px 0 0 var(--accent);
}
.verses .v.is-highlighted {
  background: color-mix(in oklab, var(--gold) 22%, transparent);
}
.verses .v.is-selected.is-highlighted {
  background: color-mix(in oklab, var(--accent) 22%, color-mix(in oklab, var(--gold) 22%, transparent));
}
.verses .v .vn {
  position: absolute;
  left: 8px; top: 12px;
  width: 28px; text-align: right;
  font-family: var(--sans);
  font-size: 11px; font-weight: 600;
  color: var(--accent);
  letter-spacing: .04em;
  line-height: 1;
  padding-top: 4px;
}
.verses .v .vt { display: inline; }
.verses .v.has-note::after {
  content: "✎";
  position: absolute;
  right: 12px; top: 10px;
  color: var(--gold);
  font-size: 13px;
  opacity: .7;
}
.verses .v.is-jesus .vt { color: var(--accent); }

@keyframes verseRise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Context menu ---------- */
.ctx {
  position: fixed; z-index: 200;
  min-width: 220px;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 14px;
  box-shadow: 0 24px 60px -20px rgba(0,0,0,.45);
  padding: 6px;
  font-family: var(--sans);
  opacity: 0; transform: scale(.96) translateY(4px);
  transform-origin: top left;
  transition: opacity .14s ease, transform .14s ease;
  pointer-events: none;
  overflow: hidden;
}
.ctx.show { opacity: 1; transform: scale(1) translateY(0); pointer-events: auto; }
.ctx button {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  background: transparent; border: 0;
  padding: 10px 12px;
  font-family: var(--sans); font-size: 14px;
  color: var(--ink);
  border-radius: 8px;
  cursor: pointer;
  transition: background .12s ease;
}
.ctx button:hover, .ctx button:focus-visible {
  background: var(--bg-2);
  outline: none;
}
.ctx button.danger { color: var(--accent); }
.ctx button .ki {
  width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-mute);
  font-size: 14px;
}
.ctx hr { border: 0; border-top: 1px solid var(--rule); margin: 4px 6px; }
.ctx .label {
  padding: 6px 12px 4px;
  font-size: 10px;
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.ctx .swatches {
  display: flex; gap: 6px; padding: 6px 12px 8px;
}
.ctx .swatches button {
  width: 26px; height: 26px; padding: 0;
  border-radius: 999px;
  border: 2px solid var(--rule);
}
.ctx .swatches button[data-color="yellow"] { background: #ffd766; }
.ctx .swatches button[data-color="rose"]   { background: #f08a8a; }
.ctx .swatches button[data-color="teal"]   { background: #7ec9c0; }
.ctx .swatches button[data-color="violet"] { background: #b39bd6; }
.ctx .swatches button[data-color="clear"]  { background: transparent; border-style: dashed; }

/* ---------- Selection action bar ---------- */
.actionbar {
  position: fixed; z-index: 50;
  left: 50%; bottom: calc(20px + var(--safe-bot));
  transform: translateX(-50%) translateY(160%);
  display: flex; align-items: center; gap: 4px;
  padding: 8px;
  background: color-mix(in oklab, var(--ink) 96%, transparent);
  color: var(--bg);
  border-radius: 999px;
  box-shadow: 0 24px 60px -20px rgba(0,0,0,.55);
  transition: transform .35s cubic-bezier(.6,.05,.2,1), opacity .25s ease;
  opacity: 0;
  font-family: var(--sans);
}
.actionbar.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.actionbar .count {
  display: inline-flex; align-items: center;
  padding: 0 12px 0 14px;
  font-size: 12px; letter-spacing: .14em; text-transform: uppercase;
  color: color-mix(in oklab, var(--bg) 80%, var(--ink-mute));
}
.actionbar button {
  background: transparent;
  border: 0; color: var(--bg);
  border-radius: 999px;
  padding: 10px 14px;
  font-family: var(--sans); font-size: 13px; font-weight: 500;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .15s ease, transform .15s ease;
}
.actionbar button:hover { background: color-mix(in oklab, var(--bg) 14%, transparent); }
.actionbar button:active { transform: scale(.96); }
.actionbar button.icon-only { padding: 10px; }
.actionbar svg { width: 16px; height: 16px; }
@media (max-width: 540px) {
  .actionbar { width: calc(100% - 24px); justify-content: space-between; border-radius: 18px; }
  .actionbar button .lab { display: none; }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; top: calc(70px + var(--safe-top));
  transform: translateX(-50%) translateY(-20px);
  background: var(--ink); color: var(--bg);
  font-family: var(--sans); font-size: 13px;
  padding: 10px 18px; border-radius: 999px;
  z-index: 220;
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  box-shadow: 0 12px 40px -10px rgba(0,0,0,.5);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Modal (notes) ---------- */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: none;
  align-items: flex-end; justify-content: center;
  padding: 0;
}
.modal.show { display: flex; }
.modal-back {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(4px);
  animation: fade .2s ease both;
}
.modal-card {
  position: relative;
  width: 100%; max-width: 560px;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 18px 18px 0 0;
  padding: 22px 22px calc(22px + var(--safe-bot));
  box-shadow: 0 -30px 80px -20px rgba(0,0,0,.5);
  animation: slideUp .3s cubic-bezier(.2,.7,.2,1) both;
}
@media (min-width: 600px) {
  .modal { align-items: center; padding: 24px; }
  .modal-card { border-radius: 18px; }
}
.modal-card h3 {
  font-family: var(--serif); font-weight: 500;
  font-size: 24px; margin: 0 0 4px;
}
.modal-card .ref {
  font-family: var(--sans); font-size: 11px;
  color: var(--accent); letter-spacing: .26em; text-transform: uppercase;
  margin-bottom: 14px;
}
.modal-card .quote {
  border-left: 2px solid var(--accent);
  padding-left: 14px;
  margin: 0 0 18px;
  color: var(--ink-soft);
  font-style: italic;
  font-size: 15px;
  line-height: 1.55;
}
.modal-card textarea {
  width: 100%; min-height: 140px;
  background: var(--bg-2);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 14px;
  font-family: var(--serif); font-size: 17px; line-height: 1.55;
  color: var(--ink);
  resize: vertical;
  outline: none;
}
.modal-card textarea:focus { border-color: var(--accent); }
.modal-actions {
  display: flex; gap: 8px; margin-top: 14px; justify-content: flex-end;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp { from { transform: translateY(40px); opacity: 0 } to { transform: translateY(0); opacity: 1 } }

/* ---------- Search overlay ---------- */
.searchpanel {
  position: fixed; inset: 0; z-index: 90;
  display: none;
  flex-direction: column;
  background: var(--bg);
  animation: fade .2s ease both;
}
.searchpanel.show { display: flex; }
.searchpanel header {
  display: flex; gap: 10px; align-items: center;
  padding: calc(10px + var(--safe-top)) 18px 12px;
  border-bottom: 1px solid var(--rule);
  background: color-mix(in oklab, var(--bg) 80%, transparent);
  backdrop-filter: blur(14px);
}
.searchpanel input {
  flex: 1;
  background: transparent;
  border: 0; outline: 0;
  font-family: var(--serif); font-size: 22px;
  color: var(--ink);
  padding: 6px 0;
}
.searchpanel input::placeholder { color: var(--ink-mute); font-style: italic; }
.searchpanel .results {
  flex: 1; overflow-y: auto;
  padding: 8px 18px 80px;
}
.searchpanel .hint {
  padding: 36px 18px;
  text-align: center;
  color: var(--ink-mute);
  font-family: var(--sans); font-size: 13px;
  letter-spacing: .04em;
}
.search-result {
  display: block;
  padding: 14px 12px;
  margin: 4px -12px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--ink);
  border-bottom: 1px solid var(--rule);
  transition: background .15s ease;
}
.search-result:hover { background: var(--bg-2); }
.search-result .ref {
  font-family: var(--sans); font-size: 11px;
  color: var(--accent); letter-spacing: .2em; text-transform: uppercase;
  margin-bottom: 4px;
}
.search-result .snip {
  font-family: var(--serif); font-size: 17px; line-height: 1.5;
}
.search-result mark {
  background: color-mix(in oklab, var(--gold) 30%, transparent);
  color: var(--ink);
  padding: 0 2px; border-radius: 3px;
}
.searchpanel .quickbooks {
  padding: 4px 18px 12px;
  border-bottom: 1px solid var(--rule);
}
.searchpanel .quickbooks .lab {
  font-family: var(--sans); font-size: 10px; letter-spacing: .26em;
  text-transform: uppercase; color: var(--ink-mute);
  display: block; margin-bottom: 8px;
}
.searchpanel .quickbooks .row {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.searchpanel .quickbooks a {
  display: inline-flex; align-items: baseline; gap: 6px;
  text-decoration: none;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 6px 12px;
  font-family: var(--serif); font-size: 14px;
  color: var(--ink);
}
.searchpanel .quickbooks a:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Bible home: categories ---------- */
.cat-stack { display: grid; gap: 14px; }
.cat {
  border: 1px solid var(--rule);
  border-radius: 16px;
  background: linear-gradient(180deg, var(--bg) 0%, color-mix(in oklab, var(--bg) 90%, var(--bg-2)) 100%);
  overflow: hidden;
  transition: border-color .25s ease;
}
.cat:hover { border-color: color-mix(in oklab, var(--accent) 40%, var(--rule)); }
.cat-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 18px 20px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.cat-head .ttl {
  font-family: var(--serif);
  font-size: 24px; font-weight: 500;
  letter-spacing: -.005em;
}
.cat-head .meta {
  font-family: var(--sans); font-size: 11px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-mute);
}
.cat-head .blurb {
  font-family: var(--serif); font-style: italic; color: var(--ink-soft);
  font-size: 14px; margin-top: 4px;
}
.cat-head .grow { flex: 1; min-width: 0; padding-right: 14px; }
.cat-head .chev {
  transition: transform .3s ease;
  color: var(--ink-mute);
}
.cat[open] .cat-head .chev { transform: rotate(90deg); color: var(--accent); }
.cat-body {
  padding: 0 20px 18px;
  border-top: 1px solid var(--rule);
  display: none;
}
.cat[open] .cat-body { display: block; animation: fade .25s ease both; }
.cat-progress {
  height: 3px;
  background: var(--rule);
  position: relative; overflow: hidden;
}
.cat-progress > span {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  transition: width .6s ease;
}

/* ripple feedback for tap */
.ripple { position: relative; overflow: hidden; }
.ripple::after {
  content: ""; position: absolute;
  left: var(--rx,50%); top: var(--ry,50%);
  width: 0; height: 0; border-radius: 50%;
  background: color-mix(in oklab, var(--accent) 30%, transparent);
  transform: translate(-50%,-50%);
  pointer-events: none;
}
.ripple.is-rippling::after {
  animation: rippleA .55s ease-out;
}
@keyframes rippleA {
  from { width: 0; height: 0; opacity: .55; }
  to { width: 240%; height: 240%; opacity: 0; }
}

/* settings row */
.reader-settings {
  position: sticky; top: calc(54px + var(--safe-top));
  z-index: 5;
  display: flex; gap: 6px; align-items: center;
  background: color-mix(in oklab, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px);
  padding: 8px 0;
  margin: 0 -12px 12px;
  padding-left: 12px; padding-right: 12px;
  border-bottom: 1px solid var(--rule);
}
.readbar .reader-settings {
  position: static;
  top: auto;
  z-index: auto;
  width: auto;
  margin: 0;
  padding: 0;
  border-bottom: 0;
  background: transparent;
  backdrop-filter: none;
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 0 0 auto;
  white-space: nowrap;
}
.readbar .reader-settings .seg {
  background: color-mix(in oklab, var(--bg-2) 56%, transparent);
  width: auto;
  height: auto;
  flex: 0 0 auto;
}
.readbar .reader-settings .seg button {
  height: 30px;
  min-width: 54px;
  padding: 0 12px;
}
.readbar .reader-settings .seg button:not([aria-pressed="true"]) {
  display: none;
}
.readbar .reader-settings .ref-tag {
  display: none;
}
.reader-settings .seg {
  display: inline-flex; gap: 0;
  background: var(--bg-2); border: 1px solid var(--rule);
  border-radius: 999px; padding: 3px;
}
.reader-settings .seg button {
  background: transparent; border: 0;
  font-family: var(--sans); font-size: 12px; font-weight: 500;
  color: var(--ink-soft);
  padding: 6px 12px; border-radius: 999px;
  cursor: pointer;
  letter-spacing: .04em;
}
.reader-settings .seg button[aria-pressed="true"] {
  background: var(--ink); color: var(--bg);
}
.reader-settings .grow { flex: 1; }
.reader-settings .ref-tag {
  font-family: var(--sans); font-size: 11px;
  color: var(--ink-mute); letter-spacing: .14em; text-transform: uppercase;
}

/* font sizing for reader */
.verses[data-size="s"] { font-size: 17px; }
.verses[data-size="m"] { font-size: 19px; }
.verses[data-size="l"] { font-size: 22px; line-height: 1.82; }
.verses[data-size="xl"]{ font-size: 25px; line-height: 1.85; }
.verses.vc-host .vc-card {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  width: 100%;
  box-sizing: border-box;
  min-height: clamp(220px, 28vh, 340px);
  margin: 0;
  padding: clamp(20px, 5vw, 36px) clamp(20px, 5vw, 32px);
  border: 1px solid color-mix(in oklab, var(--accent) 18%, var(--rule));
  border-radius: 14px;
  overflow: visible;
}
.verses.vc-host .vc-vt {
  display: block;
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: auto;
}
.verses.vc-host[data-size="s"] .vc-vt { font-size: clamp(18px, 3vw, 22px); line-height: 1.58; }
.verses.vc-host[data-size="m"] .vc-vt { font-size: clamp(20px, 3.4vw, 25px); line-height: 1.62; }
.verses.vc-host[data-size="l"] .vc-vt { font-size: clamp(23px, 3.8vw, 30px); line-height: 1.66; }
.verses.vc-host[data-size="xl"] .vc-vt { font-size: clamp(26px, 4.3vw, 34px); line-height: 1.68; }
@media (max-width: 540px) {
  .verses.vc-host .vc-card { min-height: 180px; padding: 20px; }
  .verses.vc-host[data-size="l"] .vc-vt { font-size: 22px; }
  .verses.vc-host[data-size="xl"] .vc-vt { font-size: 24px; }
}

/* notes section under chapter */
.notes-section {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--rule);
}
.notes-section h2 {
  font-family: var(--sans); font-size: 11px;
  letter-spacing: .26em; text-transform: uppercase;
  color: var(--ink-mute); font-weight: 500;
  margin: 0 0 14px;
}
.note-item {
  border-left: 2px solid var(--gold);
  padding: 4px 14px;
  margin: 12px 0;
}
.note-item .ref {
  font-family: var(--sans); font-size: 11px;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}
.note-item .body {
  font-family: var(--serif); font-size: 16px;
  color: var(--ink-soft);
  white-space: pre-wrap;
}
.note-item .verse-quote {
  font-family: var(--serif); font-style: italic;
  font-size: 14px; color: var(--ink-mute);
  margin-bottom: 6px;
}
