/* The search bar (assets/finder.js), shared by the reader and the library. It uses the page's own palette:
   --text, --ui, --ink, --ink-2, --ink-3, --paper, --line, --red, --ease */
@keyframes fxFadeIn { from { opacity: 0; } }
/* ------------------------------------------------------------------ search: a sheet of the same paper, floating over a dimmed room.
   The text's serif, red only for what is alive (the chosen passage, matched words, the active scope) */
.fx-scrim { position: fixed; inset: 0; z-index: 70; background: rgba(38, 22, 8, .32); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  opacity: 0; transition: opacity .22s var(--ease); }
html[data-theme="dark"] .fx-scrim { background: rgba(0, 0, 0, .56); }
.fx-scrim.show { opacity: 1; }
.finder { --fx-top: max(64px, 15vh); position: fixed; z-index: 71; left: 50%; top: var(--fx-top); width: min(700px, calc(100vw - 32px));
  max-height: calc(100vh - var(--fx-top) - 48px); max-height: calc(100dvh - var(--fx-top) - 48px); display: flex; flex-direction: column;
  font-family: var(--text); color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  box-shadow: 0 1px 2px rgba(30, 24, 16, .08), 0 18px 40px -18px rgba(30, 24, 16, .35), 0 50px 110px -40px rgba(30, 24, 16, .5);
  opacity: 0; transform: translate(-50%, 8px) scale(.985); transform-origin: 50% 0; transition: opacity .18s var(--ease), transform .28s var(--ease); }
html[data-theme="dark"] .finder { border-color: rgba(255, 255, 255, .07); box-shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 24px 60px -20px rgba(0, 0, 0, .8), 0 50px 120px -40px rgba(0, 0, 0, .9); }
.finder.show { opacity: 1; transform: translate(-50%, 0); }
.finder[hidden], .fx-scrim[hidden] { display: none; }

.fx-field { flex: none; display: flex; align-items: center; gap: 12px; height: 64px; padding: 0 16px 0 22px; }
.fx-icon { flex: none; display: grid; place-items: center; color: var(--red); }
.fx-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.fx-field input { flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; outline: none; background: none; color: var(--ink);
  font: 400 23px/1.2 var(--text); letter-spacing: .005em; -webkit-appearance: none; appearance: none; }
.fx-field input::placeholder { color: var(--ink-3); font-style: italic; opacity: 1; }
.fx-field input::-webkit-search-cancel-button, .fx-field input::-webkit-search-decoration { -webkit-appearance: none; display: none; }
.finder kbd { display: inline-block; min-width: 1.7em; padding: 1px 5px; border: 1px solid var(--line); border-bottom-width: 1.5px; border-radius: 5px;
  font: 11px/1.4 var(--ui); color: var(--ink-3); text-align: center; background: color-mix(in srgb, var(--ink) 3%, transparent); }
.fx-esc { flex: none; }
.fx-x { display: none; flex: none; width: 36px; height: 36px; place-items: center; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--ink-3); cursor: pointer; }
.fx-x svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }

/* the scope: two small-caps words, the chosen one underlined in red, like a heading in the book's contents */
.fx-scope { flex: none; display: flex; align-items: baseline; gap: 18px; padding: 0 22px 0 56px; height: 34px; border-bottom: 1px solid var(--line); }
.fx-scope button { position: relative; padding: 6px 0 9px; border: 0; background: none; cursor: pointer; color: var(--ink-3);
  font: 14.5px/1 var(--text); letter-spacing: .14em; font-variant-caps: all-small-caps; transition: color .2s; }
.fx-scope button:hover { color: var(--ink); }
.fx-scope button[aria-checked="true"] { color: var(--ink); }
.fx-scope button[aria-checked="true"]::after { content: ""; position: absolute; left: 0; right: .14em; bottom: -1px; height: 2px; background: var(--red); }
.fx-scope button:focus-visible { outline-offset: 3px; }
.fx-status { margin-left: auto; font: italic 13.5px/1 var(--text); color: var(--ink-3); font-variant-numeric: lining-nums; white-space: nowrap; }

/* chapters named for what is searched */
.fx-chapters { flex: none; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 18px; padding: 9px 26px 10px 56px; font-size: 15px; line-height: 1.35;
  border-bottom: 1px solid var(--line); }
.fx-chapters[hidden] { display: none; }
.fx-chl { margin-left: -2px; font-size: 13px; letter-spacing: .12em; font-variant-caps: all-small-caps; color: var(--ink-3); }
.fx-chap { display: inline-flex; align-items: baseline; gap: 7px; min-width: 0; color: var(--ink); text-decoration: none; }
.fx-cht { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--red) 40%, transparent); text-underline-offset: .2em; text-decoration-thickness: 1px; }
.fx-chap:hover .fx-cht, .fx-chap:focus-visible .fx-cht { text-decoration-color: var(--red); }
.fx-chb { font-size: 13px; letter-spacing: .08em; font-variant-caps: all-small-caps; color: var(--ink-3); white-space: nowrap; }
.fx-also { margin: 4px 0 0; font-size: 13px; font-style: italic; color: var(--ink-3); }

/* the one-sentence answer, quoted from the books, once the passages have been weighed */
.fx-answer { flex: none; min-height: calc(2 * 1.42em + 42px); display: flex; align-items: center; padding: 11px 26px 11px 56px; font-size: 16px; line-height: 1.42;
  border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--ink) 2%, transparent); }
.fx-answer[hidden] { display: none; }
.fx-wait { font-style: italic; color: var(--ink-3); animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .45; } }
.fx-answer.stale .fx-ans { opacity: .55; }
.fx-ans { display: block; min-width: 0; color: var(--ink); text-decoration: none; border-radius: 3px; animation: fxFadeIn .4s var(--ease); transition: opacity .3s; }
.fx-ans q { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-style: italic; quotes: "“" "”"; }
.fx-ans q::before, .fx-ans q::after { color: var(--red); font-style: normal; }
.fx-src { display: block; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; font-size: 13.5px; letter-spacing: .06em; font-variant-caps: all-small-caps; color: var(--ink-3); white-space: nowrap; }
.fx-src::before { content: "— "; letter-spacing: 0; }
.fx-ans:hover q { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--red) 50%, transparent); text-underline-offset: .18em; text-decoration-thickness: 1px; }

/* the passages */
.fx-list { flex: 1 1 auto; min-height: 0; list-style: none; margin: 0; padding: 6px 0 10px; overflow-y: auto; overscroll-behavior: contain;
  -webkit-mask-image: linear-gradient(#000 calc(100% - 22px), transparent); mask-image: linear-gradient(#000 calc(100% - 22px), transparent); }
.fx-list:empty { display: none; }
.fx-item { position: relative; padding: 10px 26px 12px 56px; cursor: pointer; }
.fx-item[aria-selected="true"] { background: color-mix(in srgb, var(--red) 6%, transparent); }
.fx-item[aria-selected="true"]::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--red); }
.fx-meta { display: flex; align-items: baseline; gap: 10px; min-width: 0; margin-bottom: 3px; font-size: 14.5px; line-height: 1.3; }
.fx-book { flex: none; max-width: 46%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: .1em; font-variant-caps: all-small-caps; color: var(--ink-2); }
.fx-ch { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-style: italic; color: var(--ink-3); }
.fx-in { flex: none; font-size: 13px; font-style: italic; color: var(--red); }
.fx-pp { flex: none; margin-left: auto; padding-left: 8px; color: var(--ink-2); font-variant-numeric: lining-nums tabular-nums; white-space: nowrap; }
.fx-item[aria-selected="true"] .fx-pp { color: var(--red); }
.fx-snip { margin: 0; font-size: 16.5px; line-height: 1.45; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  font-variant-numeric: oldstyle-nums; hyphens: auto; -webkit-hyphens: auto; }
.fx-snip mark { color: inherit; background: linear-gradient(transparent 60%, color-mix(in srgb, var(--red) 24%, transparent) 60%, color-mix(in srgb, var(--red) 24%, transparent) 92%, transparent 92%); }
html[data-theme="dark"] .fx-snip mark { background: linear-gradient(transparent 60%, color-mix(in srgb, var(--red) 36%, transparent) 60%, color-mix(in srgb, var(--red) 36%, transparent) 92%, transparent 92%); }

/* empty, searching, nothing found, service down */
.fx-empty { padding: 22px 26px 24px 56px; }
.fx-empty:empty { display: none; }
.finder[data-state="results"] .fx-empty { display: none; }
.fx-e1 { margin: 0; font-size: 18px; font-style: italic; color: var(--ink-2); }
.fx-e2 { margin: 4px 0 0; font-size: 14.5px; color: var(--ink-3); }
.finder[data-state="loading"] .fx-e1 { animation: breathe 1.6s ease-in-out infinite; }
.finder[data-state="down"] .fx-e1 { color: var(--ink); }
.fx-all { margin-top: 12px; padding: 0; border: 0; background: none; cursor: pointer; font: 15px var(--text); color: var(--red);
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .2em; }

.fx-foot { flex: none; display: flex; gap: 22px; padding: 9px 22px 10px 56px; border-top: 1px solid var(--line); font: 12px/1.4 var(--ui); color: var(--ink-3); }
.fx-foot kbd { margin-right: 3px; }
.finder[data-state="results"] .fx-foot { border-top-color: transparent; }

/* phones: the full width at the top of the screen, above the keyboard; a close button instead of esc */
@media (max-width: 640px) {
  .finder { --fx-top: calc(max(8px, env(safe-area-inset-top)) + 2px); width: calc(100vw - 16px); max-height: calc(100dvh - var(--fx-top) - 10px); border-radius: 14px; }
  .fx-field { height: 56px; gap: 10px; padding: 0 6px 0 16px; }
  .fx-field input { font-size: 19px; }
  .finder .fx-esc { display: none; }
  .fx-x { display: grid; }
  .fx-scope, .fx-item, .fx-answer, .fx-chapters, .fx-empty { padding-left: 18px; padding-right: 16px; }
  .fx-scope { gap: 16px; }
  .fx-item { padding-top: 11px; padding-bottom: 12px; }
  .fx-book { max-width: 52%; }
  .fx-snip { font-size: 15.5px; -webkit-line-clamp: 4; }
  .fx-answer { font-size: 15px; }
  .fx-foot { display: none; }
}
@media (hover: none) { .fx-foot, .finder .fx-esc { display: none; } .fx-x { display: grid; } }
.finder:is([data-state="down"], [data-state="none"], [data-state="loading"]) .fx-foot { display: none; }
