/* ── Reset & base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #080808;
  --surface:     #111111;
  --border:      #1e1e1e;
  --border-soft: #2e2a26;
  --text:        #ddd6cc;
  --text-dim:    #a09585;
  --text-faint:  #5c5450;
  --gold:        #b8976a;
  --gold-bright: #d4b485;
  --white:       #f0ece4;
  --radius:      10px;
}

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Crimson Pro", Georgia, serif;
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 4rem 1.25rem 6rem;
}

main {
  width: 100%;
  max-width: 660px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.5rem;
}

/* ── Animations ────────────────────────────────────────────────────────────── */
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(-14px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideDown {
  from { opacity: 0; max-height: 0; transform: translateY(-8px); }
  to   { opacity: 1; max-height: 600px; transform: translateY(0); }
}

.hidden { opacity: 0; pointer-events: none; }

.fade-slide-in {
  animation: fadeSlideIn 0.55s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.fade-in {
  animation: fadeIn 0.4s ease forwards;
}

/* Sections that slide in when revealed */
.hidden-slide {
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.visible-section {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ── Sun ───────────────────────────────────────────────────────────────────── */
.sun {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.9;

  /* Responsive size: scales with viewport, clamped between min and max */
  width: clamp(56px, 10vw, 96px);
  height: clamp(56px, 10vw, 96px);
}

.sun-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* ── Selector wrapper ──────────────────────────────────────────────────────── */
/* FIX: fit-content width so it doesn't span the full 660px column;
   z-index so the open dropdown list floats above the religion-info block below */
.selector-wrap {
  width: fit-content;
  min-width: 220px;
  position: relative;
  z-index: 10;
}

/* ── Dropdown trigger ──────────────────────────────────────────────────────── */
.dropdown {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0.85rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.2s, background 0.2s;
  outline: none;
}

.dropdown:hover,
.dropdown:focus-visible { border-color: var(--gold); }

.dropdown.open { border-color: var(--gold); border-bottom-left-radius: 0; border-bottom-right-radius: 0; }

.dropdown-label {
  font-family: "Cinzel", serif;
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  color: var(--text);
  white-space: nowrap;
}

.dropdown-label.placeholder { color: var(--text-dim); }

.dropdown-arrow {
  color: var(--text-dim);
  font-size: 0.8rem;
  transition: transform 0.25s ease;
  flex-shrink: 0;
}

.dropdown.open .dropdown-arrow { transform: rotate(180deg); }

/* ── Dropdown list ─────────────────────────────────────────────────────────── */
.dropdown-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--gold);
  border-top: none;
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
  list-style: none;
  overflow: hidden;
  z-index: 100;
  max-height: 0;
  opacity: 0;
  pointer-events: none;
  transition: max-height 0.3s cubic-bezier(0.22, 1, 0.36, 1),
              opacity 0.25s ease;
}

.dropdown-list.visible {
  max-height: 420px;
  opacity: 1;
  pointer-events: auto;
  overflow-y: auto;
}

.dropdown-list::-webkit-scrollbar { width: 4px; }
.dropdown-list::-webkit-scrollbar-track { background: transparent; }
.dropdown-list::-webkit-scrollbar-thumb { background: var(--border-soft); border-radius: 2px; }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.1rem;
  cursor: pointer;
  font-family: "Cinzel", serif;
  font-size: 0.82rem;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--text-faint);
  transition: background 0.15s, color 0.15s;
}

.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: rgba(184, 151, 106, 0.08); color: var(--gold-bright); }

.dropdown-item-icon {
  font-size: 1rem;
  width: 1.4rem;
  text-align: center;
  opacity: 0.75;
  flex-shrink: 0;
}

/* ── Religion info ─────────────────────────────────────────────────────────── */
.religion-info {
  width: 100%;
  border-left: 1px solid var(--gold);
  padding: 0.1rem 0 0.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.religion-summary {
  font-size: 1.05rem;
  font-weight: 300;
  line-height: 1.75;
  color: var(--text-dim);
}

.scripture-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.scripture-tag {
  font-family: "Cinzel", serif;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--gold);
  border: 1px solid var(--gold);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  opacity: 0.8;
}

/* ── Question area ─────────────────────────────────────────────────────────── */
.question-wrap {
  width: 100%;
  display: flex;
  align-items: flex-end;
  flex-direction: column;
  gap: 0.65rem;
}

.question {
  flex: unset;
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-soft);
  border-radius: 0;
  padding: 0.65rem 0;
  font-family: "Crimson Pro", serif;
  font-size: 1.35rem;
  font-weight: 300;
  color: var(--white);
  /* FIX: hide scrollbar that appeared as textarea grew */
  resize: none;
  overflow: hidden;
  outline: none;
  line-height: 1.5;
  caret-color: var(--gold);
  transition: border-color 0.25s;
  min-height: 44px;
}

.question::placeholder { color: var(--text-faint); }
.question:focus { border-bottom-color: var(--gold); }

.ask-btn {
  font-family: "Cinzel", serif;
  font-size: 0.75rem;
  font-weight: 550;
  letter-spacing: 0.1em;
  color: #080808;
  background: var(--gold);
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  padding: 0.5rem 1rem;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
  align-self: center;
  opacity: 0.9;
  transition: background 0.2s, transform 0.2s;
}

.ask-btn:hover:not(:disabled) { background: var(--gold-bright); color: #080808; opacity: 1; transform: scale(1.1); }
.ask-btn:disabled { opacity: 0.25; cursor: default; }

/* ── Response area ─────────────────────────────────────────────────────────── */
.response-area {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.response-text {
  font-size: 1.2rem;
  font-weight: 300;
  line-height: 1.9;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 1.5rem;
}

.status-line {
  font-family: "Cinzel", serif;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  min-height: 1rem;
}

/* ── Sources button ────────────────────────────────────────────────────────── */
.sources-btn {
  align-self: flex-start;
  font-family: "Cinzel", serif;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.sources-btn:hover { border-color: var(--gold); color: var(--gold); background: rgba(184, 151, 106, 0.06); }
.sources-btn.active { border-color: var(--gold); color: var(--gold); }
.sources-btn.hidden { display: none; }

/* ── Passages ──────────────────────────────────────────────────────────────── */
.passages-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.45s cubic-bezier(0.22, 1, 0.36, 1),
              opacity 0.35s ease;
}

.passages-wrap.visible {
  max-height: 9999999px;
  opacity: 1;
}

.passage-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}

.passage-meta {
  font-family: "Cinzel", serif;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--gold);
  margin-bottom: 0.5rem;
  opacity: 0.85;
}

.passage-text {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-dim);
  white-space: pre-wrap;
}

/* ── Scrollbar (global) ────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-soft); border-radius: 2px; }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 520px) {
  body { padding: 2.5rem 1rem 5rem; }
  main { gap: 2rem; }
  .selector-wrap { width: 100%; }
  .question { font-size: 1.15rem; }
  .response-text { font-size: 1.05rem; }
}

.error-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #1f1b0a;
  border: 1px solid #ca8a04;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  color: #fef3c7;
  font-size: 0.9rem;
}

.error-box svg {
  flex-shrink: 0;
  color: #ef4444;
}

.sources-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  gap: 0.5rem;
}

.sources-title {
  font-family: "Cinzel", serif;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}

/* Circle “i” button */
.info-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--gold);
  background: transparent;
  color: var(--gold);
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.info-btn:hover {
  background: rgba(184, 151, 106, 0.12);
}

/* Modal overlay */
.sources-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 999;
}

.sources-modal.visible {
  opacity: 1;
  pointer-events: auto;
}

/* Floating panel */
.sources-modal-content {
  width: min(520px, 90vw);
  background: var(--surface);
  border: 1px solid var(--gold);
  border-radius: 14px;
  padding: 1.2rem 1.3rem;
  transform: translateY(12px) scale(0.98);
  transition: transform 0.25s ease;
  position: relative;
}

.sources-modal.visible .sources-modal-content {
  transform: translateY(0) scale(1);
}

.sources-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1.2rem;
  cursor: pointer;
}