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

:root {
  --bg:        #07070f;
  --surface:   #0f0f1a;
  --surface2:  #171728;
  --surface3:  #1e1e32;
  --accent:    #7c3aed;
  --accent2:   #a855f7;
  --accent3:   #c084fc;
  --gold:      #d4a843;
  --gold2:     #f0c060;
  --teal:      #2dd4bf;
  --danger:    #ef4444;
  --text:      #e8e6f0;
  --muted:     #8880a8;
  --border:    rgba(124, 58, 237, 0.18);
  --radius:    10px;
  --font-body: 'Crimson Pro', Georgia, serif;
  --font-display: 'Cinzel', serif;
}

html, body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
}

a { color: var(--accent3); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navbar ──────────────────────────────────────────────────── */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 2rem;
  background: rgba(7, 7, 15, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav-logo {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--accent3);
  letter-spacing: 0.04em;
}
.nav-links { display: flex; gap: 2rem; list-style: none; }
.nav-links a { color: var(--muted); font-size: 0.9rem; font-family: var(--font-display); letter-spacing: 0.06em; transition: color 0.2s; }
.nav-links a:hover, .nav-links a.active { color: var(--text); text-decoration: none; }

/* ── Chat page layout ────────────────────────────────────────── */
.chat-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-top: 60px;
}
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
  gap: 1rem;
}

/* ── Chat header ─────────────────────────────────────────────── */
.chat-header {
  text-align: center;
  padding: 1.5rem 0 0.25rem;
}
.chat-header h2 {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--accent3);
}
.chat-header p { color: var(--muted); font-size: 0.95rem; margin-top: 0.25rem; }

/* ── Message counter ─────────────────────────────────────────── */
.message-counter {
  display: inline-block;
  margin-top: 0.75rem;
  padding: 0.3rem 1rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-family: var(--font-display);
  letter-spacing: 0.05em;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  transition: all 0.4s;
}
.message-counter.warning { border-color: var(--gold); color: var(--gold); }
.message-counter.unlocked {
  border-color: var(--accent2);
  color: var(--accent3);
  background: rgba(124, 58, 237, 0.12);
  animation: pulse-border 2s ease-in-out infinite;
}
.message-counter.unlimited { border-color: var(--teal); color: var(--teal); }

@keyframes pulse-border {
  0%, 100% { box-shadow: 0 0 0 0 rgba(168, 85, 247, 0); }
  50% { box-shadow: 0 0 0 4px rgba(168, 85, 247, 0.2); }
}

/* ── Messages window ─────────────────────────────────────────── */
.messages {
  flex: 1;
  min-height: 380px;
  max-height: 52vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.25rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  scroll-behavior: smooth;
}
.messages::-webkit-scrollbar { width: 4px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 2px; }

.message {
  max-width: 80%;
  padding: 0.75rem 1rem;
  border-radius: 14px;
  font-size: 1rem;
  line-height: 1.6;
  white-space: pre-wrap;
}
.message.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.message.bot {
  align-self: flex-start;
  background: var(--surface2);
  color: var(--text);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--border);
}
.message.error {
  align-self: flex-start;
  background: rgba(239,68,68,0.1);
  color: var(--danger);
  border: 1px solid rgba(239,68,68,0.25);
  border-bottom-left-radius: 4px;
}
.message.loading {
  align-self: flex-start;
  background: var(--surface2);
  color: var(--muted);
  font-style: italic;
  border-bottom-left-radius: 4px;
}

/* ── Input area ──────────────────────────────────────────────── */
.input-area { display: flex; gap: 0.5rem; align-items: flex-end; }
.input-area textarea {
  flex: 1;
  resize: none;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
  min-height: 52px;
  max-height: 140px;
}
.input-area textarea:focus { border-color: var(--accent); }
.input-area textarea::placeholder { color: var(--muted); }

.send-btn {
  padding: 0 1.25rem;
  height: 52px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}
.send-btn:hover { background: var(--accent2); transform: translateY(-1px); }
.send-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* ── Disclaimer ──────────────────────────────────────────────── */
.disclaimer {
  background: var(--surface2);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.6rem 1rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.disclaimer strong { color: var(--text); }

/* ═══════════════════════════════════════════════════════════════
   BELIEVER PORTAL MODAL
═══════════════════════════════════════════════════════════════ */
.portal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(5, 5, 12, 0.88);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.portal-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.portal-modal {
  background: var(--surface);
  border: 1px solid rgba(168, 85, 247, 0.35);
  border-radius: 18px;
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  transform: translateY(20px) scale(0.97);
  transition: transform 0.4s ease;
  box-shadow: 0 0 60px rgba(124, 58, 237, 0.15), 0 0 120px rgba(124, 58, 237, 0.05);
}
.portal-overlay.visible .portal-modal {
  transform: translateY(0) scale(1);
}

/* Modal header */
.portal-header { text-align: center; padding-bottom: 0.5rem; }
.portal-sigil {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 0.75rem;
  animation: spin-slow 8s linear infinite;
}
@keyframes spin-slow { to { transform: rotate(360deg); } }

.portal-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 400;
  letter-spacing: 0.1em;
  color: var(--accent3);
  margin-bottom: 0.5rem;
}
.portal-subtitle {
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 480px;
  margin: 0 auto;
}

/* Summary box */
.summary-box {
  background: var(--surface2);
  border: 1px solid rgba(168, 85, 247, 0.2);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}
.summary-label {
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  color: var(--accent2);
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}
.summary-text {
  font-size: 0.88rem;
  color: var(--muted);
  white-space: pre-wrap;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.6;
}

/* Portal options */
.portal-options { display: flex; flex-direction: column; gap: 0.75rem; }

.portal-option {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  background: var(--surface2);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: border-color 0.2s;
}
.portal-option:hover { border-color: rgba(168, 85, 247, 0.3); }

.option-icon { font-size: 1.5rem; flex-shrink: 0; margin-top: 2px; }

.option-body { flex: 1; }
.option-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  letter-spacing: 0.05em;
  color: var(--text);
  margin-bottom: 0.3rem;
}
.option-desc { font-size: 0.88rem; color: var(--muted); line-height: 1.55; }

/* Agent status */
.agent-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  font-size: 0.82rem;
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}
.status-dot.online  { background: #22c55e; box-shadow: 0 0 6px rgba(34,197,94,0.6); animation: blink 2s ease-in-out infinite; }
.status-dot.offline { background: #ef4444; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.5} }

/* Option buttons */
.option-btn {
  flex-shrink: 0;
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  border: none;
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: all 0.2s;
  align-self: center;
  white-space: nowrap;
}
.btn-live {
  background: var(--accent);
  color: #fff;
}
.btn-live:hover:not(:disabled) { background: var(--accent2); transform: translateY(-1px); }

.btn-email {
  background: var(--surface3);
  color: var(--gold2);
  border: 1px solid rgba(212, 168, 67, 0.3);
}
.btn-email:hover:not(:disabled) { background: rgba(212, 168, 67, 0.1); }

.btn-continue {
  background: var(--surface3);
  color: var(--muted);
  border: 1px solid rgba(255,255,255,0.07);
}
.btn-continue:hover { color: var(--text); }

/* Email form inside option */
.email-form {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}
.email-form input[type="email"] {
  flex: 1;
  min-width: 180px;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}
.email-form input[type="email"]:focus { border-color: var(--gold); }
.email-form input[type="email"]::placeholder { color: var(--muted); }

.email-success {
  margin-top: 0.75rem;
  font-size: 0.88rem;
  color: #22c55e;
}

.option-continue { opacity: 0.75; }
.option-continue:hover { opacity: 1; }

/* ── Floating portal button (FAB) ────────────────────────────── */
.portal-fab {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 300;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1px solid rgba(168, 85, 247, 0.4);
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.2);
  animation: spin-slow 10s linear infinite;
}
.portal-fab:hover {
  background: var(--accent);
  border-color: var(--accent2);
  transform: scale(1.1);
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 640px) {
  .portal-modal { padding: 1.25rem; }
  .portal-option { flex-direction: column; }
  .option-btn { align-self: flex-start; }
  .email-form { flex-direction: column; }
  .navbar { padding: 0.75rem 1rem; }
  .nav-links { gap: 1rem; }
}
