/* ask-ai-panel.css — minimal styles for the Ask AI sidebar section.
 * Matches the sermon-notes earthy cream + amber theme.
 */

.ss-ask-ai {
  margin-top: 1em;
  padding: 0.8em 0.9em 1em;
  background: #f8f4ec;
  border: 1px solid #e0d6bd;
  border-radius: 6px;
  font-size: 0.9em;
  color: #1c1917;
}

.ss-ask-ai-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5em;
  margin-bottom: 0.5em;
}
.ss-ask-ai-head h3 {
  margin: 0;
  font-size: 1em;
  font-weight: 600;
  color: #6b4f1e;
}
.ss-ask-ai-hint {
  font-size: 0.75em;
  color: #8b6f3d;
  font-style: italic;
}

.ss-ask-ai-form textarea {
  width: 100%;
  padding: 0.5em 0.6em;
  border: 1px solid #d9cfb9;
  border-radius: 4px;
  background: #fffdf7;
  color: #1c1917;
  font: inherit;
  resize: vertical;
  outline: none;
  box-sizing: border-box;
}
.ss-ask-ai-form textarea:focus {
  border-color: #8b6f3d;
  box-shadow: 0 0 0 2px rgba(139, 111, 61, 0.15);
}

.ss-ask-ai-row {
  display: flex;
  align-items: center;
  gap: 0.6em;
  margin-top: 0.5em;
}

.ss-ask-ai-submit {
  padding: 0.4em 1.2em;
  background: #8b6f3d;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
  font-weight: 500;
}
.ss-ask-ai-submit:hover:not(:disabled) { background: #6b4f1e; }
.ss-ask-ai-submit:disabled { opacity: 0.55; cursor: default; }

.ss-ask-ai-status {
  font-size: 0.82em;
  color: #6b4f1e;
  font-style: italic;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ss-ask-ai-status.is-error { color: #b42318; font-style: normal; }

/* Summary paragraph — Pete's own 2-3 sentence answer */
.ss-summary {
  margin: 0 0 0.8em;
  color: #1d4ed8;
  font-weight: 500;
  line-height: 1.5;
}

/* V3 inline-prose body: one flowing paragraph of [ref]"clip" tokens
 * interleaved with optional Pete glue. Each clip stays an inline
 * sepia button (.ss-iq); glue between them is blue. Natural text
 * flow — NOT a list. */
.ss-inline-body {
  margin: 0;
  color: #2a2620;
  font-family: Georgia, "Iowan Old Style", serif;
  line-height: 1.7;
  font-size: 1rem;
}
.ss-inline-body .ss-iq {
  display: inline;
  white-space: normal;
  padding: 0 0.1em;
  margin: 0;
  border: 0;
  border-bottom: 1px dashed #d2b582;
  background: transparent;
  line-height: inherit;
}
.ss-inline-body .ss-iq:hover { background: #fdf5dd; }
.ss-glue {
  display: inline;
  color: #1d4ed8;   /* Pete's blue */
  font-weight: 500;
  font-style: normal;
}

/* Clip list — one source per li, short sepia clip that says what the
 * summary says. Click any clip to see full source in the popup (or, on
 * the dedicated Ask Pete page, in the study panel). */
.ss-clips {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5em;
}
.ss-clip {
  padding: 0.4em 0.55em 0.4em 0.7em;
  background: #fdf8ea;
  border-left: 3px solid #c9a24d;
  border-radius: 0 4px 4px 0;
  line-height: 1.45;
}

.ss-ask-ai-answer {
  position: relative; /* anchors absolute popup */
  margin-top: 0.9em;
  padding: 0.7em 0.9em;
  background: #fffdf7;
  border: 1px solid #ebe4d2;
  border-left: 3px solid #2563eb;  /* bright blue to match Pete's prose */
  border-radius: 4px;
  line-height: 1.5;
  /* `pre-wrap` was preserving Pete's stray newlines around quote tokens
   * and forcing the quotes into block-looking strips. `normal` lets the
   * browser collapse single newlines into spaces; paragraph breaks still
   * come through via explicit <br><br> that pushPlainText inserts. */
  white-space: normal;
  word-wrap: break-word;
  font-size: 0.86em;
  /* Pete's own words pop in bright blue so the reader can tell at a
   * glance what Pete wrote vs what came from the library. Inline quote
   * elements override back to dark sepia. */
  color: #1d4ed8;
  font-weight: 500;
}

/* ── Inline quote: click the quoted text to see who said it ─────────
 * The ref badge (e.g. [John 15:12]) is intentionally hidden. The quoted
 * text itself is the click target; the popup gives the attribution. */
.ss-iq {
  display: inline;
  margin: 0;
  padding: 0 0.12em;
  background: transparent;
  border: 0;
  border-bottom: 1px dashed #d2b582;  /* soft affordance — quote is clickable */
  cursor: pointer;
  color: #2a2620;               /* sepia body, overrides navy inheritance */
  font: inherit;
  font-weight: 400;
  line-height: inherit;
  text-align: left;
  border-radius: 2px;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}
.ss-iq:hover { background: #fdf5dd; border-bottom-color: #8b6f3d; }
.ss-iq:focus { outline: 2px solid #8b6f3d; outline-offset: 1px; }

/* Hide the ref badge — attribution shows in the popup on click. */
.ss-iq-ref { display: none; }

.ss-iq-q {
  display: inline;
  color: #2a2620;
  font-style: italic;
}

/* Invalid quotes — struck through, not clickable-looking */
.ss-iq.ss-iq-bad {
  border-bottom: 1px dotted #b42318;
  cursor: default;
  color: #7a1a0f;
}
.ss-iq.ss-iq-bad .ss-iq-q { text-decoration: line-through; font-style: normal; }
.ss-iq.ss-iq-bad:hover { background: #fdeae6; }

/* Bare scripture ref (no quote attached) — small open-in-reader chip */
.ss-iq-bare {
  display: inline;
  font-weight: 600;
  font-size: 0.85em;
  color: #6b4f1e;
  text-decoration: none;
  background: #fdf5dd;
  padding: 0 0.25em;
  border-radius: 2px;
  border: 1px solid transparent;
}
.ss-iq-bare:hover {
  background: #fce9a8;
  border-color: #c9a951;
}

/* ── Click-through popup ─────────────────────────────────────────── */
.ss-ask-ai-popup {
  position: absolute;
  z-index: 1000;
  max-width: 360px;
  min-width: 260px;
  background: #fffdf7;
  color: #2a2620;
  border: 1px solid #c9a951;
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(40, 30, 10, 0.18);
  padding: 0.6em 0.8em;
  font-size: 0.88em;
  line-height: 1.45;
}
.ss-ask-ai-popup-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.35em;
  padding-bottom: 0.3em;
  border-bottom: 1px solid #ebe4d2;
}
.ss-ask-ai-popup-ref {
  font-size: 0.95em;
  color: #6b4f1e;
}
.ss-ask-ai-popup-close {
  background: transparent;
  border: 0;
  font-size: 1.3em;
  line-height: 1;
  color: #8b6f3d;
  cursor: pointer;
  padding: 0 0.3em;
}
.ss-ask-ai-popup-close:hover { color: #2a2620; }
.ss-ask-ai-popup-meta {
  font-size: 0.82em;
  color: #8b6f3d;
  font-style: italic;
  margin-bottom: 0.3em;
}
.ss-ask-ai-popup-body {
  max-height: 240px;
  overflow-y: auto;
  font-family: Georgia, "Iowan Old Style", serif;
  font-size: 0.96em;
  color: #2a2620;
}
.ss-ask-ai-popup-body mark {
  background: #fce9a8;
  color: inherit;
  padding: 0 0.1em;
  border-radius: 2px;
}
.ss-ask-ai-popup-foot {
  margin-top: 0.5em;
  padding-top: 0.3em;
  border-top: 1px solid #ebe4d2;
  text-align: right;
}
.ss-ask-ai-popup-link {
  font-size: 0.82em;
  color: #6b4f1e;
  text-decoration: none;
  font-weight: 600;
}
.ss-ask-ai-popup-link:hover { text-decoration: underline; }

/* ── Search-trail details (collapsed by default) ─────────────────── */
.ss-ask-ai-trace {
  margin-top: 0.6em;
  font-size: 0.82em;
  color: #6b4f1e;
}
.ss-ask-ai-trace summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.2em 0;
}
.ss-ask-ai-trace-list {
  margin: 0.3em 0 0;
  padding-left: 1.4em;
  color: #4b4a47;
  font-size: 0.88em;
}
.ss-ask-ai-trace-list li { margin: 0.15em 0; }
.ss-trace-tool { font-weight: 600; color: #6b4f1e; }
.ss-trace-arg  { font-style: italic; color: #2a2620; }
.ss-trace-meta { color: #8b6f3d; font-size: 0.9em; }
.ss-trace-fail { color: #b42318; }
/* "Pete:" intro line and "~ Pete" signature inherit via pre-wrap */
.ss-ask-ai-answer a.ss-scrip-ref {
  color: #6b4f1e;
  text-decoration: none;
  font-weight: 600;
  background: #fdf5dd;
  padding: 0 0.2em;
  border-radius: 2px;
}
.ss-ask-ai-answer a.ss-scrip-ref:hover { background: #fce9a8; }
.ss-ask-ai-answer a.ss-cite-ref {
  color: #8b6f3d;
  text-decoration: none;
  font-weight: 600;
}
.ss-ask-ai-answer a.ss-cite-ref:hover { text-decoration: underline; }

/* Scripture-refs list (primary evidence) */
.ss-ask-ai-scrips {
  margin-top: 0.9em;
  padding: 0.5em 0.7em;
  background: #fdf5dd;
  border: 1px solid #e8d998;
  border-radius: 4px;
}
.ss-ask-ai-scrips h4 {
  margin: 0 0 0.3em;
  font-size: 0.8em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b4f1e;
}
.ss-ask-ai-scrips-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.9em;
  line-height: 1.5;
}
.ss-ask-ai-scrips-list li {
  padding: 0.35em 0.4em;
  border-radius: 3px;
  transition: background-color 0.6s ease;
}
.ss-ask-ai-scrips-list li + li { margin-top: 0.3em; border-top: 1px dotted #e8d998; }
.ss-ask-ai-scrips-list li.is-flash { background: #fff2c6; }
.ss-ask-ai-scrips-list .ss-scrip-head {
  color: #6b4f1e;
  font-weight: 600;
  text-decoration: none;
  display: inline-block;
  margin-right: 0.4em;
}
.ss-ask-ai-scrips-list .ss-scrip-head:hover { text-decoration: underline; }
.ss-ask-ai-scrips-list .ss-scrip-text { color: #2a2925; font-style: italic; }
.ss-ask-ai-scrips-list .ss-scrip-warn {
  color: #a67a1a;
  font-size: 0.85em;
  font-style: italic;
}
.ss-ask-ai-scrips-list .ss-scrip-missing .ss-scrip-head {
  color: #a67a1a;
  text-decoration: line-through;
}

/* Supporting sources wrapper */
.ss-ask-ai-cites-wrap {
  margin-top: 0.8em;
  padding: 0.5em 0.7em;
  background: #faf5ea;
  border: 1px solid #ebe4d2;
  border-radius: 4px;
}
.ss-ask-ai-cites-wrap h4 {
  margin: 0 0 0.3em;
  font-size: 0.8em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #8b6f3d;
}

.ss-ask-ai-citations {
  margin: 0.8em 0 0;
  padding-left: 1.6em;
  font-size: 0.85em;
  line-height: 1.45;
  color: #4b4a47;
}
.ss-ask-ai-citations li {
  margin-bottom: 0.5em;
  padding: 0.25em 0.35em;
  border-radius: 3px;
  transition: background-color 0.6s ease;
}
.ss-ask-ai-citations li.is-flash { background: #fff2c6; }
.ss-ask-ai-citations a[data-idx] { color: #6b4f1e; font-weight: 600; }
.ss-ask-ai-citations .src { color: #8b6f3d; font-size: 0.9em; }
.ss-ask-ai-citations em { color: #4b4a47; font-style: italic; }
.ss-ask-ai-citations .txt { margin-top: 0.2em; color: #4b4a47; }

.ss-ask-ai[data-state="loading"] .ss-ask-ai-submit { background: #a88a55; }
