/* v3-r1 */

:root {
  --bg: #f7f4ee;
  --panel: #ffffff;
  --ink: #2b2620;
  --ink-soft: #5c5449;
  --accent: #8a5a2b;
  --accent-dark: #6e4620;
  --border: #ddd4c4;
  --bot-bg: #efe9dd;
  --user-bg: #8a5a2b;
  --user-ink: #ffffff;
  --danger: #a03d3d;
  /* Fixed text colors for the cream photo-overlay cards (welcome card,
     scripture/perspective cards) — these cards keep a light background in
     both themes, so their text must NOT flip with --ink/--ink-soft. */
  --card-bg: #f7f1e4;
  --card-ink: #2b2620;
  --card-ink-soft: #5c5449;
}

html[data-theme="dark"] {
  --bg: #1c1a17;
  --panel: #262320;
  --ink: #ece6da;
  --ink-soft: #b3a898;
  --accent: #c98a4b;
  --accent-dark: #e0a267;
  --border: #3a352e;
  --bot-bg: #2f2b26;
  --user-bg: #6e4620;
  --user-ink: #f7f0e6;
  --danger: #d97a7a;
}

/* Font-size control: JS sets html[data-fontsize] to one of these */
html { font-size: 100%; }
html[data-fontsize="sm"]   { font-size: 87.5%; }
html[data-fontsize="md"]   { font-size: 100%; }
html[data-fontsize="lg"]   { font-size: 112.5%; }
html[data-fontsize="xl"]   { font-size: 125%; }
html[data-fontsize="xxl"]  { font-size: 137.5%; }
html[data-fontsize="xxxl"] { font-size: 150%; }

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  font-family: 'Ubuntu', Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.app-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 8px; }

.brand-mark {
  width: 28px; height: 28px;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-family: 'Ubuntu', Arial, sans-serif;
}

.brand-name { font-size: 1.25rem; font-weight: 700; letter-spacing: 0.5px; }

.tagline { font-size: 0.8125rem; color: var(--ink-soft); font-style: italic; }

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  width: 34px;
  height: 34px;
  cursor: pointer;
  color: var(--ink-soft);
  font-size: 0.9375rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--ink-soft);
  padding: 8px 14px;
  font-size: 0.8125rem;
  font-family: inherit;
  cursor: pointer;
}

.header-btn:hover { border-color: var(--accent); color: var(--accent); }

.font-size-controls {
  display: flex;
  gap: 2px;
}

.font-btn {
  padding: 8px 11px;
  font-weight: 700;
}

.mobile-menu-btn {
  display: none;
  margin-left: auto;
  background: none;
  border: 1px solid var(--border);
  width: 40px;
  height: 40px;
  padding: 0;
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.mobile-menu-btn span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--ink);
}

.mobile-menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 60;
}

.mobile-menu {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(280px, 80vw);
  background: var(--panel);
  border-left: 1px solid var(--border);
  z-index: 61;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.mobile-menu-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mobile-menu-label {
  font-size: 0.875rem;
  color: var(--ink-soft);
}

.mobile-menu-full-btn {
  width: 100%;
  padding: 12px;
  text-align: left;
}

.icon-moon { display: none; }
html[data-theme="dark"] .icon-sun { display: none; }
html[data-theme="dark"] .icon-moon { display: inline; }

/* ---------- Welcome screen ---------- */

.welcome-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 82vh;
  padding: 6vh 8vw;
  background-image:
    linear-gradient(90deg, rgba(28, 22, 14, 0) 35%, rgba(28, 22, 14, 0.55) 100%),
    url('assets/creed-hero.png');
  background-size: cover;
  background-position: left top, left top;
  background-repeat: no-repeat;
}

.welcome-card-wrap {
  width: min(720px, 92%);
}

.welcome-card {
  width: 100%;
  background: var(--card-bg);
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(20, 14, 6, 0.22);
  padding: 56px 52px;
  text-align: left;
  color: var(--card-ink);
}

.welcome-brand {
  margin: 0 0 10px 0;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9375rem;
  color: var(--card-ink-soft);
}

.welcome-title {
  font-size: 2.5rem;
  line-height: 1.2;
  margin: 0 0 16px 0;
  font-weight: 700;
  color: var(--card-ink);
}

.welcome-subtitle {
  font-size: 1.125rem;
  line-height: 1.5;
  color: var(--card-ink-soft);
  margin: 0 0 28px 0;
}

.welcome-form {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 12px;
  margin-bottom: 18px;
}

.welcome-form input {
  flex: 1;
  padding: 15px 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1.0625rem;
  font-family: inherit;
  background: #fffdf8;
  color: var(--card-ink);
}

.welcome-form input:focus { outline: 2px solid var(--accent); }

.welcome-form button {
  width: 100%;
  padding: 16px 24px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1.0625rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}

.welcome-form button:hover { background: var(--accent-dark); }

.welcome-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.prompt-chip {
  background: #fffdf8;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--card-ink-soft);
  padding: 9px 14px;
  font-size: 0.875rem;
  cursor: pointer;
  font-family: inherit;
}

.prompt-chip:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Active conversation layout ---------- */

.layout {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* the [hidden] attribute needs this — otherwise .layout's display:flex above wins */
[hidden] {
  display: none !important;
}

.chat-pane {
  flex: 1.3;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  min-width: 0;
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.msg {
  max-width: 80%;
  padding: 12px 16px;
  line-height: 1.5;
  font-size: 0.9375rem;
}

.msg p { margin: 0 0 8px 0; }
.msg p:last-child { margin-bottom: 0; }

.msg-bot {
  background: var(--bot-bg);
  align-self: flex-start;
  border: 1px solid var(--border);
}

.msg-user {
  background: var(--user-bg);
  color: var(--user-ink);
  align-self: flex-end;
}

.msg-error {
  background: #fbeaea;
  border: 1px solid var(--danger);
  color: var(--danger);
  align-self: flex-start;
}

html[data-theme="dark"] .msg-error { background: #3a2020; }

.retry-btn {
  margin-top: 8px;
  background: none;
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 6px 14px;
  font-size: 0.8125rem;
  font-family: inherit;
  cursor: pointer;
}

.retry-btn:hover { background: var(--danger); color: #fff; }

.followups {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.followup-btn {
  background: var(--panel);
  border: 1px solid var(--accent);
  color: var(--accent-dark);
  padding: 6px 12px;
  font-size: 0.8125rem;
  cursor: pointer;
  font-family: inherit;
}

.followup-btn:hover { background: var(--accent); color: #fff; }

.ask-form {
  display: flex;
  border-top: 1px solid var(--border);
  padding: 16px 24px;
  gap: 10px;
  background: var(--panel);
}

#askInput {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  font-size: 0.9375rem;
  font-family: inherit;
  background: var(--bg);
  color: var(--ink);
}

#askInput:focus { outline: 2px solid var(--accent); }

#askBtn {
  padding: 12px 22px;
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}

#askBtn:hover { background: var(--accent-dark); }
#askBtn:disabled { opacity: 0.5; cursor: default; }

.answer-pane {
  position: relative;
  flex: 1;
  background-image:
    linear-gradient(0deg, rgba(28, 22, 14, 0.55) 0%, rgba(28, 22, 14, 0.1) 60%),
    url('assets/creed-reading.png');
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
}

.answer-pane-inner {
  height: 100%;
  overflow-y: auto;
  padding: 24px;
}

.answer-pane-close {
  display: none;
}

.answer-pane-empty {
  position: relative;
  z-index: 1;
  min-height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  margin: -24px;
  padding: 24px;
}

.answer-pane-empty p {
  background: var(--card-bg);
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(20, 14, 6, 0.25);
  color: var(--card-ink-soft);
  font-style: italic;
  font-size: 0.875rem;
  margin: 0;
  padding: 16px 20px;
  max-width: 320px;
  text-align: center;
}

.inline-scripture { margin-top: 12px; }

.inline-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--ink-soft);
  margin: 14px 0 10px 0;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}
.inline-scripture .inline-section-title:first-child { margin-top: 0; }

.answer-section-title {
  position: relative;
  z-index: 1;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--card-bg);
  margin: 0 0 10px 0;
  border-bottom: 1px solid rgba(247, 241, 228, 0.4);
  padding-bottom: 6px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.verse-card {
  position: relative;
  z-index: 1;
  background: var(--card-bg);
  color: var(--card-ink);
  border-left: 3px solid var(--accent);
  border-radius: 0 10px 10px 0;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 0.875rem;
  box-shadow: 0 8px 20px rgba(20, 14, 6, 0.25);
}

.verse-ref {
  font-weight: 700;
  color: #6e4620;
  display: block;
  margin-bottom: 4px;
  font-size: 0.8125rem;
}

.perspective-card {
  position: relative;
  z-index: 1;
  background: var(--card-bg);
  color: var(--card-ink);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
  box-shadow: 0 8px 20px rgba(20, 14, 6, 0.25);
}

.perspective-label {
  font-weight: 700;
  color: #6e4620;
  display: block;
  margin-bottom: 6px;
  font-size: 0.875rem;
}

.perspective-text { font-size: 0.875rem; line-height: 1.5; margin: 0; color: var(--card-ink); }

.typing {
  align-self: flex-start;
  color: var(--ink-soft);
  font-style: italic;
  font-size: 0.875rem;
  padding: 6px 16px;
}

@media (max-width: 780px) {
  .tagline { display: none; }
  .header-actions { display: none; }
  .mobile-menu-btn { display: flex; }

  .layout { flex-direction: column; position: relative; }
  .chat-pane { border-right: none; flex: 1; width: 100%; }
  .topics-panel { width: 100%; }

  /* No separate scripture pane/drawer on mobile — verses render inline
     in the chat thread instead (see .inline-scripture in app.js). */
  .answer-pane,
  .answer-pane-overlay,
  .mobile-context-btn {
    display: none !important;
  }

  .header-btn { padding: 6px 8px; font-size: 0.75rem; }

  .ask-form { padding: 12px 14px; gap: 8px; }
  #askBtn { padding: 12px 16px; font-size: 0.875rem; }

  .welcome-screen {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    align-items: flex-start;
    justify-content: center;
    padding: 0 16px 24px;
    background-position: 25% top, 25% top;
  }
  .welcome-card { width: 100%; }
  .welcome-form { flex-direction: column; }
}

@media (max-width: 480px) {
  .welcome-card { padding: 28px 22px; }
  .welcome-title { font-size: 1.625rem; }
}

/* ---------- Browse Topics panel ---------- */

.topics-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 40;
}

.topics-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(480px, 90vw);
  background: var(--panel);
  border-left: 1px solid var(--border);
  z-index: 50;
  display: flex;
  flex-direction: column;
  box-shadow: -6px 0 18px rgba(0, 0, 0, 0.12);
}

.topics-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.topics-panel-header h2 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.625rem;
  line-height: 1;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 0 4px;
}

.close-btn:hover { color: var(--accent); }

.topics-content {
  overflow-y: auto;
  padding: 18px 20px 40px;
}

.topics-category { margin-bottom: 22px; }

.topics-category h3 {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--ink-soft);
  margin: 0 0 10px 0;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

.topics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

@media (max-width: 560px) {
  .topics-grid { grid-template-columns: 1fr; }
}

.topic-item {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--ink);
  padding: 9px 12px;
  font-size: 0.84375rem;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.35;
}

.topic-item:hover { border-color: var(--accent); color: var(--accent-dark); background: var(--bot-bg); }


/* v3-r1: About links + disclaimer notes */
a.header-btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.welcome-note { margin: 18px 0 0; font-size: 0.8125rem; line-height: 1.5; color: var(--card-ink-soft); }
.welcome-note a { color: #8a5a2b; font-weight: 500; }
.ask-note { margin: 0; padding: 0 24px 10px; font-size: 0.75rem; color: var(--ink-soft); background: var(--panel); }
.ask-note a { color: var(--accent); }
@media (max-width: 780px) { .ask-note { padding: 0 14px 8px; } }

/* v3-r1: hidden trap field for bots (off-screen, not display:none, so naive bots still fill it) */
.hp-field { position: absolute !important; left: -10000px !important; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
