/* Qualicum Beach Q&A — vanilla CSS, no external assets. */

:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-alt: #eef2f7;
  --border: #d9dee5;
  --border-strong: #c2cad6;
  --text: #1a2433;
  --text-muted: #5a6675;
  --accent: #0b6e8f;          /* coastal teal */
  --accent-dark: #07566f;
  --accent-soft: #e1f1f6;
  --warn-bg: #fff7e0;
  --warn-border: #f0dca0;
  --warn-text: #6b5318;
  --user-bg: #0b6e8f;
  --user-fg: #ffffff;
  --assistant-bg: #ffffff;
  --assistant-fg: #1a2433;
  --shadow: 0 1px 2px rgba(15, 30, 50, 0.05), 0 2px 8px rgba(15, 30, 50, 0.04);
  --shadow-strong: 0 -2px 12px rgba(15, 30, 50, 0.06);
  --radius: 12px;
  --radius-sm: 8px;
  --max-width: 760px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- Header ---------------------------------------------------------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}
.site-header__inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.site-header__titles {
  flex: 1;
  min-width: 0;
}
.site-header h1 {
  font-size: 1.2rem;
  margin: 0;
  color: var(--accent-dark);
  letter-spacing: 0.1px;
  font-weight: 650;
}
.subtitle {
  margin: 2px 0 0 0;
  font-size: 0.86rem;
  color: var(--text-muted);
}

/* --- Disclaimer banner ----------------------------------------------- */
.disclaimer {
  background: var(--warn-bg);
  border-bottom: 1px solid var(--warn-border);
  color: var(--warn-text);
  font-size: 0.82rem;
  text-align: center;
  padding: 7px 16px;
  line-height: 1.4;
}

/* --- Buttons --------------------------------------------------------- */
.btn {
  font: inherit;
  font-size: 0.92rem;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
  white-space: nowrap;
}
.btn--primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
}
.btn--primary:hover:not(:disabled) { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn--primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn--ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
  font-size: 0.84rem;
  padding: 6px 12px;
}
.btn--ghost:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-alt); }

/* --- Chat surface ---------------------------------------------------- */
.chat {
  flex: 1;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 20px 20px 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}

.msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
}
.msg__bubble {
  padding: 11px 15px;
  border-radius: var(--radius);
  white-space: pre-wrap;
  word-wrap: break-word;
  box-shadow: var(--shadow);
  font-size: 0.97rem;
}
.msg__bubble a {
  color: inherit;
  text-decoration: underline;
}
.msg--user { align-self: flex-end; align-items: flex-end; }
.msg--user .msg__bubble {
  background: var(--user-bg);
  color: var(--user-fg);
  border-bottom-right-radius: 4px;
}
.msg--assistant { align-self: flex-start; align-items: flex-start; }
.msg--assistant .msg__bubble {
  background: var(--assistant-bg);
  color: var(--assistant-fg);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.msg--intro .msg__bubble {
  background: var(--accent-soft);
  border-color: #c5e1ea;
  color: var(--text);
}

.msg__bubble .cite {
  display: inline-block;
  font-size: 0.72em;
  vertical-align: super;
  line-height: 1;
  padding: 1px 5px;
  margin: 0 1px;
  background: rgba(11, 110, 143, 0.12);
  color: var(--accent-dark);
  border-radius: 4px;
  text-decoration: none;
  font-weight: 600;
}
.msg--user .msg__bubble .cite {
  background: rgba(255, 255, 255, 0.28);
  color: #fff;
}
.msg__bubble .cite:hover { background: rgba(11, 110, 143, 0.22); }

.sources {
  margin-top: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  max-width: 100%;
}
.sources__title {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.sources ol {
  margin: 0;
  padding-left: 22px;
}
.sources li { margin: 3px 0; }
.sources a {
  color: var(--accent-dark);
  text-decoration: none;
  overflow-wrap: anywhere;
}
.sources a:hover { text-decoration: underline; }

/* Typing cursor while streaming */
.cursor {
  display: inline-block;
  width: 7px;
  height: 1em;
  vertical-align: -2px;
  margin-left: 2px;
  background: var(--accent);
  animation: blink 1s steps(2, start) infinite;
  border-radius: 1px;
}
@keyframes blink { to { visibility: hidden; } }

/* --- Composer -------------------------------------------------------- */
.composer {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: var(--shadow-strong);
  width: 100%;
}
.composer__inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.composer textarea {
  flex: 1;
  resize: none;
  max-height: 160px;
  min-height: 44px;
  padding: 11px 14px;
  font: inherit;
  color: var(--text);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.composer textarea:hover { border-color: var(--border-strong); }
.composer textarea:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(11, 110, 143, 0.15);
}
.composer textarea::placeholder { color: var(--text-muted); opacity: 0.85; }

/* --- Footer ---------------------------------------------------------- */
.site-footer {
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--bg);
}
.site-footer__inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 14px 20px 22px;
  text-align: center;
}
.site-footer p {
  margin: 0 0 6px;
}
.site-footer__line { line-height: 1.5; }
.site-footer__disclaimer {
  color: var(--text-muted);
  opacity: 0.85;
  font-size: 0.74rem;
  margin-top: 8px !important;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  line-height: 1.45;
}
.site-footer a {
  color: var(--accent-dark);
  text-decoration: none;
}
.site-footer a:hover { text-decoration: underline; }

/* --- Small screens --------------------------------------------------- */
@media (max-width: 480px) {
  .site-header__inner { padding: 12px 14px; }
  .site-header h1 { font-size: 1.08rem; }
  .subtitle { font-size: 0.8rem; }
  .disclaimer { font-size: 0.76rem; padding: 6px 12px; }
  .msg { max-width: 94%; }
  .msg__bubble { font-size: 0.94rem; padding: 10px 13px; }
  .chat { padding: 14px 12px 6px; gap: 12px; }
  .composer__inner { padding: 10px 12px; gap: 8px; }
  .composer textarea { min-height: 42px; padding: 10px 12px; }
  .site-footer__inner { padding: 12px 14px 18px; }
}
