/* Stylesheet for AnswerPageController's server-rendered /q/{shareCode} snapshot page (quran-ai-api,
   not this SPA) -- kept as a real, same-origin stylesheet file rather than an inline <style> tag
   because the site-wide Content-Security-Policy header (docker/nginx/*.conf) sets
   style-src 'self' with no 'unsafe-inline', and that header applies to every response nginx
   serves, this one included. A <link rel="stylesheet"> to a same-origin file satisfies 'self';
   an inline <style> block would just be silently dropped by the browser.

   Color tokens and the .answer-quote / .citation rule families below are kept in sync by hand
   with src/index.css and src/App.css -- this page is server-rendered HTML (AnswerHighlighter.java),
   not React, so it can't share those files directly, but the citation highlighting should look
   identical to FormattedAnswer.tsx's own rendering of the same answer text. theme-init.js (loaded
   by answer.html) sets the same [data-theme] attribute this file reads, so a visitor's stored
   light/dark preference applies here too. */

:root {
  --paper: #f3f1e9;
  --paper-raised: #ffffff;
  --ink: #1e2a2f;
  --ink-soft: #4b5a5e;
  --ink-faint: #7c877f;
  --rule: #d8d3c2;
  --emerald: #0e6b5c;
  --emerald-soft: #0e6b5c1a;
  --gold: #a9762f;
  --gold-soft: #a9762f1f;
  --violet: #6e4a96;
  --violet-soft: #6e4a961f;
  --danger: #9c3b2e;

  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --paper: #14191b;
    --paper-raised: #1b2224;
    --ink: #e8e3d3;
    --ink-soft: #a6aca6;
    --ink-faint: #71807a;
    --rule: #2b3336;
    --emerald: #3fbfa0;
    --emerald-soft: #3fbfa022;
    --gold: #d6a24a;
    --gold-soft: #d6a24a26;
    --violet: #c7a8ea;
    --violet-soft: #c7a8ea26;
    --danger: #e08772;
  }
}

:root[data-theme='dark'] {
  --paper: #14191b;
  --paper-raised: #1b2224;
  --ink: #e8e3d3;
  --ink-soft: #a6aca6;
  --ink-faint: #71807a;
  --rule: #2b3336;
  --emerald: #3fbfa0;
  --emerald-soft: #3fbfa022;
  --gold: #d6a24a;
  --gold-soft: #d6a24a26;
  --violet: #c7a8ea;
  --violet-soft: #c7a8ea26;
  --danger: #e08772;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.6 var(--sans);
}

/* Matches src/index.css's own ::selection rule. */
::selection {
  background: var(--emerald-soft);
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.back {
  color: var(--ink-faint);
  text-decoration: none;
  font-size: 0.9rem;
}

h1 {
  font-size: 1.5rem;
  line-height: 1.35;
  margin: 1rem 0 1.5rem;
}

/* "Listen to this answer" control -- built by answer-audio.js and inserted above the answer, so
   it only ever appears when the browser can actually speak it. Sits quietly as a pair of pills. */
.answer-audio {
  display: flex;
  gap: 8px;
  margin: 0 0 1.25rem;
}

.answer-audio__btn {
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 5px 14px;
  cursor: pointer;
}

.answer-audio__btn:hover,
.answer-audio__btn:focus-visible {
  color: var(--emerald);
  border-color: var(--emerald);
  background: var(--emerald-soft);
}

/* Hold the toggle in the emerald state while narration is playing or paused, so it reads as an
   active control rather than just another idle button. */
.answer-audio--active .answer-audio__btn:first-child {
  color: var(--emerald);
  border-color: var(--emerald);
  background: var(--emerald-soft);
}

/* Matches FormattedAnswer.tsx's rendering of the same answer text -- see AnswerHighlighter.java. */
.answer-card__answer {
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 1em;
}

.answer-card__answer p {
  margin: 0;
}

.answer-quote {
  display: inline;
  border-radius: 4px;
  padding: 0.05em 0.1em;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

/* Qur'an quotations in emerald, Sunni hadith (Sahih al-Bukhari) in gold, Shia hadith (Al-Kafi) in
   violet -- three accent colors so a reader can tell the source tradition apart at a glance, not
   just "Qur'an vs. hadith". */
.answer-quote--quran {
  background: var(--emerald-soft);
}

.answer-quote--hadith-sunni {
  background: var(--gold-soft);
}

.answer-quote--hadith-shia {
  background: var(--violet-soft);
}

.answer-quote__ref--quran {
  color: var(--emerald);
}

.answer-quote__ref--hadith-sunni {
  color: var(--gold);
}

.answer-quote__ref--hadith-shia {
  color: var(--violet);
}

.answer-quote__text {
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink);
  quotes: "\201C" "\201D";
}

.answer-quote__ref {
  font-family: var(--mono);
  font-size: 0.72em;
  font-weight: 600;
  text-decoration: none;
  margin-left: 0.35em;
  white-space: nowrap;
}

.answer-quote__ref:hover,
.answer-quote__ref:focus-visible {
  text-decoration: underline;
}

.answer-card__citations {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--rule);
}

.answer-card__citations h3 {
  font-family: var(--mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  font-weight: 600;
  margin-bottom: 10px;
}

.answer-card__citations ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.citation {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  scroll-margin-top: 16px;
}

.citation:target {
  background: var(--emerald-soft);
  border-color: var(--emerald);
}

.citation__mark {
  font-family: var(--mono);
  font-size: 0.85rem;
  width: 1.2em;
  flex-shrink: 0;
  text-align: center;
}

.citation--matched .citation__mark {
  color: var(--emerald);
}

.citation__reference {
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
}

.disclaimer {
  margin-top: 2rem;
  font-size: 0.85rem;
  color: var(--ink-faint);
}

.cta {
  display: inline-block;
  margin-top: 1rem;
  color: var(--gold);
  font-weight: 600;
  text-decoration: none;
}
