/* CTS Q&A — styled to match « Quatre ans dans la Parole » (https://ebne.net/etudes/) */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --ink: #1a2130;
  --muted: #586276;
  --line: #dbe1ea;
  --accent: #2b4a8b;
  --accent-soft: #e5ebf6;
  --mark: #fde9a8;
  --danger: #a3343f;
  --y1: #3d7a4c; --y2: #9b6a10; --y3: #8c2e3b; --y4: #2b4a8b;
  --shadow: 0 1px 2px rgba(26, 33, 48, .06), 0 8px 24px rgba(26, 33, 48, .06);
  --serif: "Alegreya", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Alegreya Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --radius: 8px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11151c; --surface: #19202a; --ink: #e5e9f0; --muted: #9ba5b7; --line: #2a3340;
    --accent: #93acea; --accent-soft: #1f2b43; --mark: #5c4a12; --danger: #e58a97;
    --y1: #7cc08e; --y2: #e0b25a; --y3: #e58a97; --y4: #93acea;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #11151c; --surface: #19202a; --ink: #e5e9f0; --muted: #9ba5b7; --line: #2a3340;
  --accent: #93acea; --accent-soft: #1f2b43; --mark: #5c4a12; --danger: #e58a97;
  --y1: #7cc08e; --y2: #e0b25a; --y3: #e58a97; --y4: #93acea;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; width: 100%; max-width: 100%; overflow-x: hidden; }
body { background: var(--bg); color: var(--ink); font: 18px/1.6 var(--serif); }
a { color: var(--accent); }
button, input, textarea, select { font: 15px/1.4 var(--sans); color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
mark { background: var(--mark); color: inherit; padding: 0 .1em; border-radius: 2px; }

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 10;
  background: var(--accent); color: var(--surface); padding: 8px 14px;
  font: 700 15px var(--sans); border-radius: var(--radius); text-decoration: none;
}
.skip-link:focus { left: 12px; top: 12px; }

.wrap { max-width: 46rem; margin: 0 auto; padding: 28px 20px 64px; }

/* Header */
header.app-head {
  display: flex; flex-wrap: wrap; gap: 12px 20px;
  justify-content: space-between; align-items: flex-start;
  margin-bottom: 20px;
}
.brand { min-width: 0; flex: 1 1 260px; }
.eyebrow {
  display: block; margin: 0 0 4px; text-decoration: none;
  font: 700 13px var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--accent);
}
.eyebrow:hover { text-decoration: underline; }
.brand h1 {
  font-family: var(--serif); font-weight: 800; letter-spacing: -.015em;
  font-size: clamp(30px, 5vw, 40px); line-height: 1.15; margin: 0 0 6px; text-wrap: balance;
}
.tagline { margin: 0; color: var(--muted); font-size: 17px; font-style: italic; line-height: 1.45; }
.credit { margin: 2px 0 0; font: 13px/1.4 var(--sans); color: var(--muted); }
.credit a { color: var(--muted); text-decoration: none; }
.credit a:hover { color: var(--accent); text-decoration: underline; }

.head-actions {
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
  font-family: var(--sans); font-size: 15px;
}
.lang-toggle {
  display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; background: var(--surface);
}
.lang-toggle button {
  appearance: none; border: 0; background: transparent; color: var(--muted);
  padding: 6px 12px; cursor: pointer; font-weight: 700; letter-spacing: .04em;
}
.lang-toggle button + button { border-left: 1px solid var(--line); }
.lang-toggle button:hover { background: var(--bg); color: var(--ink); }
.lang-toggle button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.lang-toggle button:focus-visible { outline-offset: -2px; }
.open-full { display: none; color: var(--accent); font-size: 14px; white-space: nowrap; }

/* Panels */
.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 22px 22px;
}
label.q-label {
  display: block; margin-bottom: 8px;
  font: 700 20px/1.25 var(--serif); color: var(--ink);
}
.ask-row { display: flex; gap: 10px; flex-wrap: wrap; }
textarea#question {
  flex: 1 1 260px; min-width: 0; min-height: 5rem; resize: vertical;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg); color: var(--ink); font-size: 16px;
}
textarea#question::placeholder { color: var(--muted); }
textarea#question:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button.primary {
  align-self: stretch; min-width: 8rem;
  background: var(--accent); color: var(--surface);
  border: 1px solid var(--accent); border-radius: var(--radius); cursor: pointer;
  font-weight: 700; padding: 9px 16px;
}
button.primary:hover { filter: brightness(1.08); }

.samples { margin-top: 16px; }
.samples h2 {
  font: 700 13px var(--sans); letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 8px;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: var(--bg); border: 1px solid var(--line); color: var(--ink);
  border-radius: var(--radius); padding: 5px 11px; cursor: pointer; text-align: left;
  max-width: 100%;
}
.chip:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.status { margin: 12px 0 0; color: var(--muted); font: 14px/1.4 var(--sans); }
.status.error { color: var(--danger); }

/* Answer */
.answer-panel { margin-top: 20px; }
.meta-row {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-bottom: 6px; font-family: var(--sans);
}
.badge {
  font: 700 13px var(--sans); letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-soft);
  padding: 2px 8px; border-radius: 6px;
}
.match-score { color: var(--muted); font-size: 14px; }
.answer-panel h2, .answer-panel h3 { font-family: var(--serif); line-height: 1.2; text-wrap: balance; }
.answer-panel h2 { font-size: 26px; font-weight: 700; margin: 6px 0 12px; }
.answer-panel h3 { font-size: 20px; font-weight: 700; margin: 22px 0 8px; }
.answer-body p { margin: 0 0 14px; overflow-wrap: anywhere; }
.key-points { margin: 0; padding-left: 1.2rem; }
.key-points li { margin-bottom: 6px; }
.key-points li::marker { color: var(--accent); }
.scripture, .sources { list-style: none; padding: 0; margin: 0; }
.scripture { display: flex; flex-wrap: wrap; gap: 6px; }
.scripture li {
  font: 500 15px var(--sans); background: var(--accent-soft); color: var(--accent);
  padding: 3px 10px; border-radius: 6px;
}
.sources li { margin-bottom: 6px; font-size: 16px; overflow-wrap: anywhere; }

.closest { margin-top: 18px; padding-top: 4px; border-top: 1px solid var(--line); }
.closest button {
  display: block; width: 100%; text-align: left;
  background: var(--bg); border: 1px solid var(--line); color: var(--ink);
  border-radius: var(--radius); padding: 9px 12px; margin-bottom: 6px; cursor: pointer;
}
.closest button:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* Related studies (« Quatre ans dans la Parole »). Each card carries its year colour, as on ebne.net/etudes. */
.y1 { --yc: var(--y1); } .y2 { --yc: var(--y2); } .y3 { --yc: var(--y3); } .y4 { --yc: var(--y4); }
.badge-study { color: var(--yc, var(--accent)); }
.study-only-note { color: var(--muted); font-style: italic; }
.related { margin-top: 22px; padding-top: 2px; border-top: 1px solid var(--line); }
.study-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.study-card {
  background: var(--bg); border: 1px solid var(--line); border-left: 4px solid var(--yc, var(--accent));
  border-radius: var(--radius); padding: 12px 14px 12px; min-width: 0;
}
.study-meta {
  margin: 0 0 2px; font: 700 12.5px/1.4 var(--sans); letter-spacing: .06em; text-transform: uppercase;
  color: var(--yc, var(--accent));
}
.study-term {
  display: block; text-transform: none; letter-spacing: 0; font-weight: 500; font-size: 14px; color: var(--muted);
}
.study-card h4 { margin: 4px 0 4px; font: 700 19px/1.25 var(--serif); text-wrap: balance; }
.study-card h4 a { color: var(--ink); text-decoration: none; }
.study-card h4 a:hover { color: var(--accent); text-decoration: underline; }
.study-sum { margin: 0 0 8px; font-size: 16.5px; line-height: 1.5; overflow-wrap: anywhere; }
.study-card .scripture { margin-bottom: 8px; }
.study-card .scripture li { font-size: 14px; padding: 2px 8px; background: var(--surface); border: 1px solid var(--line); }
.study-res { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0; font: 14px/1.5 var(--sans); }
.study-res a { white-space: nowrap; }
.study-res .study-open { font-weight: 700; }

/* CTS Annotated Glossary (chafer-qa.json) */
.badge-soft { color: var(--muted); background: var(--bg); border: 1px solid var(--line); text-transform: none; letter-spacing: 0; }
.gloss { margin-top: 22px; padding-top: 2px; border-top: 1px solid var(--line); }
.gloss-item {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 8px; min-width: 0;
}
.gloss-item > summary {
  list-style: none; cursor: pointer; padding: 10px 14px 10px 34px; position: relative;
  border-radius: var(--radius);
}
.gloss-item > summary::-webkit-details-marker { display: none; }
.gloss-item > summary::before {
  content: "+"; position: absolute; left: 12px; top: 9px; width: 16px; text-align: center;
  font: 700 17px/1.4 var(--sans); color: var(--accent);
}
.gloss-item[open] > summary::before { content: "−"; }
.gloss-item > summary:hover { background: var(--accent-soft); }
.gloss-q { display: block; font: 700 17px/1.3 var(--serif); color: var(--ink); overflow-wrap: anywhere; }
.gloss-short { display: block; margin-top: 2px; color: var(--muted); font: 15px/1.45 var(--sans); overflow-wrap: anywhere; }
.gloss-item[open] .gloss-short { display: none; }
.gloss-body { padding: 0 14px 12px 34px; }
.gloss-body p { font-size: 16.5px; line-height: 1.55; }
.gloss-body .scripture { margin-bottom: 10px; }
.gloss-body .scripture li { font-size: 14px; padding: 2px 8px; background: var(--surface); border: 1px solid var(--line); }
.gloss-source { font: 15px/1.5 var(--sans); margin: 4px 0 6px !important; }
.answer-body .gloss-note, .gloss-body .gloss-note {
  margin: 0 0 10px; color: var(--muted); font: 13.5px/1.5 var(--sans); overflow-wrap: anywhere;
}
.gloss-own-note { display: block; margin-top: 4px; font-style: italic; }
.gloss-about { margin: 0 0 6px; font: 13.5px/1.5 var(--sans); color: var(--muted); }
.gloss-about summary { cursor: pointer; color: var(--accent); }
.gloss-about p { margin: 6px 0 0 !important; font-size: 13.5px; }

/* Reference resources (references.json: YouTube teaching + bibleframework.org) — always credited */
.badge-ref { color: var(--y2); }
.refs { margin-top: 22px; padding-top: 2px; border-top: 1px solid var(--line); }
.ref-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.ref-card {
  background: var(--bg); border: 1px solid var(--line); border-left: 4px solid var(--y2);
  border-radius: var(--radius); padding: 12px 14px; min-width: 0;
}
.ref-card h4 { margin: 0 0 4px; font: 700 18px/1.25 var(--serif); overflow-wrap: anywhere; }
.ref-card h4 a { color: var(--ink); text-decoration: none; }
.ref-card h4 a:hover { color: var(--accent); text-decoration: underline; }
.answer-body .ref-sum { margin: 0 0 8px; font-size: 16.5px; line-height: 1.5; }
.ref-main-title { font: 700 19px/1.3 var(--serif); margin-bottom: 8px !important; }
.ref-main-title a { color: var(--ink); }
.ref-excerpt { margin: 0 0 8px; min-width: 0; }
.ref-excerpt figcaption {
  font: 700 12px/1.4 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 3px;
}
.ref-excerpt blockquote {
  margin: 0; padding: 6px 12px; border-left: 3px solid var(--line); background: var(--surface);
  border-radius: 0 6px 6px 0; font: italic 15.5px/1.5 var(--serif); color: var(--ink); overflow-wrap: anywhere;
}
.answer-body .ref-open { margin: 0 0 4px; font: 700 14.5px/1.5 var(--sans); }
.answer-body .ref-credit { margin: 0; font: 14px/1.5 var(--sans); color: var(--muted); overflow-wrap: anywhere; }
.answer-body .ref-credit-main {
  margin: 4px 0 14px; padding: 6px 10px; background: var(--accent-soft); border-radius: 6px; color: var(--ink); font-weight: 600;
}
.answer-body .ref-note { margin: 8px 0 0; color: var(--muted); font: 13.5px/1.5 var(--sans); }
@media (max-width: 640px) {
  .ref-card { padding: 10px 12px; }
  .ref-card h4 { font-size: 17px; }
  .ref-excerpt blockquote { font-size: 15px; padding: 6px 10px; }
}

.disclaimer {
  margin: 20px 0 0; padding: 10px 14px;
  background: var(--bg); border-left: 3px solid var(--accent);
  color: var(--muted); font: 15px/1.5 var(--sans); border-radius: 0 var(--radius) var(--radius) 0;
}

footer { margin-top: 28px; color: var(--muted); font: 14px/1.5 var(--sans); text-align: center; }

@media (max-width: 640px) {
  body { font-size: 17px; }
  .wrap { padding: 20px 16px 48px; }
  .head-actions { flex-direction: row; align-items: center; justify-content: space-between; width: 100%; }
  .panel { padding: 16px; }
  button.primary { width: 100%; }
  .answer-panel h2 { font-size: 23px; }
  .study-card { padding: 10px 12px; }
  .study-card h4 { font-size: 18px; }
  .study-res a { white-space: normal; }
  .gloss-item > summary { padding: 9px 12px 9px 30px; }
  .gloss-item > summary::before { left: 9px; }
  .gloss-body { padding: 0 12px 10px 14px; }
}

/* Embed mode: compact, sits on the host page's surface colour */
html.embed, html.embed body { background: var(--surface); }
body.embed .wrap { max-width: 100%; width: 100%; padding: 14px 14px 16px; }
body.embed header.app-head { margin-bottom: 12px; gap: 8px 14px; align-items: center; }
body.embed .brand h1 { font-size: 24px; margin-bottom: 2px; }
body.embed .eyebrow { font-size: 12px; margin-bottom: 2px; }
body.embed .tagline { font-size: 15px; }
body.embed .credit { font-size: 12px; margin-top: 0; }
body.embed .skip-link { display: none; }
body.embed .open-full { display: inline; }
body.embed .panel { box-shadow: none; padding: 14px 16px 16px; }
body.embed label.q-label { font-size: 18px; }
body.embed textarea#question { min-height: 4rem; }
body.embed .answer-panel { margin-top: 12px; }
body.embed .answer-panel h2 { font-size: 22px; }
body.embed .study-card { background: var(--bg); }
body.embed footer { margin-top: 12px; font-size: 13px; }
@media (max-width: 480px) {
  body.embed .wrap { padding: 10px; }
  body.embed .tagline { display: none; }
}

/* The answer panel receives programmatic focus for screen readers; no visible ring needed. */
.answer-panel:focus { outline: none; }

/* « (en anglais) » after links that stay in English in French mode */
.lang-note { font: italic 0.88em var(--sans); color: var(--muted); white-space: nowrap; }
